Dough Git

clove/pkviewer

web/src/lib/components/manage/SystemNav.svelte

back to web/src/lib/components/manage

<!-- web/src/lib/components/manage/SystemNav.svelte -->
<script lang="ts">
  import { page } from "$app/state";
  import type { IconName } from "$lib/icons.ts";
  import Icon from "../Icon.svelte";

  let { systemId }: { systemId: string } = $props();

  const SECTIONS: Array<{ slug: string; label: string; icon: IconName }> = [
    { slug: "", label: "Overview", icon: "grid-1x2" },
    { slug: "address", label: "Public address", icon: "globe2" },
    { slug: "appearance", label: "Appearance", icon: "palette-fill" },
    { slug: "directory", label: "Layout", icon: "sliders" },
    { slug: "links", label: "Social links", icon: "link-45deg" },
    { slug: "members", label: "Members", icon: "people" },
    // Last and "Advanced" on purpose: the only control that can produce a broken page
    { slug: "css", label: "Advanced CSS", icon: "code-slash" },
  ];

  const base = $derived(`/manage/${systemId}`);
  const pathname = $derived(page.url.pathname);
</script>

<nav class="mg-nav" aria-label="System settings">
  {#each SECTIONS as section (section.label)}
    {@const href = section.slug ? `${base}/${section.slug}` : base}
    {@const active = section.slug
      ? pathname.startsWith(href)
      : pathname === base || pathname === `${base}/`}
    <a {href} aria-current={active ? "page" : undefined}>
      <Icon name={section.icon} />
      {section.label}
    </a>
  {/each}
</nav>