Skip to content

Commit

Permalink
fix: move nav outside ul and fix dropdown styling
Browse files Browse the repository at this point in the history
  • Loading branch information
seandreassen committed Nov 21, 2024
1 parent 8c3ef66 commit 21d3599
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 37 deletions.
18 changes: 8 additions & 10 deletions src/components/layout/header/DesktopNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ function DesktopNavMenu({ t }: DesktopNavMenuProps) {
<EllipsisIcon aria-hidden />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className='hidden min-w-[6rem] md:flex' align='end'>
<SecondaryNav
asDropDown
onClick={() => setOpen(false)}
t={{
storage: t.storage,
shiftSchedule: t.shiftSchedule,
}}
/>
</DropdownMenuContent>
<SecondaryNav
asDropDown
onClick={() => setOpen(false)}
t={{
storage: t.storage,
shiftSchedule: t.shiftSchedule,
}}
/>
</DropdownMenu>
);
}
Expand Down
19 changes: 8 additions & 11 deletions src/components/layout/header/MobileSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ function MobileSheet({ className, t }: MobileSheetProps) {
/>
<Separator />
<div className='mt-6 ml-2 flex flex-row gap-2'>
<Separator orientation='vertical' className='h-max' />
<ul>
<SecondaryNav
className='flex flex-col space-y-3'
onClick={() => setOpen(false)}
t={{
storage: t.storage,
shiftSchedule: t.shiftSchedule,
}}
/>
</ul>
<Separator orientation='vertical' />
<SecondaryNav
onClick={() => setOpen(false)}
t={{
storage: t.storage,
shiftSchedule: t.shiftSchedule,
}}
/>
</div>
</SheetContent>
</Sheet>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/header/NavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type NavItemProps = ComponentProps<typeof Link> & {

function NavItem({ onClick, t, ...props }: NavItemProps) {
return (
<Button variant='nav' size='none' asChild>
<Button className='justify-start' variant='nav' size='none' asChild>
<Link onClick={onClick} {...props}>
{t}
</Link>
Expand Down
43 changes: 28 additions & 15 deletions src/components/layout/header/SecondaryNav.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { NavItem } from '@/components/layout/header/NavItem';
import { DropdownMenuItem } from '@/components/ui/DropdownMenu';
import {
DropdownMenuContent,
DropdownMenuItem,
} from '@/components/ui/DropdownMenu';

type SecondaryNavProps = {
asDropDown?: boolean;
className?: string;
onClick?: () => void;
t: {
storage: string;
shiftSchedule: string;
};
};

function SecondaryNav({
asDropDown = false,
className,
onClick,
t,
}: SecondaryNavProps) {
function SecondaryNav({ asDropDown = false, onClick, t }: SecondaryNavProps) {
const items = [
<NavItem key={0} onClick={onClick} href='/storage' t={t.storage} />,
<NavItem
Expand All @@ -28,13 +25,29 @@ function SecondaryNav({
];

return (
<nav className={className}>
{items.map((item) =>
asDropDown ? (
<DropdownMenuItem key={item.key}>{item}</DropdownMenuItem>
) : (
<li key={item.key}>{item}</li>
),
<nav>
{!asDropDown && (
<ul className='space-y-3'>
{items.map((item) => (
<li key={item.key}>{item}</li>
))}
</ul>
)}
{asDropDown && (
<DropdownMenuContent
className='hidden min-w-[6rem] flex-col items-start md:flex'
align='end'
>
{items.map((item) => (
<DropdownMenuItem
className='w-full justify-start'
key={item.key}
asChild
>
{item}
</DropdownMenuItem>
))}
</DropdownMenuContent>
)}
</nav>
);
Expand Down

0 comments on commit 21d3599

Please sign in to comment.