Skip to content

Commit

Permalink
dev: Additions to navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-crowell committed Jun 13, 2024
1 parent 2ba4f35 commit 975ed02
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 13 deletions.
14 changes: 14 additions & 0 deletions packages/ui/src/Navigation/Navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ const links: Link[] = [
{
title: 'Contact',
url: '#contact',
links: [
{
title: 'Location',
url: '#location',
},
{
title: 'Email',
url: '#email',
},
{
title: 'Phone',
url: '#phone',
},
],
},
];

Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/Navigation/NavigationIsland.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ export function NavigationIsland({
const [ colors ] = twColors(color);

return (
<Navbar>
<NavbarContent justify="start" className="py-3">
<Navbar className="items-center justify-center">
<NavbarContent justify="start" className="flex items-center">
<NavigationPart_Brand title={title} />
</NavbarContent>
<NavbarContent justify="center">
<div className={clsx(color && colors, 'flex gap-1 rounded-full px-4 py-1')}>
<NavigationPart_Links links={links} />
</div>
</NavbarContent>
<NavbarContent justify="start">
<NavbarContent justify="end">

</NavbarContent>
</Navbar>
Expand Down
9 changes: 8 additions & 1 deletion packages/ui/src/Navigation/NavigationStandard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@ import { twColors } from '@do-ob/ui/utility';
import { clsx } from '@do-ob/core';
import type { NavigationProps } from './Navigation';
import { NavigationPart_Brand } from './parts/NavigationPart_Brand';
import { NavigationPart_Links } from './parts/NavigationPart_Links';

export function NavigationStandard({
title,
color,
links,
}: NavigationProps) {

const [ colors ] = twColors(color);

return (
<Navbar className={clsx(color && colors)}>
<NavbarContent>
<NavbarContent justify="start">
<NavigationPart_Brand title={title} />
</NavbarContent>

<NavbarContent justify="center">
<NavigationPart_Links links={links} />
</NavbarContent>

</Navbar>
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/Navigation/parts/NavigationPart_Brand.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NavbarBrand } from '@nextui-org/react';
import { NavbarBrand, Link } from '@nextui-org/react';

/**
* Navigation Brand properties
Expand All @@ -18,7 +18,7 @@ export function NavigationPart_Brand({
}: NavigationPart_BrandProps) {
return (
<NavbarBrand>
<h1 className="text-2xl">{title}</h1>
<Link href="/" className="text-lg text-inherit">{title}</Link>
</NavbarBrand>
);
}
Expand Down
53 changes: 46 additions & 7 deletions packages/ui/src/Navigation/parts/NavigationPart_Links.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NavbarMenuItem, Link, Button } from '@nextui-org/react';
import { NavbarMenuItem, Link, Button, Popover, PopoverTrigger, PopoverContent } from '@nextui-org/react';
import { ChevronDownIcon } from '@heroicons/react/24/solid';
import { Link as LinkType } from '@do-ob/ui/types';

/**
Expand All @@ -11,18 +12,56 @@ export interface NavigationPart_LinksProps {
links?: LinkType[];
}

function LinkLeaf({ link }: { link: LinkType }) {
return (
<NavbarMenuItem>
<Button
as={Link}
href={link.url}
variant="light"
className="text-inherit"
>
{link.title}
</Button>
</NavbarMenuItem>
);
}

function LinkBranch({ link }: { link: LinkType }) {
return (
<Popover
placement="bottom"
>
<NavbarMenuItem>
<PopoverTrigger>
<Button
variant="light"
className="text-inherit"
endContent={<ChevronDownIcon className="size-4" />}
>
{link.title}
</Button>
</PopoverTrigger>
</NavbarMenuItem>
<PopoverContent className="min-w-32 items-start p-2">
<Link href={link.url} className="w-full rounded px-4 py-2 text-inherit">
{link.title}
</Link>
</PopoverContent>
</Popover>
);
}

/**
* Navigation Links component
*/
export function NavigationPart_Links({
links = [],
}: NavigationPart_LinksProps) {
return links.length ? links.map((link) => (
<NavbarMenuItem>
<Button as={Link} href={link.url} variant="light" className="text-inherit">
{link.title}
</Button>
</NavbarMenuItem>
return links.length ? links.map((link) => !link.links?.length ? (
<LinkLeaf key={link.title} link={link} />
) : (
<LinkBranch key={link.title} link={link} />
)) : (
<NavbarMenuItem>
&nbsp;
Expand Down

0 comments on commit 975ed02

Please sign in to comment.