Skip to content

Commit

Permalink
remove import and use of navschema in MobileMenu, NavigationMenu and
Browse files Browse the repository at this point in the history
scripts/nav/inedx.tsx
  • Loading branch information
irfankhan10 committed Oct 10, 2024
1 parent 05de846 commit b458edb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
14 changes: 12 additions & 2 deletions src/custom/docs/components/navmenu/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ import {
DropdownMenuTrigger,
} from "src"
import { MenuIcon } from "lucide-react"
import { NavConfig } from "./schema"

export const MobileMenu = (props: Pick<NavConfig, 'navTextLinks'>) => {
export const MobileMenu = (props: {
navTextLinks: {
href: string,
title: string,
logo: JSX.Element,
description: string,
dropDown: {
href: string,
title: string,
}[],
}[];
}) => {
return <DropdownMenu>
<DropdownMenuTrigger asChild><Button variant='outline' className="w-8 p-0 h-8"> <MenuIcon/></Button></DropdownMenuTrigger>
<DropdownMenuContent>
Expand Down
26 changes: 16 additions & 10 deletions src/custom/docs/components/navmenu/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ import {
NavigationMenuContent,
} from 'src'

import { RegularLink } from './config'
import { NavConfig } from './schema'
import NextLink from 'next/link'


export const Navigation = (props: {
activePath: string
} & Pick<NavConfig, 'navTextLinks'>) => {
activePath: string,
navTextLinks: {
href: string,
title: string,
logo: JSX.Element,
description: string,
dropDown: {
href: string,
title: string,
}[],
}[];
} ) => {
const isActivePath = (activePath: string, path: string) => {
return activePath.startsWith(path)
}
Expand All @@ -30,27 +36,27 @@ export const Navigation = (props: {
<ul className="grid gap-3 p-4 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<li className="row-span-4">
<NavigationMenuLink asChild>
<RegularLink
<a
className="flex h-full w-full select-none flex-col justify-end rounded-md bg-gradient-to-b from-muted/50 to-muted p-6 no-underline outline-none focus:shadow-md"
href={item.href}
>
{item.logo}
<p className="text-sm leading-tight text-muted-foreground py-6">
{item.description}
</p>
</RegularLink>
</a>
</NavigationMenuLink>
</li>
{ item.dropDown.map((subtitle) => {
return (
<li>
<NavigationMenuLink asChild>
<RegularLink
<a
className="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"
href={subtitle.href}
>
<div className="text-sm font-medium leading-none">{subtitle.title}</div>
</RegularLink>
</a>
</NavigationMenuLink>
</li>
)})}
Expand Down
8 changes: 1 addition & 7 deletions src/custom/docs/scripts/nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {createRoot} from "react-dom/client"
import { ComponentProps } from "react";
import { NavBar } from "../../components/navmenu";
import { navConfigSchema } from '../../components/navmenu/schema';

(() => {
const mountElement = document.querySelector('.nexus-nav')
Expand All @@ -11,12 +10,7 @@ import { navConfigSchema } from '../../components/navmenu/schema';
mountElement.appendChild(renderIn)

const root = createRoot(renderIn)

const navConfig = navConfigSchema.parse({
navTextLinks: typeof navTextLinks !== "undefined" ? navTextLinks : null,
navIconLinks: typeof navIconLinks !== "undefined" ? navIconLinks : null,
navProductName: typeof navProductName !== "undefined" ? navProductName : null
})

root.render(
<div className="use-tailwind"> <div className="antialiased" style={{fontFamily: `Inter, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`}}><NavBar activePath="/" ></NavBar> </div></div>
)
Expand Down

0 comments on commit b458edb

Please sign in to comment.