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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123<script lang="ts"> import { tileElement, type Board } from '../board.svelte'; import type { Mark } from './moves'; import { half } from './dock.svelte'; import { frameOf } from './tree';
// What the layout keys show over the board: a letter on every window to // pick from, the half of a window the next one will land in, and a line // saying what the keys do now. let { board, picks, hint, }: { board: Board; picks: Mark[]; hint: string | null } = $props();
let area = $state<{ left: number; top: number; width: number; height: number; } | null>(null);
// Measured every frame, so it follows a resize, a pan or a zoom. $effect(() => { const presel = board.presel; if (!presel) return void (area = null); let frame = requestAnimationFrame(function measure() { const tile = frameOf(board.root, presel.pane); const element = tileElement(tile?.id ?? presel.pane); const next = element ? half(element.getBoundingClientRect(), presel.side) : null; if (JSON.stringify(next) !== JSON.stringify(area)) area = next; frame = requestAnimationFrame(measure); }); return () => cancelAnimationFrame(frame); });</script>
<div class="marks" aria-hidden="true"> {#if area} <div class="presel" style:left="{area.left}px" style:top="{area.top}px" style:width="{area.width}px" style:height="{area.height}px" ></div> {/if} {#each picks as mark (mark.window)} <span class="pick" class:tab={mark.tab} class:own={mark.window === board.selected} style:left="{mark.tab ? mark.rect.right - 22 : mark.rect.left + mark.rect.width / 2 - 17}px" style:top="{mark.tab ? mark.rect.top + mark.rect.height / 2 - 10 : mark.rect.top + mark.rect.height / 2 - 17}px">{mark.letter}</span > {/each}</div>{#if hint} <p class="say" role="status">{hint}</p>{/if}
<style> .marks { position: fixed; inset: 0; z-index: var(--z-docking); pointer-events: none; } .presel { position: fixed; background: repeating-linear-gradient( 45deg, color-mix(in oklab, var(--accent) 18%, transparent) 0 6px, transparent 6px 12px ); border: 2px dashed color-mix(in oklab, var(--accent) 70%, transparent); border-radius: 12px; } .pick { position: fixed; width: 34px; height: 34px; color: var(--surface); font: 600 17px/34px var(--mono); text-align: center; background: var(--accent); border-radius: 9px; box-shadow: var(--shadow-lg); } .pick.tab { width: 20px; height: 20px; font-size: 12px; line-height: 20px; border-radius: 6px; } .pick.own { opacity: 0.45; } .say { position: absolute; bottom: 60px; left: 50%; z-index: var(--z-docking); margin: 0; padding: 6px 12px; color: var(--text); font-size: calc(12px * var(--ui-scale)); white-space: nowrap; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-lg); transform: translateX(-50%); pointer-events: none; }</style>