Skip to content

Commit

Permalink
feat: Cookbook Onboard integration
Browse files Browse the repository at this point in the history
  • Loading branch information
AE-0h committed Dec 5, 2024
1 parent e77fe01 commit 1672c01
Show file tree
Hide file tree
Showing 9 changed files with 2,239 additions and 69 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

3 changes: 2 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const config = {
baseUrl: '/',
customFields: {
keys : {
mendable : process.env.MENDABLE_KEY
mendable : process.env.MENDABLE_KEY,
cookbook : process.env.COOKBOOK_PUBLIC_API_KEY,
},
homePage: {
editUrl: 'https://github.com/rsksmart/devportal/tree/main/',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@cookbookdev/docsbot": "^4.24.7",
"@docusaurus/core": "^3.4.0",
"@docusaurus/plugin-google-tag-manager": "^3.4.0",
"@docusaurus/preset-classic": "^3.4.0",
Expand Down Expand Up @@ -54,5 +55,6 @@
"last 3 firefox version",
"last 5 safari version"
]
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
3 changes: 3 additions & 0 deletions src/theme/Layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import LayoutProvider from '@theme/Layout/Provider';
import ErrorPageContent from '@theme/ErrorPageContent';
import styles from './styles.module.css';
import SVGSprite from "./SVGSprite";
import AskCookbook from '../Navbar/AskCookbook/index';

export default function Layout(props) {
const {
children,
Expand Down Expand Up @@ -49,6 +51,7 @@ export default function Layout(props) {

{!noFooter && <Footer />}
<SVGSprite />
<AskCookbook />
</LayoutProvider>
);
}
89 changes: 44 additions & 45 deletions src/theme/Navbar/AIButton/index.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
import React, {useEffect, useState} from 'react';
import {MendableFloatingButton} from "@mendable/search"
import {useColorMode} from "@docusaurus/theme-common";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
// import React, {useEffect, useState} from 'react';
// import {MendableFloatingButton} from "@mendable/search"
// import {useColorMode} from "@docusaurus/theme-common";
// import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

export default function AIButton() {
const {
siteConfig: {customFields},
} = useDocusaurusContext();
// export default function AIButton() {
// const {
// siteConfig: {customFields},
// } = useDocusaurusContext();
// const {keys} = customFields;

const {keys} = customFields;
// const ANON_KEY = keys.mendable;const {colorMode} = useColorMode();
// const [style, setStyle] = useState({darkMode: colorMode === 'dark', accentColor: colorMode === 'dark' ? "#fff" : '#000'})

const {colorMode} = useColorMode();
const [style, setStyle] = useState({darkMode: colorMode === 'dark', accentColor: colorMode === 'dark' ? "#fff" : '#000'})
// const floatingButtonStyle = {
// color: "var(--bs-body-color)",
// backgroundColor: "var(--bs-body-bg)",
// }
//

const floatingButtonStyle = {
color: "var(--bs-body-color)",
backgroundColor: "var(--bs-body-bg)",
}
const ANON_KEY = keys.mendable;
// const icon = (
// <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
// <path
// d="M14.707 12L5.99992 3.29295C5.80945 3.11109 5.55624 3.00961 5.29289 3.00961C5.02955 3.00961 4.77633 3.11109 4.58587 3.29295L3.29287 4.58595C3.10564 4.77362 3.00049 5.02789 3.00049 5.29298C3.00049 5.55807 3.10564 5.81234 3.29287 6L11.9994 14.7071C12.1871 14.8942 12.4414 14.9994 12.7064 14.9994C12.9715 14.9994 13.2258 14.8942 13.4135 14.7071L14.707 13.4138C14.7998 13.321 14.8735 13.2107 14.9238 13.0894C14.9741 12.9681 14.9999 12.8381 14.9999 12.7068C14.9999 12.5755 14.9741 12.4454 14.9238 12.3241C14.8735 12.2028 14.7998 12.0928 14.707 12ZM3.99992 5.29295L5.29287 4L7.79287 6.5L6.49957 7.79345L3.99957 5.29345L3.99992 5.29295Z"
// fill="currentColor"/>
// <path d="M1.99999 6.99999L1 7.99998L1.99999 8.99997L2.99998 7.99998L1.99999 6.99999Z" fill="currentColor"/>
// <path d="M7.99999 1.00001L7 2L7.99999 2.99999L8.99998 2L7.99999 1.00001Z" fill="currentColor"/>
// <path d="M1.99999 1.00001L1 2L1.99999 2.99999L2.99998 2L1.99999 1.00001Z" fill="currentColor"/>
// </svg>
// )

const icon = (
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<path
d="M14.707 12L5.99992 3.29295C5.80945 3.11109 5.55624 3.00961 5.29289 3.00961C5.02955 3.00961 4.77633 3.11109 4.58587 3.29295L3.29287 4.58595C3.10564 4.77362 3.00049 5.02789 3.00049 5.29298C3.00049 5.55807 3.10564 5.81234 3.29287 6L11.9994 14.7071C12.1871 14.8942 12.4414 14.9994 12.7064 14.9994C12.9715 14.9994 13.2258 14.8942 13.4135 14.7071L14.707 13.4138C14.7998 13.321 14.8735 13.2107 14.9238 13.0894C14.9741 12.9681 14.9999 12.8381 14.9999 12.7068C14.9999 12.5755 14.9741 12.4454 14.9238 12.3241C14.8735 12.2028 14.7998 12.0928 14.707 12ZM3.99992 5.29295L5.29287 4L7.79287 6.5L6.49957 7.79345L3.99957 5.29345L3.99992 5.29295Z"
fill="currentColor"/>
<path d="M1.99999 6.99999L1 7.99998L1.99999 8.99997L2.99998 7.99998L1.99999 6.99999Z" fill="currentColor"/>
<path d="M7.99999 1.00001L7 2L7.99999 2.99999L8.99998 2L7.99999 1.00001Z" fill="currentColor"/>
<path d="M1.99999 1.00001L1 2L1.99999 2.99999L2.99998 2L1.99999 1.00001Z" fill="currentColor"/>
</svg>
)
// useEffect(() => {
// setStyle({darkMode: colorMode === 'dark', accentColor: colorMode === 'dark' ? "#fff" : '#000'})
// }, [colorMode]);

useEffect(() => {
setStyle({darkMode: colorMode === 'dark', accentColor: colorMode === 'dark' ? "#fff" : '#000'})
}, [colorMode]);

return (
<MendableFloatingButton
language={`en`}
showPopup={false}
popupText={``}
dismissPopupAfter={0}
cmdShortcutKey={'i'}
icon={icon}
botIcon={icon}
anon_key={ANON_KEY}
style={style}
floatingButtonStyle={floatingButtonStyle}
positionOverwriteClassname={`position-statick`}/>
);
}
// return (
// <MendableFloatingButton
// language={`en`}
// showPopup={false}
// popupText={``}
// dismissPopupAfter={0}
// cmdShortcutKey={'i'}
// icon={icon}
// botIcon={icon}
// anon_key={ANON_KEY}
// style={style}
// floatingButtonStyle={floatingButtonStyle}
// positionOverwriteClassname={`position-statick`}/>
// );
// }
23 changes: 23 additions & 0 deletions src/theme/Navbar/AskCookbook/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { Suspense } from "react";
import BrowserOnly from "@docusaurus/BrowserOnly";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

const BaseAskCookbook = React.lazy(() =>
import("@cookbookdev/docsbot/react-fixed")
);
export default function AskCookbook() {
const {
siteConfig: {customFields},
} = useDocusaurusContext();
const {keys} = customFields;
const COOKBOOK_PUBLIC_API_KEY = keys.cookbook;
return (
<BrowserOnly>
{() => (
<Suspense>
<BaseAskCookbook apiKey={COOKBOOK_PUBLIC_API_KEY} />
</Suspense>
)}
</BrowserOnly>
);
}
4 changes: 2 additions & 2 deletions src/theme/Navbar/Content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export default function NavbarContent() {
<SearchBar />
</NavbarSearch>
)}
<div>
{/* <div>
<AIButton />
</div>
</div> */}
</div>
<RightNavbarItems items={rightItems} />
<NavbarColorModeToggle />
Expand Down
2 changes: 0 additions & 2 deletions src/theme/Navbar/MobileSidebar/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import NavbarSearch from "@theme/Navbar/Search";
import SearchBar from "@theme/SearchBar";
import {useThemeConfig} from "@docusaurus/theme-common";
import AIButton from "@theme/Navbar/AIButton";

export default function NavbarMobileSidebarSearch() {
const items = useThemeConfig().navbar.items;
Expand All @@ -16,7 +15,6 @@ export default function NavbarMobileSidebarSearch() {
<SearchBar />
</NavbarSearch>
)}
<AIButton />
</div>
)
}
Loading

0 comments on commit 1672c01

Please sign in to comment.