|
1 | 1 | <script lang="ts"> |
2 | 2 | import NavAnchor from '$lib/components/shared/NavAnchor.svelte'; |
3 | 3 | import { Button } from '$lib/components/ui/button'; |
4 | | - import { IconMoon, IconSun } from '@tabler/icons-svelte'; |
| 4 | + import { IconMenu2, IconMoon, IconSun, IconX } from '@tabler/icons-svelte'; |
5 | 5 | import { toggleMode } from 'mode-watcher'; |
| 6 | + import SideNav from '$lib/components/shared/SideNav.svelte'; |
| 7 | +
|
| 8 | + let sidebarOpen = $state(false); |
| 9 | +
|
| 10 | + const toggleSidebar = () => (sidebarOpen = !sidebarOpen); |
| 11 | +
|
| 12 | + $effect(() => { |
| 13 | + if (sidebarOpen) { |
| 14 | + document.body.style.overflow = 'hidden'; |
| 15 | + } else { |
| 16 | + document.body.style.overflow = 'auto'; |
| 17 | + } |
| 18 | + }); |
6 | 19 | </script> |
7 | 20 |
|
8 | 21 | <div class="sticky top-0 z-50 w-full bg-background"> |
| 22 | + {#if sidebarOpen} |
| 23 | + <div |
| 24 | + class="absolute left-0 top-0 z-[100] h-screen w-screen space-y-4 bg-background p-4 opacity-95 lg:hidden" |
| 25 | + > |
| 26 | + <Button variant="outline" size="icon" onclick={toggleSidebar}> |
| 27 | + <IconX /> |
| 28 | + </Button> |
| 29 | + <SideNav class="-ml-4" /> |
| 30 | + </div> |
| 31 | + {/if} |
9 | 32 | <div class="flex flex-grow justify-center p-4"> |
10 | | - <div class="flex w-1/2 justify-center"> |
11 | | - <div class="flex items-center space-x-8"> |
| 33 | + <div class="flex w-full justify-start lg:w-1/2 lg:justify-center"> |
| 34 | + <Button variant="outline" size="icon" class="mr-4 lg:mr-0 lg:hidden" onclick={toggleSidebar}> |
| 35 | + <IconMenu2 /> |
| 36 | + </Button> |
| 37 | + <div class="hidden sm:flex sm:flex-grow sm:items-center sm:space-x-8"> |
12 | 38 | <NavAnchor href="/">Home</NavAnchor> |
13 | 39 | <NavAnchor fuzzy href="/projects">Projects</NavAnchor> |
14 | 40 | <NavAnchor fuzzy href="/blog">Blog</NavAnchor> |
15 | 41 | <NavAnchor fuzzy href="/hobbies">Hobbies</NavAnchor> |
16 | 42 | </div> |
17 | | - <div class="flex-grow"> |
| 43 | + <div> |
18 | 44 | <Button onclick={toggleMode} class="float-right" variant="outline" size="icon"> |
19 | 45 | <IconSun |
20 | 46 | class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" |
|
0 commit comments