|
| 1 | +<script lang="ts"> |
| 2 | + import { DarkMode } from "flowbite-svelte"; |
| 3 | + import { EllipsisVertical } from "lucide-svelte"; |
| 4 | + import { page } from "$app/stores"; |
| 5 | +
|
| 6 | + export let menuItemsArray: any[]; |
| 7 | +
|
| 8 | + let current_url = ""; |
| 9 | + $: { |
| 10 | + current_url = $page.url.pathname.split("/").filter(Boolean).pop() || "/"; |
| 11 | + } |
| 12 | +
|
| 13 | + let showMenuMobile = false; |
| 14 | +</script> |
| 15 | + |
| 16 | +<nav |
| 17 | + class="p-4 flex justify-between items-center glass fixed top-0 dark:text-white z-50 md:px-16 border-b w-full dark:border-b-0" |
| 18 | +> |
| 19 | + <a href="/">GBS Svelte Building Block</a> |
| 20 | + <div class="flex justify-center items-center gap-2"> |
| 21 | + <DarkMode /> |
| 22 | + <input |
| 23 | + placeholder="Search Documentation" |
| 24 | + class="bg-gray-100 px-2 py-1 rounded-lg outline-none hidden md:block" |
| 25 | + /> |
| 26 | + <a |
| 27 | + href="https://github.com/ananduremanan/svelte-docs-template" |
| 28 | + target="_blank"><img src="/icons/github.svg" alt="" class="w-6 h-6" /></a |
| 29 | + > |
| 30 | + <button |
| 31 | + on:click={() => { |
| 32 | + showMenuMobile = !showMenuMobile; |
| 33 | + }} |
| 34 | + > |
| 35 | + <EllipsisVertical size="18" class="md:hidden" /> |
| 36 | + </button> |
| 37 | + </div> |
| 38 | +</nav> |
| 39 | + |
| 40 | +{#if showMenuMobile} |
| 41 | + <div class="z-10 sticky top-16 bg-white p-4 border-b glass"> |
| 42 | + {#if menuItemsArray} |
| 43 | + <ul class="dark:text-white"> |
| 44 | + <li |
| 45 | + class={`mt-2 w-full py-1 ${current_url === "/" ? "bg-blue-200 rounded-lg text-blue-500 dark:bg-blue-300" : ""}`} |
| 46 | + > |
| 47 | + <a |
| 48 | + href="/" |
| 49 | + class="p-1 w-full block" |
| 50 | + on:click={() => { |
| 51 | + showMenuMobile = !showMenuMobile; |
| 52 | + }}>Introduction</a |
| 53 | + > |
| 54 | + </li> |
| 55 | + {#each menuItemsArray as menu} |
| 56 | + <li |
| 57 | + class={`mt-2 w-full py-1 ${current_url === menu ? "bg-blue-200 text-blue-500 rounded-lg dark:bg-blue-300" : ""}`} |
| 58 | + > |
| 59 | + <a |
| 60 | + href={`/components/${menu}`} |
| 61 | + class="w-full block p-1" |
| 62 | + on:click={() => { |
| 63 | + showMenuMobile = !showMenuMobile; |
| 64 | + }}>{menu}</a |
| 65 | + > |
| 66 | + </li> |
| 67 | + {/each} |
| 68 | + </ul> |
| 69 | + {/if} |
| 70 | + </div> |
| 71 | +{/if} |
| 72 | + |
| 73 | +<style> |
| 74 | + .glass { |
| 75 | + background: rgba(255, 255, 255, 0.25); |
| 76 | + backdrop-filter: blur(4px); |
| 77 | + -webkit-backdrop-filter: blur(4px); |
| 78 | + } |
| 79 | +</style> |
0 commit comments