Files
minstrel/web/src/lib/components/SectionRail.svelte
T
bvandeusenandClaude Opus 5.5 10d50dccbd docs: web comments say what the app does, not how it came to be (#6277)
Rewrites the web app's comments to rule 32. Task, milestone, rule and
spec ids are gone; regression stories are restated as the trap they
guard (public auth routes, the menu's stopPropagation, universal loads
under adapter-static, metric deltas with their margin). Flutter and
Tauri mentions now name the Android app or a native shell, operator
quotes and dates are dropped, and one library's counts no longer
appear outside test fixtures. Verified with a TypeScript-scanner token
comparison (template literals and regex literals re-scanned): only
comment text changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:42:12 -04:00

62 lines
2.3 KiB
Svelte

<script lang="ts" module>
export type RailItem = {
href: string;
label: string;
count?: number;
attention?: number;
// Further paths that belong to this item, e.g. an artist's page under
// the Catalogue. The item is also current on any path below its href.
also?: string[];
// The item is current only on its exact href (a section's landing page,
// whose href prefixes every other item's).
exact?: boolean;
};
</script>
<script lang="ts">
import { page } from '$app/state';
// A section's pages, down the left: Collection and Settings
// both use it, so a section's navigation sits in the same place and looks
// the same everywhere (stable chrome). On a narrow screen the rail
// runs across the top. An item can carry a count and, accented, how many
// of those need a person.
let { label, items }: { label: string; items: RailItem[] } = $props();
function isActive(item: RailItem): boolean {
const path = page.url.pathname;
if (item.also?.some((p) => path.startsWith(p))) return true;
return item.exact ? path === item.href : path === item.href || path.startsWith(item.href + '/');
}
</script>
<nav aria-label={label} class="border-b border-border md:border-b-0 md:border-r md:pr-3">
<ul class="flex gap-1 overflow-x-auto md:flex-col md:overflow-visible">
{#each items as item (item.href)}
{@const active = isActive(item)}
<li>
<a
href={item.href}
aria-current={active ? 'page' : undefined}
class="flex items-center gap-1.5 whitespace-nowrap border-b-2 px-3 py-2 text-sm transition-colors md:rounded-md md:border-b-0 md:border-l-2 {active
? 'border-accent text-text-primary md:bg-surface-hover'
: 'border-transparent text-text-secondary hover:text-text-primary md:hover:bg-surface-hover'}"
>
<span class="md:flex-1">{item.label}</span>
{#if item.attention}
<span
class="rounded-full bg-accent px-1.5 text-xs text-text-on-accent"
aria-label="{item.attention} need you"
data-testid="tab-attention">{item.attention}</span
>
{/if}
{#if item.count !== undefined}
<span class="text-xs tabular-nums text-text-muted">{item.count}</span>
{/if}
</a>
</li>
{/each}
</ul>
</nav>