diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index 90e847a..be78b4f 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -1,82 +1,97 @@ -import { createContext, useContext, useState } from 'react' -import { motion } from 'framer-motion' -import { motion } from 'framer-motion' -import { Button } from '@/components/ui/button' -import { - List, - House, - Atom, - FlowArrow, - Layout, - X, -} from '@phosphor-icons/react' -import { cn } from '@/lib/utils' - -const navigationItems = [ - { path: '/', label: 'Home', icon: House }, - { path: '/atoms', label: 'Atoms', icon: Atom }, - { path: '/molecules', label: 'Molecules', icon: FlowArrow }, - { path: '/organisms', label: 'Organisms', icon: Layout }, - { path: '/templates', label: 'Templates', icon: Layout }, -] - -type NavigationContextType = { - menuOpen: boolean - setMenuOpen: (open: boolean) => void -} - -const NavigationContext = createContext(undefined) - -export function NavigationProvider({ children }: { children: React.ReactNode }) { - const [menuOpen, setMenuOpen] = useState(false) - - {chi - ) - - const context = useContext(Navi - - - - const { menuOpen, setMenuOpen } - return ( - variant="gh - onClick={() => setMenuOpen(!menuOpen)} - - ) - - - - setMenuOpen(false - - - -
- -
-
-} - - - - +import { createContext, useContext, useState } from 'react' +import { motion } from 'framer-motion' +import { Button } from '@/components/ui/button' +import { + List, + House, + Atom, + FlowArrow, + Layout, + X, +} from '@phosphor-icons/react' +import { cn } from '@/lib/utils' +import { Link, useLocation } from 'react-router-dom' + +const navigationItems = [ + { path: '/', label: 'Home', icon: House }, + { path: '/atoms', label: 'Atoms', icon: Atom }, + { path: '/molecules', label: 'Molecules', icon: FlowArrow }, + { path: '/organisms', label: 'Organisms', icon: Layout }, + { path: '/templates', label: 'Templates', icon: Layout }, +] + +type NavigationContextType = { + menuOpen: boolean + setMenuOpen: (open: boolean) => void +} + +const NavigationContext = createContext(undefined) + +export function NavigationProvider({ children }: { children: React.ReactNode }) { + const [menuOpen, setMenuOpen] = useState(false) + + return ( + + {children} + + ) +} + +export function useNavigation() { + const context = useContext(NavigationContext) + if (!context) { + throw new Error('useNavigation must be used within NavigationProvider') + } + return context +} + +export function Navigation() { + const { menuOpen, setMenuOpen } = useNavigation() + return ( + + ) +} + +export function NavigationSidebar() { + const { menuOpen, setMenuOpen } = useNavigation() + const location = useLocation() + + return ( + +
+
+

Navigation

+ +
+