Refactored navigation component
This commit is contained in:
@@ -62,6 +62,58 @@ export const components: {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const ListItem = React.forwardRef<
|
||||||
|
React.ElementRef<"a">,
|
||||||
|
React.ComponentPropsWithoutRef<"a">
|
||||||
|
>(({ className, title, children, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<NavigationMenuLink asChild>
|
||||||
|
<a
|
||||||
|
ref={ref}
|
||||||
|
className={ny(
|
||||||
|
"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<div className="text-sm font-medium leading-none">{title}</div>
|
||||||
|
<p className="line-clamp-2 text-sm leading-snug text-muted-foreground">
|
||||||
|
{children}
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const ListItem2 = React.forwardRef<
|
||||||
|
React.ElementRef<"a">,
|
||||||
|
React.ComponentPropsWithoutRef<"a">
|
||||||
|
>(({ className, title, children, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<NavigationMenuLink asChild>
|
||||||
|
<a
|
||||||
|
data-umami-event={title}
|
||||||
|
ref={ref}
|
||||||
|
className={ny(
|
||||||
|
"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<div className="text-sm font-medium leading-none">{title}</div>
|
||||||
|
<p className="line-clamp-2 text-sm leading-snug text-muted-foreground">
|
||||||
|
{children}
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ListItem.displayName = "ListItem";
|
||||||
|
ListItem.displayName = "ListItem2";
|
||||||
|
|
||||||
export function Navigation() {
|
export function Navigation() {
|
||||||
return (
|
return (
|
||||||
<div className="border-grey fixed left-0 top-0 z-40 flex w-full items-center justify-center border-b bg-background p-2">
|
<div className="border-grey fixed left-0 top-0 z-40 flex w-full items-center justify-center border-b bg-background p-2">
|
||||||
@@ -116,6 +168,7 @@ export function Navigation() {
|
|||||||
<ListItem2
|
<ListItem2
|
||||||
title="Patreon"
|
title="Patreon"
|
||||||
href="https://patreon.com/zen_browser?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink"
|
href="https://patreon.com/zen_browser?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink"
|
||||||
|
target="_blank"
|
||||||
>
|
>
|
||||||
Support us on Patreon and get exclusive rewards and keep the
|
Support us on Patreon and get exclusive rewards and keep the
|
||||||
project alive.
|
project alive.
|
||||||
@@ -123,6 +176,7 @@ export function Navigation() {
|
|||||||
<ListItem2
|
<ListItem2
|
||||||
title="Ko-Fi"
|
title="Ko-Fi"
|
||||||
href="https://ko-fi.com/zen_browser?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink"
|
href="https://ko-fi.com/zen_browser?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink"
|
||||||
|
target="_blank"
|
||||||
>
|
>
|
||||||
Ko-fi is a way to support us with a one-time donation and help
|
Ko-fi is a way to support us with a one-time donation and help
|
||||||
us keep the project alive.
|
us keep the project alive.
|
||||||
@@ -134,15 +188,18 @@ export function Navigation() {
|
|||||||
<NavigationMenuTrigger>{"Useful Links"}</NavigationMenuTrigger>
|
<NavigationMenuTrigger>{"Useful Links"}</NavigationMenuTrigger>
|
||||||
<NavigationMenuContent>
|
<NavigationMenuContent>
|
||||||
<ul className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px]">
|
<ul className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px]">
|
||||||
{components.map((component) => (
|
{components.map(
|
||||||
<ListItem
|
({ description, href, title, isTargetBlank }) => (
|
||||||
key={component.title}
|
<ListItem
|
||||||
title={component.title}
|
key={title}
|
||||||
href={component.href}
|
title={title}
|
||||||
>
|
href={href}
|
||||||
{component.description}
|
target={isTargetBlank ? "_blank" : "_self"}
|
||||||
</ListItem>
|
>
|
||||||
))}
|
{description}
|
||||||
|
</ListItem>
|
||||||
|
),
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
@@ -152,55 +209,3 @@ export function Navigation() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListItem = React.forwardRef<
|
|
||||||
React.ElementRef<"a">,
|
|
||||||
React.ComponentPropsWithoutRef<"a">
|
|
||||||
>(({ className, title, children, ...props }, ref) => {
|
|
||||||
return (
|
|
||||||
<li>
|
|
||||||
<NavigationMenuLink asChild>
|
|
||||||
<a
|
|
||||||
ref={ref}
|
|
||||||
className={ny(
|
|
||||||
"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<div className="text-sm font-medium leading-none">{title}</div>
|
|
||||||
<p className="line-clamp-2 text-sm leading-snug text-muted-foreground">
|
|
||||||
{children}
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</NavigationMenuLink>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const ListItem2 = React.forwardRef<
|
|
||||||
React.ElementRef<"a">,
|
|
||||||
React.ComponentPropsWithoutRef<"a">
|
|
||||||
>(({ className, title, children, ...props }, ref) => {
|
|
||||||
return (
|
|
||||||
<li>
|
|
||||||
<NavigationMenuLink asChild>
|
|
||||||
<a
|
|
||||||
data-umami-event={title}
|
|
||||||
ref={ref}
|
|
||||||
className={ny(
|
|
||||||
"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<div className="text-sm font-medium leading-none">{title}</div>
|
|
||||||
<p className="line-clamp-2 text-sm leading-snug text-muted-foreground">
|
|
||||||
{children}
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</NavigationMenuLink>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
ListItem.displayName = "ListItem";
|
|
||||||
ListItem.displayName = "ListItem2";
|
|
||||||
|
|||||||
Reference in New Issue
Block a user