Merge branch 'images-fix' of https://github.com/kamranahmedse/developer-roadmap into images-fix

images-fix
Arik Chakma 1 year ago
commit 27cb89494f
  1. 62
      src/components/CommandMenu/CommandMenu.tsx
  2. 28
      src/components/ReactIcons/BestPracticesIcon.tsx
  3. 28
      src/components/ReactIcons/ClipboardIcon.tsx
  4. 26
      src/components/ReactIcons/GroupIcon.tsx
  5. 23
      src/components/ReactIcons/GuideIcon.tsx
  6. 23
      src/components/ReactIcons/HomeIcon.tsx
  7. 25
      src/components/ReactIcons/RoadmapIcon.tsx
  8. 21
      src/components/ReactIcons/UserIcon.tsx
  9. 23
      src/components/ReactIcons/VideoIcon.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 { useKeydown } from '../../hooks/use-keydown';
import { useOutsideClick } from '../../hooks/use-outside-click'; 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 { httpGet } from '../../lib/http';
import { isLoggedIn } from '../../lib/jwt'; 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 = { export type PageType = {
id: string; id: string;
url: string; url: string;
title: string; title: string;
group: string; group: string;
icon?: string; icon?: ReactElement;
isProtected?: boolean; isProtected?: boolean;
metadata?: Record<string, any>; metadata?: Record<string, any>;
}; };
const defaultPages: PageType[] = [ const defaultPages: PageType[] = [
{ id: 'home', url: '/', title: 'Home', group: 'Pages', icon: HomeIcon.src }, {
id: 'home',
url: '/',
title: 'Home',
group: 'Pages',
icon: <HomeIcon className="mr-2 h-4 w-4 stroke-2" />,
},
{ {
id: 'account', id: 'account',
url: '/account', url: '/account',
title: 'Account', title: 'Account',
group: 'Pages', group: 'Pages',
icon: UserIcon.src, icon: <UserIcon className="mr-2 h-4 w-4 stroke-2" />,
isProtected: true, isProtected: true,
}, },
{ {
@ -37,7 +49,7 @@ const defaultPages: PageType[] = [
url: '/team', url: '/team',
title: 'Teams', title: 'Teams',
group: 'Pages', group: 'Pages',
icon: GroupIcon.src, icon: <GroupIcon className="mr-2 h-4 w-4 stroke-2" />,
isProtected: true, isProtected: true,
}, },
{ {
@ -45,7 +57,7 @@ const defaultPages: PageType[] = [
url: '/account/friends', url: '/account/friends',
title: 'Friends', title: 'Friends',
group: 'Pages', group: 'Pages',
icon: GroupIcon.src, icon: <GroupIcon className="mr-2 h-4 w-4 stroke-2" />,
isProtected: true, isProtected: true,
}, },
{ {
@ -53,14 +65,14 @@ const defaultPages: PageType[] = [
url: '/roadmaps', url: '/roadmaps',
title: 'Roadmaps', title: 'Roadmaps',
group: 'Pages', group: 'Pages',
icon: RoadmapIcon.src, icon: <RoadmapIcon className="mr-2 h-4 w-4 stroke-2" />,
}, },
{ {
id: 'account-roadmaps', id: 'account-roadmaps',
url: '/account/roadmaps', url: '/account/roadmaps',
title: 'Custom Roadmaps', title: 'Custom Roadmaps',
group: 'Pages', group: 'Pages',
icon: RoadmapIcon.src, icon: <RoadmapIcon className="mr-2 h-4 w-4 stroke-2" />,
isProtected: true, isProtected: true,
}, },
{ {
@ -68,28 +80,28 @@ const defaultPages: PageType[] = [
url: '/best-practices', url: '/best-practices',
title: 'Best Practices', title: 'Best Practices',
group: 'Pages', group: 'Pages',
icon: BestPracticesIcon.src, icon: <BestPracticesIcon className="mr-2 h-4 w-4 stroke-2" />,
}, },
{ {
id: 'questions', id: 'questions',
url: '/questions', url: '/questions',
title: 'Questions', title: 'Questions',
group: 'Pages', group: 'Pages',
icon: ClipboardIcon.src, icon: <ClipboardIcon className="mr-2 h-4 w-4 stroke-2" />,
}, },
{ {
id: 'guides', id: 'guides',
url: '/guides', url: '/guides',
title: 'Guides', title: 'Guides',
group: 'Pages', group: 'Pages',
icon: GuideIcon.src, icon: <GuideIcon className="mr-2 h-4 w-4 stroke-2" />,
}, },
{ {
id: 'videos', id: 'videos',
url: '/videos', url: '/videos',
title: 'Videos', title: 'Videos',
group: 'Pages', group: 'Pages',
icon: VideoIcon.src, icon: <VideoIcon className="mr-2 h-4 w-4 stroke-2" />,
}, },
]; ];
@ -199,7 +211,7 @@ export function CommandMenu() {
} else if (e.key === 'ArrowUp') { } else if (e.key === 'ArrowUp') {
const canGoPrev = activeCounter > 0; const canGoPrev = activeCounter > 0;
setActiveCounter( setActiveCounter(
canGoPrev ? activeCounter - 1 : searchResults.length - 1 canGoPrev ? activeCounter - 1 : searchResults.length - 1,
); );
} else if (e.key === 'Tab') { } else if (e.key === 'Tab') {
e.preventDefault(); e.preventDefault();
@ -242,13 +254,7 @@ export function CommandMenu() {
{!page.icon && ( {!page.icon && (
<span className="mr-2 text-gray-400">{page.group}</span> <span className="mr-2 text-gray-400">{page.group}</span>
)} )}
{page.icon && ( {page.icon && page.icon}
<img
alt={page.title}
src={page.icon}
className="mr-2 h-4 w-4"
/>
)}
{page.title} {page.title}
</a> </a>
</Fragment> </Fragment>

@ -0,0 +1,28 @@
type BestPracticesIconProps = {
className?: string;
};
export function BestPracticesIcon(props: BestPracticesIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
<line x1="10" x2="21" y1="6" y2="6"></line>
<line x1="10" x2="21" y1="12" y2="12"></line>
<line x1="10" x2="21" y1="18" y2="18"></line>
<polyline points="3 6 4 7 6 5"></polyline>
<polyline points="3 12 4 13 6 11"></polyline>
<polyline points="3 18 4 19 6 17"></polyline>
</svg>
);
}

@ -0,0 +1,28 @@
type ClipboardIconProps = {
className?: string;
};
export function ClipboardIcon(props: ClipboardIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
<rect width="8" height="4" x="8" y="2" rx="1" ry="1" />
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" />
<path d="M12 11h4" />
<path d="M12 16h4" />
<path d="M8 11h.01" />
<path d="M8 16h.01" />
</svg>
);
}

@ -0,0 +1,26 @@
type GroupIconProps = {
className?: string;
};
export function GroupIcon(props: GroupIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
<circle cx="9" cy="7" r="4" />
<path d="M22 21v-2a4 4 0 0 0-3-3.87" />
<path d="M16 3.13a4 4 0 0 1 0 7.75" />
</svg>
);
}

@ -0,0 +1,23 @@
type GuideIconProps = {
className?: string;
};
export function GuideIcon(props: GuideIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className={className}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M9 6.75V15m6-6v8.25m.503 3.498l4.875-2.437c.381-.19.622-.58.622-1.006V4.82c0-.836-.88-1.38-1.628-1.006l-3.869 1.934c-.317.159-.69.159-1.006 0L9.503 3.252a1.125 1.125 0 00-1.006 0L3.622 5.689C3.24 5.88 3 6.27 3 6.695V19.18c0 .836.88 1.38 1.628 1.006l3.869-1.934c.317-.159.69-.159 1.006 0l4.994 2.497c.317.158.69.158 1.006 0z"
/>
</svg>
);
}

@ -0,0 +1,23 @@
type HomeIconProps = {
className?: string;
};
export function HomeIcon(props: HomeIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className={className}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"
/>
</svg>
);
}

@ -0,0 +1,25 @@
type RoadmapIconProps = {
className?: string;
};
export function RoadmapIcon(props: RoadmapIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
<path d="M18 6H5a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h13l4-3.5L18 6Z"></path>
<path d="M12 13v8"></path>
<path d="M12 3v3"></path>
</svg>
);
}

@ -0,0 +1,21 @@
type UserIconProps = {
className?: string;
};
export function UserIcon(props: UserIconProps) {
const { className } = props;
return (
<svg
stroke="currentColor"
fill="currentColor"
strokeWidth="0"
viewBox="0 0 1024 1024"
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path d="M858.5 763.6a374 374 0 0 0-80.6-119.5 375.63 375.63 0 0 0-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 0 0-80.6 119.5A371.7 371.7 0 0 0 136 901.8a8 8 0 0 0 8 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 0 0 8-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"></path>
</svg>
);
}

@ -0,0 +1,23 @@
type VideoIconProps = {
className: string;
};
export function VideoIcon(props: VideoIconProps) {
const { className } = props;
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className={className}
>
<path
strokeLinecap="round"
d="M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z"
/>
</svg>
);
}
Loading…
Cancel
Save