diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b1b152e64..d63d81243 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -8,6 +8,7 @@ import { GoogleAnalytics } from '@/components/analytics/GoogleAnalytics'; import { siteConfig } from '@/config/site-config'; import { Toaster } from 'sonner'; import { Navbar } from '@/components/Navbar'; +import HelpIcon from '@/components/helpSection/helpIcon'; const satoshi = localFont({ display: 'swap', @@ -35,6 +36,7 @@ export default function RootLayout({ children }: { children: ReactNode }) { {children} + diff --git a/src/components/helpSection/dialogPage.tsx b/src/components/helpSection/dialogPage.tsx new file mode 100644 index 000000000..e2327ba78 --- /dev/null +++ b/src/components/helpSection/dialogPage.tsx @@ -0,0 +1,29 @@ +import React from 'react'; + +export default function DialogPage({ + onCloseRequest, + title, + children, +}: { + onCloseRequest: () => void; + title: string; + children: React.ReactNode; +}) { + return ( +
+
+
+ +

+ {title} +

+ {children} +
+
+ ); +} diff --git a/src/components/helpSection/helpDialog.tsx b/src/components/helpSection/helpDialog.tsx new file mode 100644 index 000000000..5175fdb15 --- /dev/null +++ b/src/components/helpSection/helpDialog.tsx @@ -0,0 +1,162 @@ +import React from 'react'; +import DialogPage from './dialogPage'; +import { + SiInstagram, + SiYoutube, + SiX, + SiGithub, + SiNotion, + SiGoogleplay, +} from '@icons-pack/react-simple-icons'; + +function HeaderElement({ + href, + icon, + label, +}: { + href: string; + icon: React.ReactNode; + label: string; +}) { + return ( + + {icon} + {label} + + ); +} + +function Header() { + return ( +
+ } + label="Slides" + /> + } + label="Found an issue? Submit" + /> + } + label="Mobile App" + /> + } + label="YouTube" + /> + } + label="Twitter" + /> + } + label="Instagram" + /> +
+ ); +} + +function Section({ children }: { children: React.ReactNode }) { + return ( +
+ {children} +
+ ); +} + +const specialKeyMapping: { [key: string]: string } = { + 'Arrow Up': 'Arrow Up (↑)', + 'Arrow Down': 'Arrow Down (↓)', + 'Arrow Left': 'Arrow Left (←)', + 'Arrow Right': 'Arrow Right (→)', +}; + +function Shortcut({ + label, + shortcuts, +}: { + label: string; + shortcuts: string[]; +}) { + const splitShortcutKeys = shortcuts.map((shortcut) => { + const keys = shortcut.split('+'); + return keys.map((key) => ( + + {specialKeyMapping[key] || key.toUpperCase()} + + )); + }); + + return ( +
+
{label}
+
+ {splitShortcutKeys.reduce( + (acc, el, idx) => + idx === 0 + ? [el] + : [...acc,  or , el], + [], + )} +
+
+ ); +} + +export default function HelpDialog({ onClose }: { onClose: () => void }) { + return ( + +
+
+

+ Keyboard shortcuts +

+
+
+
+ + + + + + +
+
+ + + + + +
+
+
+
+
+ ); +} diff --git a/src/components/helpSection/helpIcon.tsx b/src/components/helpSection/helpIcon.tsx new file mode 100644 index 000000000..55961ee73 --- /dev/null +++ b/src/components/helpSection/helpIcon.tsx @@ -0,0 +1,40 @@ +'use client'; +import React, { useState } from 'react'; +import HelpDialog from './helpDialog'; + +export default function HelpIcon() { + const [isHelpDialogOpen, setHelpDialogOpen] = useState(false); + + return ( + <> +
setHelpDialogOpen(!isHelpDialogOpen)} + className="fixed bottom-6 right-5 z-[1000] h-10 w-10 cursor-pointer rounded-md bg-slate-600 p-2 text-white hover:bg-slate-500" + > + +
+ + {isHelpDialogOpen && ( + setHelpDialogOpen(false)} /> + )} + + ); +}