Sidebar.svelte 891 B

12345678910111213141516171819202122232425262728293031
  1. <script lang="ts">
  2. import { page } from "$app/state";
  3. import { onMount } from "svelte";
  4. type Link = { label: string; href: string };
  5. let links: Link[] = [];
  6. onMount(async () => {
  7. links = [
  8. { label: "Главная", href: "/" },
  9. { label: "Клиенты", href: "/clients" },
  10. { label: "Товары", href: "/products" },
  11. { label: "Звонки", href: "/calls" },
  12. { label: "Заказы", href: "/orders" },
  13. ];
  14. });
  15. </script>
  16. <nav class="flex flex-col w-44 p-4 bg-gray-100 h-screen">
  17. {#each links as link}
  18. <a
  19. href={link.href}
  20. class="px-4 py-2 mb-2 rounded font-medium text-black {page.url
  21. .pathname === link.href
  22. ? 'bg-gray-300 '
  23. : ''}"
  24. >
  25. {link.label}
  26. </a>
  27. {/each}
  28. </nav>