Something went wrong. Try again.
small gleam coding and (not yet) persistent agent daemon with a detachable cli forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197<script lang="ts"> import { onMount } from 'svelte'; import type { LoginTerms } from './api';
// A provider's warning that its sign-in breaks its terms outside its own // apps, centred over the page like the terminal's box: Enter or the primary // button goes on, Esc or the other button backs out. let { terms, title, back, proceed, once = false, onback, onproceed, }: { terms: LoginTerms; title: string; back: string; proceed: string; /** Says the warning will not come back after `proceed`. */ once?: boolean; onback: () => void; onproceed: () => void; } = $props();
let dialog = $state<HTMLDialogElement>(); let primary = $state<HTMLButtonElement>();
// Focus goes back to where it was, the message's field, when the dialog // goes away. onMount(() => { const before = document.activeElement; dialog?.showModal(); primary?.focus(); return () => { if (before instanceof HTMLElement) before.focus(); }; });
// Enter on a focused button is that button's; anywhere else it goes on. function keydown(event: KeyboardEvent) { const target = event.target as HTMLElement; if ( event.key === 'Enter' && !event.isComposing && !target.closest('button') ) onproceed(); else if (event.key === 'Escape') onback(); else return; event.preventDefault(); event.stopPropagation(); }</script>
<dialog bind:this={dialog} aria-labelledby="terms-headline" oncancel={(event) => (event.preventDefault(), onback())} onkeydown={keydown}> <div class="box"> <header> <span class="title">{title}</span><span class="about">{terms.about}</span> </header> <p class="headline" id="terms-headline">{terms.headline}</p> {#each terms.paragraphs as paragraph, index (index)} <p class="note">{paragraph}</p> {/each} {#if once}<p class="once">albedo shows this once per provider.</p>{/if} <footer> <button type="button" class="quiet" onclick={onback} >{back}<kbd>esc</kbd></button > <button type="button" class="primary" bind:this={primary} onclick={onproceed}>{proceed}<kbd>↵</kbd></button > </footer> </div></dialog>
<style> dialog { width: min(480px, calc(100vw - 24px)); padding: 0; color: var(--text); background: var(--surface); border: 0; border-radius: 14px; box-shadow: var(--shadow-raised); } dialog::backdrop { background: var(--scrim); } .box { display: flex; flex-direction: column; padding: 14px 18px 16px; font-size: calc(13.5px * var(--ui-scale)); line-height: 1.45; } header { display: flex; align-items: baseline; gap: 10px; min-width: 0; margin-bottom: 10px; } .title { flex: none; font: 600 calc(12.5px * var(--ui-scale)) var(--mono); } .about { min-width: 0; overflow: hidden; color: var(--muted); font: calc(12.5px * var(--ui-scale)) var(--mono); white-space: nowrap; text-overflow: ellipsis; } p { margin: 0; } .headline { color: var(--danger); font-size: calc(15px * var(--ui-scale)); font-weight: 600; } .note { margin-top: 8px; color: var(--muted); } .once { margin-top: 10px; color: var(--faint); font-size: calc(12.5px * var(--ui-scale)); } footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; } footer button { display: inline-flex; align-items: center; gap: 2px; padding: 6px 8px 6px 12px; color: var(--text); font: inherit; font-weight: 550; background: var(--well); border: 0; border-radius: 9px; cursor: pointer; } footer .primary { color: var(--surface); background: var(--accent); } footer button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; } kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 4px; color: inherit; font: 600 calc(11px * var(--ui-scale)) var(--sans); background: color-mix(in oklab, currentColor 14%, transparent); border-radius: 5px; opacity: 0.8; } @media (max-width: 760px) { dialog { width: calc(100vw - 20px); margin: auto auto 10px; } kbd { display: none; } footer button { flex: 1; justify-content: center; padding: 10px 12px; } }</style>