Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/SantaClaas/gigit. git client
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import { For, Show } from "solid-js";
import type { RefEntry } from "../lib/bindings";import type { Refs } from "../lib/refs";
/** * The repository's references. * * Entries are text rather than buttons: nothing happens when you click a * branch yet, and a control that looks interactive but is not is worse than * plain text. They become controls when checking out exists. */export default function RepositoryNav(props: { refs: Refs; /** The checked-out branch, so it can be marked among the others. */ head?: string; /** Whether a repository is open at all. */ isOpen: boolean;}) { return ( <nav aria-label="Repository" class="overflow-auto border-r border-outline-variant bg-surface-container-low p-3" > <ul class="flex flex-col gap-5"> <Section title="Branches" entries={props.refs.grouped().branches} head={props.head} isOpen={props.isOpen} /> <Section title="Remotes" entries={props.refs.grouped().remotes} isOpen={props.isOpen} /> <Section title="Tags" entries={props.refs.grouped().tags} isOpen={props.isOpen} /> </ul> </nav> );}
function Section(props: { title: string; entries: RefEntry[]; head?: string; isOpen: boolean }) { const headingId = () => `refs-${props.title.toLowerCase()}`;
return ( <li> <h2 id={headingId()} class="flex items-baseline gap-2 px-2 py-1"> <span class="text-label-lg text-on-surface-variant">{props.title}</span> <Show when={props.entries.length > 0}> {/* A count is worth having when a repository has hundreds of remote branches and the list below is mostly off screen. */} <span class="text-label-sm text-on-surface-variant tabular-nums"> {props.entries.length} </span> </Show> </h2>
<Show when={props.entries.length > 0} fallback={ <p class="px-2 text-body-sm text-on-surface-variant">{props.isOpen ? "None" : "—"}</p> } > <ul aria-labelledby={headingId()} class="flex flex-col"> <For each={props.entries}> {(entry) => ( <li class={[ "truncate px-2 py-0.5 text-body-md", entry.shorthand === props.head ? "font-medium text-primary" : "text-on-surface", ]} title={entry.name} > <Show when={entry.shorthand === props.head}> <span class="sr-only">current branch: </span> </Show> {entry.shorthand} </li> )} </For> </ul> </Show> </li> );}