Skip to content

Commit

Permalink
update: algolia api integration
Browse files Browse the repository at this point in the history
  • Loading branch information
subhadipbhowmik committed Dec 13, 2023
1 parent a60b59a commit f0d4df7
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 53 deletions.
50 changes: 0 additions & 50 deletions docs/intro.md

This file was deleted.

20 changes: 20 additions & 0 deletions docs/intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
sidebar_position: 1
description: Get started with Docusaurus in less than 50 minutes.
sidebar_label: Introduction
title: Introduction
---

import CustomTag from "@site/src/components/TagsComponents/CustomTag";
import Callout from "@site/src/components/Callout/Callout";
import { useState } from "react";
import ToastMessage from "@site/src/components/Toast/Toast";
import React, { useState } from "react";

# Toast Message

# Example MDX File

Some content before the toast message.

<ToastMessage />
6 changes: 3 additions & 3 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ const config = {
({
// Replace with your project's social card
algolia: {
apiKey: "f60c2ae59dd332b43d4efef67ad46e87",
indexName: "30-days-of-cpp",
appId: "OU047TL2DP",
apiKey: "4eadbd9906c2db99f8c4d53bb7202144",
indexName: "subhadipbhowmik",
appId: "SKRAQTXG41",
contextualSearch: true,
placeholder: "Search Tutorial",
},
Expand Down
18 changes: 18 additions & 0 deletions src/components/Callout/Callout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Callout.js
import React from "react";

const Callout = ({ type, children }) => {
const styles = {
border: "2px solid",
padding: "10px",
borderRadius: "5px",
backgroundColor:
type === "info" ? "#e2f0ff" : type === "warning" ? "#ffe5b3" : "#d9f7be",
borderColor:
type === "info" ? "#1890ff" : type === "warning" ? "#faad14" : "#52c41a",
};

return <div style={styles}>{children}</div>;
};

export default Callout;
28 changes: 28 additions & 0 deletions src/components/Toast/Toast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useState } from "react";
import "./toastStyles.css"; // Import CSS file for styling

const ToastMessage = () => {
const [showToast, setShowToast] = useState(false);

const toggleToast = () => {
setShowToast(!showToast);
// Automatically hide the toast after 3 seconds (3000 milliseconds)
setTimeout(() => {
setShowToast(false);
}, 3000);
};

return (
<div>
<button onClick={toggleToast}>Show Toast</button>

{showToast && (
<div className="toast">
<span className="toast-text">This is a toast message!</span>
</div>
)}
</div>
);
};

export default ToastMessage;
17 changes: 17 additions & 0 deletions src/components/Toast/toastStyles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* toastStyles.css */

.toast {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background-color: #333;
color: #fff;
padding: 10px 20px;
border-radius: 5px;
z-index: 9999;
}

.toast-text {
font-size: 16px;
}

0 comments on commit f0d4df7

Please sign in to comment.