Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/SantaClaas/gigit. git client
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import { For, Show } from "solid-js";
import type { RecentRepository } from "../lib/bindings";import { absoluteTime, isoTime, relativeTime } from "../lib/format";import type { Recents } from "../lib/recents";
/** * Repositories opened before. * * Each row is two controls rather than one with a nested button, which HTML * does not allow: opening is the row itself, forgetting sits beside it. */export default function RecentRepositories(props: { recents: Recents; onOpen: (path: string) => void;}) { return ( <Show when={props.recents.entries().length > 0}> <div class="mt-8 w-full max-w-xl"> <h3 id="recent-heading" class="mb-2 text-label-lg text-on-surface-variant"> Recent </h3>
{/* Named after its heading so it is addressable as "the recent list" rather than just "a list". Naming a <ul> keeps it a list; naming a <section> would turn it into a region landmark, which this is not. */} <ul aria-labelledby="recent-heading" class="flex flex-col gap-1"> <For each={props.recents.entries()}> {(entry) => <Row entry={entry} onOpen={props.onOpen} recents={props.recents} />} </For> </ul> </div> </Show> );}
function Row(props: { entry: RecentRepository; recents: Recents; onOpen: (path: string) => void }) { return ( <li class="flex items-center gap-2"> <button type="button" onClick={() => props.onOpen(props.entry.path)} class="flex min-w-0 flex-1 items-baseline gap-3 rounded-medium px-3 py-2 text-left hover:bg-surface-container focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary" > <span class="shrink-0 text-body-lg">{props.entry.name}</span>
<span class="min-w-0 flex-1 truncate text-body-sm text-on-surface-variant"> {props.entry.path} </span>
<Show when={!props.entry.exists}> {/* Still openable — a network mount may simply be away — but the reason a click might fail should be visible before it does. */} <span class="shrink-0 rounded-extra-small bg-error-container px-1.5 py-0.5 text-label-sm text-on-error-container"> Missing </span> </Show>
<time datetime={isoTime(props.entry.lastOpened)} title={absoluteTime(props.entry.lastOpened)} class="shrink-0 text-body-sm text-on-surface-variant" > {relativeTime(props.entry.lastOpened)} </time> </button>
<button type="button" onClick={() => void props.recents.forget(props.entry.id)} class="shrink-0 rounded-medium px-3 py-2 text-label-lg text-on-surface-variant hover:bg-surface-container focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary" > Forget {/* Every one of these reads "Forget" on screen; the name says which. */} <span class="sr-only"> {props.entry.name}</span> </button> </li> );}