Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Cookbook Onboard integration #165

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions 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
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() {
AE-0h marked this conversation as resolved.
Show resolved Hide resolved
const items = useThemeConfig().navbar.items;
Expand All @@ -16,7 +15,6 @@ export default function NavbarMobileSidebarSearch() {
<SearchBar />
</NavbarSearch>
)}
<AIButton />
</div>
)
}
Loading
Loading