lumbda/wasm/app/style.css
russell@unturf.com ffada026ae
playground: split streamed chunks into per-line divs + per-program drafts
Two fixes in one push.

(1) Streaming horizontal-output bug, take three. textContent += chunk
then appendChild(createTextNode(chunk)) both still rendered chunks
horizontally in fox's Firefox tab even though the chunks clearly
contained \\n (node test confirmed; deployed loader hash matched
local; curl-fetched lumbda-c.loader.js carried the line + '\\n' fix).
Whatever the browser was doing with sibling text nodes inside a
<pre> wasn't honoring the embedded newlines.

Switch to one <div class=\"stream-line\"> per logical line. liveBlock.append
walks the incoming chunk byte by byte, every \\n closes the current
pending div and spawns a fresh empty one for the next line. CSS
adds .stream-line { display: block; white-space: pre; } so each
finished line stacks vertically no matter what the parent
white-space rule was doing. Empty lines get a single space so they
take a row instead of collapsing. Reconcile path inside finalize()
compares the joined per-line text to the full output and rebuilds
the div column if they diverge — for the asm-tier fallback we
already had and now also for any future browser/wasm combo where
a flush silently drops a chunk.

Also drops the temporary [c-tier print] console.log debug we added
in the last commit — diagnosis arrived from elsewhere, no point
keeping the spam.

(2) Per-program autosave drafts. scheduleFreeFormSave previously
returned early if the selected program wasn't \"free-form\", so a
user who unlocked the vault, edited the bend-gpu demo, and came
back later found their edits gone — only free-form persisted.
Now drafts live as { [programName]: text } in the vault payload;
every edit, regardless of which radio is selected, debounces a
save into drafts[currentProgram]. unlockVault loads any saved
draft for the current program (and lifts the legacy
top-level freeForm field into drafts['free-form'] so existing
users don't lose their work). loadCurrentDemo shows a saved
draft instead of the ship default whenever one exists; vault bar
stays visible across all programs once the vault is engaged so
the save status note is always reachable.
2026-06-15 06:02:37 -04:00

383 lines
9.3 KiB
CSS

/* lumbda playground — grid-only layout, matches lumbda.com homepage palette.
* No flexbox. Every multi-child layout uses CSS Grid. */
@font-face {
font-family: 'chunkfive';
src: url('fonts/chunkfive/chunkfive-regular-webfont.woff2') format('woff2'),
url('fonts/chunkfive/chunkfive-regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
:root {
--fg: #1a1a1a;
--bg: #fafaf7;
--muted: #666;
--accent: #227842;
--green: #227842;
--rule: #d4d4d0;
--code-bg: #f0ede4;
--pane-bg: #ffffff;
--busy: #b15a00;
--err: #b1262b;
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
@media (prefers-color-scheme: dark) {
:root {
--fg: #e8e6e0;
--bg: #161613;
--muted: #9a9892;
--accent: #5ec07a;
--green: #5ec07a;
--rule: #3a3a36;
--code-bg: #22221f;
--pane-bg: #1c1c19;
--busy: #e0a050;
--err: #f06070;
}
}
* { box-sizing: border-box; }
/* The hidden attribute must beat author display rules.
* Without !important, .lock-screen { display: grid } overrides
* [hidden]'s UA default of display: none. */
[hidden] { display: none !important; }
html {
/* Comfortable default zoom. */
zoom: 1.33;
}
html, body {
margin: 0; padding: 0;
background: var(--bg);
color: var(--fg);
font-family: var(--mono);
font-size: 14px;
line-height: 1.55;
}
/* ─── Header ────────────────────────────────────────────────────── */
header {
border-bottom: 1px solid var(--rule);
padding: 1.5rem 1.5rem 1rem;
}
.brand {
display: inline-grid;
grid-template-columns: auto auto;
align-items: end;
gap: 0.6rem;
text-decoration: none;
color: inherit;
}
.brand:hover .period { transform: translateY(-2px); }
.brand .logo {
width: 3.2rem;
height: auto;
display: block;
/* Flip vertically + horizontally (= 180°) to match the inverted-λ
* convention from the homepage's hand-drawn artwork. */
transform: scale(-1, -1);
}
header h1 {
font-family: 'chunkfive', Georgia, serif;
font-size: 2.4rem;
margin: 0;
letter-spacing: -0.01em;
line-height: 1;
font-weight: normal;
}
header h1 .period {
color: var(--green);
display: inline-block;
transition: transform 120ms ease;
}
header .tagline {
font-family: 'chunkfive', Georgia, serif;
color: var(--muted);
margin: 0.4rem 0 0.6rem;
font-size: 1rem;
letter-spacing: 0.01em;
}
header .lede {
margin: 0;
max-width: 70rem;
color: var(--fg);
font-size: 0.85rem;
line-height: 1.55;
}
header .lede strong {
color: var(--green);
font-weight: 600;
}
header code {
background: var(--code-bg);
padding: 0 0.2em;
border-radius: 2px;
font-size: 0.9em;
}
/* ─── Controls ──────────────────────────────────────────────────── */
.controls {
padding: 0.75rem 1.5rem;
border-bottom: 1px solid var(--rule);
display: grid;
grid-template-columns: auto auto auto auto 1fr;
grid-template-rows: auto auto;
gap: 0.3rem 1rem;
align-items: center;
background: var(--bg);
}
.controls fieldset {
border: 1px solid var(--rule);
border-radius: 3px;
padding: 3px 10px 5px;
margin: 0;
background: var(--pane-bg);
}
.controls fieldset legend {
color: var(--muted);
font-size: 0.7rem;
padding: 0 0.4em;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.controls label {
display: block;
margin: 0.1em 0;
cursor: pointer;
user-select: none;
font-size: 0.85em;
}
.controls label input {
margin-right: 0.3em;
accent-color: var(--green);
}
.controls button {
font-family: var(--mono);
font-size: 0.85em;
font-weight: 600;
padding: 6px 16px;
border-radius: 3px;
cursor: pointer;
border: 1px solid var(--green);
}
.controls button.primary {
background: var(--green);
color: var(--bg);
}
.controls button.primary:hover { filter: brightness(1.08); }
.controls button.primary:disabled {
opacity: 0.4; cursor: wait;
filter: none;
}
.controls button.secondary {
background: transparent;
color: var(--green);
}
.controls button.secondary:hover {
background: var(--code-bg);
}
.controls button.secondary:disabled {
opacity: 0.35; cursor: default;
}
.controls .status {
/* Tuck the live ms counter directly under the run + cancel buttons
* (columns 3-4 in the controls grid) so the eye finds the elapsed
* timer next to the action that started it. */
grid-column: 3 / span 2;
grid-row: 2;
justify-self: start;
color: var(--muted);
font-size: 0.8em;
}
.controls .status.busy { color: var(--busy); }
.controls .status.warn { color: var(--busy); }
.controls .status.err { color: var(--err); }
.controls .status.ok { color: var(--green); }
/* ─── Config bar: bend + vault side by side ────────────────────── */
.config-bar {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.6rem;
padding: 0.4rem 1.5rem;
border-bottom: 1px solid var(--rule);
background: var(--bg);
font-size: 0.85em;
}
.bend-bar {
display: grid;
grid-template-columns: auto 1fr auto auto;
gap: 0.5rem;
align-items: center;
}
.bend-bar .bend-icon { font-size: 1em; }
.bend-bar input[type=url] {
background: var(--code-bg);
border: 1px solid var(--rule);
color: var(--fg);
padding: 0.3rem 0.5rem;
font-family: var(--mono);
font-size: 0.9em;
border-radius: 3px;
min-width: 0;
}
.bend-bar input[type=url]:focus { outline: none; border-color: var(--green); }
.bend-bar button {
background: transparent;
color: var(--green);
border: 1px solid var(--green);
font-family: var(--mono);
font-size: 0.85em;
font-weight: 600;
padding: 0.3rem 0.8rem;
border-radius: 3px;
cursor: pointer;
}
.bend-bar button:hover { background: var(--code-bg); }
.bend-bar .bend-state { color: var(--green); font-size: 0.8em; min-width: 4em; }
.vault-bar {
display: grid;
grid-template-columns: auto auto auto auto auto 1fr;
gap: 0.5rem;
align-items: center;
}
.vault-bar .vault-icon { font-size: 1em; }
.vault-bar .vault-state { color: var(--muted); }
.vault-bar .vault-state.unlocked { color: var(--green); }
.vault-bar input[type=password] {
background: var(--code-bg);
border: 1px solid var(--rule);
color: var(--fg);
padding: 0.3rem 0.5rem;
font-family: var(--mono);
font-size: 0.9em;
border-radius: 3px;
min-width: 0;
}
.vault-bar input[type=password]:focus { outline: none; border-color: var(--green); }
.vault-bar button {
background: transparent;
color: var(--green);
border: 1px solid var(--green);
font-family: var(--mono);
font-size: 0.85em;
font-weight: 600;
padding: 0.3rem 0.8rem;
border-radius: 3px;
cursor: pointer;
}
.vault-bar button:hover { background: var(--code-bg); }
.vault-bar .vault-note { color: var(--muted); font-size: 0.85em; }
.vault-bar .vault-note.err { color: var(--err); }
/* ─── Panes ─────────────────────────────────────────────────────── */
.panes {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1px;
background: var(--rule);
align-items: start;
}
.pane {
background: var(--pane-bg);
padding: 0.5rem 0.75rem 0.75rem;
display: grid;
grid-template-rows: auto 1fr;
gap: 0.4rem;
}
.pane h2 {
margin: 0;
font-size: 0.7rem;
font-weight: 500;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.1em;
}
#editor {
border-radius: 2px;
}
.cm-editor { font-size: 13px; }
.cm-editor.cm-focused { outline: none; }
.cm-scroller { overflow: visible; }
#output {
white-space: pre;
background: var(--code-bg);
border-radius: 2px;
padding: 0.6rem 0.8rem;
font-size: 13px;
line-height: 1.35;
}
#output .tier-block { margin-bottom: 1rem; }
#output .tier-block:last-child { margin-bottom: 0; }
#output .tier-block h3 {
margin: 0 0 0.25rem;
font-size: 0.7rem;
color: var(--green);
text-transform: uppercase;
letter-spacing: 0.1em;
font-weight: 600;
}
#output .tier-block .time {
color: var(--muted);
font-size: 0.65rem;
font-weight: 400;
letter-spacing: 0;
text-transform: none;
}
#output .tier-block pre {
margin: 0;
white-space: pre;
font-family: var(--mono);
}
/* Streamed output: each emit_chunk slice that ended with \n becomes
its own <div class="stream-line"> child of the <pre>. Block display
guarantees vertical stacking regardless of how the browser handles
raw \n inside a sequence of text nodes — the bug we kept chasing
in firefox where "tick 0\ntick 10000\n..." rendered horizontally
even though each text node clearly contained the newline byte. */
#output .tier-block .stream-line {
display: block;
white-space: pre;
}
#output .err { color: var(--err); }
/* ─── Footer ────────────────────────────────────────────────────── */
footer {
padding: 0.7rem 1.5rem;
border-top: 1px solid var(--rule);
color: var(--muted);
font-size: 0.75rem;
}
footer code {
background: var(--code-bg);
padding: 0 0.2em;
border-radius: 2px;
}
footer a {
color: var(--green);
text-decoration: none;
}
footer a:hover { text-decoration: underline; }
footer strong { color: var(--fg); }