diff --git a/src/components/CommandMenu/CommandMenu.tsx b/src/components/CommandMenu/CommandMenu.tsx new file mode 100644 index 000000000..6184cfbf4 --- /dev/null +++ b/src/components/CommandMenu/CommandMenu.tsx @@ -0,0 +1,67 @@ +import { useState } from 'preact/hooks'; + +const defaultPages = [ + { href: '/profile', title: 'Account', group: 'Pages' }, + { href: '/roadmaps', title: 'Roadmaps', group: 'Pages' }, + { href: '/best-practices', title: 'Best Practices', group: 'Pages' }, + { href: '/guides', title: 'Guides', group: 'Pages' }, + { href: '/videos', title: 'Videos', group: 'Pages' }, +]; + +export function CommandMenu() { + const [isActive, setIsActive] = useState(true); + const [pages, setPages] = useState(defaultPages); + const [searchedText, setSearchedText] = useState(''); + const [activeCounter, setActiveCounter] = useState(0); + + if (!isActive) { + return null; + } + + return ( +
+
+
+ { + if (e.key === 'ArrowDown') { + const canGoNext = activeCounter < pages.length - 1; + setActiveCounter(canGoNext ? activeCounter + 1 : 0); + } else if (e.key === 'ArrowUp') { + const canGoPrev = activeCounter > 0; + setActiveCounter( + canGoPrev ? activeCounter - 1 : pages.length - 1 + ); + } + }} + /> + + +
+
+
+ ); +} diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 08b65ad77..c048f6f63 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,6 +1,7 @@ --- import Analytics from '../components/Analytics/Analytics.astro'; import Authenticator from '../components/Authenticator/Authenticator.astro'; +import { CommandMenu } from '../components/CommandMenu/CommandMenu'; import Footer from '../components/Footer.astro'; import Navigation from '../components/Navigation/Navigation.astro'; import OpenSourceBanner from '../components/OpenSourceBanner.astro'; @@ -149,6 +150,7 @@ const gaPageIdentifier = Astro.url.pathname +