Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216<script lang="ts"> import type { Board } from '../board.svelte'; import Gesture, { drawn } from '../Gesture.svelte'; import { canvasKeys } from '../keys'; import ExpandIcon from './ExpandIcon.svelte'; import { canvasAbove, type Canvas } from './tree';
// A canvas's view bar: the keys it answers that nothing on screen shows, // as the terminal's footer lists them (the key and the gesture with it, // drawn to keep the card short; the board's own canvas only, since one // inside the layout answers the same keys), and its zoom, fit and overview // map. A // canvas inside the layout can fill the board from here, and in the tiles // be closed (its windows stay) or carried by its grip beside another tile // (dock.svelte.ts); one on a canvas has its header for those. let { board, canvas, shown, width = $bindable(188), onenter, onleave, }: { board: Board; canvas: Canvas; shown: boolean; width?: number; onenter: () => void; onleave: () => void } = $props();
const hints = canvasKeys.filter(({ where }) => where !== 'pane');
const nested = $derived(board.root.id !== canvas.id); const tiled = $derived(nested && !canvasAbove(board.root, canvas.id)); const zoom = $derived(Math.round(board.viewOf(canvas.id).zoom * 100));</script>
<div class="view" class:shown onpointerenter={onenter} onpointerleave={onleave} role="presentation"> {#if !nested} <p class="hints" aria-hidden="true"> {#each hints as { keys, does } (does)} <span class="hint"> <kbd> {#each keys as key, at (at)} {#if drawn(key)}<Gesture kind={key} />{:else}{key}{/if} {/each} </kbd> {does} </span> {/each} </p> {/if} <div class="controls" role="toolbar" aria-label="View" tabindex="-1" bind:offsetWidth={width}> <button class="step" aria-label="Zoom out" title="Zoom out (−)" onclick={() => board.stepZoom(-1, canvas.id)}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 8h8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" /></svg> </button> <button class="level" title="Zoom to 100% (⇧0)" onclick={() => board.zoomTo(1, canvas.id)}>{zoom}%</button> <button class="step" aria-label="Zoom in" title="Zoom in (+)" onclick={() => board.stepZoom(1, canvas.id)}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 8h8M8 4v8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" /></svg> </button> <button class="fit" aria-label="Fit all windows" title="Fit all windows (⇧1)" onclick={() => board.fit(canvas.id)}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M2.5 6V3.5a1 1 0 011-1H6M10 2.5h2.5a1 1 0 011 1V6M13.5 10v2.5a1 1 0 01-1 1H10M6 13.5H3.5a1 1 0 01-1-1V10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" /></svg> </button> <button class="map" aria-label="Overview map" aria-pressed={!!canvas.map} title="Overview map (M)" class:on={canvas.map} onclick={() => board.toggleMap(canvas.id)}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><rect x="2" y="3" width="12" height="10" rx="2" fill="none" stroke="currentColor" stroke-width="1.3" /><rect x="4.5" y="5.5" width="4" height="3" rx="0.75" fill="currentColor" /></svg> </button> {#if nested} {@const expanded = board.expanded === canvas.id} <button aria-label={expanded ? 'Unfocus canvas' : 'Focus canvas'} aria-pressed={expanded} title={expanded ? 'Back to the board (esc)' : 'Focus: fill the board with this canvas'} onclick={() => board.toggleExpanded(canvas.id)}> <ExpandIcon {expanded} size={14} /> </button> {/if} {#if tiled} <button class="grip" aria-label="Move canvas" title="Drag to move this canvas beside another tile" data-dock-tile={canvas.id}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"> {#each [4, 8, 12] as y (y)}<circle cx="6" cy={y} r="1.1" fill="currentColor" /><circle cx="10" cy={y} r="1.1" fill="currentColor" />{/each} </svg> </button> <button aria-label="Ungroup" title="Ungroup: its windows are tiled in its place" onclick={() => board.ungroupCanvas(canvas.id)}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M6.5 8H2m0 0 2-2M2 8l2 2M9.5 8H14m0 0-2-2m2 2-2 2" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" /></svg> </button> <button aria-label="Close canvas" title="Close canvas and the windows in it" onclick={() => board.closeTile(canvas.id)}> <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4.5 4.5l7 7M11.5 4.5l-7 7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" /></svg> </button> {/if} </div></div>
<style> /* Hidden, it lets clicks through to whatever window sits under it. */ .view { visibility: hidden; opacity: 0; transition: opacity 600ms ease, visibility 0s linear 600ms; position: absolute; right: 14px; bottom: 14px; left: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; /* The stretch between the hints and the controls is still canvas. */ pointer-events: none; } .view.shown, .view:focus-within { visibility: visible; opacity: 1; transition: opacity 160ms ease, visibility 0s; } @media (prefers-reduced-motion: reduce) { .view { transition: none; } } .view button { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; color: var(--muted); font: inherit; font-size: calc(12px * var(--ui-scale)); background: none; border: 0; border-radius: 8px; cursor: pointer; transition: background-color 120ms ease, color 120ms ease; } .view button:hover { color: var(--text); background: var(--hover); } .view button:active { transform: scale(0.95); } .view .grip { cursor: grab; touch-action: none; } .view .on { color: var(--accent); } .view .level { min-width: 52px; font-variant-numeric: tabular-nums; } /* A small canvas tile, or one on a canvas zoomed out, keeps its grip, close and zoom level, the level still a reset to 100%: fit and the map go first, then the zoom steps. */ @container canvas (max-width: 300px) or (max-height: 200px) { .view .fit, .view .map { display: none; } } @container canvas (max-width: 220px) or (max-height: 140px) { .view { right: 6px; left: 6px; } .view .step { display: none; } } .controls { display: flex; flex: none; align-items: center; gap: 2px; margin-left: auto; pointer-events: auto; padding: 4px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); } /* As the terminal's footer, the key standing out from what it does, each pair on a surface of its own beside the controls. One row of them: on a narrow canvas the ones that do not fit wrap out of sight, never cut in half; the padding is room for their shadows. */ .hints { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 6px; min-width: 0; height: 46px; margin: -8px; padding: 8px; overflow: hidden; color: var(--muted); font-size: calc(12px * var(--ui-scale)); white-space: nowrap; pointer-events: none; } /* Centred rather than on a baseline: a key that is all drawing has none. */ .hints .hint { display: flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; background: var(--surface); border-radius: 9px; box-shadow: var(--shadow); } .hints kbd { display: inline-flex; align-items: center; gap: 3px; min-width: 0; height: auto; padding: 0; color: var(--text); font: inherit; background: none; }</style>