Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / lib / components / ui / Tabs.svelte
1.4 kB 56 lines
1<script module lang="ts"> 2 import type { Component } from "svelte"; 3 import type { SvelteHTMLElements } from "svelte/elements"; 4 5 export interface TabDef { 6 id: string; 7 label: string; 8 href: string; 9 icon?: Component<SvelteHTMLElements["svg"]>; 10 count?: number; 11 } 12</script> 13 14<script lang="ts"> 15 import { resolve } from "$app/paths"; 16 17 interface Props { 18 tabs: TabDef[]; 19 active: string; 20 label?: string; 21 } 22 23 let { tabs, active, label }: Props = $props(); 24</script> 25 26<nav class="w-full overflow-x-auto overflow-y-hidden pl-4" aria-label={label}> 27 <div class="flex"> 28 {#each tabs as tab (tab.id)} 29 {@const isActive = active === tab.id} 30 {@const Glyph = tab.icon} 31 <a 32 href={resolve(tab.href as "/")} 33 class="group relative -mr-px no-underline hover:no-underline" 34 aria-current={isActive ? "page" : undefined} 35 > 36 <div 37 class={`relative mr-1 min-w-[80px] rounded-t px-4 py-1 text-center whitespace-nowrap text-foreground-default ${ 38 isActive 39 ? "-mb-px bg-background-default font-medium" 40 : "group-hover:bg-background-inset/25" 41 }`} 42 > 43 <span class="flex items-center justify-center"> 44 {#if Glyph} 45 <Glyph class="mr-2 h-4 w-4" aria-hidden="true" /> 46 {/if} 47 {tab.label} 48 {#if tab.count} 49 <span class="ml-1 rounded bg-background-inset px-1 text-sm">{tab.count}</span> 50 {/if} 51 </span> 52 </div> 53 </a> 54 {/each} 55 </div> 56</nav>