diff --git a/src/components/CommandMenu/CommandMenu.tsx b/src/components/CommandMenu/CommandMenu.tsx index 2bd8ba3a6..3965ba14f 100644 --- a/src/components/CommandMenu/CommandMenu.tsx +++ b/src/components/CommandMenu/CommandMenu.tsx @@ -1,35 +1,47 @@ -import { Fragment, useEffect, useRef, useState } from 'react'; +import { + Fragment, + type ReactElement, + useEffect, + useRef, + useState, +} from 'react'; import { useKeydown } from '../../hooks/use-keydown'; import { useOutsideClick } from '../../hooks/use-outside-click'; -import BestPracticesIcon from '../../icons/best-practices.svg'; -import ClipboardIcon from '../../icons/clipboard.svg'; -import GuideIcon from '../../icons/guide.svg'; -import HomeIcon from '../../icons/home.svg'; -import RoadmapIcon from '../../icons/roadmap.svg'; -import UserIcon from '../../icons/user.svg'; -import GroupIcon from '../../icons/group.svg'; -import VideoIcon from '../../icons/video.svg'; import { httpGet } from '../../lib/http'; import { isLoggedIn } from '../../lib/jwt'; +import { BestPracticesIcon } from '../ReactIcons/BestPracticesIcon.tsx'; +import { UserIcon } from '../ReactIcons/UserIcon.tsx'; +import { GroupIcon } from '../ReactIcons/GroupIcon.tsx'; +import { RoadmapIcon } from '../ReactIcons/RoadmapIcon.tsx'; +import { ClipboardIcon } from '../ReactIcons/ClipboardIcon.tsx'; +import { GuideIcon } from '../ReactIcons/GuideIcon.tsx'; +import { HomeIcon } from '../ReactIcons/HomeIcon.tsx'; +import { VideoIcon } from '../ReactIcons/VideoIcon.tsx'; export type PageType = { id: string; url: string; title: string; group: string; - icon?: string; + icon?: ReactElement; isProtected?: boolean; metadata?: Record; }; const defaultPages: PageType[] = [ - { id: 'home', url: '/', title: 'Home', group: 'Pages', icon: HomeIcon.src }, + { + id: 'home', + url: '/', + title: 'Home', + group: 'Pages', + icon: , + }, { id: 'account', url: '/account', title: 'Account', group: 'Pages', - icon: UserIcon.src, + icon: , isProtected: true, }, { @@ -37,7 +49,7 @@ const defaultPages: PageType[] = [ url: '/team', title: 'Teams', group: 'Pages', - icon: GroupIcon.src, + icon: , isProtected: true, }, { @@ -45,7 +57,7 @@ const defaultPages: PageType[] = [ url: '/account/friends', title: 'Friends', group: 'Pages', - icon: GroupIcon.src, + icon: , isProtected: true, }, { @@ -53,14 +65,14 @@ const defaultPages: PageType[] = [ url: '/roadmaps', title: 'Roadmaps', group: 'Pages', - icon: RoadmapIcon.src, + icon: , }, { id: 'account-roadmaps', url: '/account/roadmaps', title: 'Custom Roadmaps', group: 'Pages', - icon: RoadmapIcon.src, + icon: , isProtected: true, }, { @@ -68,28 +80,28 @@ const defaultPages: PageType[] = [ url: '/best-practices', title: 'Best Practices', group: 'Pages', - icon: BestPracticesIcon.src, + icon: , }, { id: 'questions', url: '/questions', title: 'Questions', group: 'Pages', - icon: ClipboardIcon.src, + icon: , }, { id: 'guides', url: '/guides', title: 'Guides', group: 'Pages', - icon: GuideIcon.src, + icon: , }, { id: 'videos', url: '/videos', title: 'Videos', group: 'Pages', - icon: VideoIcon.src, + icon: , }, ]; @@ -199,7 +211,7 @@ export function CommandMenu() { } else if (e.key === 'ArrowUp') { const canGoPrev = activeCounter > 0; setActiveCounter( - canGoPrev ? activeCounter - 1 : searchResults.length - 1 + canGoPrev ? activeCounter - 1 : searchResults.length - 1, ); } else if (e.key === 'Tab') { e.preventDefault(); @@ -242,13 +254,7 @@ export function CommandMenu() { {!page.icon && ( {page.group} )} - {page.icon && ( - {page.title} - )} + {page.icon && page.icon} {page.title} diff --git a/src/components/ReactIcons/BestPracticesIcon.tsx b/src/components/ReactIcons/BestPracticesIcon.tsx new file mode 100644 index 000000000..671c921e0 --- /dev/null +++ b/src/components/ReactIcons/BestPracticesIcon.tsx @@ -0,0 +1,28 @@ +type BestPracticesIconProps = { + className?: string; +}; +export function BestPracticesIcon(props: BestPracticesIconProps) { + const { className } = props; + + return ( + + + + + + + + + ); +} diff --git a/src/components/ReactIcons/ClipboardIcon.tsx b/src/components/ReactIcons/ClipboardIcon.tsx new file mode 100644 index 000000000..788ff736c --- /dev/null +++ b/src/components/ReactIcons/ClipboardIcon.tsx @@ -0,0 +1,28 @@ +type ClipboardIconProps = { + className?: string; +}; +export function ClipboardIcon(props: ClipboardIconProps) { + const { className } = props; + + return ( + + + + + + + + + ); +} diff --git a/src/components/ReactIcons/GroupIcon.tsx b/src/components/ReactIcons/GroupIcon.tsx new file mode 100644 index 000000000..e35f95510 --- /dev/null +++ b/src/components/ReactIcons/GroupIcon.tsx @@ -0,0 +1,26 @@ +type GroupIconProps = { + className?: string; +}; +export function GroupIcon(props: GroupIconProps) { + const { className } = props; + + return ( + + + + + + + ); +} diff --git a/src/components/ReactIcons/GuideIcon.tsx b/src/components/ReactIcons/GuideIcon.tsx new file mode 100644 index 000000000..3ce1c3d49 --- /dev/null +++ b/src/components/ReactIcons/GuideIcon.tsx @@ -0,0 +1,23 @@ +type GuideIconProps = { + className?: string; +}; +export function GuideIcon(props: GuideIconProps) { + const { className } = props; + + return ( + + + + ); +} diff --git a/src/components/ReactIcons/HomeIcon.tsx b/src/components/ReactIcons/HomeIcon.tsx new file mode 100644 index 000000000..5b745b2ae --- /dev/null +++ b/src/components/ReactIcons/HomeIcon.tsx @@ -0,0 +1,23 @@ +type HomeIconProps = { + className?: string; +}; +export function HomeIcon(props: HomeIconProps) { + const { className } = props; + + return ( + + + + ); +} diff --git a/src/components/ReactIcons/RoadmapIcon.tsx b/src/components/ReactIcons/RoadmapIcon.tsx new file mode 100644 index 000000000..992718661 --- /dev/null +++ b/src/components/ReactIcons/RoadmapIcon.tsx @@ -0,0 +1,25 @@ +type RoadmapIconProps = { + className?: string; +}; +export function RoadmapIcon(props: RoadmapIconProps) { + const { className } = props; + + return ( + + + + + + ); +} diff --git a/src/components/ReactIcons/UserIcon.tsx b/src/components/ReactIcons/UserIcon.tsx new file mode 100644 index 000000000..43634fc02 --- /dev/null +++ b/src/components/ReactIcons/UserIcon.tsx @@ -0,0 +1,21 @@ +type UserIconProps = { + className?: string; +}; +export function UserIcon(props: UserIconProps) { + const { className } = props; + + return ( + + + + ); +} diff --git a/src/components/ReactIcons/VideoIcon.tsx b/src/components/ReactIcons/VideoIcon.tsx new file mode 100644 index 000000000..a92f87298 --- /dev/null +++ b/src/components/ReactIcons/VideoIcon.tsx @@ -0,0 +1,23 @@ +type VideoIconProps = { + className: string; +}; + +export function VideoIcon(props: VideoIconProps) { + const { className } = props; + + return ( + + + + ); +}