[portal][ui] improve product navbar

pull/360/head
Yangshun Tay 2 years ago
parent a905f31b2c
commit b52db41965

@ -109,6 +109,7 @@ export default function AppShell({ children }: Props) {
navigation: ProductNavigationItems; navigation: ProductNavigationItems;
showGlobalNav: boolean; showGlobalNav: boolean;
title: string; title: string;
titleHref: string;
}> = (() => { }> = (() => {
const path = router.pathname; const path = router.pathname;
if (path.startsWith('/resumes')) { if (path.startsWith('/resumes')) {
@ -190,6 +191,7 @@ export default function AppShell({ children }: Props) {
<ProductNavigation <ProductNavigation
items={currentProductNavigation.navigation} items={currentProductNavigation.navigation}
title={currentProductNavigation.title} title={currentProductNavigation.title}
titleHref={currentProductNavigation.titleHref}
/> />
</div> </div>
<div className="ml-2 flex items-center space-x-4 sm:ml-6 sm:space-x-6"> <div className="ml-2 flex items-center space-x-4 sm:ml-6 sm:space-x-6">

@ -17,6 +17,7 @@ const config = {
navigation, navigation,
showGlobalNav: true, showGlobalNav: true,
title: 'Tech Interview Handbook', title: 'Tech Interview Handbook',
titleHref: '/',
}; };
export default config; export default config;

@ -1,5 +1,6 @@
import clsx from 'clsx'; import clsx from 'clsx';
import Link from 'next/link'; import Link from 'next/link';
import { useRouter } from 'next/router';
import { Fragment } from 'react'; import { Fragment } from 'react';
import { Menu, Transition } from '@headlessui/react'; import { Menu, Transition } from '@headlessui/react';
import { ChevronDownIcon } from '@heroicons/react/20/solid'; import { ChevronDownIcon } from '@heroicons/react/20/solid';
@ -8,6 +9,7 @@ type NavigationItem = Readonly<{
children?: ReadonlyArray<NavigationItem>; children?: ReadonlyArray<NavigationItem>;
href: string; href: string;
name: string; name: string;
target?: '_blank';
}>; }>;
export type ProductNavigationItems = ReadonlyArray<NavigationItem>; export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
@ -15,15 +17,21 @@ export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
type Props = Readonly<{ type Props = Readonly<{
items: ProductNavigationItems; items: ProductNavigationItems;
title: string; title: string;
titleHref: string;
}>; }>;
export default function ProductNavigation({ items, title }: Props) { export default function ProductNavigation({ items, title, titleHref }: Props) {
const router = useRouter();
return ( return (
<nav aria-label="Global" className="flex space-x-8"> <nav aria-label="Global" className="flex h-full items-center space-x-8">
<span className="text-primary-700 text-sm font-medium">{title}</span> <Link className="text-primary-700 text-sm font-medium" href={titleHref}>
<div className="hidden space-x-8 md:flex"> {title}
{items.map((item) => </Link>
item.children != null && item.children.length > 0 ? ( <div className="hidden h-full items-center space-x-8 md:flex">
{items.map((item) => {
const isActive = router.pathname === item.href;
return item.children != null && item.children.length > 0 ? (
<Menu key={item.name} as="div" className="relative text-left"> <Menu key={item.name} as="div" className="relative text-left">
<Menu.Button className="focus:ring-primary-600 flex items-center rounded-md text-sm font-medium text-slate-900 focus:outline-none focus:ring-2 focus:ring-offset-2"> <Menu.Button className="focus:ring-primary-600 flex items-center rounded-md text-sm font-medium text-slate-900 focus:outline-none focus:ring-2 focus:ring-offset-2">
<span>{item.name}</span> <span>{item.name}</span>
@ -63,12 +71,15 @@ export default function ProductNavigation({ items, title }: Props) {
) : ( ) : (
<Link <Link
key={item.name} key={item.name}
className="hover:text-primary-600 text-sm font-medium text-slate-900" className={clsx(
'hover:text-primary-600 inline-flex h-full items-center border-y-2 border-t-transparent text-sm font-medium text-slate-900',
isActive ? 'border-b-primary-500' : 'border-b-transparent',
)}
href={item.href}> href={item.href}>
{item.name} {item.name}
</Link> </Link>
), );
)} })}
</div> </div>
</nav> </nav>
); );

@ -9,6 +9,7 @@ const config = {
navigation, navigation,
showGlobalNav: false, showGlobalNav: false,
title: 'Tech Offers Repo', title: 'Tech Offers Repo',
titleHref: '/offers',
}; };
export default config; export default config;

@ -1,5 +0,0 @@
export default function QuestionBankTitle() {
return (
<h1 className="text-center text-4xl font-bold">Interview Questions</h1>
);
}

@ -1,7 +1,6 @@
import type { ProductNavigationItems } from '~/components/global/ProductNavigation'; import type { ProductNavigationItems } from '~/components/global/ProductNavigation';
const navigation: ProductNavigationItems = [ const navigation: ProductNavigationItems = [
{ href: '/questions', name: 'Home' },
{ href: '/questions', name: 'My Lists' }, { href: '/questions', name: 'My Lists' },
{ href: '/questions', name: 'My Questions' }, { href: '/questions', name: 'My Questions' },
{ href: '/questions', name: 'History' }, { href: '/questions', name: 'History' },
@ -11,6 +10,7 @@ const config = {
navigation, navigation,
showGlobalNav: false, showGlobalNav: false,
title: 'Questions Bank', title: 'Questions Bank',
titleHref: '/questions',
}; };
export default config; export default config;

@ -11,6 +11,7 @@ const navigation: ProductNavigationItems = [
children: [], children: [],
href: 'https://www.techinterviewhandbook.org/resume/', href: 'https://www.techinterviewhandbook.org/resume/',
name: 'Resume Guide', name: 'Resume Guide',
target: '_blank',
}, },
]; ];
@ -18,6 +19,7 @@ const config = {
navigation, navigation,
showGlobalNav: false, showGlobalNav: false,
title: 'Resumes', title: 'Resumes',
titleHref: '/resumes',
}; };
export default config; export default config;

Loading…
Cancel
Save