Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/SantaClaas/gigit. git client
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394import { For, Show } from "solid-js";
import type { GraphRow, RefBadge } from "../lib/bindings";import { absoluteTime, isoTime, relativeTime, shortId } from "../lib/format";import GraphLanes from "./GraphLanes";
/** What a ref badge is, spoken rather than shown. */function describe(badge: RefBadge): string { switch (badge.kind) { case "localBranch": return badge.isHead ? "current branch" : "branch"; case "remoteBranch": return "remote branch"; case "tag": return "tag"; case "other": return "reference"; }}
/** * One commit. * * The row is a button because selecting a commit is an action, and a button * brings its own role, focus ring and Enter/Space handling. That constrains the * contents to phrasing content — which is why the ref badges are spans rather * than a list. */export default function CommitRow(props: { row: GraphRow; isSelected: boolean; onSelect: () => void; onKeyDown: (event: KeyboardEvent) => void;}) { return ( <li> <button type="button" data-row={props.row.row} // Roving tabindex: one stop for the whole history, not one per commit. tabindex={props.isSelected ? 0 : -1} aria-current={props.isSelected ? "true" : undefined} onClick={props.onSelect} onFocus={props.onSelect} onKeyDown={props.onKeyDown} class="flex h-(--row-height) w-full items-center gap-3 rounded-small px-2 text-left whitespace-nowrap hover:bg-surface-container focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary aria-[current]:bg-secondary-container aria-[current]:text-on-secondary-container" > <GraphLanes row={props.row} />
<Show when={props.row.refs.length > 0}> <span class="flex shrink-0 items-center gap-1"> <For each={props.row.refs}> {(badge) => ( <span class={[ "rounded-extra-small px-1.5 py-0.5 text-label-sm", badge.isHead ? "bg-primary text-on-primary" : "bg-surface-container-highest text-on-surface-variant", ]} > <span class="sr-only">{describe(badge)}: </span> {badge.shorthand} </span> )} </For> </span> </Show>
<span class="min-w-0 flex-1 overflow-hidden text-body-md text-ellipsis"> {props.row.summary} </span>
<span class="hidden shrink-0 text-body-sm text-on-surface-variant sm:inline"> {props.row.author} </span>
<time datetime={isoTime(props.row.time)} title={absoluteTime(props.row.time)} class="shrink-0 text-body-sm text-on-surface-variant tabular-nums" > {relativeTime(props.row.time)} </time>
<span class="shrink-0 font-mono text-body-sm text-on-surface-variant"> <span class="sr-only">commit </span> {shortId(props.row.id)} </span> </button> </li> );}