feat(overlay): package shell and the css-in-ts style system

Styles are authored in TypeScript and emitted into the overlay's own shadow root.
The overlay is injected into a page it does not control, so it can neither leak
styles into that page nor inherit them from it.

check-css.mjs is the guard: it fails the build on a raw value where a token
exists, which is the drift that would otherwise accumulate one hex code at a
time.
This commit is contained in:
Nayan
2026-07-31 17:56:00 +05:30
parent 5eab615279
commit 896c0982d1
21 changed files with 3869 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
{
"name": "@airship/overlay",
"version": "0.0.0",
"private": true,
"type": "module",
"exports": {
"./bundle": "./dist/overlay.global.js",
"./hook": "./dist/hook.global.js"
},
"scripts": {
"build": "node scripts/check-css.mjs && tsup",
"build-storybook": "storybook build",
"check:css": "node scripts/check-css.mjs",
"clean": "rm -rf dist .turbo storybook-static",
"dev": "tsup --watch",
"storybook": "storybook dev -p 6006 --no-open",
"test": "vitest run",
"test:browser": "vitest run --config vitest.browser.config.ts",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@airship/editor-icons": "workspace:*",
"@airship/editor-tokens": "workspace:*",
"@airship/protocol": "workspace:*",
"@airship/source": "workspace:*",
"@dnd-kit/abstract": "0.5.0",
"@dnd-kit/dom": "0.5.0",
"@dnd-kit/geometry": "0.5.0",
"bippy": "^0.5.32"
},
"devDependencies": {
"@storybook/addon-a11y": "10.5.7",
"@storybook/addon-vitest": "10.5.7",
"@storybook/html-vite": "10.5.7",
"@vitest/browser": "^4.1.10",
"@vitest/browser-playwright": "^4.1.10",
"happy-dom": "^20.11.1",
"playwright": "^1.62.1",
"storybook": "10.5.7",
"vite": "^7.3.6",
"vitest": "^4.1.10"
}
}
+145
View File
@@ -0,0 +1,145 @@
/*
* Guard the CSS template literals in `src/styles/*.css.ts`.
*
* Those files are one big backtick string each, so an unescaped backtick inside
* a CSS comment — the natural way to write `position: relative` in prose —
* silently terminates the literal and turns the rest of the stylesheet into
* TypeScript. `tsc` does catch it, but it reports a parse error thirty rules
* downstream of the cause and reads as a compiler bug. This names it.
*
* The scan starts at `export const css = \`` and walks the literal properly,
* stepping over `${ ... }` interpolations (which may themselves contain nested
* template literals) so only backticks in *CSS* text are reported.
*
* It also enforces one design rule that cannot be expressed in the type system:
* canvas chrome does not animate. See `NO_TRANSITION`.
*/
import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
const DIR = new URL("../src/styles/", import.meta.url).pathname;
const START = /export const css\s*=\s*`/;
const problems = [];
/**
* Stylesheets that may not declare a `transition`, and why.
*
* The hover and selection outlines are re-positioned on every pointer move, by
* writing a measured rect straight into `left`/`top`/`width`/`height`. A
* transition on those properties interpolates between one element's box and the
* next, so the outline visibly trails the cursor and lags behind whatever it is
* supposed to be tracking. It does not read as easing; it reads as the overlay
* being slow.
*
* This is not obvious from the rule that causes it — the offending declaration
* was a plausible-looking `transition: all .05s ease` that survived a long time
* — and it is exactly the sort of thing a well-meaning motion pass would put
* back. Hence a build check rather than a comment.
*
* Chrome that is *shown and hidden* rather than moved may still fade; list it in
* `allow` with the reason, and keep that list short.
*/
const NO_TRANSITION = [{ allow: ["snap-label"], file: "chrome.css.ts" }];
/** A `transition` / `transition-property` declaration starting a value. */
const TRANSITION_DECL = /(^|[;\s])transition(-[a-z]+)?\s*:/;
/** Walk one template literal from just after its opening backtick. */
function scan(source, from, file) {
let depth = 0; // `${ ... }` nesting
for (let i = from; i < source.length; i += 1) {
const c = source[i];
if (c === "\\") {
i += 1;
continue;
}
if (c === "$" && source[i + 1] === "{") {
depth += 1;
i += 1;
continue;
}
if (c === "}" && depth > 0) {
depth -= 1;
continue;
}
if (c === "`") {
if (depth > 0) {
// A nested literal inside an interpolation — skip to its end.
i = scan(source, i + 1, file).end;
continue;
}
return { closed: true, end: i };
}
}
problems.push(`${file}: template literal is never closed`);
return { closed: false, end: source.length };
}
for (const file of readdirSync(DIR).filter((f) => f.endsWith(".css.ts"))) {
const source = readFileSync(join(DIR, file), "utf8");
const start = START.exec(source);
if (!start) {
continue;
}
const open = start.index + start[0].length;
const { end } = scan(source, open, file);
// Anything after the literal should be whitespace and a semicolon. If the
// literal closed early, real CSS is sitting out here as broken TypeScript.
const tail = source.slice(end + 1).trim();
if (tail && tail !== ";") {
const line = source.slice(0, end).split("\n").length;
problems.push(
`${file}: the CSS literal closes at line ${line}, but the file continues.\n` +
" Almost always an unescaped backtick in a comment — escape it (\\`) " +
"or drop the quotes."
);
}
const body = source.slice(open, end);
const opens = (body.match(/{/g) ?? []).length;
const closes = (body.match(/}/g) ?? []).length;
// `${...}` contributes one of each, so they cancel.
if (opens !== closes) {
problems.push(
`${file}: unbalanced braces (${opens} open, ${closes} close)`
);
}
checkNoTransition(file, body);
}
/** Report `transition` declarations in a stylesheet that may not have them. */
function checkNoTransition(file, body) {
const rule = NO_TRANSITION.find((r) => r.file === file);
if (!rule) {
return;
}
// Split on `}` so each chunk holds one rule's selector and its declarations,
// which is enough to tell an allowed selector from a forbidden one.
for (const chunk of body.split("}")) {
if (!TRANSITION_DECL.test(chunk)) {
continue;
}
if (rule.allow.some((name) => chunk.includes(name))) {
continue;
}
const selector = chunk.split("{")[0].trim().split("\n").pop().trim();
problems.push(
`${file}: \`transition\` on \`${selector}\`.\n` +
" Canvas chrome is re-positioned on every pointer move, so a " +
"transition makes the outline trail the cursor.\n" +
" If this element is faded rather than moved, add its class to " +
"NO_TRANSITION's `allow` list with a reason."
);
}
}
if (problems.length) {
console.error(`check-css: ${problems.length} problem(s)\n`);
for (const p of problems) {
console.error(` ${p}`);
}
process.exit(1);
}
console.log("check-css: ok");
+100
View File
@@ -0,0 +1,100 @@
import { PREFIX } from "../dom";
import { ROOT, Z } from "./const";
/** Root reset, icon colour roles, edit/drag cursors, the drop sentinel. */
export const css = `
${ROOT}, ${ROOT} * { box-sizing: border-box; }
${ROOT} {
position: fixed; inset: 0; z-index: ${Z}; pointer-events: none;
font-family: var(--ap-font-sans); color: var(--ap-text-primary);
-webkit-font-smoothing: antialiased;
}
/* Icons sit one step below text, the way a design tool's do — an icon that matches the
text colour reads as loud as a label, which is what made the old chrome feel
busy. The --ap-icon-* ramp exists for exactly this and was previously unused,
so every glyph inherited --ap-text-primary (#FFF).
The tone comes through a custom property rather than being set flat, because
this selector is \`#id .class\` and it matches the glyph's own span. A rule
that matches an element beats any \`color\` that element would have inherited,
whatever the parent's specificity — so a button could not tint its own glyph.
Send was the visible casualty: \`.action.primary\` sets white, and the caret
painted #BEBEBE on the blue anyway, which is most of why it read as badly
set rather than merely small. A custom property inherits, so any ancestor can
set --ic-tone and the var() picks it up here with no specificity contest. */
${ROOT} .${PREFIX}-ic, .${PREFIX}-chrome-layer .${PREFIX}-ic {
display: inline-flex;
color: var(--${PREFIX}-ic-tone, var(--ap-icon-secondary));
}
${ROOT} .${PREFIX}-ic svg, .${PREFIX}-chrome-layer .${PREFIX}-ic svg { display: block; }
/* State tones set the same property, so there is one way to tint a glyph. These
land on the \`.ic\` element itself and a container's --ic-tone only reaches it
by inheritance, which is what keeps hover and disabled winning over it. */
${ROOT} button:hover .${PREFIX}-ic,
${ROOT} .${PREFIX}-ctl-seg-on .${PREFIX}-ic,
${ROOT} .${PREFIX}-insp-tab-on .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-icon-primary); }
${ROOT} button:disabled .${PREFIX}-ic,
${ROOT} [disabled] .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-icon-disabled); }
.${PREFIX}-hidden { display: none !important; }
/* Edit mode: the page is a canvas, not an app. Element-level cursors (a link's
pointer, an input's text caret) beat \`document.body.style.cursor\`, so the
arrow has to be forced from here — and text selection has to be off, or
dragging across the page selects paragraphs instead of moving elements.
The cursor is a plain arrow and not a crosshair, which is what this was for a
long time. A crosshair is what a design tool shows when you are about to *draw*
something — it means "click and drag defines a new rect". Edit mode does the
opposite: it points at things that already exist. Forcing a crosshair over
every element in the page turned a direct-manipulation surface into something
that read like a screenshot tool, and it fought the resize and grab cursors
the chrome sets deliberately.
The \`:not([data-…-drag])\` guard hands the cursor over to the drag rule below
for the duration of a gesture, which would otherwise lose on specificity. The
\`:not([data-…-text-edit])\` guard on the descendant does the same job for the
node being edited in place: this selector carries two ID-weight \`:not()\`
arguments and declares \`!important\`, so the rules in \`portable.css.ts\` cannot
beat it on merit, and without the exemption you get a crosshair and
\`user-select: none\` sitting on top of the text you are typing into. Inline
only — which is exactly why it is the sort of thing that gets found late.
Scoped to \`:not([data-…-shell])\` because it only applies to the inline
overlay. On the canvas this document contains no app to make inert — the
frames handle that with \`pointer-events: none\` — and blanket-crosshairing
the shell would put a crosshair on the chat composer. */
html[data-${PREFIX}-mode="edit"]:not([data-${PREFIX}-shell]):not([data-${PREFIX}-drag]),
html[data-${PREFIX}-mode="edit"]:not([data-${PREFIX}-shell]):not([data-${PREFIX}-drag]) body,
html[data-${PREFIX}-mode="edit"]:not([data-${PREFIX}-shell]):not([data-${PREFIX}-drag]) body *:not(${ROOT}):not(${ROOT} *):not([data-${PREFIX}-text-edit]) {
cursor: default !important;
user-select: none !important;
}
/* A text cursor over anything a double-click would open for editing, so the
gesture reads as available rather than as something you have to already know
about. Driven from a root attribute for the reason the block above is:
\`document.body.style.cursor\` loses to any element-level \`cursor: pointer\`, so
a link you can edit the label of would keep showing a hand. Written by
\`SelectionController.applyHover\`, and only when the value changes.
Placed after the edit-mode block and before the drag block deliberately: it
has to beat the blanket \`cursor: default\`, and lose to a live drag. */
html[data-${PREFIX}-mode="edit"][data-${PREFIX}-cursor="text"]:not([data-${PREFIX}-shell]):not([data-${PREFIX}-drag]) body *:not(${ROOT}):not(${ROOT} *) {
cursor: text !important;
}
/* While a drag is live the gesture owns the cursor, overlay chrome included. */
html[data-${PREFIX}-drag], html[data-${PREFIX}-drag] body, html[data-${PREFIX}-drag] body * {
cursor: var(--${PREFIX}-drag-cursor, grabbing) !important;
user-select: none !important;
}
html[data-${PREFIX}-drag="col-resize"] { --${PREFIX}-drag-cursor: col-resize; }
html[data-${PREFIX}-drag="ns-resize"] { --${PREFIX}-drag-cursor: ns-resize; }
html[data-${PREFIX}-drag="ew-resize"] { --${PREFIX}-drag-cursor: ew-resize; }
html[data-${PREFIX}-drag="nwse-resize"] { --${PREFIX}-drag-cursor: nwse-resize; }
html[data-${PREFIX}-drag="nesw-resize"] { --${PREFIX}-drag-cursor: nesw-resize; }
/* Viewport-sized stand-in that gives the canvas droppable a shape. It is never
hit-tested — the collision detector reads the pointer against the live DOM. */
.${PREFIX}-drop-sentinel {
position: fixed; inset: 0; pointer-events: none; opacity: 0;
}`;
+282
View File
@@ -0,0 +1,282 @@
import { PREFIX } from "../dom";
/** The pan/zoom surface, the frames on it, and their per-frame chrome. */
export const css = `
/* The clipping viewport — full-bleed, the way a design tool's canvas is. The docks
float on top of it rather than pushing it in, so opening one no longer
resizes the surface underneath: the frames stay exactly where they were.
What stops a fit from parking frames behind a dock is the safe-area inset
(\`setSafeInset\` in app.ts → \`safeRect\` in viewport.ts), not this box.
Sits *below* the overlay root in z-order: it is the substrate, not chrome. */
.${PREFIX}-canvas-viewport {
position: fixed; inset: 0;
overflow: hidden; z-index: 0; touch-action: none;
background: var(--ap-surface-canvas);
/* A faint dot grid, so panning and zooming read as motion over a surface. */
background-image: radial-gradient(rgba(255,255,255,var(--ap-opacity-08)) 1px, transparent 1px);
background-size: 24px 24px;
font-family: var(--ap-font-sans);
}
.${PREFIX}-canvas-world {
position: absolute; top: 0; left: 0; width: 0; height: 0;
transform-origin: 0 0;
/* One composited layer for the whole canvas: panning past several live app
instances moves an existing layer instead of re-rasterising them. */
will-change: transform;
}
/* Space held down, or the Hand tool armed: the canvas is ready to be grabbed.
Both put the same class on the viewport, so there is one cursor rule for the
pair — see \`CanvasViewport.setHandTool\` for why the tool exists on top of the
modifier. Nothing here reaches inside a frame: an iframe renders its own
cursor, which is exactly the boundary the Hand respects. */
.${PREFIX}-canvas-pannable { cursor: grab; }
.${PREFIX}-canvas-panning { cursor: grabbing; }
.${PREFIX}-canvas-panning .${PREFIX}-canvas-world,
/* Mid-wheel-gesture, stop hit-testing the world: every frame of a pan would
otherwise drive an elementFromPoint into a moving iframe. */
.${PREFIX}-canvas-gesture .${PREFIX}-canvas-world { pointer-events: none; }
/* A frame: a device-sized window onto the app, positioned in world space. The
#fff background and drop shadow are the *app preview's* defaults, not editor
chrome theming — the frame renders the user's own app (which defaults to a
white page) as a card floating on the canvas, so it intentionally does not
reference the editor surface/shadow tokens. */
.${PREFIX}-frame {
position: absolute; overflow: hidden;
background: #fff; border-radius: 2px;
box-shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
}
.${PREFIX}-frame-doc {
display: block; width: 100%; height: 100%; border: 0; background: #fff;
color-scheme: normal;
}
/* The capture plane. In edit mode it takes every pointer event so all input is
handled in the shell's document and hit-tested into the frame — which is what
lets one dnd-kit manager see every gesture. Hidden in view mode, when the app
below is meant to be used.
A plain arrow, matching the inline overlay's edit-mode rule in \`base.css.ts\`
— and changing one without the other leaves the same tool showing two
different cursors depending on which stage it is running on. See that rule for
why a crosshair is the wrong cursor for pointing at things. */
.${PREFIX}-frame-plane {
position: absolute; inset: 0; cursor: default;
}
/* The canvas half of the editable-text affordance. The plane is the shell
element the pointer is actually over, so it is the one that has to say so —
the node it is hovering lives a realm down and behind it. Paired with the
\`[data-…-cursor="text"]\` rule in \`base.css.ts\`, which does the same job
inline; both are driven from the same attribute write. */
html[data-${PREFIX}-cursor="text"] .${PREFIX}-frame-plane { cursor: text; }
html[data-${PREFIX}-drag] .${PREFIX}-frame-plane { cursor: inherit; }
/* Per-frame furniture, drawn in screen space at 1x — see frame-chrome.ts. */
.${PREFIX}-fchrome-root { position: absolute; inset: 0; pointer-events: none; }
.${PREFIX}-fc { position: absolute; pointer-events: none; }
.${PREFIX}-fc-label {
position: absolute; left: 0; bottom: 100%; margin-bottom: 6px;
display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
pointer-events: auto; cursor: grab; user-select: none; white-space: nowrap;
font-size: var(--ap-font-size-body); line-height: 1.6; color: var(--ap-text-tertiary);
}
.${PREFIX}-fc-label:active { cursor: grabbing; }
/* The name is the drag handle — the badge beside it is a real <button>, and
dnd-kit's pointer sensor ignores presses that start on native interactive
elements, so pressing the badge opens the menu rather than moving the frame.
That is the right split, but it leaves the name as the only grab target, so
give it enough padding to be one. */
.${PREFIX}-fc-name {
overflow: hidden; text-overflow: ellipsis;
padding: 3px 4px; margin: -3px -4px 0;
}
.${PREFIX}-fc-active .${PREFIX}-fc-name { color: var(--ap-primary); }
/* A readout, not a control — it used to open the per-frame menu. The padding
stays so the numbers keep their inset from the name beside them; the pointer,
hover surface and button reset go, because there is nothing here to press.
\`pointer-events\` is inherited from \`.fc-label\`, which is the drag handle. */
.${PREFIX}-fc-size {
padding: 0 4px;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
color: var(--ap-text-placeholder);
}
/* Inline rename field — sized and styled to sit exactly where the title was. */
.${PREFIX}-fc-rename {
pointer-events: auto; width: 12ch; min-width: 8ch; padding: 0 2px;
background: var(--ap-surface-panel); color: var(--ap-text-primary);
border: 1px solid var(--ap-primary); border-radius: var(--ap-radius-xs);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-body); line-height: 1.6;
}
.${PREFIX}-fc-outline {
position: absolute; inset: 0; pointer-events: none;
outline: 1px solid transparent; outline-offset: 0;
}
/* Selection is explicit now — no frame is selected until you pick one — so the
highlight can say something. An earlier version highlighted whichever frame
was touched last, which meant one was always lit; toning that down to a
hairline then left clicking a frame with no visible result at all. */
.${PREFIX}-fc-active .${PREFIX}-fc-outline {
outline: 2px solid var(--ap-primary);
outline-offset: 1px;
}
.${PREFIX}-fc-busy .${PREFIX}-fc-outline { outline-color: var(--ap-primary); }
/* Frame grips sit on the frame's own border — distinct from the element grips
in picker.ts, which sit on the selection inside it. */
.${PREFIX}-fc-grip { position: absolute; pointer-events: auto; }
.${PREFIX}-fc-grip-n, .${PREFIX}-fc-grip-s { left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.${PREFIX}-fc-grip-e, .${PREFIX}-fc-grip-w { top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.${PREFIX}-fc-grip-n { top: -4px; }
.${PREFIX}-fc-grip-s { bottom: -4px; }
.${PREFIX}-fc-grip-w { left: -4px; }
.${PREFIX}-fc-grip-e { right: -4px; }
.${PREFIX}-fc-grip-nw, .${PREFIX}-fc-grip-ne,
.${PREFIX}-fc-grip-sw, .${PREFIX}-fc-grip-se { width: 12px; height: 12px; }
.${PREFIX}-fc-grip-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.${PREFIX}-fc-grip-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.${PREFIX}-fc-grip-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.${PREFIX}-fc-grip-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
/* Edit mode: the frame furniture goes inert — see \`FrameChrome.setEditing\`.
Interaction is gated, identity is not. The title and size badge stay *visible*
so you can still tell which frame you are working inside; they simply stop
answering, along with the grips and the selection outline. Dropping the label
entirely is what made the first attempt at this unusable. */
/* The badge is a plain span inside the label now, so one rule on the label
covers both — it used to need naming separately because it was a button. */
.${PREFIX}-fchrome-inert .${PREFIX}-fc-label { pointer-events: none; cursor: default; }
.${PREFIX}-fchrome-inert .${PREFIX}-fc-grip { display: none; }
.${PREFIX}-fchrome-inert .${PREFIX}-fc-active .${PREFIX}-fc-outline { outline-color: transparent; }
.${PREFIX}-fchrome-inert .${PREFIX}-fc-active .${PREFIX}-fc-name { color: var(--ap-text-tertiary); }
/* A live resize still shows its outline: the gesture cannot start in edit mode,
but one begun in view mode must not lose its feedback if anything toggles. */
.${PREFIX}-fchrome-inert .${PREFIX}-fc-busy .${PREFIX}-fc-outline { outline-color: var(--ap-primary); }
/* Device menu on the size badge.
Placement is computed in JS (see \`placeMenu\`), not declared here: a frame can
be anywhere on the canvas, so a menu fixed to one side opens off-screen as
soon as its frame is near that edge. The offsets below are only the defaults
for the first paint, before it has been measured.
\`min-width\` is a floor for the widest device row *anywhere in the list*, not
just in whichever pane is showing. Two things move the box's natural width
now: swapping panes, and expanding a different accordion group — with Desktop
open the longest row is "MacBook Pro 16"", with Phone open it is
"iPhone 16 & 17 Pro Max" beside "440 × 956" in mono. Without one floor that
fits them all, the box would resize on every toggle; and since \`placePopover\`
derives \`left\` from \`offsetWidth\`, a width jump is a horizontal jump too. A
menu that slides sideways when you open a section is worse than one wider than
its four verbs need, so the root pane being over-wide is the price. */
.${PREFIX}-fc-menu {
position: absolute; left: 0; top: 0; z-index: 2;
pointer-events: auto; min-width: 288px; padding: 4px;
display: flex; flex-direction: column;
background: var(--ap-surface-panel); border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-md); box-shadow: var(--ap-elevation-card);
overflow-y: auto; overscroll-behavior: contain;
}
/* \`nowrap\` because \`.fc-menu\` is absolutely positioned with no width, so it is
shrink-to-fit: the floor above stops it narrowing below the widest row, and
this stops an under-sized floor from showing up as a wrapped device name
rather than as a few pixels of drift. */
.${PREFIX}-fc-menu-item {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding: 5px 8px; border: 0; border-radius: var(--ap-radius-xs);
background: transparent; cursor: pointer; text-align: left; white-space: nowrap;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label); color: var(--ap-text-primary);
}
.${PREFIX}-fc-menu-item:hover { background: var(--ap-surface-active); }
.${PREFIX}-fc-menu-on { color: var(--ap-primary); }
.${PREFIX}-fc-menu-dim { font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption); opacity: .5; }
.${PREFIX}-fc-menu-head {
padding: 4px 8px 6px; font-family: var(--ap-font-mono); text-transform: uppercase;
font-size: var(--ap-font-size-caption); letter-spacing: .6px; opacity: .5;
}
/* Device groups — Phone / Tablet / Desktop, one open at a time.
The hairline is drawn from adjacency rather than from separator nodes: a rule
about "between groups" cannot be forgotten the day a fourth group is
added. */
.${PREFIX}-fc-dgroup { display: flex; flex-direction: column; }
.${PREFIX}-fc-dgroup + .${PREFIX}-fc-dgroup {
margin-top: 4px; padding-top: 4px;
border-top: 1px solid var(--ap-border-default);
}
/* Sentence case and body type, not the uppercase mono of \`fc-menu-head\`: these
are section headers in a list you are reading, not the menu's own title. */
.${PREFIX}-fc-dgroup-head {
display: flex; align-items: center; gap: 6px; width: 100%;
padding: 5px 8px; border: 0; border-radius: var(--ap-radius-xs);
background: transparent; cursor: pointer; text-align: left;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
color: var(--ap-text-primary);
}
.${PREFIX}-fc-dgroup-head:hover { background: var(--ap-surface-active); }
/* One mark for the whole menu. Rotating \`chev-right\` a quarter turn reproduces
\`chev-down\` exactly — the set draws them as one path at two rotations — so
this is exact rather than approximate.
Driven from \`aria-expanded\` rather than swapped in JS the way the chat
timeline's collapsibles are. A timeline row is built once and changed by a
click; this menu's derived state is rewritten by \`syncMenus\` on every frame of
a pan, and re-parsing three SVGs per frame to flip a direction the DOM already
records is work that lands on the one gesture that has to stay smooth.
No transition, deliberately: \`.fc-menu\` is re-placed continuously while the
canvas moves, and an animating transform inside a box that is itself being
re-positioned is the smear \`scripts/check-css.mjs\` describes. That guard only
polices \`chrome.css.ts\`, so this is a choice rather than a constraint. */
.${PREFIX}-fc-dgroup-head .${PREFIX}-ic { flex: 0 0 16px; opacity: .5; }
.${PREFIX}-fc-dgroup-head[aria-expanded="true"] .${PREFIX}-ic { transform: rotate(90deg); }
/* 8px padding + 16px glyph + 6px gap, so the group's name and every device name
under it share one left edge and the triangle hangs in a gutter of its own.
Getting this wrong is what makes an accordion read as two unrelated lists
rather than a tree. */
.${PREFIX}-fc-dgroup-body .${PREFIX}-fc-menu-item { padding-left: 30px; }
/* Custom size: the escape hatch from the preset list. */
.${PREFIX}-fc-menu-custom {
display: flex; align-items: center; gap: 4px; padding: 4px 8px 6px;
}
.${PREFIX}-fc-menu-num {
width: 62px; padding: 3px 6px; border-radius: var(--ap-radius-xs);
background: var(--ap-surface-active); color: var(--ap-text-primary);
border: 1px solid var(--ap-border-default);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
}
.${PREFIX}-fc-menu-go {
margin-left: auto; padding: 3px 8px; border: 0; cursor: pointer;
border-radius: var(--ap-radius-xs);
background: var(--ap-primary); color: var(--ap-text-primary);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-body);
}
/* The + menu hangs off the toolbar; same JS placement, same clamping. */
.${PREFIX}-fbar-menu { left: 0; top: 0; }
/* Canvas tools — add a frame, fit, zoom readout. A section of the bottom bar
rather than a surface of its own: the bar already carries the card, so this
only has to be a row. */
.${PREFIX}-fbar {
display: inline-flex; align-items: center; gap: 2px;
}
/* The frame verb group, in the bar's view-mode zone rather than in \`bar-tools\`.
Stretched for the same reason \`.bar-tools .fbar\` is: the dimensions menu is
placed against this group's rect, and a row centred inside a taller bar would
measure the gap above the buttons and land the menu on the card's top edge. */
.${PREFIX}-fbar-frame { align-self: stretch; }
/* These are mounted into the app's own bottom bar, so they take its button box:
\`.tool\` is a 28px square (see docks.css). This used to be a 24-tall,
36-wide rectangle carrying an \`md\` glyph, which put the canvas verbs both a
size and a shape apart from the tools beside them.
\`.fbar-zoom\` keeps the horizontal padding — it carries a text readout, not a
glyph, so it has to be free to be wider than it is tall. */
.${PREFIX}-fbar-btn, .${PREFIX}-fbar-zoom {
display: inline-flex; align-items: center; justify-content: center; gap: 4px;
height: var(--ap-control-icon-box); border: 0; cursor: pointer;
border-radius: var(--ap-radius-xs); background: transparent;
color: var(--ap-text-primary); font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
}
.${PREFIX}-fbar-btn { width: var(--ap-control-icon-box); padding: 0; }
.${PREFIX}-fbar-zoom { min-width: var(--ap-control-icon-box); padding: 0 6px; }
.${PREFIX}-fbar-btn:hover, .${PREFIX}-fbar-zoom:hover { background: var(--ap-surface-active); }
.${PREFIX}-fbar-off { opacity: .35; pointer-events: none; }
.${PREFIX}-fbar-sep { width: 1px; height: 14px; margin: 0 2px; background: var(--ap-border-default); }`;
+495
View File
@@ -0,0 +1,495 @@
import { PREFIX } from "../dom";
import { ROOT } from "./const";
/** Left dock: transcript, bubbles, composer, chips, actions, todos, diffs. */
export const css = `
.${PREFIX}-transcript {
flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column;
gap: var(--ap-space-md); padding: var(--ap-space-md) var(--ap-space-lg);
}
/* The transcript's empty state is a \`.empty-md\` block (empty.css). This class
carries no styling of its own any more — it is the handle \`pushBubble\` uses
to find and drop the block when the first bubble lands. */
.${PREFIX}-msg { font-size: var(--ap-font-size-heading); line-height: 1.5; }
.${PREFIX}-msg-user {
align-self: flex-end; max-width: 88%; padding: 8px 12px; word-break: break-word;
background: var(--ap-surface-selected); color: var(--ap-text-primary);
border-radius: var(--ap-radius-md) var(--ap-radius-md) var(--ap-radius-xs) var(--ap-radius-md);
}
.${PREFIX}-msg-assistant {
align-self: flex-start; max-width: 96%; padding: 10px 12px; word-break: break-word;
background: var(--ap-surface-active); border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-md) var(--ap-radius-md) var(--ap-radius-md) var(--ap-radius-xs);
}
/* A failed turn. The bubble's body *is* the error string (\`fillAssistant\` puts
\`bundle.error\` or "Edit failed." there), so the words already carry the news;
a tinted box around a sentence that says "Edit failed" is the same message a
second time, in the loudest register the panel has. A stronger border is
enough to mark it as the odd bubble in the column. */
.${PREFIX}-msg-assistant.${PREFIX}-msg-err { border-color: var(--ap-border-strong); }
.${PREFIX}-msg-body > *:first-child { margin-top: 0; }
.${PREFIX}-msg-body > *:last-child { margin-bottom: 0; }
.${PREFIX}-msg-body p { margin: 6px 0; }
.${PREFIX}-msg-body h4, .${PREFIX}-msg-body h5, .${PREFIX}-msg-body h6 { margin: 8px 0 4px; font-size: var(--ap-font-size-heading); font-weight: 600; }
.${PREFIX}-msg-body ul, .${PREFIX}-msg-body ol { margin: 6px 0; padding-left: 18px; }
.${PREFIX}-msg-body li { margin: 2px 0; }
/* Underlined rather than tinted. A link still has to announce itself, but the
affordance can be a rule instead of a hue — see the panel's colour note at
\`.tl-glyph\` below. */
.${PREFIX}-msg-body a { color: var(--ap-text-primary); text-decoration: underline; text-underline-offset: 2px; }
.${PREFIX}-msg-stream { white-space: pre-wrap; }
.${PREFIX}-md-code {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label); padding: 0 4px;
background: var(--ap-surface-panel); border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-xs);
}
.${PREFIX}-md-pre {
margin: 6px 0; padding: 8px 10px; overflow-x: auto;
background: var(--ap-surface-panel); border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-md);
}
.${PREFIX}-md-pre code { font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label); white-space: pre; }
/* Composer (pinned below the transcript).
One field, not a stack. The chips, the textarea and Send share a single
bordered box that starts one line tall — the previous arrangement spent
~145px at rest on padding, a 64px textarea floor and a Send pill on its own
row, which is a lot of permanent furniture for a panel whose real content is
the transcript above it. The right padding clears the absolutely-positioned
Send glyph so text never runs under it. */
.${PREFIX}-composer { flex: 0 0 auto; border-top: 1px solid var(--ap-border-default); padding: var(--ap-space-sm) var(--ap-space-md); }
.${PREFIX}-field {
position: relative; display: flex; flex-direction: column; gap: 4px;
padding: 6px 65px 6px 8px;
background: var(--ap-input-bg); border: 1px solid var(--ap-input-border);
border-radius: var(--ap-radius-sm);
}
.${PREFIX}-field:focus-within { border-color: var(--ap-input-focus-border); }
/* Chip rows scroll sideways rather than wrapping: each pending change is now
its own chip, and wrapping a dozen of them would push the field to half the
dock. Hidden when empty so they cost nothing at rest. */
.${PREFIX}-sel-chips {
display: flex; flex-wrap: nowrap; gap: var(--ap-space-xs);
overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.${PREFIX}-sel-chips::-webkit-scrollbar { display: none; }
.${PREFIX}-sel-chips:empty { display: none; }
/* In a nowrap row a chip would otherwise shrink to fit rather than scroll. */
.${PREFIX}-sel-chips > * { flex: 0 0 auto; }
.${PREFIX}-sel-chip {
display: inline-flex; align-items: center; gap: 6px; font-size: var(--ap-font-size-label); font-family: var(--ap-font-mono);
color: var(--ap-text-primary); background: var(--ap-surface-active);
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-sm); padding: 3px 6px 3px 8px;
}
/* Pending-change chips — one per inspector delta, riding into Send.
Deliberately quiet. These used to be a single accent-filled pill, which put
a second saturated element inches from the filled Send button; with a dozen
of them that reads as an alarm rather than a list. Demoting them to a hover
surface leaves the selection chip as the one emphasised thing in the strip,
which is the hierarchy the row wants — now a step of the surface ladder
rather than a hue, since the strip has no colour left to spend. */
.${PREFIX}-tweak-chip {
color: var(--ap-text-secondary); background: var(--ap-surface-hover);
border-color: var(--ap-border-subtle);
font-size: var(--ap-font-size-caption); max-width: 240px;
}
.${PREFIX}-tweak-chip:hover { color: var(--ap-text-primary); border-color: var(--ap-border-default); }
.${PREFIX}-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The bulk escape hatch, at the end of the strip. Ghost — it is the most
destructive thing in the row and should not look like the cheapest. */
.${PREFIX}-chip-all {
cursor: pointer; color: var(--ap-text-tertiary);
background: transparent; border-style: dashed;
font-size: var(--ap-font-size-caption);
}
.${PREFIX}-chip-all:hover { color: var(--ap-text-primary); border-color: var(--ap-border-strong); }
/* Past-chats drawer (overlays the whole left dock). */
/* A column for the same reason \`.insp-body\` is one: it covers the whole dock,
so its empty state has a dock's worth of space to centre in, and \`margin:
auto\` needs a flex container to have anything to distribute. The head stays
pinned at the top either way — it is content-sized. */
.${PREFIX}-drawer {
position: absolute; inset: 0; z-index: 2; overflow-y: auto;
padding: var(--ap-space-md) var(--ap-space-lg); background: var(--ap-surface-panel);
display: flex; flex-direction: column;
}
.${PREFIX}-drawer-head {
flex: 0 0 auto; display: flex; align-items: center;
justify-content: space-between; margin-bottom: var(--ap-space-sm);
}
/* Prompt preview — the instruction as the agent will actually receive it.
A pane in flow, not a \`.drawer\`. The drawer is \`inset: 0\` over the whole
dock, which is right for Past chats and wrong here: the point of this surface
is watching the string change as you type, and a full-dock overlay covers the
field you type into. So it takes the transcript's slot (hidden while this is
up) and leaves the head and composer where they are. Borrows the drawer's
head, eyebrow and close button so it still reads as the same kind of surface. */
.${PREFIX}-pane {
flex: 1 1 auto; min-height: 0; overflow-y: auto;
padding: var(--ap-space-md) var(--ap-space-lg); background: var(--ap-surface-panel);
display: flex; flex-direction: column;
}
/* A column, so the empty state has the pane's height to centre in — same
reasoning as \`.drawer\`. */
.${PREFIX}-prompt-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.${PREFIX}-prompt-text {
margin: 0; flex: 1 1 auto;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
line-height: 1.5; color: var(--ap-text-secondary);
/* pre-wrap, not pre: a source-context fence runs past 100 columns and a 340px
dock would scroll sideways for every line of it. */
white-space: pre-wrap; word-break: break-word;
-webkit-user-select: text; user-select: text;
}
/* The character count. Genuinely useful here — it is the one place the user can
see what a dozen chips actually cost in context. */
.${PREFIX}-prompt-count {
align-self: center; font-family: var(--ap-font-mono);
font-size: var(--ap-font-size-caption); color: var(--ap-text-tertiary);
margin-right: var(--ap-space-xs); white-space: nowrap;
}
/* Past-chats list rows. Hover rides the hover surface (one step lighter than
the panel, not the pressed/active step) and the radius matches the buttons. */
.${PREFIX}-thread-item { display: flex; align-items: flex-start; gap: var(--ap-space-xs); cursor: pointer; padding: 8px; border-radius: var(--ap-radius-sm); }
.${PREFIX}-thread-item:hover { background: var(--ap-surface-hover); }
.${PREFIX}-thread-item .${PREFIX}-ic { margin-top: 2px; opacity: .6; }
.${PREFIX}-thread-main { min-width: 0; flex: 1 1 auto; }
.${PREFIX}-thread-title { font-size: var(--ap-font-size-title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.${PREFIX}-thread-meta { font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption); opacity: .5; margin-top: 2px; }
.${PREFIX}-eyebrow {
font-family: var(--ap-font-mono); text-transform: uppercase;
font-size: var(--ap-font-size-body); letter-spacing: .6px; color: var(--ap-text-primary); opacity: .55;
margin-bottom: var(--ap-space-xs);
}
.${PREFIX}-meta {
margin-top: 4px; font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
color: var(--ap-text-primary); opacity: .5; word-break: break-word;
}
/* Chat input. The box, border and background now belong to \`.field\`; this is
just the text surface inside it. \`resize: none\` because the height is
driven by content (see \`autoGrow\`) — a manual resize handle would fight it
on the next keystroke. No min-height: one row is the resting state. */
.${PREFIX}-input {
width: 100%; resize: none; display: block; font-family: var(--ap-font-sans);
font-size: var(--ap-font-size-title); line-height: 1.45; color: var(--ap-text-primary);
background: transparent; border: 0; padding: 2px 0;
}
.${PREFIX}-input::placeholder { color: var(--ap-text-placeholder); }
.${PREFIX}-input:focus { outline: none; }
/* Send. Sits inside the field's right gutter rather than on a row of its own.
Icon-only — the label lives in \`data-tip\`, which also picks up its ⌘⏎
binding because tooltips resolve shortcuts by tooltip text.
The box comes from \`.action\`/\`.action-icon\` below: 28px. This rule used to
restate 24 and lose on source order, so the numbers here described a button
that never existed. */
.${PREFIX}-send {
position: absolute; right: 5px; bottom: 5px;
}
/* The prompt-preview toggle, in the field's gutter beside Send — the control
that answers "what will Send send?" belongs next to Send.
Send is 28px, so this clears 28 + a 4px gap, and its \`bottom\` is 7px rather
than 5 so that a 24px ghost sits centred against a 28px primary. Smaller on
purpose — it is the secondary control of the pair. Overrides \`.iconbtn\`'s
taller control height without \`!important\`, since this file loads after
docks.css.
The tone goes on --ic-tone, not \`color\`: the glyph is a child span with its
own rule in base.css, so a \`color\` here never reached it and "secondary
control is dimmer" was a hierarchy that only existed in this file. */
.${PREFIX}-field-btn {
position: absolute; right: 37px; bottom: 7px;
width: 24px; height: 24px; padding: 0;
--${PREFIX}-ic-tone: var(--ap-text-tertiary);
}
/* A toggle that stays down while its surface is open. */
.${PREFIX}-iconbtn-on { background: var(--ap-surface-selected); color: var(--ap-text-primary); }
/* Chips. */
.${PREFIX}-chips {
display: flex; flex-wrap: nowrap; gap: var(--ap-space-xs);
overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.${PREFIX}-chips::-webkit-scrollbar { display: none; }
.${PREFIX}-chips:empty { display: none; }
.${PREFIX}-chips > * { flex: 0 0 auto; }
.${PREFIX}-chip {
display: inline-flex; align-items: center; gap: 6px; font-size: var(--ap-font-size-label);
background: var(--ap-surface-active); border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-sm); padding: 4px 6px 4px 8px;
}
.${PREFIX}-chip-x { cursor: pointer; display: inline-flex; opacity: .6; }
.${PREFIX}-chip-x:hover { opacity: 1; }
/* Action buttons — compact, at editor density. Self-sized and right-aligned in the
composer (not a full-width marketing pill): the editor's controls are 28px
tall with a 6px radius, so the primary Send reads as one of them, not as a
CTA dropped in from the marketing site. State tokens drive hover/pressed so
there's no opacity hack. */
.${PREFIX}-actions { display: flex; justify-content: flex-end; gap: var(--ap-space-xs); margin-top: var(--ap-space-sm); }
.${PREFIX}-action {
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
height: var(--ap-control-icon-box); padding: 0 12px; cursor: pointer;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label); font-weight: 500;
background: var(--ap-surface-hover); color: var(--ap-text-primary);
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-sm);
transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease), border-color var(--ap-motion-dur-micro) var(--ap-motion-ease), opacity var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-action:not(:disabled):hover { background: var(--ap-surface-active); border-color: var(--ap-border-strong); }
.${PREFIX}-action:not(:disabled):active { background: var(--ap-surface-selected); }
/* The primary action — one step up the surface ladder from its siblings, plus a
stronger border. It used to be an accent fill, which made Send the loudest
thing in a panel whose content is the transcript above it; the ladder still
ranks it above the secondary actions without spending the panel's only hue on
a button that sits in the same place every time.
--ic-tone alongside \`color\`: the label is this element's own text and takes
\`color\`, the glyph is a child span that base.css paints, and both have to be
the bright tone against the fill. */
.${PREFIX}-action.${PREFIX}-primary {
background: var(--ap-surface-selected); color: var(--ap-text-primary); border-color: var(--ap-border-strong);
--${PREFIX}-ic-tone: var(--ap-text-primary);
}
.${PREFIX}-action.${PREFIX}-primary:not(:disabled):hover { background: var(--ap-gray-700); border-color: var(--ap-border-strong); }
.${PREFIX}-action.${PREFIX}-primary:not(:disabled):active { background: var(--ap-gray-600); }
.${PREFIX}-action:disabled { opacity: .45; cursor: default; }
/* Square, so the per-turn actions read as one cluster of glyphs rather than
three pills competing with the message above them. Their labels live in the
tooltip. */
.${PREFIX}-action-icon { width: var(--ap-control-icon-box); padding: 0; }
.${PREFIX}-action:focus-visible {
outline: 1px solid var(--ap-border-focus); outline-offset: 1px;
}
/* Streaming step indicator (inside the assistant bubble). The dot pulses; that
is what says "running". Tinting it as well says it twice, and a saturated dot
blinking through a long turn is the most attention-drawing thing the panel
could do for its least surprising message. */
.${PREFIX}-step,
.${PREFIX}-turn-status { display: flex; align-items: center; gap: var(--ap-space-xs); font-size: var(--ap-font-size-title); color: var(--ap-text-tertiary); }
.${PREFIX}-turn-status { margin-top: var(--ap-space-xs); }
.${PREFIX}-dot { width: 7px; height: 7px; border-radius: var(--ap-radius-full); background: var(--ap-text-tertiary); animation: ${PREFIX}-pulse 1s infinite; }
@keyframes ${PREFIX}-pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
/* ---- Agent activity timeline ------------------------------------------- *
* Claude Code's terminal grammar rendered in editor tokens: a status dot
* leading the tool name, an elbow rail carrying the one-line result, and the
* full output behind a disclosure. The rail glyphs are drawn SVGs, not text —
* U+23FA/U+23BF aren't in the latin font subsets we self-host.
*
* The overlay has no shadow root, so every rule below states its box, type and
* background outright rather than inheriting from the host page.
*/
.${PREFIX}-tl { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 0; }
.${PREFIX}-tl:empty { display: none; }
.${PREFIX}-tl-row { display: block; margin: 0; padding: 0; border: 0; background: none; }
/* Header row. A <button> when expandable, a <div> when not — both must present
as the same dense, left-aligned line. */
.${PREFIX}-tl-head {
display: flex; align-items: baseline; gap: var(--ap-space-xs);
width: 100%; margin: 0; padding: 2px 4px; cursor: pointer; text-align: left;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label);
line-height: 1.5; color: var(--ap-text-primary);
background: transparent; border: 0; border-radius: var(--ap-radius-xs);
-webkit-appearance: none; appearance: none;
}
.${PREFIX}-tl-head:hover { background: var(--ap-surface-hover); }
.${PREFIX}-tl-head:focus-visible { outline: 1px solid var(--ap-border-focus); outline-offset: -1px; }
/* Nothing to expand — drop the affordance but keep the alignment. */
.${PREFIX}-tl-flat > .${PREFIX}-tl-head { cursor: default; }
.${PREFIX}-tl-flat > .${PREFIX}-tl-head:hover { background: transparent; }
/* Leading glyph. Shape carries which tool (\`TOOL_GLYPH\` in tool-row.ts) and
nothing else — every glyph in the timeline rests at one quiet tone.
There used to be a per-phase colour here: green for ok, red for error, purple
on the thinking row. It never actually rendered — \`base.css\` paints every
\`.ic\` under \`#\${PREFIX}-root\`, and an id outranks any number of classes,
so the wrapper's colour was overridden by the icon inside it. Making it work
showed why it should not: a finished turn is thirty rows, nearly all of them
\`ok\`, so the effect was a column of green demanding attention on behalf of
"this worked", which is the least surprising thing a transcript can say.
That argument has since been taken to its end across this whole file. Diff
add/del is the only hue left in the panel — the one place where the thing
being distinguished has no shape, weight or position of its own to carry it.
Everything else ranks by the tools a monochrome column still has: the text
ramp for emphasis, \`font-weight\` for the row that matters, \`opacity\` for
the row that does not, the surface ladder for fills, and motion for pending.
Failure is still the loudest thing here, just not the reddest — the result
line under a failed row goes bright and bold (see \`.tl-res-text\` below),
which is what separates it from thirty \`--ap-text-secondary\` siblings.
Scoped to \`ROOT\` and reaching the \`.ic\` for the same specificity reason: a
rule on the wrapper alone would lose to \`base.css\` and the glyphs would sit
at \`--ap-icon-secondary\`, a step brighter than the rest of the row. */
.${PREFIX}-tl-glyph { display: inline-flex; flex: 0 0 auto; align-self: center; }
${ROOT} .${PREFIX}-tl-glyph .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-text-tertiary); }
.${PREFIX}-tl-row[data-phase="pending"] .${PREFIX}-tl-glyph { animation: ${PREFIX}-pulse 1s infinite; }
.${PREFIX}-tl-name { font-weight: 600; color: var(--ap-text-primary); white-space: nowrap; }
.${PREFIX}-tl-args {
min-width: 0; flex: 0 1 auto; color: var(--ap-text-tertiary);
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Result line. Lives outside the collapsible body so the summary reads at rest;
the glyph column is indented to sit under the tool name. */
.${PREFIX}-tl-res {
display: flex; align-items: baseline; gap: var(--ap-space-xs);
margin: 0; padding: 0 4px 2px 10px;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
line-height: 1.5; color: var(--ap-text-secondary); word-break: break-word;
}
${ROOT} .${PREFIX}-tl-res .${PREFIX}-ic { flex: 0 0 auto; --${PREFIX}-ic-tone: var(--ap-text-tertiary); align-self: flex-start; }
.${PREFIX}-tl-res-text { min-width: 0; }
/* The one row in a thirty-row turn worth finding. Brighter and heavier than the
\`--ap-text-secondary\` result lines around it, which is enough to catch the
eye scanning the column — see the glyph note above for why it is not red. */
.${PREFIX}-tl-row[data-phase="error"] .${PREFIX}-tl-res-text { color: var(--ap-text-primary); font-weight: 600; }
/* Expanded body. */
/* Collapsing is per-row state (see TimelineView.setCollapsed) — deliberately
no \`.tl-collapsed .tl-body { display: none }\` here. A descendant rule like
that outranks the row's own disclosure, which is what used to freeze every
finished turn's rows shut. */
.${PREFIX}-tl-body { margin: 0 0 var(--ap-space-xs) 0; padding: 0 4px 0 26px; }
.${PREFIX}-tl-args-list {
display: grid; grid-template-columns: auto 1fr; gap: 0 var(--ap-space-xs);
margin: 0 0 var(--ap-space-xs) 0; padding: 0;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body); line-height: 1.6;
}
.${PREFIX}-tl-args-list dt { margin: 0; color: var(--ap-text-tertiary); }
.${PREFIX}-tl-args-list dd { margin: 0; color: var(--ap-text-secondary); word-break: break-word; }
.${PREFIX}-tl-out {
margin: 0; padding: 6px 8px; max-height: 260px; overflow: auto;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body); line-height: 1.5;
color: var(--ap-text-secondary); white-space: pre-wrap; word-break: break-word;
background: var(--ap-surface-panel);
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-xs);
}
.${PREFIX}-tl-trunc {
margin-top: 2px; font-family: var(--ap-font-mono);
font-size: var(--ap-font-size-caption); color: var(--ap-text-tertiary);
}
/* Thinking. Sans and italic so it reads as reflection, not tool activity —
carried by the label alone. The bulb stays at the timeline's one glyph tone
like every other row: the italic word beside it already says what kind of row
this is, and tinting the mark as well says it twice.
The label was purple until the semantic palette lost that family, and the
panel has since stopped spending hue on anything but diff add/del. It would
not have earned one back regardless: "the model is thinking" is a *kind* of
row rather than a state, and the sans face and the italic already carry that
against a column of mono tool names. */
.${PREFIX}-tl-think > .${PREFIX}-tl-head { font-family: var(--ap-font-sans); font-size: var(--ap-font-size-title); }
.${PREFIX}-tl-think-label { color: var(--ap-text-tertiary); font-style: italic; }
.${PREFIX}-tl-think-text {
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-title); line-height: 1.55;
color: var(--ap-text-secondary); white-space: pre-wrap; word-break: break-word;
}
/* Assistant prose inside the timeline keeps the bubble's sans body scale. */
.${PREFIX}-tl-text { padding: var(--ap-space-xs) 4px; font-size: var(--ap-font-size-heading); }
/* Todos, hung off the same rail as a tool result. */
.${PREFIX}-tl-todos { display: flex; align-items: flex-start; gap: var(--ap-space-xs); padding: 0 4px 0 10px; }
.${PREFIX}-tl-todos .${PREFIX}-tl-res-glyph { display: inline-flex; flex: 0 0 auto; color: var(--ap-text-tertiary); }
.${PREFIX}-tl-todos .${PREFIX}-todos { margin-top: 0; flex: 1 1 auto; min-width: 0; }
/* A diff nested in a tool body already sits inside a bordered box. */
.${PREFIX}-tl-body .${PREFIX}-diff { margin: 0; border: 0; border-radius: 0; }
.${PREFIX}-turn-result:empty { display: none; }
/* Todos. Status rides opacity and weight, not hue.
Completed used to be green and in-progress blue, which inverted the hierarchy
the list actually wants: a checklist is read to find the row still in flight,
and colouring the finished ones made the answered question the loud one. The
\`check\` glyph and the line-through already say "done" twice over, so done
recedes and in-progress is the single brightest, heaviest line. */
.${PREFIX}-todos { margin-top: var(--ap-space-sm); list-style: none; padding: 0; }
.${PREFIX}-todos li { display: flex; gap: var(--ap-space-xs); align-items: center; font-size: var(--ap-font-size-title); padding: 2px 0; opacity: .8; }
.${PREFIX}-todos li .${PREFIX}-ic { opacity: .6; }
.${PREFIX}-todos li[data-s="completed"] { opacity: .55; }
.${PREFIX}-todos li[data-s="completed"] span { text-decoration: line-through; }
.${PREFIX}-todos li[data-s="in_progress"] { opacity: 1; font-weight: 500; }
/* A collapsed disclosure outside the timeline. The timeline uses its status dot
as the affordance and draws no chevron; anything else has to, or it reads as
a line of inert text. */
.${PREFIX}-disc-chev { display: inline-flex; align-items: center; flex: 0 0 auto; color: var(--ap-text-tertiary); }
.${PREFIX}-disc-head {
display: flex; align-items: center; gap: var(--ap-space-xs);
width: 100%; padding: 5px 8px; cursor: pointer; text-align: left;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
color: var(--ap-text-secondary);
background: transparent; border: 0; border-radius: var(--ap-radius-sm);
-webkit-appearance: none; appearance: none;
}
.${PREFIX}-disc-head:hover { color: var(--ap-text-primary); background: var(--ap-surface-hover); }
.${PREFIX}-disc-body { padding-top: var(--ap-space-xs); }
.${PREFIX}-follow-disc { margin-top: var(--ap-space-xs); }
/* Diffs. */
.${PREFIX}-diffs { margin-top: var(--ap-space-md); }
.${PREFIX}-diff { margin-bottom: var(--ap-space-sm); border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-md); overflow: hidden; }
/* Also the disclosure header for a collapsed file, hence the button reset and
the pointer — a plain header and a toggle have to look identical here. */
.${PREFIX}-diff-head {
display: flex; align-items: center; gap: var(--ap-space-xs);
width: 100%; padding: 6px 10px; text-align: left; cursor: pointer;
background: var(--ap-surface-active); font-size: var(--ap-font-size-body);
color: var(--ap-text-primary); border: 0;
-webkit-appearance: none; appearance: none;
}
.${PREFIX}-diff-head:hover { background: var(--ap-surface-selected); }
.${PREFIX}-diff-head .${PREFIX}-diff-file { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.${PREFIX}-diff-more {
display: inline-flex; align-items: center; justify-content: center;
width: 20px; height: 20px; flex: 0 0 auto; padding: 0; cursor: pointer;
color: var(--ap-text-tertiary); background: transparent; border: 0;
border-radius: var(--ap-radius-xs); opacity: 0;
}
.${PREFIX}-diff:hover .${PREFIX}-diff-more,
.${PREFIX}-diff-more:focus-visible { opacity: 1; }
.${PREFIX}-diff-more:hover { color: var(--ap-text-primary); background: var(--ap-surface-hover); }
.${PREFIX}-diff-plain { display: block; }
.${PREFIX}-diff-file { font-family: var(--ap-font-mono); color: var(--ap-text-primary); font-weight: 600; }
.${PREFIX}-diff-stat { font-family: var(--ap-font-mono); opacity: .5; }
.${PREFIX}-diff-body { margin: 0; padding: 6px 0; background: var(--ap-surface-panel); overflow-x: auto; font: var(--ap-font-size-body)/1.5 var(--ap-font-mono); }
.${PREFIX}-diff-line { padding: 0 10px; white-space: pre; }
.${PREFIX}-diff-add { background: var(--ap-semantic-success-bg); color: var(--ap-semantic-success); }
.${PREFIX}-diff-del { background: var(--ap-semantic-error-bg); color: var(--ap-semantic-error); }
/* Structural punctuation between hunks, not content — quieter than the code it
separates. The add/del pair below are the only hue left in this panel. */
.${PREFIX}-diff-hunk { color: var(--ap-text-tertiary); }
.${PREFIX}-diff-ctx { opacity: .55; }
/* Follow-ups — same secondary-button recipe as the composer actions: 6px
radius, 12px type, surface-hover default → surface-active on hover, so they
read as one control family with Send rather than a third distinct shape. */
.${PREFIX}-follow { margin-top: var(--ap-space-sm); display: flex; flex-direction: column; gap: var(--ap-space-xs); }
.${PREFIX}-follow button {
display: flex; align-items: center; gap: var(--ap-space-xs); text-align: left; cursor: pointer;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label); color: var(--ap-text-primary);
background: var(--ap-surface-hover); border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-sm); padding: 6px 10px;
}
.${PREFIX}-follow button:hover { border-color: var(--ap-border-strong); background: var(--ap-surface-active); }
.${PREFIX}-follow button { --${PREFIX}-ic-tone: var(--ap-text-tertiary); }`;
+287
View File
@@ -0,0 +1,287 @@
import { design } from "@airship/editor-tokens";
import { PREFIX } from "../dom";
import { Z } from "./const";
/**
* The X that marks an edge a guide matched, as a background image.
*
* Inline SVG in a data URI, which forces the colour to be a literal — a `var()`
* cannot be URL-encoded into one. Read from the token object rather than typed
* out, so it still moves when the palette does; `portable.css.ts` reaches for
* `design` for the same reason, from the other direction.
*
* Lives here rather than beside the geometry in `guide-overlay.ts` because it is
* the only part of that module a stylesheet needs, and importing the module here
* would pull the whole chrome layer into this file's import graph for one string.
*/
function markImage(): string {
const stroke = encodeURIComponent(design.semantic.error);
const svg =
"%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E" +
`%3Cline x1='2' y1='2' x2='6' y2='6' stroke='${stroke}' stroke-width='1'/%3E` +
`%3Cline x1='6' y1='2' x2='2' y2='6' stroke='${stroke}' stroke-width='1'/%3E` +
"%3C/svg%3E";
return `url("data:image/svg+xml,${svg}")`;
}
/** The floating chrome layer: hover/selection boxes, handles, drop indicators. */
export const css = `
/* The one surface every piece of floating chrome is drawn on. Fixed at inset 0
so it *is* the viewport, which makes its absolutely-positioned children take
screen coordinates with no per-element offset. */
.${PREFIX}-chrome-layer {
position: fixed; inset: 0; z-index: ${Z}; pointer-events: none;
font-family: var(--ap-font-sans);
}
/* Border-box is load-bearing, not housekeeping. Chrome is positioned by writing
a measured rect straight into width/height, and every outline here has a
border — under content-box that border is added *outside* the number, so a
1136px element gets a 1140px selection box sitting 2px off on every side. It
used to be masked by host apps that set \`* { box-sizing: border-box }\`
globally, which is not a thing to depend on. */
.${PREFIX}-chrome-layer, .${PREFIX}-chrome-layer * { box-sizing: border-box; }
/* Hover + selection boxes.
Everything on the canvas is drawn at exactly 1px with no radius, and that is
the single biggest thing separating chrome that reads as an editor from chrome
that reads as a debug tool. Two reasons it has to be this way:
A rounded outline is a claim about the element. The box is measured from
\`getBoundingClientRect()\` and traces the border box exactly; putting a 4px
radius on it draws corners the element does not have, and on a square element
— most elements — the mismatch is visible at 100% zoom. A design tool's selection is
square whatever the object's own corner radius is, for the same reason.
And there is no transition here on purpose. The hover box is re-\`place()\`d on
every \`mousemove\`, so a transition on \`all\` interpolates left/top/width/height
between two elements and the outline visibly trails the cursor. It read as lag
in the overlay rather than as easing.
Hover carries no fill either. What distinguishes hover from selection is the
handles, which is the distinction a design tool draws; a tinted fill on top of that
just puts a wash over the thing you are trying to look at. */
.${PREFIX}-hover-box {
position: absolute; z-index: ${Z}; pointer-events: none;
border: 1px solid var(--ap-primary);
}
.${PREFIX}-sel-box {
position: absolute; z-index: ${Z}; pointer-events: none;
border: 1px solid var(--ap-primary);
}
/* Additional nodes in a multi-selection. Deliberately lighter than the primary
outline: the panel shows the primary's values, so which one it is has to
stay legible. At 1px the only headroom left is opacity, which is enough —
the primary is the one wearing handles. */
.${PREFIX}-extra-box {
position: absolute; z-index: ${Z}; pointer-events: none;
border: 1px solid var(--ap-primary);
opacity: .65;
}
/* Marquee rubber band. The one place a fill belongs: it is a region being swept
rather than an element being pointed at. */
.${PREFIX}-marquee {
position: absolute; z-index: ${Z}; pointer-events: none;
border: 1px solid var(--ap-primary);
background: var(--ap-primary-bg);
}
/* Structural context, dotted rather than solid.
The grammar the whole canvas follows: **solid** is the thing you are pointing
at (hover, selection), **dotted** is context you did not ask for but need —
where the selection sits in its tree — **dashed** is a drop target, and red is
only ever measurement. Keeping those four apart is what lets several of them
be on screen at once without the canvas turning into noise. */
.${PREFIX}-ctx-parent, .${PREFIX}-ctx-sibling {
position: absolute; z-index: ${Z}; pointer-events: none;
border: 1px dotted var(--ap-primary);
}
.${PREFIX}-ctx-sibling { opacity: .5; }
/* Identity badge on the hover / selection box (tag.class · W×H).
A sibling of its box on the layer rather than a child of it, which it used to
be. \`place()\` writes a \`clip-path\` onto the box to fence chrome inside its
frame, and a clip applies to descendants — so a badge hanging above a box near
the top of a frame was being sliced in half by its own outline. As a sibling
it is positioned independently and clips on its own terms, which for a badge
is "not at all": it is an annotation *about* the frame's contents, like the
frame's own title, not something drawn inside them.
Anchored to the top-left of the box by default, with the corner nearest the
box left square so it reads as a tab attached to it — and flipped below when
the box is close enough to the top of the frame that there is no room, which
is the case that used to push it off-screen entirely. */
.${PREFIX}-box-label {
position: absolute; z-index: ${Z}; transform: translateY(-100%);
max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
padding: 1px 6px; pointer-events: none;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption); line-height: 1.7;
color: var(--ap-text-primary); background: var(--ap-primary);
border-radius: var(--ap-radius-xs) var(--ap-radius-xs) var(--ap-radius-xs) 0;
}
.${PREFIX}-box-label[data-flip] {
transform: none;
border-radius: 0 var(--ap-radius-xs) var(--ap-radius-xs) var(--ap-radius-xs);
}
/* Resize grips: four visible corner squares, and four *invisible*
strips along the edges between them.
A design tool does not draw a square at the midpoint of an edge — it makes the whole
edge grabbable — and eight white squares crowding a small element was most of
what made the selection read as heavy. All eight are still registered as
dnd-kit draggables in \`picker.ts\`; only paint and geometry are decided here.
The strips span corner to corner rather than sitting at a midpoint, so the
entire edge is a target. They are inset by half a corner handle at each end so
the two never fight over the same pixel, and centred on the border so their
6px of slop falls evenly inside and outside it. Expressing the span as
\`left: 4px; right: 4px\` rather than a computed width is what makes this free:
the handles are children of a box that is already sized to the element, so the
browser derives \`width − 8\` and clamps at zero on its own. There is no
per-frame handle layout to run, and nothing goes negative on a 6px element at
10% zoom. */
.${PREFIX}-handle { position: absolute; pointer-events: auto; z-index: 1; }
.${PREFIX}-handle-nw, .${PREFIX}-handle-ne,
.${PREFIX}-handle-se, .${PREFIX}-handle-sw {
width: 8px; height: 8px; border-radius: 1px;
background: var(--ap-selection-handle); border: 1px solid var(--ap-primary);
}
.${PREFIX}-handle-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.${PREFIX}-handle-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.${PREFIX}-handle-se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.${PREFIX}-handle-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.${PREFIX}-handle-n { top: -3px; left: 4px; right: 4px; height: 6px; cursor: ns-resize; }
.${PREFIX}-handle-s { bottom: -3px; left: 4px; right: 4px; height: 6px; cursor: ns-resize; }
.${PREFIX}-handle-e { right: -3px; top: 4px; bottom: 4px; width: 6px; cursor: ew-resize; }
.${PREFIX}-handle-w { left: -3px; top: 4px; bottom: 4px; width: 6px; cursor: ew-resize; }
/* The grab area for drag-to-reposition: a transparent stand-in pinned over the
selection, and the only thing dnd-kit's sensors are ever bound to on the
canvas (see reorder.ts). It must opt back into pointer events — the chrome
layer around it is \`pointer-events: none\` — and must sit *below* the
selection box, whose resize handles would otherwise be unreachable behind it.
Clicks that land here still resolve normally: the picker hit-tests inside the
frame rather than reading the event target, so clicking a child of the
selection selects that child. */
.${PREFIX}-drag-proxy {
position: absolute; z-index: 1; pointer-events: auto; cursor: grab;
}
html[data-${PREFIX}-drag] .${PREFIX}-drag-proxy { cursor: inherit; }
/* Drag-to-reposition: target-container highlight, insertion line, dragged node. */
.${PREFIX}-drop-box {
position: absolute; z-index: ${Z}; pointer-events: none;
background: var(--ap-primary-bg);
border: 1px dashed var(--ap-primary); border-radius: var(--ap-radius-xs);
}
/* The insertion bar. Flat, with the glow it used to carry removed: the halo and
the 6px bloom were doing the job of making a 2px bar visible, and a 2px bar
inset clear of the container's border is already visible. What the glow
actually added was a second, softer edge that made the bar read as
approximate — a suggestion of where the element might go — when the whole
point of it is that it is exact. Geometry in \`reorder.ts\`. */
.${PREFIX}-drop-line {
position: absolute; z-index: ${Z}; pointer-events: none;
background: var(--ap-primary); border-radius: 1px;
}
/* \`.${PREFIX}-dragging\` is *not* here. It styles a node in the host app rather
than a piece of chrome, so it lives in \`portable.css.ts\` — the one stylesheet
served into a frame's document as well as this one. It used to be declared
here and hand-copied into \`frame-agent.ts\`'s \`FRAME_CSS\`, which meant the two
could disagree, and for a while they did. */
/* Spacing measurement (Alt-hover). Zero-thickness divs with one border rather
than SVG, drawn on this layer at 1x so the numbers stay readable at any
canvas zoom.
These live here, with the rest of the chrome layer, because that is where
\`position: absolute\` comes from. They were authored in controls.css.ts
carrying only \`cls("layer")\` besides their own class — and \`layer\` is
edit-guard's hit-test marker, not a style — so nothing positioned them, the
left/top writes in place() were inert against a static box, and every
allocated line and chip rendered in normal flow at the top of the page. */
.${PREFIX}-measure-line {
position: absolute; z-index: ${Z}; pointer-events: none;
border-top: 1px solid var(--ap-semantic-error);
}
.${PREFIX}-measure-line[data-axis="v"] {
border-top: none; border-left: 1px solid var(--ap-semantic-error);
}
.${PREFIX}-measure-line[data-dashed] { border-style: dashed; }
.${PREFIX}-measure-label {
position: absolute; z-index: ${Z}; pointer-events: none;
padding: 1px var(--ap-space-xxs); border-radius: var(--ap-radius-xs);
background: var(--ap-semantic-error); color: var(--ap-text-primary);
font-size: var(--ap-font-size-caption); font-weight: 500;
font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* How the label sits off its anchor point: centred on the line and lifted clear
of it. Static, so it belongs here rather than being re-assigned as an inline
style on every pointermove — and the clearance is a token rather than the
bare \`4\` it was written as in the arithmetic. */
.${PREFIX}-measure-label[data-axis="h"] {
transform: translate(-50%, calc(-100% - var(--ap-space-xxs)));
}
.${PREFIX}-measure-label[data-axis="v"] {
transform: translate(var(--ap-space-xxs), -50%);
}
/* Alignment guides. Same red as the measurements, because they are the same
claim — a fact about distance and position rather than about structure — and
the same zero-thickness-div-with-one-border trick, which lands on exact
device pixels where an SVG stroke would not. Geometry in \`guide-overlay.ts\`. */
.${PREFIX}-guide {
position: absolute; z-index: ${Z}; pointer-events: none;
border-left: 1px solid var(--ap-semantic-error);
}
.${PREFIX}-guide[data-axis="y"] {
border-left: none; border-top: 1px solid var(--ap-semantic-error);
}
/* The crosses a design tool puts on the edges a guide matched: one on a centre, two on
a pair of corners. A background image and not two rotated children — an X is
one glyph, and drawing it as two elements doubles the pool for no gain.
Encoded rather than tokenised because a data URI cannot carry a \`var()\`; the
colour still comes from the palette, via \`markImage()\`. */
.${PREFIX}-guide-mark {
position: absolute; z-index: ${Z}; pointer-events: none;
background-image: ${markImage()};
background-size: contain; background-repeat: no-repeat;
}
/* Box-model hatching: the padding, margin and gap a container is spending.
Diagonal stripes rather than a flat tint, because these overlap each other and
overlap the element they describe — a wash would stack into an opaque block,
while hatching at two angles stays readable through itself. The 4px period is
a *screen* constant and the rects are drawn at 1×, so it stays 4px at any
canvas zoom, which is the whole reason this layer exists.
Three hues, and they are conventions rather than our choice: blue inside the
border, amber outside it, pink for the space between children. Anyone who has
used a browser's element inspector already knows which is which. */
.${PREFIX}-hatch {
position: absolute; z-index: ${Z}; pointer-events: none;
}
.${PREFIX}-hatch[data-kind="padding"] {
background-image: repeating-linear-gradient(-45deg,
transparent, transparent 3px,
color-mix(in srgb, var(--ap-box-padding) 50%, transparent) 3px,
color-mix(in srgb, var(--ap-box-padding) 50%, transparent) 4px);
}
.${PREFIX}-hatch[data-kind="margin"] {
background-image: repeating-linear-gradient(-45deg,
transparent, transparent 3px,
color-mix(in srgb, var(--ap-box-margin) 50%, transparent) 3px,
color-mix(in srgb, var(--ap-box-margin) 50%, transparent) 4px);
}
.${PREFIX}-hatch[data-kind="gap"] {
background-image: repeating-linear-gradient(-45deg,
transparent, transparent 3px,
color-mix(in srgb, var(--ap-box-gap) 50%, transparent) 3px,
color-mix(in srgb, var(--ap-box-gap) 50%, transparent) 4px);
}`;
+42
View File
@@ -0,0 +1,42 @@
import { PREFIX } from "../dom";
/** One stacking level for every piece of overlay chrome. */
export const Z = "2147483600";
/**
* The popover layer, one step above the rest of the chrome.
*
* This has to be a real `z-index` rather than "be the last child of the root".
* The docks declare `z-index: ${Z}` explicitly, and a positioned element with
* `z-index: auto` paints in an earlier step of the algorithm than any positioned
* element with a numeric one — so an auto-stacked host loses to a dock however
* late it appears in the DOM. It is also appended last, and `toast.ts` mounts
* its own host ahead of this one to keep that true, but that is hygiene rather
* than the mechanism.
*/
export const Z_POP = "2147483601";
/**
* The toast layer, one step above the popovers.
*
* Above rather than below, and that ordering is deliberate: a toast is
* `pointer-events: none` and gone in under three seconds, so putting it on top
* can never cost anyone a click — whereas a toast painted *under* an open colour
* picker is unreadable at exactly the moment it is trying to tell you something.
*/
export const Z_TOAST = "2147483602";
/** The overlay root selector — token vars and the reset are scoped to it. */
export const ROOT = `#${PREFIX}-root`;
/**
* The narrowest a dock can be dragged.
*
* Here rather than in `app.ts` because it is a number the stylesheet, the
* splitter clamp and the story catalogue all have to agree on, and this module
* is already where those shared numbers live. The stories in particular need it
* without paying for `app.ts`: importing a 3,000-line module that constructs the
* dnd-kit singleton on load, in order to read one integer, would put the whole
* application in the dependency graph of every control story.
*/
export const MIN_DOCK_W = 280;
+907
View File
@@ -0,0 +1,907 @@
import { PREFIX } from "../dom";
import { ROOT } from "./const";
/** Inspector control widgets: fields, segmented groups, box model, swatches. */
export const css = `
/*
* A value the element does not declare — it comes from an ancestor.
*
* Dimmed rather than badged: the panel is dense, and an extra glyph per inherited
* field would be most of a typography section. The tooltip on the control names the
* ancestor; this is the at-a-glance half, and it reads as "not set here" without
* claiming the value is wrong. See DesignPanel.markInherited.
*/
.${PREFIX}-ctl-num[data-inherited] .${PREFIX}-ctl-input,
.${PREFIX}-select[data-inherited],
.${PREFIX}-ctl-seg[data-inherited] {
opacity: 0.62;
}
/* The widths below which a control stops being readable.
The panel is resizable from 280px to 720px and nothing in it ever wrapped:
every box is min-width: 0, so a field just shrank until its value was gone.
These are the floors that make it reflow instead — stated once here and read
by the grid track lists and flex bases further down, rather than restated as a
breakpoint in each of the four contexts that would need a different one. A
container query would have worked and was the first design; it was dropped
because every threshold would have had to hard-code its neighbours' constants
(the section's 48px of padding, a row list's 44px of icons, the 68px label
rail), and because it cannot reach the stroke popover, which reuses .row and
.grid outside the panel's subtree.
Deliberately overlay-local vars and not --ap-*. That namespace belongs to
@airship/editor-tokens, and EDITOR.md's control block is a *rhythm* scale —
one height and four gaps. A measurement of one control's contents is not a
rhythm value, and filing it beside {control.group-gap} would tell the next
reader they are the same kind of quantity. Same reasoning as the pad's
hairlines below, which stay literals for being drawing units. */
${ROOT} {
/* A number field at its floor: 20px glyph + 2x2px input padding + 2x1px
border + six glyphs of JetBrains Mono at {font-size.label} (0.6em advance,
so 43px) = 69px. .paint-pct, .grad-angle and .grad-stop-row all land on 72
too, by a different derivation — they agree by coincidence, not by
construction, so they keep their own literals. */
--${PREFIX}-field-min: 72px;
/* And the width at which it stops being *tight*. Nine or ten glyphs, so a
signed length with a unit — "-12.5px" — has room around it.
Two numbers rather than one because they answer different questions, and
conflating them is a bug with a shape: a reflow whose trigger is the floor
lands exactly on the floor, so the control halves the moment it "fits" and
the panel getting wider makes its fields smaller. Both crossovers below —
the label rail, and the shadow row going four across — are keyed to this
one, and every hard minimum to the one above. */
--${PREFIX}-field-roomy: 96px;
/* A labelled row's control, before the 68px label rail gives up its line.
Set by the widest thing that is not a pad row: three word pills reading
"Inside / Centre / Outside", which want 192 between them. Under that the
rail stacks, which is cheaper than ellipsing a word. */
--${PREFIX}-row-ctl-min: 192px;
/* "#AABBCC" — seven mono glyphs (50px) plus the 12px empty glyph slot and
4px of padding. */
--${PREFIX}-hex-min: 66px;
}
/* Keyboard focus, in one place.
Every control below is a real <button> and every one of them was invisible to
the keyboard: exactly one :focus-visible rule existed in this file, on the
row-icon. Tabbing through the panel moved a focus ring nobody could see.
Inset on the pad and segment cells because they sit flush inside a filled
track, where an outset ring would be clipped by the parent's overflow. */
${[
"ctl-seg-btn",
"pad-cell",
"pad-mode",
"pad-spread",
"sect-act",
"anchor-bar",
"select",
"row-icon",
"tree-act",
"iconbtn",
"fbar-btn",
"ctl-toggle",
]
.map((c) => `.${PREFIX}-${c}:focus-visible`)
.join(",\n")} {
outline: 1px solid var(--ap-border-focus);
outline-offset: -1px;
opacity: 1;
}
.${PREFIX}-align-btn:focus-visible,
.${PREFIX}-insp-tab:focus-visible {
outline: 1px solid var(--ap-border-focus); outline-offset: -2px; opacity: 1;
}
.${PREFIX}-sect-head:focus-visible {
outline: 1px solid var(--ap-border-focus); outline-offset: -2px; opacity: .9;
}
/* Number field.
A design tool's fields are borderless until you touch them — the always-on 1px boxes
are what made this panel read as a web form. The leading glyph is the field's
own label AND its scrub handle, which is why it takes the ew-resize cursor
rather than the input doing so. */
.${PREFIX}-ctl-num {
display: flex; align-items: center; gap: var(--ap-control-field-gap); min-width: 0;
height: var(--ap-control-height); padding-left: var(--ap-control-field-gap);
border: 1px solid transparent; border-radius: var(--ap-radius-sm);
background: transparent; transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease), border-color var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-ctl-num:hover { background: var(--ap-surface-hover); }
.${PREFIX}-ctl-num:focus-within {
background: var(--ap-surface-active); border-color: var(--ap-primary);
}
/* Either a span (the scrub handle) or a real button (the gradient opener), so
it resets the button chrome rather than assuming it is never one. */
.${PREFIX}-ctl-glyph {
display: inline-flex; align-items: center; justify-content: center;
width: 20px; height: 20px; flex: 0 0 auto;
padding: 0; border: 0; background: transparent; color: var(--ap-icon-muted);
cursor: ew-resize; user-select: none; touch-action: none;
}
/* A field with no glyph still gets the slot, because the slot is the scrub
handle. At the full 20px it was pure dead space: the alpha field is 62px
wide, and 20 of those going to an empty box left ~22px for the value, which
is where "100%" was being clipped. Narrow enough to still be a drag target,
not so wide that it costs the number its digits. */
.${PREFIX}-ctl-glyph:empty { width: 12px; }
.${PREFIX}-ctl-num:hover .${PREFIX}-ctl-glyph { color: var(--ap-icon-secondary); }
.${PREFIX}-ctl-glyph .${PREFIX}-ic { color: inherit; }
.${PREFIX}-ctl-glyph-static { cursor: default; }
.${PREFIX}-ctl-glyph-txt {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
line-height: 1; opacity: .85;
}
.${PREFIX}-ctl-input {
flex: 1 1 auto; width: 100%; min-width: 0;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label);
color: var(--ap-text-primary);
background: transparent; border: 0; padding: 0 var(--ap-control-field-gap);
}
.${PREFIX}-ctl-input:focus { outline: none; }
.${PREFIX}-ctl-suffix {
flex: 0 0 auto; padding-right: var(--ap-control-field-gap);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body);
color: var(--ap-text-tertiary);
}
/* A unit belongs to the number it follows, so the number goes to meet it.
The input is \`flex: 1 1 auto\` and its text is left-aligned, so it absorbed
every pixel between the digits and the rigid suffix: the fill row's alpha
field rendered "25" and its "%" about 29px apart, at two different sizes and
two different tones, which read as two controls rather than one value. Only
where there is a suffix — a field without one has nothing to meet, and its
digits belong on the left beside the glyph that names them. */
.${PREFIX}-ctl-num:has(> .${PREFIX}-ctl-suffix) > .${PREFIX}-ctl-input {
text-align: right;
}
/* Segmented group. Text options stay pills; an all-icon group becomes square
cells one control tall, which is the shape a design tool uses. */
.${PREFIX}-ctl-seg {
display: flex; gap: var(--ap-control-field-gap); background: var(--ap-surface-active);
border-radius: var(--ap-radius-sm); padding: var(--ap-control-field-gap); flex-wrap: wrap;
}
.${PREFIX}-ctl-seg-btn {
display: inline-flex; align-items: center; justify-content: center;
padding: 3px var(--ap-space-xs); border: none; background: transparent;
color: var(--ap-text-primary);
opacity: .6; border-radius: var(--ap-radius-xs); cursor: pointer; font-size: var(--ap-font-size-body);
font-family: var(--ap-font-sans); transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease), opacity var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-ctl-seg-btn:hover { opacity: .9; background: var(--ap-surface-hover); }
/* A word pill's safety net. In a labelled row the cells take \`min-width: 0\`
(see inspector.css.ts), which makes their hypothetical main size zero — so
the group never wraps and a long label simply painted over its neighbour
instead. Stroke position ("Inside/Centre/Outside") is the one group narrow
enough to reach it. With the label rail now stacking before that happens the
words fit anyway; this is what stops it being silent if they ever do not. */
.${PREFIX}-ctl-seg-btn > span {
min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.${PREFIX}-ctl-seg[data-variant="icon"] { flex-wrap: nowrap; }
.${PREFIX}-ctl-seg[data-variant="icon"] .${PREFIX}-ctl-seg-btn {
flex: 1 1 0; padding: 0; height: var(--ap-control-height); min-width: var(--ap-control-height);
}
.${PREFIX}-ctl-seg-on { background: var(--ap-primary); color: var(--ap-text-primary); opacity: 1; }
.${PREFIX}-ctl-seg-on:hover { background: var(--ap-primary-hover); }
${ROOT} .${PREFIX}-ctl-seg-on .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-text-primary); }
/* ---- Auto layout ------------------------------------------------------- */
/* Direction row, then the 3x3 pad beside a stack of fields — the design-tool layout. */
.${PREFIX}-al-dir { margin-bottom: var(--ap-control-group-gap); }
.${PREFIX}-al-main { display: flex; align-items: flex-start; gap: var(--ap-control-gutter); }
.${PREFIX}-al-fields { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--ap-control-row-gap); }
/* The 3x3 alignment pad. Each cell previews its result with three bars drawn
as pseudo-elements — nine more SVGs would cost ~8KB to say the same thing
less clearly, and these can respond to the direction with CSS alone.
The literal 1px and 1.5px below are the only gaps in this file that are not
on the control rhythm, and deliberately so: they are hairlines *inside a
drawing*, sized against the 72px pad and the 11px ink bars. Snapping them to
a 2px spacing token would visibly thicken the widget while telling the reader
they are the same kind of quantity as the space between two fields. */
/* Room for the spread button, which hangs 20px below the pad on \`bottom: -20px\`
and is out of flow — so the wrap measured 72px, the fields column beside it
measured 80 in sides mode, and the button painted straight through the
padding row's second line. Reserving its height is what makes "below the pad"
a place rather than an overlap. */
.${PREFIX}-pad-wrap {
position: relative; flex: 0 0 auto; padding-bottom: var(--ap-space-md);
}
.${PREFIX}-pad {
display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
width: 72px; height: 72px; gap: 1px;
background: var(--ap-surface-active); border-radius: var(--ap-radius-sm);
overflow: hidden;
}
.${PREFIX}-pad-cell {
display: grid; place-items: center; border: 0; padding: 0; cursor: pointer;
background: transparent; transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-pad-cell:hover { background: var(--ap-surface-hover); }
.${PREFIX}-pad-on { background: var(--ap-primary-bg); }
/* The ink: three bars whose stacking axis follows the container's direction,
so the preview reads correctly in both row and column mode. Differing
lengths are what make the alignment legible at this size. */
.${PREFIX}-pad-ink {
display: flex; gap: 1.5px; pointer-events: none;
--${PREFIX}-ink: var(--ap-icon-muted);
}
.${PREFIX}-pad-ink i { background: var(--${PREFIX}-ink); border-radius: 1px; }
.${PREFIX}-pad-cell:hover .${PREFIX}-pad-ink { --${PREFIX}-ink: var(--ap-icon-secondary); }
.${PREFIX}-pad-on .${PREFIX}-pad-ink { --${PREFIX}-ink: var(--ap-primary); }
/* Row: three vertical bars, aligned to the cell's row band. */
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-ink { flex-direction: row; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-ink i { width: 2px; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-ink i:nth-child(1) { height: 11px; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-ink i:nth-child(2) { height: 7px; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-ink i:nth-child(3) { height: 9px; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-cell[data-row="0"] .${PREFIX}-pad-ink { align-items: flex-start; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-cell[data-row="1"] .${PREFIX}-pad-ink { align-items: center; }
.${PREFIX}-pad[data-dir="row"] .${PREFIX}-pad-cell[data-row="2"] .${PREFIX}-pad-ink { align-items: flex-end; }
/* Column: three horizontal bars. */
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-ink { flex-direction: column; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-ink i { height: 2px; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-ink i:nth-child(1) { width: 11px; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-ink i:nth-child(2) { width: 7px; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-ink i:nth-child(3) { width: 9px; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-cell[data-col="0"] .${PREFIX}-pad-ink { align-items: flex-start; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-cell[data-col="1"] .${PREFIX}-pad-ink { align-items: center; }
.${PREFIX}-pad[data-dir="column"] .${PREFIX}-pad-cell[data-col="2"] .${PREFIX}-pad-ink { align-items: flex-end; }
/* space-between owns the main axis, so the pad's main axis stops meaning
anything and says so rather than silently disagreeing with the canvas. */
.${PREFIX}-pad[data-spread="true"] .${PREFIX}-pad-cell { opacity: .4; }
.${PREFIX}-pad-spread {
position: absolute; left: 0; right: 0; bottom: -20px;
justify-content: center;
display: inline-flex; align-items: center; gap: var(--ap-control-field-gap);
height: 18px; padding: 0 5px; border: 0; cursor: pointer;
background: transparent; border-radius: var(--ap-radius-xs);
}
.${PREFIX}-pad-spread span { width: 2px; height: 9px; background: var(--ap-icon-muted); border-radius: 1px; }
.${PREFIX}-pad-spread:hover { background: var(--ap-surface-active); }
.${PREFIX}-pad-spread:hover span { background: var(--ap-icon-secondary); }
/* Padding: two fields with a switch to four. */
.${PREFIX}-pad-row { display: flex; align-items: flex-start; gap: var(--ap-control-field-gap); }
/* auto-fit, and that is the whole point rather than a flourish.
This grid holds two fields, or four in a 2x2 — but \`createQuadField\`
collapsed renders exactly *one*, and a lone child in a fixed \`1fr 1fr\` took
half the box and left the other half empty. In Appearance that box is already
a half-width grid cell, so the everyday state of the corner radius field —
four corners agreeing — was 58px wide at the default dock width, of which 20
was the glyph. It was the narrowest field in the panel and it was narrow in
the common case, not the edge case.
auto-fit collapses the empty track and the gutter beside it, so one field
takes the row. The max() caps the count at two when there is room and drops
it to one when a field would go under its floor. auto-fit rather than
auto-fill precisely because collapsing is the fix here; the .grid below wants
the opposite and says so. */
.${PREFIX}-pad-fields {
flex: 1 1 auto; min-width: 0;
display: grid;
grid-template-columns: repeat(auto-fit,
minmax(max(var(--${PREFIX}-field-min), (100% - var(--ap-control-gutter)) / 2), 1fr));
gap: var(--ap-control-field-gap) var(--ap-control-gutter);
}
/* Four fields cannot be a 2x2 inside a half-width cell: (S-8)/2 - 26 has to
reach 2x72 + 8, i.e. a section 372px wide, which is a 424px dock. So a quad
that has split takes the whole row instead. \`data-mode\` is published by
\`createQuadField\` for this, the way \`createPadding\` already published it. */
.${PREFIX}-grid > .${PREFIX}-pad-row[data-mode="sides"] { grid-column: 1 / -1; }
.${PREFIX}-pad-mode {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
width: var(--ap-control-height); height: var(--ap-control-height);
padding: 0; border: 0; cursor: pointer; background: transparent;
border-radius: var(--ap-radius-xs); transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-pad-mode:hover { background: var(--ap-surface-active); }
.${PREFIX}-pad-mode-on { background: var(--ap-primary-bg); }
${ROOT} .${PREFIX}-pad-mode-on .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-primary); }
/* Size: a W/H field with its Hug/Fill/Fixed switch on the same line.
The two rows and the aspect lock share one flex line rather than living in
the two-column .grid: a .size-row already spans both of that grid's columns,
so a lock appended as a third child auto-placed onto a row of its own
underneath them — which is what it did. Here the rows stack in a column and
the lock is their sibling, so "beside the two fields" is structural. */
.${PREFIX}-size-wrap {
display: flex; align-items: center; gap: var(--ap-control-gutter);
}
.${PREFIX}-size-rows {
flex: 1 1 auto; min-width: 0;
display: flex; flex-direction: column; gap: var(--ap-control-row-gap);
}
/* Two children, or three when the axis has a sizing token — so the columns are
counted rather than declared. \`1fr auto\` with a badge between the field and
the Fixed/Hug/Fill switch auto-placed the switch onto an implicit second row
underneath, which is what it did in any project declaring width/height
tokens. \`grid-auto-flow: column\` gives the extra child a track of its own,
and no trailing gap when there is no badge. The minmax floor makes the row
overflow rather than crush the W/H field, which cannot happen in range
(72 + 8 + 37 + 8 + 80 = 205, against 230 at the narrowest dock). */
.${PREFIX}-size-row {
display: grid;
grid-template-columns: minmax(var(--${PREFIX}-field-min), 1fr);
grid-auto-flow: column; grid-auto-columns: auto;
gap: var(--ap-control-gutter);
align-items: center;
}
.${PREFIX}-grid-tracks { display: flex; flex-direction: column; gap: var(--ap-control-row-gap); }
/* A labelled on/off toggle — Clip content, and anything else that is one
boolean with a name. A segmented group of two would be the alternative and
it is the wrong shape: "on" and "off" are not two peer choices you pick
between, they are one state you flip. */
.${PREFIX}-ctl-toggle {
display: inline-flex; align-items: center; gap: var(--ap-control-gutter);
height: var(--ap-control-height); padding: 0 var(--ap-space-xs) 0 4px;
cursor: pointer; background: transparent; color: var(--ap-text-secondary);
border: 1px solid transparent; border-radius: var(--ap-radius-sm);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease), color var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-ctl-toggle { --${PREFIX}-ic-tone: var(--ap-icon-muted); }
.${PREFIX}-ctl-toggle:hover {
background: var(--ap-surface-hover); color: var(--ap-text-primary);
}
${ROOT} .${PREFIX}-ctl-toggle:hover .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-icon-secondary); }
.${PREFIX}-ctl-toggle-on {
background: var(--ap-primary-bg); color: var(--ap-text-primary);
}
${ROOT} .${PREFIX}-ctl-toggle-on .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-primary); }
/* ---- Repeatable rows (Fill / Stroke / Effects) -------------------------- */
.${PREFIX}-rows { display: flex; flex-direction: column; gap: var(--ap-control-row-gap); }
.${PREFIX}-rows-row { display: flex; align-items: center; gap: var(--ap-control-field-gap); }
/* A real basis rather than \`auto\`. The eye and the minus are 44px of tax this
row cannot shed — they belong to it — so nothing reflows here today; the
number is for correctness, so that a list nested in a wrapping parent breaks
at a width that means something instead of at the intrinsic width of an
<input> with its default size="20". */
.${PREFIX}-rows-row > *:first-child {
flex: 1 1 var(--${PREFIX}-field-min); min-width: 0;
}
.${PREFIX}-rows-off > *:first-child { opacity: .4; }
/* Row affordances stay quiet until the row is hovered — a design tool's rows are quiet
until you reach for them, which is what keeps a stack of six fills from
reading as twelve buttons.
Quiet, not invisible. These used to rest at opacity 0, and the minus is the
only way to remove a fill or a shadow: a destructive action with no resting
trace is not "restrained", it is hidden. .55 is below the text tone and above
nothing, which is the line — contrast .tree-act and .css-del, which stay at 0
because a layer list and a declaration list have dozens of rows each and
their actions are all reachable another way.
A .row is the third host, and it was missing from the reveal below. The
panel's labelled rows carry ghost icons too — the token badge fieldCell
appends after a control, Text's overflow menu — and neither .rows-row nor
.token-cell reaches them, so both sat pinned at .55 with no hover state at
all: a resting tone that was chosen to mean "quiet until you reach for it"
on rows where reaching for it did nothing. */
.${PREFIX}-row-icon {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
width: 20px; height: 20px; padding: 0; border: 0; cursor: pointer;
background: transparent; border-radius: var(--ap-radius-xs); opacity: .55;
transition: opacity var(--ap-motion-dur-micro) var(--ap-motion-ease), background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-rows-row:hover .${PREFIX}-row-icon,
.${PREFIX}-rows-off .${PREFIX}-row-icon,
.${PREFIX}-row:hover .${PREFIX}-row-icon,
.${PREFIX}-row-icon:focus-visible { opacity: .8; }
.${PREFIX}-row-icon:hover { opacity: 1; background: var(--ap-surface-active); }
/* A paint row: swatch, hex, alpha. The hex field takes the slack. */
.${PREFIX}-paint-row { display: flex; align-items: center; gap: var(--ap-control-field-gap); min-width: 0; }
.${PREFIX}-paint-hex { flex: 1 1 var(--${PREFIX}-hex-min); min-width: 0; }
.${PREFIX}-paint-hex .${PREFIX}-ctl-input { text-transform: uppercase; }
/* Wide enough for "100" plus its % without clipping. It was 62px, which fit
the digits only while the empty glyph slot beside them was 20px wide.
Shrinkable now, with a floor of its own. Rigid at 72 it was fine on a plain
fill row and wrong on a bound one, where a token badge has already taken its
share: at the narrowest dock that left the hex 49px, under the 66px seven hex
digits need. 56 still holds "100%" beside the 12px glyph slot, and the hex
gets the difference. */
.${PREFIX}-paint-pct { flex: 0 1 72px; min-width: 56px; }
/* An effect row stacks: type + four offsets, then its colour. */
.${PREFIX}-effect-row {
display: flex; flex-direction: column; gap: var(--ap-control-field-gap); min-width: 0;
padding: var(--ap-control-row-gap) 0; border-top: 1px solid var(--ap-border-default);
}
.${PREFIX}-rows-row:first-child .${PREFIX}-effect-row { border-top: 0; }
/* The four offsets, as two pairs that wrap — not four tracks that reflow.
Four across gave each field 65px at the default dock width, of which 20 was
the glyph: 39px, about five characters of mono, for a value like "-12.5px".
The obvious fix is a track list with a floor, and it does not work here. For
any minimum M, the count floor((W+g)/(M+g)) passes through 3 on its way from
4 to 2, and that 3-wide band lands squarely on the default width — X, Y and
Blur on one line with Spread alone under them. Pairing X/Y and Blur/Spread in
the DOM makes the pair the thing that wraps, so the step is 4 across or 2x2
and never 3+1. */
.${PREFIX}-effect-nums {
display: flex; flex-wrap: wrap; gap: var(--ap-control-field-gap);
}
/* The basis is two roomy fields, not two minimum ones — so the row only goes
four across once four across is comfortable, rather than the instant it is
possible. Keyed to the floor it stepped from 145px to exactly 72px on
widening past a 388px dock; keyed here the step is 193px to 96px at 484. */
.${PREFIX}-effect-pair {
flex: 1 1 calc(var(--${PREFIX}-field-roomy) * 2 + var(--ap-control-field-gap));
min-width: 0;
display: grid; grid-template-columns: 1fr 1fr; gap: var(--ap-control-field-gap);
}
/* The layer's type, which is a dropdown and was drawn as a bare 20px glyph with
no caret — the only one in the panel — sitting alone on a line that therefore
said nothing. Named now, with the caret every other dropdown here wears.
Shape from row-icon, the panel's one ghost icon button, overridden the way
.token-badge and .aspect-lock override it: the reset, the radius and the
hover fill are all worth keeping, the 20px square is not. Full width because
.effect-row is a stretching column, so the caret lands on the right edge over
the fields it heads — the same shape as .select, which is the same control.
Opacity 1 and a secondary text colour rather than row-icon's .55: that tone
is for a glyph nobody is meant to read, and this line is words. */
/* The header line: the type dropdown, and the row's own eye and minus.
\`createRowList\` puts them here rather than beside the block — see its
\`actionSlot\`. The button takes the slack so the actions stay hard right,
where they are in every single-line row in the panel. */
.${PREFIX}-effect-head {
display: flex; align-items: center; gap: var(--ap-control-field-gap);
}
.${PREFIX}-effect-head > .${PREFIX}-effect-kind { flex: 1 1 auto; min-width: 0; }
.${PREFIX}-effect-kind {
display: flex; align-items: center; gap: var(--ap-control-field-gap);
width: auto; height: var(--ap-control-height);
padding: 0 var(--ap-control-field-gap); opacity: 1;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
color: var(--ap-text-secondary);
}
.${PREFIX}-effect-kind { --${PREFIX}-ic-tone: var(--ap-icon-secondary); }
/* The row's quiet-until-hovered rule reaches every .row-icon inside it and
outranks the opacity above, so hovering the row would have *dimmed* this one
from 1 to .8. It is a label, not an affordance waiting to be found. */
.${PREFIX}-rows-row:hover .${PREFIX}-effect-kind { opacity: 1; }
.${PREFIX}-effect-kind:hover { color: var(--ap-text-primary); }
${ROOT} .${PREFIX}-effect-kind:hover .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-icon-primary); }
.${PREFIX}-effect-kind-label { flex: 1 1 auto; min-width: 0; text-align: left; }
/* Dropdown. For enums whose labels are words rather than glyphs — five text
options in a 320px panel wrap into two rows as a segmented group, which
reads as a bug. Design tools use a select here for exactly that reason.
Unlike the number fields above, this one is *not* borderless at rest. A field
you type into announces itself the moment you put a caret in it; a dropdown
announces nothing at all, so a transparent one was only discoverable by
hovering the right 200×24 rectangle. The --ap-input-* family exists for
exactly this — it is what the chat composer uses — and a hairline plus one
3-5% surface step is EDITOR.md's own prescription, not a form outline. */
.${PREFIX}-select {
display: flex; align-items: center; justify-content: space-between;
gap: var(--ap-control-gutter);
width: 100%; height: var(--ap-control-height); padding: 0 var(--ap-space-xs);
cursor: pointer; text-align: left;
background: var(--ap-input-bg); color: var(--ap-text-primary);
border: 1px solid var(--ap-input-border); border-radius: var(--ap-radius-sm);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease), border-color var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
/* The caret is the other half of the affordance and it was drawn at the icon
set's muted tone, which is the resting colour for a glyph nobody is meant to
look at. It carries the whole "this opens" signal, so it sits at
{icon.secondary} — one step below text, per EDITOR.md — and lifts on hover. */
.${PREFIX}-select { --${PREFIX}-ic-tone: var(--ap-icon-secondary); }
.${PREFIX}-select:hover {
background: var(--ap-input-hover); border-color: var(--ap-border-strong);
}
${ROOT} .${PREFIX}-select:hover .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-icon-primary); }
.${PREFIX}-select[aria-expanded="true"] {
background: var(--ap-input-focus); border-color: var(--ap-input-focus-border);
}
${ROOT} .${PREFIX}-select[aria-expanded="true"] .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-icon-primary); }
/* No position: relative — the menu is not a child any more. It went to the
popover host precisely because being positioned against this box put it
inside .insp-body's scroller and .dock's overflow:hidden, which clipped it. */
.${PREFIX}-select-wrap { flex: 1 1 auto; min-width: 0; }
/* ---- Text extras -------------------------------------------------------- */
/* The font-family field, then Style / Vertical / Case as labelled rows.
The three icon groups used to sit in a bespoke .text-row that packed them
left at their content width — three 24px cells, 80px all in — on the
argument that a stretched icon cell is the shape of a toolbar rather than of
a control, and that two groups sharing a line met edge to edge as one
undifferentiated strip. Neither observation was wrong; both were about a
*shared* row, and neither survives a group having a name of its own. What
the rule actually bought was 230px of nothing to the right of each group in
the default rail, three rows running, directly beneath an Align row whose
four icon cells do span the width — text-align is span: "full", so the
section was already contradicting itself. The panel has one shape for a
named choice: a 68px rail and a control taking the rest of the line. These
three are named choices. They are labelled() rows now, and .text-row is gone.
A block, not a flex column, and with no gap of its own. A .row spaces itself
with \`margin: 6px 0\` (see inspector.css.ts) and margins do not collapse
between flex items, so a 6px column gap put 18px between two rows and 12px
above the first — one pitch reading as three. Block flow is the model those
margins were written for, the one .sect-body already gives every other
section, and the one where :first-child and :last-child mean what they say.
What is left here is the group gap above, which is all this wrapper was ever
for. The font-family field is still full width under it: a \`display: flex\`
box in block flow is block-level and fills the line exactly as a stretching
column made it. */
.${PREFIX}-text-extras { margin-top: var(--ap-control-group-gap); }
/* An icon group is not three word pills, and {row-ctl-min} is a measurement of
words — "Inside / Centre / Outside", per the note where it is defined. Three
icon cells are legible from 24px, so 3x40 plus the group's 8px of chrome is
what these rows ask for before the rail gives up its line. Under the shared
192 all three wrapped at the narrowest dock, spending 54px of height to say
nothing while the cells they freed were already twice as wide as they needed
to be. At 124 the widest of them — Case, which also carries the 20px overflow
button — fits the 230px rail a 280px dock leaves: 68 + 8 + 124 + 8 + 20. The
grow factor is untouched, so they still fill at every width above that. */
.${PREFIX}-text-extras > .${PREFIX}-row > .${PREFIX}-ctl-seg {
--${PREFIX}-row-ctl-min: 124px;
}
/* ---- Constraints -------------------------------------------------------- */
/* Composed from a frame and four edge bars rather than 25 inlined SVGs — see
inspector/constraints.ts. The frame takes the icon set's own 0.3 tone and an
engaged anchor its 0.9, so the widget reads as part of the same family. */
.${PREFIX}-anchor-wrap { display: flex; align-items: center; gap: var(--ap-control-gutter); }
.${PREFIX}-anchor {
position: relative; flex: 0 0 auto; width: 52px; height: 52px;
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-xs);
}
.${PREFIX}-anchor-core {
position: absolute; left: 50%; top: 50%; width: 14px; height: 14px;
transform: translate(-50%, -50%);
border: 1px solid var(--ap-icon-muted); border-radius: 2px;
pointer-events: none;
}
.${PREFIX}-anchor-bar {
position: absolute; border: 0; padding: 0; cursor: pointer;
background: var(--ap-icon-muted); opacity: .3; border-radius: 1px;
transition: opacity var(--ap-motion-dur-micro) var(--ap-motion-ease), background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-anchor-bar:hover { opacity: .65; }
.${PREFIX}-anchor-on { background: var(--ap-primary); opacity: .9; }
.${PREFIX}-anchor-bar[data-side="top"],
.${PREFIX}-anchor-bar[data-side="bottom"] { left: 50%; width: 2px; height: 11px; margin-left: -1px; }
.${PREFIX}-anchor-bar[data-side="left"],
.${PREFIX}-anchor-bar[data-side="right"] { top: 50%; height: 2px; width: 11px; margin-top: -1px; }
.${PREFIX}-anchor-bar[data-side="top"] { top: 5px; }
.${PREFIX}-anchor-bar[data-side="bottom"] { bottom: 5px; }
.${PREFIX}-anchor-bar[data-side="left"] { left: 5px; }
.${PREFIX}-anchor-bar[data-side="right"] { right: 5px; }
.${PREFIX}-anchor-modes {
flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
gap: var(--ap-control-field-gap);
}
/* The alpha checkerboard, declared once and composited under any translucent
swatch. Two layers on one element — colour over checker — rather than a
wrapper per swatch. Without it a 40% fill and a dark opaque one are the same
square, which is the kind of thing that makes a colour control untrustworthy. */
/* Image only — no position/size. It is interpolated into background-image,
where a "0 0 / 6px 6px" shorthand tail is a parse error that takes the whole
declaration with it, swatch colour included. Size is set per element below. */
.${PREFIX}-pop-host, .${PREFIX}-ctl-swatch, .${PREFIX}-pop-recent {
--${PREFIX}-checker: conic-gradient(
from 90deg,
var(--ap-surface-hover) 0 25%,
var(--ap-surface-base) 0 50%
);
}
.${PREFIX}-ctl-swatch {
width: 22px; height: 22px; flex: 0 0 auto; padding: 0;
border-radius: var(--ap-radius-sm); border: 1px solid var(--ap-border-default);
cursor: pointer; background-color: transparent; background-size: 6px 6px;
transition: border-color var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-ctl-swatch:hover { border-color: var(--ap-border-strong); }
.${PREFIX}-ctl-swatch:focus-visible {
outline: 1px solid var(--ap-border-focus); outline-offset: 1px;
}
/* Several values at once. A diagonal hairline rather than an arbitrary colour —
picking one of the selection's colours to show would be a lie about the rest. */
.${PREFIX}-ctl-swatch[data-mixed] {
background-image: linear-gradient(
135deg,
transparent 46%, var(--ap-border-strong) 46% 54%, transparent 54%
);
}
/* -- Design tokens ---------------------------------------------------------
The badge is a quiet trailing affordance, not a control: it must not compete
with the value it annotates. It only renders where the project actually has
tokens for that property, so an app without a design system sees the panel
it always had rather than a column of dead icons.
It carries .row-icon for its shape and adds only the two state colours. The
panel had grown four hand-authored 20/22px ghost buttons that were all this
control with different metrics; there is one now. */
.${PREFIX}-token-cell {
display: flex; align-items: center; gap: var(--ap-control-field-gap); min-width: 0;
}
.${PREFIX}-token-cell > :first-child { flex: 1 1 auto; min-width: 0; }
/* Linked: the value comes from the design system. */
/* One glyph, and the 20px square its base class gives it.
It was the \`libraries\` mark plus a caret, on a box widened to \`width: auto\`
to hold both — 37px of trailing furniture on every field the project has
tokens for, which in Appearance is most of them. Two glyphs abutting at 16px
read as one unfamiliar mark rather than as an icon and its caret, and
\`libraries\` is the set's sidebar glyph: two book spines, which is a noun about
a panel and says nothing about this control. \`var-apply\` is the icon set's
own answer — it is filed under "Design tokens / variables. The token badge
and picker are the client" — and being a verb it needs no caret to say it
does something, any more than the eye, the minus or the aspect lock do. */
.${PREFIX}-token-badge[data-on] { color: var(--ap-primary); opacity: 1; }
/* The badge rests quiet and lifts when you reach for it — but the only rule
that lifted it keyed off .rows-row, and in the field grid a badge sits in a
.token-cell instead, so it was pinned at .55 forever. */
.${PREFIX}-token-cell:hover > .${PREFIX}-token-badge { opacity: .8; }
.${PREFIX}-token-cell:hover > .${PREFIX}-token-badge[data-on] { opacity: 1; }
/* A badge can also sit in a section header, where the property it annotates is
the whole section rather than one field — Effects' \`box-shadow\` is one
property holding a list, so a token stands for all of it. There it takes the
header's own 18px metrics and lifts with the heading. */
.${PREFIX}-sect-actions > .${PREFIX}-token-badge { width: 18px; height: 18px; }
.${PREFIX}-sect-head:hover .${PREFIX}-token-badge { opacity: .8; }
.${PREFIX}-sect-head:hover .${PREFIX}-token-badge[data-on] { opacity: 1; }
/* Near, not exact — a suggestion. Dimmer than linked, so the two never read
as the same state at a glance. */
.${PREFIX}-token-badge[data-near] {
color: var(--ap-semantic-warning); opacity: var(--ap-opacity-64);
}
/* The bound state — a tint on the field, not a different control.
A bound field reads the token's name instead of its number, and that is the
only thing that changes: same chrome, same height, same glyph, same place in
the grid. An earlier version replaced the whole control with a pill, which
meant binding a property visibly restructured its row — so a panel with three
bound properties had three controls that no longer looked like the ones
around them, and picking a token felt like the panel breaking rather than
like a value being chosen.
Applied on the field wrapper so it covers every shape that carries a value:
.ctl-num for a number or the hex, .paint-row for a whole colour row. */
.${PREFIX}-ctl-num[data-token],
.${PREFIX}-paint-row[data-token] .${PREFIX}-paint-hex {
background: var(--ap-selection-fill);
}
.${PREFIX}-ctl-num[data-token] .${PREFIX}-ctl-input,
.${PREFIX}-paint-row[data-token] .${PREFIX}-paint-hex .${PREFIX}-ctl-input {
color: var(--ap-primary);
/* Sans, not the mono a number wears: this is a name now, and reading it as
one is the point. And not uppercased — .paint-hex shouts its six hex
characters, which is right for AABBCC and wrong for a token name. */
font-family: var(--ap-font-sans);
text-transform: none;
text-overflow: ellipsis;
}
/* A field whose value is not its own to edit: bound to a token, or locked
because something it belongs to is. The scrub grip goes quiet and the caret
goes away, because both would be a lie about what the field will accept. */
.${PREFIX}-ctl-num[data-locked] .${PREFIX}-ctl-input { cursor: default; }
.${PREFIX}-ctl-num[data-locked] .${PREFIX}-ctl-glyph {
cursor: default; opacity: var(--ap-opacity-64);
}
/* A read-only stand-in for a control that has no bound state of its own — the
shadow list, whose token names the whole stack rather than one layer. Wears
the field chrome so it sits in the row the list used to. */
.${PREFIX}-bound-value { cursor: default; }
/* A bound field is read-only — its value is the design system's — so the text
caret would be a lie about what clicking does. The badge beside it is how the
binding is changed or removed. */
.${PREFIX}-ctl-num[data-token] .${PREFIX}-ctl-input,
.${PREFIX}-paint-row[data-token] .${PREFIX}-paint-hex .${PREFIX}-ctl-input { cursor: default; }
/* The scrub grip goes quiet for the same reason: there is no number to drag. */
.${PREFIX}-ctl-num[data-token] .${PREFIX}-ctl-glyph {
cursor: default; opacity: var(--ap-opacity-64);
}
/* The picker is a menu with a search field on top, so it is built from
.pop-menu / .pop-item rather than a private set of rows that agreed with
them on nothing — not the padding, not the radius, not the hover tone, and
not the font size, which an inherited shorthand had resolved to the initial
16px because the overlay root sets a family and no size. */
.${PREFIX}-token-head {
flex: 0 0 auto;
padding: var(--ap-control-row-gap);
border-bottom: 1px solid var(--ap-border-subtle);
}
.${PREFIX}-token-search {
width: 100%; box-sizing: border-box;
height: var(--ap-control-height); padding: 0 var(--ap-space-xs);
border: 1px solid var(--ap-input-border); border-radius: var(--ap-radius-sm);
background: var(--ap-input-bg); color: var(--ap-text-primary);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
outline: none;
}
.${PREFIX}-token-search:focus { border-color: var(--ap-input-focus-border); }
/* Scrolls inside the shell rather than growing it. min-height: 0 is what lets a
flex child actually shrink to its scroll container. */
.${PREFIX}-token-list { flex: 1 1 auto; min-height: 0; max-height: 260px; }
.${PREFIX}-token-swatch {
width: 12px; height: 12px; flex: 0 0 auto;
border-radius: var(--ap-radius-xs); border: 1px solid var(--ap-border-default);
}
.${PREFIX}-token-name {
min-width: 0; overflow: hidden;
text-overflow: ellipsis; white-space: nowrap;
}
/* A token the element's cascade does not define. Dimmed rather than dropped:
it may live under a theme class or a media query that is not matching, and it
still applies correctly — the preview carries the token's own value as the
var() fallback. Hiding it would quietly remove a real token. */
.${PREFIX}-pop-item[data-out-of-scope] { opacity: var(--ap-opacity-64); }
.${PREFIX}-pop-item[data-out-of-scope]:hover { opacity: 1; }
.${PREFIX}-token-empty {
padding: var(--ap-space-xs) var(--ap-control-row-gap);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
color: var(--ap-text-tertiary);
}
/* -- Scope + State ---------------------------------------------------------
Above the alignment strip and outside the sections, because these two govern
every control below them. The tinted left edge is the standing reminder that
edits are not landing on the resting style of this one element.
Padded to the panel's own gutter: this sits directly on top of .align-row,
and an inset of its own put a visible step in the left edge at the very top
of the panel. The rows space themselves through their .row margins, so there
is deliberately no grid gap here — the two do not collapse together, and
setting both is what made these rows sit 16px apart. */
.${PREFIX}-scope-row {
display: grid;
padding: var(--ap-space-sm) var(--ap-space-lg);
border-bottom: 1px solid var(--ap-border-subtle);
}
.${PREFIX}-scope-row[data-scoped] {
box-shadow: inset var(--ap-control-field-gap) 0 0 var(--ap-primary);
background: var(--ap-surface-hover);
}
/* -- Section sub-heading ---------------------------------------------------
Names a stack inside a section: Filter vs Backdrop, Background vs Image.
Same mono eyebrow as .pop-head, which is the panel's other group heading —
it was authored here as \`rows-sub-head\` at its own size and tracking, and
the \`rows-\` prefix means "part of a createRowList" everywhere else.
No horizontal padding: this sits inside the section body, which is already
inset to the panel's 24px gutter, so any of its own would step the left edge
in from the rows it heads. */
.${PREFIX}-sect-sub-head {
padding: var(--ap-control-row-gap) 0 var(--ap-control-field-gap);
font-family: var(--ap-font-mono); text-transform: uppercase;
font-size: var(--ap-font-size-micro); letter-spacing: .6px;
color: var(--ap-text-tertiary);
}
.${PREFIX}-sect-sub-head:first-child { padding-top: 0; }
/* -- Filters ---------------------------------------------------------------
Glyph, name, value — The effect-row shape. The type reads from the icon
before the word, which is what makes a stack of five scannable. The value
track is fixed rather than a minmax range so every row in a stack lines its
numbers up on the same edge. */
.${PREFIX}-filter-row {
display: grid; grid-template-columns: 1fr 84px;
align-items: center; gap: var(--ap-control-gutter); width: 100%; min-width: 0;
}
.${PREFIX}-filter-name {
display: flex; align-items: center; gap: var(--ap-control-gutter);
min-width: 0;
font-size: var(--ap-font-size-label); color: var(--ap-text-secondary);
}
.${PREFIX}-filter-name { --${PREFIX}-ic-tone: var(--ap-icon-muted); }
.${PREFIX}-filter-name .${PREFIX}-ic { flex: 0 0 auto; }
.${PREFIX}-filter-label {
min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* A drop-shadow row carries four controls, so it wraps rather than crushing
them into a single line the way the other filter rows can afford to. */
/* A column of three lines — name, offsets, colour — rather than a grid with a
spanning last child. The name line is new: it is what every other filter row
already had, and it is where the eye and the minus now live. */
.${PREFIX}-filter-shadow {
display: flex; flex-direction: column;
gap: var(--ap-control-field-gap); width: 100%; min-width: 0;
}
.${PREFIX}-filter-shadow-head {
display: flex; align-items: center; gap: var(--ap-control-field-gap);
}
.${PREFIX}-filter-shadow-head > .${PREFIX}-filter-name {
flex: 1 1 auto; min-width: 0;
}
.${PREFIX}-filter-shadow-nums {
display: grid; grid-template-columns: repeat(3, 1fr);
gap: var(--ap-control-field-gap); min-width: 0;
}
/* A filter function we do not model. Mono, because it is source text. */
.${PREFIX}-filter-raw {
flex: 1 1 auto; min-width: 0;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
font-family: var(--ap-font-mono);
color: var(--ap-text-tertiary);
}
/* -- Aspect lock -----------------------------------------------------------
Sits beside the two size rows, because the thing it locks is the
relationship between them. See .size-wrap for why that is a flex sibling
rather than a grid cell. Shape from .row-icon; this adds only the on state. */
.${PREFIX}-aspect-lock[data-on] { color: var(--ap-primary); opacity: 1; }
/* -- Gradient editor -------------------------------------------------------
Opened from the fill layer's glyph. The raw CSS field stays beside it and
stays authoritative — this is an alternative view of the same value. */
.${PREFIX}-ctl-glyph-action { cursor: pointer; }
.${PREFIX}-ctl-glyph-action:hover { color: var(--ap-icon-primary); }
/* Shell sets the width, content owns the padding — the same split .pop-color
and .pop-color-body already use. */
.${PREFIX}-pop-grad { min-width: 236px; }
.${PREFIX}-grad-edit {
display: flex; flex-direction: column; gap: var(--ap-control-gutter);
padding: var(--ap-space-xs);
}
/* The type switch is a .ctl-seg like every other icon segmented group; the two
whole-gradient verbs sit after it, pushed to the far end. */
.${PREFIX}-grad-kinds {
display: flex; align-items: center; gap: var(--ap-control-gutter);
}
.${PREFIX}-grad-kinds > .${PREFIX}-ctl-seg { flex: 1 1 auto; min-width: 0; }
.${PREFIX}-grad-acts { display: flex; align-items: center; gap: var(--ap-control-field-gap); }
/* The bar is the hit target; the chits are decoration, so a click 3px off a
stop still grabs it rather than falling through to "add a stop". */
.${PREFIX}-grad-bar-wrap { position: relative; height: 28px; cursor: pointer; }
.${PREFIX}-grad-bar {
position: absolute; inset: 0 0 10px 0;
border-radius: var(--ap-radius-sm); border: 1px solid var(--ap-border-default);
background-color: var(--ap-surface-base);
}
/* 10px chits on a 1px rail: the sizes below are the drawing, not the layout,
and are the same kind of quantity as .pad-ink's hairlines rather than a gap
between two controls. */
.${PREFIX}-grad-stop {
position: absolute; bottom: 0; width: 10px; height: 10px;
margin-left: -5px; pointer-events: none;
border-radius: var(--ap-radius-xs); border: 1px solid var(--ap-border-strong);
background: var(--stop-color, var(--ap-surface-panel));
box-shadow: 0 0 0 1px var(--ap-surface-base);
}
.${PREFIX}-grad-stop[data-on] {
border-color: var(--ap-primary);
box-shadow: 0 0 0 2px var(--ap-primary);
}
.${PREFIX}-grad-angle { display: flex; align-items: center; gap: var(--ap-control-gutter); }
.${PREFIX}-grad-angle > .${PREFIX}-ctl-num { flex: 0 0 72px; }
.${PREFIX}-grad-na { color: var(--ap-text-tertiary); }
.${PREFIX}-grad-stops {
display: flex; flex-direction: column; gap: var(--ap-control-field-gap);
}
.${PREFIX}-grad-stop-row {
display: grid; grid-template-columns: 1fr 72px 20px;
align-items: center; gap: var(--ap-control-field-gap);
padding: var(--ap-control-field-gap); border-radius: var(--ap-radius-sm);
}
.${PREFIX}-grad-stop-row[data-on] { background: var(--ap-surface-hover); }
.${PREFIX}-grad-del:disabled { opacity: var(--ap-opacity-32); cursor: default; }
.${PREFIX}-grad-del:disabled:hover { background: transparent; }
`;
+129
View File
@@ -0,0 +1,129 @@
import { PREFIX } from "../dom";
/**
* CSS pane: box-model diagram, matched rules, grouped computed list.
*
* The box model is the one place in this panel where hue is the content rather
* than a state: four concentric rings that are only distinguishable by colour,
* which is the convention every browser's inspector already taught. So it keeps
* a four-way distinction — but drawn from the editor's own \`-bg\` tints
* (red/yellow/green, then the selection blue for the content box) rather than
* DevTools' literal orange. The tints are all ~12% over the panel surface,
* which is enough to separate four nested boxes and not enough to read as four
* warnings.
*/
export const css = `
.${PREFIX}-css-pane { padding-bottom: var(--ap-space-md); }
.${PREFIX}-css-block { border-bottom: 1px solid var(--ap-border-default); }
/* ---- Box model ---------------------------------------------------------- */
.${PREFIX}-css-bm {
display: flex; justify-content: center;
padding: var(--ap-space-md) var(--ap-space-lg) var(--ap-space-sm);
border-bottom: 1px solid var(--ap-border-default);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
}
/* Each ring is a labelled box padded enough to seat its four side fields. */
.${PREFIX}-css-bm-ring {
position: relative; flex: 1 1 auto;
padding: 20px 34px; border: 1px dashed var(--ap-border-strong);
border-radius: var(--ap-radius-xs); text-align: center;
}
.${PREFIX}-css-bm-margin { background: var(--ap-semantic-error-bg); }
.${PREFIX}-css-bm-border { background: var(--ap-semantic-warning-bg); }
.${PREFIX}-css-bm-padding { background: var(--ap-semantic-success-bg); }
.${PREFIX}-css-bm-content {
position: relative; padding: 18px 8px;
background: var(--ap-selection-fill);
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-xs);
}
.${PREFIX}-css-bm-label {
position: absolute; top: 2px; left: 5px;
text-transform: uppercase; letter-spacing: .5px;
font-size: var(--ap-font-size-micro); color: var(--ap-text-tertiary);
}
.${PREFIX}-css-bm-size { color: var(--ap-text-primary); }
/* Side fields sit on the ring they belong to, one per edge. */
.${PREFIX}-css-bm-cell { position: absolute; display: block; }
.${PREFIX}-css-bm-cell[data-side="top"] { top: 1px; left: 50%; transform: translateX(-50%); }
.${PREFIX}-css-bm-cell[data-side="bottom"] { bottom: 1px; left: 50%; transform: translateX(-50%); }
.${PREFIX}-css-bm-cell[data-side="left"] { left: 1px; top: 50%; transform: translateY(-50%); }
.${PREFIX}-css-bm-cell[data-side="right"] { right: 1px; top: 50%; transform: translateY(-50%); }
/* The side cells are real number fields now — the panel's one numeric field —
rather than the bare inputs they used to be, which had no keystroke filter,
no bounds and a parser that let arbitrary text through. That brings the
shared control chrome with it, and a 20px scrub glyph plus a 28px-tall row
does not fit on the edge of a ring, so the wrapper is compressed back to the
cell it sits in. The field's behaviour is what was wanted, not its size. */
.${PREFIX}-css-bm-field-wrap {
height: auto; padding-left: 0; gap: 0;
border-radius: var(--ap-radius-xs);
}
.${PREFIX}-css-bm-field-wrap .${PREFIX}-ctl-glyph { display: none; }
.${PREFIX}-css-bm-field-wrap .${PREFIX}-ctl-input {
width: 34px; padding: 1px 2px; text-align: center;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
}
.${PREFIX}-css-bm-field-wrap:hover { background: var(--ap-surface-active); }
/* ---- Matched rules ------------------------------------------------------ */
.${PREFIX}-css-rules { padding: 0 0 var(--ap-space-xs); }
.${PREFIX}-css-rule { padding: var(--ap-space-xs) var(--ap-space-lg) 0; }
.${PREFIX}-css-rule + .${PREFIX}-css-rule { border-top: 1px solid var(--ap-border-subtle); }
.${PREFIX}-css-rule-head {
display: flex; align-items: baseline; justify-content: space-between; gap: var(--ap-space-xs);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label);
}
.${PREFIX}-css-selector {
min-width: 0; color: var(--ap-text-primary); font-weight: 600;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.${PREFIX}-css-origin { flex: 0 0 auto; color: var(--ap-text-tertiary); font-size: var(--ap-font-size-caption); }
/* Tertiary, the same tone as .css-origin beside it: an @media or @supports
condition is the same class of thing as the stylesheet a rule came from —
metadata about where the block applies, not one of its declarations. It was
purple, which in a panel that otherwise spends colour only on state read as a
warning about a rule that is merely conditional. Its own line and its indent
are what separate it from the selector above. */
.${PREFIX}-css-cond {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
color: var(--ap-text-tertiary); padding: 1px 0 0 var(--ap-space-xs);
}
/* A declaration a stronger rule already answered. */
.${PREFIX}-css-struck { opacity: .5; }
.${PREFIX}-css-struck .${PREFIX}-css-prop-ro,
.${PREFIX}-css-struck .${PREFIX}-css-val-ro { text-decoration: line-through; }
.${PREFIX}-css-val-ro {
flex: 1 1 auto; min-width: 0;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label);
color: var(--ap-text-secondary); word-break: break-word;
}
.${PREFIX}-css-scan {
display: flex; align-items: center; justify-content: space-between; gap: var(--ap-space-xs);
padding: 2px var(--ap-space-lg) var(--ap-space-xs);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
color: var(--ap-text-tertiary);
}
.${PREFIX}-css-rescan {
display: inline-flex; align-items: center; justify-content: center;
width: 18px; height: 18px; padding: 0; cursor: pointer;
color: var(--ap-text-tertiary); background: transparent;
border: 0; border-radius: var(--ap-radius-xs);
}
.${PREFIX}-css-rescan:hover { color: var(--ap-text-primary); background: var(--ap-surface-active); }
.${PREFIX}-css-scan-note {
padding: var(--ap-space-xs) var(--ap-space-lg) 0;
font-size: var(--ap-font-size-caption); color: var(--ap-text-tertiary); opacity: .8;
}
/* ---- Computed ----------------------------------------------------------- */
.${PREFIX}-css-groups { padding-bottom: var(--ap-space-xs); }
/* Provenance dot: where this value came from. Colour is the whole signal, so
it stays a 6px mark rather than a word per row. */
.${PREFIX}-css-badge {
width: 6px; height: 6px; flex: 0 0 auto; margin-right: 4px;
border-radius: var(--ap-radius-full);
}
.${PREFIX}-css-badge-inline { background: var(--ap-primary); }
.${PREFIX}-css-badge-css { background: var(--ap-semantic-success); }
.${PREFIX}-css-badge-default { background: var(--ap-border-strong); }`;
+220
View File
@@ -0,0 +1,220 @@
import { PREFIX } from "../dom";
import { ROOT, Z } from "./const";
/** Bottom bar, mode toggle, the two floating docks, splitters, pills, headers. */
export const css = `
/* Bottom bar — tools, Edit/View mode, plus whatever controls the stage owns (on
the canvas: add a frame, fit, zoom). Compact and understated: small radius,
hairline border + subtle ring, no pill. */
.${PREFIX}-bar {
position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
pointer-events: auto; display: inline-flex; align-items: center; gap: 2px;
padding: 4px; border-radius: var(--ap-radius-md);
background: var(--ap-surface-panel); border: 1px solid var(--ap-border-default);
box-shadow: var(--ap-elevation-card);
}
.${PREFIX}-bar-sep { width: 1px; align-self: stretch; background: var(--ap-border-default); margin: 4px 2px; }
/* Stretched to the bar's content box on purpose. The add-frame menu is placed
against the toolbar's rect, and a row centred in a taller bar sits a few
pixels inside the card — so the menu's gap would be measured from the buttons
and land on the card's top edge. Spanning the box makes the two the same. */
.${PREFIX}-bar-tools { display: inline-flex; align-items: stretch; align-self: stretch; }
.${PREFIX}-bar-tools .${PREFIX}-fbar { align-self: stretch; }
/* The stage's *second* slot — the selected frame's verbs, beside the Hand. See
\`Stage.mountFrameTools\`.
\`display: contents\` rather than a plain wrapper. The bar is a flex row with a
gap, so a wrapper whose only child is hidden is still a zero-width flex item
earning itself a gap — a stray hairline of space that appears and disappears
with the selection. \`contents\` makes the group the bar's own flex item, and
\`.hidden\`'s \`display: none !important\` still outranks it when the mode hides
the host. */
.${PREFIX}-bar-frame-tools { display: contents; }
/* Inline has no stage controls, and a separator with nothing after it is just a
stub of hairline hanging off the mode toggle. Scoped to \`bar-sep-tools\` — the
one that divides the mode toggle from the stage slot — rather than to every
separator in the bar, which is what it used to say and which collapsed the
tool, inspect and mode groups into one undivided row inline. */
.${PREFIX}-bar-bare .${PREFIX}-bar-sep-tools,
.${PREFIX}-bar-bare .${PREFIX}-bar-tools { display: none; }
/* Edit/View mode segmented toggle — compact, restrained, border over shadow. */
.${PREFIX}-seg-group {
display: inline-flex; align-items: center; gap: 2px; padding: 2px;
background: var(--ap-surface-active);
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-sm);
}
.${PREFIX}-seg {
display: inline-flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer;
padding: 5px 10px; border: none; background: transparent;
border-radius: var(--ap-radius-xs); font-size: var(--ap-font-size-label); font-weight: 500;
color: var(--ap-text-primary); opacity: .65;
transition: opacity var(--ap-motion-dur-micro) var(--ap-motion-ease), background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-seg:hover { opacity: 1; }
.${PREFIX}-seg-on {
background: var(--ap-surface-panel); opacity: 1;
box-shadow: var(--ap-elevation-card);
}
/* Floating panels — rounded cards inset from the viewport edges.
Small radius + hairline border + subtle ring (no heavy drop shadow). */
.${PREFIX}-dock {
position: fixed; top: var(--ap-space-md); bottom: var(--ap-space-md);
pointer-events: auto; z-index: ${Z};
display: flex; flex-direction: column; overflow: hidden;
background: var(--ap-surface-panel);
border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-md);
box-shadow: var(--ap-elevation-card);
}
/* Widths are set as custom properties on the root by app.ts and persisted to
localStorage; the literals here are the same defaults, for the first paint. */
.${PREFIX}-dock-left { left: var(--ap-space-md); width: var(--${PREFIX}-left-w, 340px); }
.${PREFIX}-dock-right { right: var(--ap-space-md); width: var(--${PREFIX}-right-w, 360px); }
/* Torn off its edge and floating.
Position and height come from three more custom properties written by
\`applyPlacement\`, and the collapsed pill reads the same three — which is what
preserves the docked arrangement's one invariant (see \`.pill\` below):
collapsing a floating panel leaves the pill exactly where its header was.
Vars rather than inline styles for that sharing, and because a floating panel
still takes its *width* from \`--left-w\`/\`--right-w\`, so the splitter goes on
working in both states with nothing to reconcile.
\`right\`/\`bottom\` are cleared because \`.dock\` and \`.dock-right\` set them and a
box with all four is over-constrained. Two classes, so these beat the
single-class edge anchors above without needing \`!important\`. */
.${PREFIX}-dock.${PREFIX}-dock-float { right: auto; bottom: auto; }
.${PREFIX}-dock-left.${PREFIX}-dock-float {
top: var(--${PREFIX}-left-y, 20px);
left: var(--${PREFIX}-left-x, 20px);
height: var(--${PREFIX}-left-h, 60vh);
}
.${PREFIX}-dock-right.${PREFIX}-dock-float {
top: var(--${PREFIX}-right-y, 20px);
left: var(--${PREFIX}-right-x, 20px);
height: var(--${PREFIX}-right-h, 60vh);
}
/* Lifted while it travels, so it reads as being carried rather than redrawn. */
.${PREFIX}-dock-moving { box-shadow: var(--ap-elevation-modal); opacity: .92; }
/* Dock resize splitter — a slim invisible grab strip on the dock's inner edge
that only shows itself on hover or while dragging. */
.${PREFIX}-splitter {
position: absolute; top: 0; bottom: 0; width: 7px; z-index: 2;
cursor: col-resize; pointer-events: auto; background: transparent;
transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-splitter::after {
content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
width: 2px; transform: translateX(-50%);
background: var(--ap-primary); opacity: 0;
transition: opacity var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-splitter:hover::after { opacity: .7; }
.${PREFIX}-splitter-left { right: -1px; }
.${PREFIX}-splitter-right { left: -1px; }
/* Collapsed panel — the dock's header row, left floating in the corner the dock
itself would occupy. Same surface recipe as \`.dock\` and, crucially, the same
\`top\`/\`left\`/\`right\`: expanding grows a panel downwards from here rather than
moving anything, which is what makes the two read as one control. */
.${PREFIX}-pill {
position: fixed; top: var(--ap-space-md);
pointer-events: auto; z-index: ${Z};
display: inline-flex; align-items: center; gap: 6px;
/* Same 4px card padding as the bottom bar, plus a little on the label side —
the wordmark is bare text, so it has no button box to give it inset. */
padding: 4px 4px 4px 8px;
background: var(--ap-surface-panel);
border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-md);
box-shadow: var(--ap-elevation-card);
}
.${PREFIX}-pill-left { left: var(--ap-space-md); }
.${PREFIX}-pill-right { right: var(--ap-space-md); }
/* …and the same when the panel it stands for is floating: the pill goes where
the header was, not back to the corner. \`height\` is deliberately absent — a
pill is content-sized, and the panel's floating height is not its height.
Each side anchors on the edge it lives against, which is *not* the edge its
panel is positioned from. A pill is much narrower than its panel, so the two
differ: anchoring the right pill on \`--right-x\` like the dock does would hold
its left edge and pull the right one inwards, and the panel would read as
collapsing leftwards — the thing that made this look like the agent panel.
\`applyPlacement\` publishes both edges so each side can take the one it needs;
the docked rules above already get this for free from \`left\`/\`right\`. */
.${PREFIX}-pill-left.${PREFIX}-pill-float {
top: var(--${PREFIX}-left-y, 20px); left: var(--${PREFIX}-left-x, 20px);
}
.${PREFIX}-pill-right.${PREFIX}-pill-float {
top: var(--${PREFIX}-right-y, 20px); right: var(--${PREFIX}-right-r, 20px);
}
/* Both are grab handles. \`.iconbtn\` and \`.seg\` declare \`cursor: pointer\` on
their own elements and win there, so the header's buttons keep their own
affordance; the brand and the empty space inherit the grab. */
.${PREFIX}-pill { cursor: grab; user-select: none; }
html[data-${PREFIX}-drag] .${PREFIX}-pill,
html[data-${PREFIX}-drag] .${PREFIX}-head { cursor: inherit; }
/* Header. Vertical padding is tighter than the body's — the row is a 24px
button tall, and \`space-md\` on top of that reads as a banner. Horizontal
stays \`space-lg\` so the brand lines up with the transcript below it. */
.${PREFIX}-head {
display: flex; align-items: center; justify-content: space-between;
padding: var(--ap-space-sm) var(--ap-space-lg);
border-bottom: 1px solid var(--ap-border-default); flex: 0 0 auto;
cursor: grab; user-select: none;
}
.${PREFIX}-brand { display: inline-flex; align-items: center; gap: 6px; }
/* One wordmark size for the pill and the dock header. They share a position, so
expanding a panel must not resize the brand — it should only drop the body in
underneath. 12px/500 is the bottom bar's label size (\`.seg\`); the extra weight
is what keeps it reading as a mark rather than a button. */
.${PREFIX}-brand-name { font-weight: 560; font-size: var(--ap-font-size-label); letter-spacing: -0.1px; }
.${PREFIX}-head-actions { display: inline-flex; gap: 2px; }
/* Same ghost-button recipe as \`.fbar-btn\` on the bottom bar: no fill, no border,
the card around it carries the surface. */
.${PREFIX}-iconbtn {
display: inline-flex; align-items: center; justify-content: center;
width: var(--ap-control-icon-box); height: var(--ap-control-icon-box); padding: 0; cursor: pointer;
color: var(--ap-text-primary); background: transparent; border: 0;
border-radius: var(--ap-radius-xs); transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-iconbtn:hover { background: var(--ap-surface-active); }
/* Tools. Icon-only, one control tall, grouped by what they are for — what a
click does, then how you read the page, then the mode. */
.${PREFIX}-tool-group { display: inline-flex; align-items: center; gap: 2px; }
.${PREFIX}-tool {
display: inline-flex; align-items: center; justify-content: center;
width: var(--ap-control-icon-box); height: var(--ap-control-icon-box);
padding: 0; border: 0; cursor: pointer;
background: transparent; border-radius: var(--ap-radius-xs);
transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-tool:hover { background: var(--ap-surface-active); }
.${PREFIX}-tool-on { background: var(--ap-primary); }
.${PREFIX}-tool-on:hover { background: var(--ap-primary-hover); }
${ROOT} .${PREFIX}-tool-on .${PREFIX}-ic { --${PREFIX}-ic-tone: var(--ap-text-primary); }
.${PREFIX}-tool:disabled { cursor: default; }
.${PREFIX}-tool:disabled:hover { background: transparent; }
/* Redo is Undo mirrored. The imported set publishes \`rotate-ccw\` and no clockwise
twin, and the mark is symmetric about its vertical axis, so the flip is exact
rather than approximate — cheaper and more honest than hand-authoring a
near-copy into \`icons.ts\`'s \`LEGACY\` block. */
.${PREFIX}-bar-redo .${PREFIX}-ic { transform: scaleX(-1); }
/* Tooltip. Sits above everything, carries its own shortcut hint. */
.${PREFIX}-tip {
position: absolute; z-index: ${Z}; pointer-events: none;
display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
max-width: 280px; padding: 4px 8px;
background: var(--ap-surface-selected); color: var(--ap-text-primary);
border: 1px solid var(--ap-border-default); border-radius: var(--ap-radius-xs);
box-shadow: var(--ap-elevation-floating);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-body); line-height: 1.5;
}
.${PREFIX}-tip-key {
font-family: var(--ap-font-mono); color: var(--ap-text-tertiary);
}`;
+54
View File
@@ -0,0 +1,54 @@
import { PREFIX } from "../dom";
/**
* Empty states: the brand mark over a title and an optional sentence.
*
* The mark is pure `currentColor` (see `empty.ts`), so one declaration moves all
* of it and the two-tone inside does the work a second colour would otherwise
* have to.
*
* The old empty states were a single line at `opacity: .5`. That is not carried
* forward: fading a block fades the mark *and* the words together, and the words
* are the part that has to stay readable. Each part takes a token colour instead
* — title at the secondary text level, body at the tertiary one, the mark below
* both — which is the same ladder every other stacked pair in the panel is built
* on.
*/
export const css = `
.${PREFIX}-empty {
display: flex; flex-direction: column; align-items: center; text-align: center;
}
/* Dock-sized: takes the whole empty panel and centres in it. Auto margins
rather than \`justify-content\` — the transcript is a scroll container, and
this centres without fighting the flow the first message arrives in. */
.${PREFIX}-empty-md {
margin: auto 0; gap: var(--ap-space-xxs);
padding: var(--ap-space-lg) var(--ap-space-md);
}
/* Section-sized: sits inline where a one-line hint used to, so it keeps the
hint's own left/right padding and only spends height. */
.${PREFIX}-empty-sm {
gap: var(--ap-space-hair); padding: var(--ap-space-md) var(--ap-space-lg);
}
/* Below the icon ramp's resting tone, and further below it than the line
drawings this replaced needed to be. \`--ap-icon-muted\` is calibrated for a
glyph read at 16px; the brand mark is solid where those were 1.25-unit
hairlines, so at 48px it carries far more ink per unit and has to be dimmed to
sit back. The fade rides on top of the token rather than being a darker
colour, so the mark stays tied to the icon ramp — it is scenery behind the
words, not a status. */
.${PREFIX}-empty-art { display: block; color: var(--ap-icon-muted); opacity: .55; }
.${PREFIX}-empty-md .${PREFIX}-empty-art { margin-bottom: var(--ap-space-xs); }
.${PREFIX}-empty-sm .${PREFIX}-empty-art { margin-bottom: var(--ap-space-xxs); }
.${PREFIX}-empty-title {
color: var(--ap-text-secondary); font-size: var(--ap-font-size-title);
line-height: 1.4;
}
.${PREFIX}-empty-sm .${PREFIX}-empty-title { font-size: var(--ap-font-size-label); }
/* Capped rather than free. A sentence set across a 320px dock is one long line,
and the column the title sets is narrower than that. */
.${PREFIX}-empty-body {
max-width: 32ch; font-size: var(--ap-font-size-label); line-height: 1.5;
color: var(--ap-text-tertiary);
}
.${PREFIX}-empty-sm .${PREFIX}-empty-body { font-size: var(--ap-font-size-body); }`;
+114
View File
@@ -0,0 +1,114 @@
import { buildCss, design } from "@airship/editor-tokens";
import { describe, expect, it } from "vitest";
import { overlayCss } from "./index";
const VAR_USE = /var\(\s*(--ap-[a-z0-9-]+)/gi;
const VAR_DECL = /^\s*(--ap-[a-z0-9-]+)\s*:/gm;
const CSS_COMMENT = /\/\*[\s\S]*?\*\//g;
function declared(): Set<string> {
const out = new Set<string>();
for (const match of buildCss().matchAll(VAR_DECL)) {
out.add(match[1]);
}
return out;
}
/**
* Comments are stripped first.
*
* These stylesheets carry a lot of prose, and that prose names token families as
* `var(--ap-motion-*)` — a real reference in a sentence, not a declaration. Left
* in, the wildcard reads as a token called `--ap-motion-` that nothing emits,
* and the check fails on its own documentation.
*/
function used(css: string): Set<string> {
const out = new Set<string>();
for (const match of css.replace(CSS_COMMENT, "").matchAll(VAR_USE)) {
out.add(match[1]);
}
return out;
}
describe("overlay stylesheet", () => {
it("only references tokens the palette actually emits", () => {
// An undefined custom property is not a fallback to the initial value — the
// whole declaration is invalid at computed-value time and is dropped, with
// no error anywhere. A typo'd token is therefore a rule that silently stops
// existing, which is a great deal harder to notice than a build failure.
const available = declared();
const missing = [...used(overlayCss())].filter(
(name) => !available.has(name)
);
expect(missing).toEqual([]);
});
it("carries the motion vocabulary the modules are written against", () => {
const available = declared();
for (const name of [
"--ap-motion-dur-micro",
"--ap-motion-dur-base",
"--ap-motion-ease",
"--ap-motion-ease-out",
"--ap-box-padding",
"--ap-box-margin",
"--ap-box-gap",
]) {
expect(available.has(name)).toBe(true);
}
});
it("uses the size tokens it emits, or does not emit them", () => {
/*
* The inverse of the check above, and the one that would have caught the
* icon-sizing drift.
*
* `--ap-icon-size-*` was emitted for a long time and referenced by exactly
* zero rules: icon size is applied as SVG `width`/`height` attributes, so
* the real scale lived in a hand-copied literal in `icons.ts` that happened
* to agree with the tokens. Editing `EDITOR.md` moved the variables and
* changed nothing on screen — the two could drift apart silently, and a
* "single source of truth" that nothing reads is worse than none, because
* it reads as though it is being obeyed.
*
* `icons.ts` now imports `design.iconSize` directly, which is why the group
* is allowed here rather than asserted-on: its consumer is JavaScript, and
* a CSS test cannot see it. Everything else in the size families has to be
* live in the stylesheet or be deleted.
*/
const SIZE_FAMILIES = ["space", "radius", "font-size", "control"];
const live = used(overlayCss());
// Per family, not per token: a scale is allowed steps nobody has reached
// for yet — `radius-pill` and `space-section` are real parts of a complete
// ramp. A whole family with no references is the thing that means someone
// is sizing from somewhere else.
const dead = SIZE_FAMILIES.filter((family) => {
const members = [...declared()].filter((name) =>
name.startsWith(`--ap-${family}-`)
);
return members.length > 0 && !members.some((name) => live.has(name));
});
expect(dead).toEqual([]);
});
it("keeps the icon scale and the icon-size tokens the same numbers", () => {
// `icons.ts` reads `design.iconSize`, so this cannot drift by construction
// — but it is the assertion that says so, and the thing that fails loudly
// if anyone reintroduces a local copy of the scale.
const css = buildCss();
for (const [name, px] of Object.entries(design.iconSize)) {
expect(css).toContain(`--ap-icon-size-${name}: ${px}px;`);
}
});
it("honours reduced motion, once, at the end", () => {
const css = overlayCss();
const at = css.indexOf("prefers-reduced-motion");
expect(at).toBeGreaterThan(-1);
// Exactly one block: the policy is centralised in `motion.css.ts`
// specifically so it cannot drift into a hand-kept list of selectors.
expect(css.indexOf("prefers-reduced-motion", at + 1)).toBe(-1);
// And last, so it outranks the modules it overrides on order alone.
expect(css.slice(at)).not.toContain("transition:");
});
});
+113
View File
@@ -0,0 +1,113 @@
import { buildCss } from "@airship/editor-tokens";
import { PREFIX } from "../dom";
import { css as base } from "./base.css";
import { css as canvas } from "./canvas.css";
import { css as chat } from "./chat.css";
import { css as chrome } from "./chrome.css";
import { ROOT } from "./const";
import { css as controls } from "./controls.css";
import { css as cssPane } from "./css-pane.css";
import { css as docks } from "./docks.css";
import { css as empty } from "./empty.css";
import { css as inspector } from "./inspector.css";
import { css as motion } from "./motion.css";
import { css as pop } from "./pop.css";
import { css as portable } from "./portable.css";
import { css as toast } from "./toast.css";
let injected = false;
export function injectStyles(): void {
if (injected) {
return;
}
injected = true;
const style = document.createElement("style");
style.id = `${PREFIX}-styles`;
style.textContent = CSS;
document.head.append(style);
}
// Airship's editor design tokens, scoped under the overlay root. They come from
// @airship/editor-tokens (a dark editor palette — dense neutral
// surfaces, hairline borders, striking Blue #0D99FF), independent of the
// marketing tokens; the overlay is editor chrome floating over the user's own
// app. Fonts are self-hosted; the proxy serves the woff2 from
// @airship/editor-tokens at /__airship/fonts/* (same-origin, no CORS).
const FONTS = `
@font-face {
font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
src: url("/__airship/fonts/inter-variable.woff2") format("woff2");
}
@font-face {
font-family: "JetBrains Mono"; font-style: normal; font-display: swap; font-weight: 400;
src: url("/__airship/fonts/jetbrains-mono-400.woff2") format("woff2");
}
@font-face {
font-family: "JetBrains Mono"; font-style: normal; font-display: swap; font-weight: 700;
src: url("/__airship/fonts/jetbrains-mono-700.woff2") format("woff2");
}`;
// Token vars are scoped, not global, so they can't leak into the host app. The
// floating chrome (hover/selection boxes, drop indicators) lives outside the
// overlay root — as a sibling on `document.body`, so it can paint over anything
// — so `.__airship-layer` is scoped alongside the root. Without it every
// `var(--ap-*)` on those elements is invalid-at-computed-value-time and silently
// drops the declaration. The toast host is listed for the same reason: it is a
// child of the root today, and that is one refactor away from not being true.
const VARS = buildCss({
scope: `${ROOT}, .${PREFIX}-layer, .${PREFIX}-chrome-layer, .${PREFIX}-canvas-viewport, .${PREFIX}-toast-host`,
});
/**
* The whole stylesheet, as one string.
*
* Exported so it can be asserted about. Every rule here is written in terms of
* `var(--ap-*)`, and a variable that is not actually emitted does not fall back
* to anything — the declaration is invalid at computed-value time and the
* browser drops it, silently and at runtime. That failure mode has bitten this
* file before (see the note on `VARS`), and it is the sort of thing a test can
* catch for nothing while a person cannot.
*/
export function overlayCss(): string {
return CSS;
}
// One stylesheet, assembled from co-equal modules. The order is the cascade:
// base establishes the reset and the icon colour roles, canvas is the substrate
// beneath the chrome, and chrome sits near the end so its z-indexed layers win
// ties. `pop` sits after `controls` because a popover's shell overrides control
// styling its content inherits, not the other way round. `toast` is the last of
// the *layers* because it is the topmost of them — see `Z_TOAST`; `motion` comes
// after it, but it is policy rather than a layer and overrides all of them.
//
// Two placements are load-bearing rather than aesthetic. `portable` goes
// directly after `base` because its text-edit rules and `base`'s edit-mode
// block both target the same node and can tie on specificity — and `portable`
// is the one that must win. It is also the only module here that is *not*
// exclusive to this document: `frame-agent.ts` serves the same string inside
// every frame, because the node it styles is a page node in both stages.
const CSS = [
FONTS,
VARS,
base,
portable,
canvas,
docks,
chat,
inspector,
cssPane,
// Empty states are surface-agnostic — the same block renders in the chat
// dock, the inspector and the CSS pane — so it sits after all three, where
// its own tones win over whatever the host surface set on the container.
empty,
controls,
pop,
chrome,
toast,
// Last, and it has to be: it overrides the motion every module above declares,
// and it does so by winning on order rather than on `!important` everywhere.
motion,
]
.join("\n")
.trim();
@@ -0,0 +1,418 @@
import { PREFIX } from "../dom";
import { Z } from "./const";
/** Right dock: tabs, the DOM tree, sections, the field grid, the CSS tab. */
export const css = `
/*
* A fill layer and its geometry, stacked.
*
* background-size, -position, -repeat and -blend-mode are parallel lists index-aligned
* with background-image, so each layer's four entries belong *with* that layer rather
* than in one shared row elsewhere. See sections/fill.ts.
*/
.${PREFIX}-fill-layer {
display: flex;
flex-direction: column;
gap: 2px;
}
.${PREFIX}-fill-geom {
display: grid;
gap: 2px 4px;
grid-template-columns: 1fr 1fr;
padding-left: 8px;
}
.${PREFIX}-insp { display: flex; flex-direction: column; flex: 1 1 auto; overflow: hidden; }
/* Bare container: the Source section inside it brings its own padding and
bottom rule, so anything here would double them. Hidden with no selection. */
.${PREFIX}-insp-head { flex: 0 0 auto; }
.${PREFIX}-insp-multi {
padding: var(--ap-space-xs) var(--ap-space-lg);
font-size: var(--ap-font-size-caption); opacity: .5;
}
/* Basename plus line, riding in the Source section's header. \`text-transform\`
is reset because the heading row uppercases its contents, and a file name is
not a heading — \`APP.TSX:31\` names nothing on disk. */
.${PREFIX}-insp-src {
flex: 0 1 auto; min-width: 0;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
color: var(--ap-text-primary); opacity: .75; text-transform: none;
letter-spacing: normal;
}
.${PREFIX}-insp-src-off { font-style: italic; opacity: .5; }
/* Why the element has no source. Prose, not a path — it wraps on words. */
.${PREFIX}-insp-src-note {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
opacity: .55; line-height: 1.5;
}
/* The expanded section: Path and Line as two labelled facts, sharing the
panel's 68px label rail so they line up with every other row in the dock. */
.${PREFIX}-insp-src-kv > .${PREFIX}-row { align-items: baseline; }
/* Baseline, not center, puts "Path" on the first line of a path that wrapped
rather than halfway down it — and reconciles the 12px label against the 10px
value for free. An icon button has no baseline worth aligning to. */
.${PREFIX}-insp-src-kv .${PREFIX}-sect-act { align-self: center; }
/* Breaks anywhere: a deep path has no useful break points and an ellipsis would
defeat the point of expanding. */
/* The basis is load-bearing, not decoration. A .row wraps now, and wrapping is
decided on an item's flex-basis before any shrinking — so \`auto\` here means
the max-content width of a full source path, which exceeds the rail at every
dock width and would put "Path" on a line of its own always. 140px is under
the 154px a row's control gets at the narrowest dock, and break-all above
means going narrow costs nothing. */
.${PREFIX}-insp-src-val {
flex: 1 1 140px; min-width: 0;
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
color: var(--ap-text-secondary); word-break: break-all; line-height: 1.5;
}
.${PREFIX}-insp-tabs { display: flex; border-bottom: 1px solid var(--ap-border-default); }
.${PREFIX}-insp-tab {
flex: 1; display: inline-flex; align-items: center; justify-content: center;
gap: var(--ap-control-row-gap);
padding: var(--ap-space-xs); cursor: pointer; background: transparent; border: none;
color: var(--ap-text-primary); opacity: .55; font-family: var(--ap-font-sans); font-size: var(--ap-font-size-title);
border-bottom: 2px solid transparent;
}
.${PREFIX}-insp-tab-on { opacity: 1; border-bottom-color: var(--ap-primary); }
/* DOM tab — expandable tree + drag-to-reparent. */
.${PREFIX}-tree { padding: 4px 0 var(--ap-space-md); }
/* Layer rows. Sans, not mono, and named after the component or its text — a
row reading "Button" is worth far more than div.inline-flex.items-center. */
.${PREFIX}-tree-node {
display: flex; align-items: center; gap: var(--ap-control-field-gap);
padding: 2px var(--ap-space-xxs) 2px 0;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
white-space: nowrap; opacity: .85;
}
.${PREFIX}-tree-kind {
display: inline-flex; align-items: center; flex: 0 0 auto;
color: var(--ap-icon-muted);
}
.${PREFIX}-tree-node:hover .${PREFIX}-tree-kind { color: var(--ap-icon-secondary); }
.${PREFIX}-tree-self .${PREFIX}-tree-kind { color: var(--ap-primary); }
/* A component reads as the primary thing in the tree, the way it does in a design tool. */
.${PREFIX}-tree-node[data-kind="component"] .${PREFIX}-tree-kind,
.${PREFIX}-tree-node[data-kind="instance"] .${PREFIX}-tree-kind {
color: var(--ap-primary);
}
.${PREFIX}-tree-hidden { opacity: .45; }
.${PREFIX}-tree-locked .${PREFIX}-tree-label { opacity: .6; }
/* Row actions stay hidden until hover, or until they are doing something. */
.${PREFIX}-tree-act {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
width: 18px; height: 18px; padding: 0; border: 0; cursor: pointer;
background: transparent; border-radius: var(--ap-radius-xs); opacity: 0;
transition: opacity var(--ap-motion-dur-micro) var(--ap-motion-ease), background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-tree-node:hover .${PREFIX}-tree-act,
.${PREFIX}-tree-hidden .${PREFIX}-tree-act,
.${PREFIX}-tree-locked .${PREFIX}-tree-act,
.${PREFIX}-tree-act:focus-visible { opacity: .65; }
.${PREFIX}-tree-act:hover { opacity: 1; background: var(--ap-surface-active); }
.${PREFIX}-tree-node:hover { background: var(--ap-surface-active); opacity: 1; }
.${PREFIX}-tree-self { color: var(--ap-primary); background: var(--ap-surface-active); opacity: 1; }
.${PREFIX}-tree-chev {
display: inline-flex; align-items: center; justify-content: center;
width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; opacity: .55;
}
.${PREFIX}-tree-chev:hover { opacity: 1; }
.${PREFIX}-tree-chev-spacer { width: 16px; flex: 0 0 auto; }
.${PREFIX}-tree-label {
flex: 1 1 auto; min-width: 0;
cursor: pointer; overflow: hidden; text-overflow: ellipsis; user-select: none;
padding: 1px 4px; border-radius: var(--ap-radius-xs);
}
.${PREFIX}-tree-drop-line {
position: absolute; z-index: ${Z}; pointer-events: none;
background: var(--ap-primary); border-radius: 2px;
box-shadow: 0 0 0 1px rgba(255,255,255,var(--ap-opacity-48)), 0 0 6px color-mix(in srgb, var(--ap-primary) 50%, transparent);
}
.${PREFIX}-tree-drop-into {
position: absolute; z-index: ${Z}; pointer-events: none;
background: var(--ap-primary-bg); border: 1px solid var(--ap-primary);
border-radius: var(--ap-radius-xs);
}
/* Sections + rows.
The scrollbar is hidden, not the scrolling — same treatment the chip rails
get in \`chat.css\`. A dock this narrow loses real width to a gutter, and the
bar is drawn *over* the right-hand column of the field grid, which is where
the number fields sit. Section headings already say how much is below. */
/* A column, not a block. Sections stack identically either way — a column flex
container with the default \`align-items: stretch\` reproduces block flow for
full-width children, and \`min-height: auto\` keeps them at content height —
but a *block* container gives \`margin: auto\` nothing to distribute, so the
panel's empty state pinned itself to the top while the transcript's (already
a flex column) centred correctly. Same block, two different results, which is
the bug. Both hosts are columns now. */
.${PREFIX}-insp-body {
flex: 1 1 auto; overflow-y: auto; scrollbar-width: none;
display: flex; flex-direction: column;
}
.${PREFIX}-insp-body::-webkit-scrollbar { display: none; }
.${PREFIX}-insp-hint { font-size: var(--ap-font-size-label); opacity: .5; padding: var(--ap-space-md) var(--ap-space-lg); }
.${PREFIX}-sect { border-bottom: 1px solid var(--ap-border-default); }
/* Symmetric inset, matching \`sect-body\` and the field grid: with the chevron
moved to the right (see \`section()\`) the heading starts on the same margin
as the rows it heads, and no arrow is pressed against the dock edge. */
.${PREFIX}-sect-head {
display: flex; align-items: center; justify-content: space-between; cursor: pointer;
gap: var(--ap-control-row-gap);
padding: var(--ap-space-xs) var(--ap-space-lg);
font-family: var(--ap-font-mono); text-transform: uppercase;
font-size: var(--ap-font-size-caption); letter-spacing: .6px; opacity: .6;
}
.${PREFIX}-sect-head:hover { opacity: .9; }
.${PREFIX}-sect-title { flex: 1 1 auto; }
.${PREFIX}-sect-chev { display: inline-flex; align-items: center; flex: 0 0 auto; }
.${PREFIX}-sect-actions {
display: inline-flex; align-items: center; flex: 0 0 auto;
gap: var(--ap-control-field-gap);
}
/* \`flex: 0 0 auto\` because a header action is not always inside
\`sect-actions\` — the computed sub-head puts one straight next to a
\`flex: 1 1 auto\` filter box, which squashed an 18px button to a sliver. */
.${PREFIX}-sect-act {
display: inline-flex; align-items: center; justify-content: center;
width: 18px; height: 18px; flex: 0 0 auto; padding: 0; border: 0; cursor: pointer;
background: transparent; border-radius: var(--ap-radius-xs);
}
.${PREFIX}-sect-act:hover { background: var(--ap-surface-active); }
/* Symmetric, and both halves from the rhythm. It was 4px top / 20px bottom,
which put consecutive sections at two different distances from their shared
divider — the heading crowded its own body and floated away from the section
above it. A heading is now exactly one group-gap from its content, which is
the same distance two groups inside it are from each other. */
.${PREFIX}-sect-body {
padding: var(--ap-control-group-gap) var(--ap-space-lg);
}
/* The field grid.
A design tool's rail is two columns of glyph-fielded controls, not a label rail with
one control per row — the field carries its own identity, so the 68px of
left-hand text is dead weight. Controls that genuinely need a word (Weight,
Align) opt back into a labelled full-width row via \`span: "full"\`. */
/* Three pitches, not one. See EDITOR.md's control group.
There used to be a single --ap-row-gap, described in a comment as the pitch
"everything below defers to it" — which was true of this file and not of
controls.css.ts, where twenty rules hardcoded 1, 1.5, 2, 3, 4, 5, 6 and 8px.
More to the point, one pitch cannot express structure: with every row the
same distance from every other, a section is a flat list and the reader has
to work out for themselves which two controls are one decision.
--ap-control-field-gap (2) parts of one control
--ap-control-row-gap (6) rows within a group
--ap-control-group-gap (12) groups within a section
--ap-control-gutter (8) columns on one row */
/* Two columns, with a floor under them. auto-fill and not auto-fit: auto-fit
collapses a track nothing is placed in, and Auto layout's grid branch builds
a .grid holding a single gutter field — which would then stretch across the
rail. Half a row of deliberate space is the shape this grid has always had.
(.pad-fields above wants the opposite, and takes auto-fit for it.)
In the 280-720 range this resolves to two tracks at every width; it drops to
one only below a 202px dock, which MIN_DOCK_W does not allow. It is a
guarantee, not a reflow. */
.${PREFIX}-grid {
display: grid;
grid-template-columns: repeat(auto-fill,
minmax(max(var(--${PREFIX}-field-min), (100% - var(--ap-control-gutter)) / 2), 1fr));
gap: var(--ap-control-row-gap) var(--ap-control-gutter);
align-items: center;
}
.${PREFIX}-grid > .${PREFIX}-span2 { grid-column: 1 / -1; }
.${PREFIX}-grid > .${PREFIX}-cell { min-width: 0; }
/* Margin, not gap: a .row is a sibling of grids and lists rather than a child
of one, so it owns its own separation. Collapsed against the section's own
padding at the edges. */
/* Wraps, so the 68px label rail gives up its line before the control gives up
its legibility. The rail is \`flex: 0 0 68px\` and never yielded, so at the
narrowest dock Padding, Margin and Stroke position were working in 154px —
two number fields and a mode switch in less room than one field wants. Now
the label goes above and the control gets the whole 230px back.
Two-value gap: once the row is two lines, the distance between the label and
its control is rows-within-a-group (6), not columns-on-one-row (8). */
.${PREFIX}-row {
display: flex; flex-wrap: wrap; align-items: center;
gap: var(--ap-control-row-gap) var(--ap-control-gutter);
margin: var(--ap-control-row-gap) 0;
}
.${PREFIX}-row:first-child { margin-top: 0; }
.${PREFIX}-row:last-child { margin-bottom: 0; }
/* A group: the level between a row and a section. Everything inside it is one
decision — the alignment pad and the fields beside it, a stroke's colour and
its weight — and the gap above says where the previous decision ended. */
.${PREFIX}-group + .${PREFIX}-group,
.${PREFIX}-group + .${PREFIX}-grid,
.${PREFIX}-grid + .${PREFIX}-group,
.${PREFIX}-group + .${PREFIX}-rows,
.${PREFIX}-rows + .${PREFIX}-group {
margin-top: var(--ap-control-group-gap);
}
.${PREFIX}-row-label {
flex: 0 0 68px; font-size: var(--ap-font-size-label); color: var(--ap-text-tertiary);
}
/* Opt out of the row's centring, for a one-line control standing beside a
control that stacks. A .row centres because almost everything in it is one
line tall; where that stops being true — Stroke's advanced button next to a
quad field that has split into a 2x2 — centred means "in the gutter between
the two rows", level with neither. */
.${PREFIX}-row > .${PREFIX}-row-top { align-self: flex-start; }
/* A labelled row's control takes the rest of the line, whatever it is — so
Stroke's Style and Position segmented groups end up the same width as the
Constraints select above them instead of each sizing to its own content.
The options then share that width equally: two content-sized pills in a
full-width track leave half of it visibly empty.
A real basis and not auto, because the row wraps now and the browser picks
the line break from the hypothetical main size — the flex-basis, before any
shrinking. On a box wrapping an input, auto resolves to that input's default
size="20" intrinsic width, so every labelled row would have wrapped at every
width. 180px is what these controls actually want: two fields plus a gutter
plus the 24px mode switch is 178, and three word pills about 191.
.pad-row joins them here rather than staying content-sized: it is the widest
thing the rail carries and the reason the rail had to start yielding. */
.${PREFIX}-row > .${PREFIX}-ctl-seg,
.${PREFIX}-row > .${PREFIX}-select-wrap,
.${PREFIX}-row > .${PREFIX}-pad-row {
flex: 1 1 var(--${PREFIX}-row-ctl-min); min-width: 0;
}
/* A pad row asks for more, and asks for it in its own terms: two roomy fields,
the gutter between them, and the mode switch. Sharing the 192 above, the rail
unstacked as soon as two fields and a switch could technically be crammed in,
so widening the dock from 280 to 306 made Padding's fields shrink from 98px
to 73 — a control getting smaller as its panel gets bigger, which reads as a
bug because it is one. Stated this way the step lands on {field.roomy} by
construction and cannot drift away from it. */
.${PREFIX}-row > .${PREFIX}-pad-row {
--${PREFIX}-row-ctl-min: calc(
var(--${PREFIX}-field-roomy) * 2 + var(--ap-control-gutter) +
var(--ap-control-height) + var(--ap-control-field-gap)
);
}
.${PREFIX}-row > .${PREFIX}-ctl-seg > .${PREFIX}-ctl-seg-btn {
flex: 1 1 0; min-width: 0;
}
/* Alignment row — always present, never collapsible, above the first section.
Three groups of three, mirroring the design-tool layout exactly. */
.${PREFIX}-align-row {
display: flex; justify-content: space-between; gap: var(--ap-space-xs);
padding: var(--ap-space-sm) var(--ap-space-lg);
border-bottom: 1px solid var(--ap-border-default);
}
.${PREFIX}-align-grp { display: inline-flex; gap: 1px; }
.${PREFIX}-align-btn {
display: inline-flex; align-items: center; justify-content: center;
width: var(--ap-control-height); height: var(--ap-control-height);
padding: 0; border: 0; cursor: pointer; background: transparent;
border-radius: var(--ap-radius-xs); transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-align-btn:hover:not(:disabled) { background: var(--ap-surface-active); }
.${PREFIX}-align-btn:disabled { cursor: default; opacity: .3; }
/* A button that reaches past the selection carries a hairline accent mark, so
the side effect is visible before you commit to it rather than after. */
.${PREFIX}-align-btn[data-scope="parent"] { position: relative; }
.${PREFIX}-align-btn[data-scope="parent"]::after {
content: ""; position: absolute; left: 50%; bottom: 3px;
width: 8px; height: 1px; transform: translateX(-50%);
background: var(--ap-primary); opacity: .5;
}
.${PREFIX}-align-btn[data-scope="parent"]:hover::after { opacity: 1; }
/* The parent-edited flash. Deliberately the selection blue at low weight — it
should read as "this was touched", not as a second selection. */
.${PREFIX}-flash-box {
position: absolute; z-index: ${Z}; pointer-events: none;
border: 1px solid var(--ap-primary); border-radius: var(--ap-radius-xs);
background: var(--ap-primary-bg);
animation: ${PREFIX}-flash .62s ease-out forwards;
}
@keyframes ${PREFIX}-flash {
0% { opacity: 0; }
18% { opacity: 1; }
100% { opacity: 0; }
}
/* CSS tab — DevTools-style declaration editor. Horizontal padding is
\`space-lg\` throughout, the same margin the sections and the layer tree
start on; this pane was alone on \`space-md\` and read as a wider column
pushed out past everything above and below it. */
.${PREFIX}-css-head {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-body); opacity: .5;
padding: var(--ap-space-sm) var(--ap-space-lg) 0;
}
.${PREFIX}-css-list { padding: 4px var(--ap-space-lg) var(--ap-space-md); }
.${PREFIX}-css-decl { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.${PREFIX}-css-decl.${PREFIX}-css-off { opacity: .4; }
.${PREFIX}-css-cb {
width: 13px; height: 13px; flex: 0 0 auto; cursor: pointer;
accent-color: var(--ap-primary);
}
.${PREFIX}-css-cb-spacer { width: 13px; flex: 0 0 auto; }
.${PREFIX}-css-prop, .${PREFIX}-css-val {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label); color: var(--ap-text-primary);
background: transparent; border: 1px solid transparent; border-radius: var(--ap-radius-xs);
padding: 2px 4px; min-width: 40px;
}
.${PREFIX}-css-prop { flex: 0 1 auto; max-width: 46%; color: var(--ap-primary); }
.${PREFIX}-css-val { flex: 1 1 auto; }
.${PREFIX}-css-prop:hover, .${PREFIX}-css-val:hover { background: var(--ap-surface-active); }
.${PREFIX}-css-prop:focus, .${PREFIX}-css-val:focus {
outline: none; background: var(--ap-surface-active); border-color: var(--ap-primary);
}
.${PREFIX}-css-prop::placeholder, .${PREFIX}-css-val::placeholder { color: var(--ap-text-primary); opacity: .35; }
.${PREFIX}-css-colon { opacity: .45; }
.${PREFIX}-css-del {
display: inline-flex; align-items: center; justify-content: center;
width: 20px; height: 20px; flex: 0 0 auto; padding: 0; cursor: pointer; opacity: 0;
color: var(--ap-text-primary); background: transparent; border: none; border-radius: var(--ap-radius-sm);
}
.${PREFIX}-css-decl:hover .${PREFIX}-css-del { opacity: .5; }
.${PREFIX}-css-del:hover { opacity: 1; background: var(--ap-surface-active); }
.${PREFIX}-css-del-spacer {
display: inline-flex; align-items: center; justify-content: center;
width: 20px; flex: 0 0 auto; opacity: .4;
}
.${PREFIX}-css-add .${PREFIX}-css-prop, .${PREFIX}-css-add .${PREFIX}-css-val {
border: 1px dashed var(--ap-border-default);
}
/* CSS tab — computed styles (full list, filterable, editable values).
No \`border-top\` here: whatever precedes this already draws one (the matched
rules are a \`sect\`, and every \`sect\` carries a bottom rule), so owning a
second put two lines 4px apart with nothing between them. */
.${PREFIX}-css-sub-head {
display: flex; align-items: center; gap: 8px;
padding: var(--ap-space-sm) var(--ap-space-lg) 4px;
}
/* A control, not a declaration: sans on the input scale, on the same bg,
border, height and radius as \`select\` and the number fields. It was mono at
its own padding, which made the one thing here you type into look like the
property values underneath it. */
.${PREFIX}-css-filter {
flex: 1 1 auto; min-width: 0;
height: var(--ap-control-height); padding: 0 var(--ap-space-xs);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
color: var(--ap-text-primary); background: var(--ap-input-bg);
border: 1px solid var(--ap-input-border); border-radius: var(--ap-radius-sm);
transition: border-color var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-css-filter::placeholder { color: var(--ap-text-placeholder); }
.${PREFIX}-css-filter:focus { outline: none; border-color: var(--ap-primary); }
.${PREFIX}-css-computed { padding-top: 2px; }
.${PREFIX}-css-prop-ro {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-label); color: var(--ap-primary);
flex: 0 1 auto; max-width: 46%; padding: 2px 4px;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}`;
+33
View File
@@ -0,0 +1,33 @@
import { PREFIX } from "../dom";
import { ROOT } from "./const";
/**
* Motion policy: the one place `prefers-reduced-motion` is honoured.
*
* Every other module declares its transitions in terms of `--ap-motion-*` and
* says nothing about whether they should run. This module answers that once, for
* all of them, which is the only way the answer stays consistent — the
* alternative is the shape the reference implementation ended up in, a hand-kept
* list of twenty-odd selectors that drifts the moment anyone adds a control.
*
* `transition-duration: 0s` rather than `transition: none`: the duration is the
* part someone asked us not to animate, and zeroing it leaves the declared
* property list intact so a `transitionend` listener still fires. Killing the
* shorthand outright would strand any code waiting on one — which is exactly how
* a "reduce motion" setting turns into a stuck panel.
*
* Appended last in `styles/index.ts` so it outranks every module it overrides
* without needing `!important` on anything but the animation reset, where the
* competing declaration is often a shorthand with its own duration inside it.
*/
export const css = `
@media (prefers-reduced-motion: reduce) {
${ROOT}, ${ROOT} *,
.${PREFIX}-chrome-layer, .${PREFIX}-chrome-layer *,
.${PREFIX}-canvas-viewport, .${PREFIX}-canvas-viewport * {
transition-duration: 0s !important;
animation-duration: 0s !important;
animation-delay: 0s !important;
transition-delay: 0s !important;
}
}`;
+252
View File
@@ -0,0 +1,252 @@
import { PREFIX } from "../dom";
import { Z_POP } from "./const";
/**
* The popover layer: the host, the shared shell, and the menu shape.
*
* The host is the overlay root's last child and covers it exactly, so a shell's
* `position: absolute` coordinates are already screen coordinates and
* `placePopover`'s offset-parent conversion collapses to the identity.
*
* The colour picker's own internals live in `controls.css.ts` next to the swatch
* they belong to; only the shell chrome is here.
*/
export const css = `
.${PREFIX}-pop-host {
position: absolute; inset: 0; z-index: ${Z_POP}; pointer-events: none;
}
/* The shell is the scroller, because the shell is what carries the cap.
\`placePopover\` measures the content and writes a \`max-height\` *here* — and a
max-height on a box with no overflow does not scroll. It just shortens the
painted box and lets the rest of the content run out through the radius, over
the page, with no background under it. A long menu rendered its first dozen
rows on the panel and the rest on the canvas.
\`.fc-menu\` — the canvas's own client of the same placement code — has always
carried \`overflow-y: auto\`. This rule was written from it and kept
\`overscroll-behavior\`, which is only meaningful on a scroller, while dropping
the property that made it one.
\`overflow-x: hidden\` rather than auto: nothing here should ever be wider than
its own shell (see \`matchAnchorWidth\`), and a horizontal scrollbar under a
menu is a bug report rather than an affordance. Note this also makes the shell
a clipping box, so a popover that hangs a decoration outside its content will
lose it — every current one keeps its knobs and chits inside the 8px padding. */
.${PREFIX}-pop {
position: absolute; pointer-events: auto;
background: var(--ap-surface-panel);
border: 1px solid var(--ap-border-default);
border-radius: var(--ap-radius-md);
box-shadow: var(--ap-elevation-floating);
overflow-x: hidden; overflow-y: auto;
overscroll-behavior: contain;
}
/* Menu. Mirrors \`.fc-menu-item\` rather than sharing it: the canvas keeps its
own \`.fc-menu*\` for the device and add-frame menus, which are placed against
world-space geometry on every pan and re-anchor themselves, so they never
came through this host. Two shapes that look alike but answer to different
placement code are better apart than accidentally coupled. */
/* \`overflow-y\` here is now redundant for a plain menu — the shell hits its cap
first — but it is load-bearing for \`.token-list\`, which composes this class
and takes its scrolling from it. Do not tidy it away. */
.${PREFIX}-pop-menu {
display: flex; flex-direction: column;
padding: 4px; min-width: 150px; overflow-y: auto;
}
.${PREFIX}-pop-item {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding: 5px 8px; border: 0; border-radius: var(--ap-radius-xs);
background: transparent; cursor: pointer; text-align: left;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
color: var(--ap-text-primary);
}
.${PREFIX}-pop-item:hover { background: var(--ap-surface-active); }
/* The selected value and the keyboard cursor are different states — you arrow
past the current value on the way to another one, and a menu that moves its
checkmark with the arrow keys is lying about what is set. */
.${PREFIX}-pop-item-on { color: var(--ap-primary); }
.${PREFIX}-pop-item[data-pop-active] {
background: var(--ap-surface-active); outline: none;
}
.${PREFIX}-pop-item:focus-visible {
outline: 1px solid var(--ap-border-focus); outline-offset: -1px;
}
.${PREFIX}-pop-item-hint {
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption); opacity: .5;
}
.${PREFIX}-pop-sep { height: 1px; margin: 4px 2px; background: var(--ap-border-default); }
/* Group heading. Same mono eyebrow as the inspector's section headers, so a
grouped menu reads as part of the same system. */
.${PREFIX}-pop-head {
padding: 6px 8px 2px; font-family: var(--ap-font-mono); text-transform: uppercase;
font-size: var(--ap-font-size-micro); letter-spacing: .6px; color: var(--ap-text-tertiary);
}
.${PREFIX}-pop-item-main { display: inline-flex; align-items: center; gap: var(--ap-space-xs); min-width: 0; }
.${PREFIX}-pop-item-main { --${PREFIX}-ic-tone: var(--ap-icon-secondary); }
.${PREFIX}-pop-item-main .${PREFIX}-ic { flex: 0 0 auto; }
.${PREFIX}-pop-item[aria-disabled="true"] { opacity: .4; cursor: default; }
.${PREFIX}-pop-item[aria-disabled="true"]:hover { background: transparent; }
/* ---- Review comment box ------------------------------------------------- */
/* Anchored to the diff it is about, rather than prefilling the composer: the
whole value of a comment is that it points at specific lines. */
.${PREFIX}-pop-comment { padding: var(--ap-space-xs); }
.${PREFIX}-comment-pop { display: flex; flex-direction: column; gap: 6px; width: 280px; }
.${PREFIX}-comment-where {
display: flex; align-items: center; gap: var(--ap-space-xs);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
color: var(--ap-text-tertiary);
}
.${PREFIX}-comment-where { --${PREFIX}-ic-tone: var(--ap-primary); }
.${PREFIX}-comment-input {
width: 100%; resize: vertical; min-height: 56px;
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-label);
line-height: 1.45; color: var(--ap-text-primary);
background: var(--ap-input-bg); border: 1px solid var(--ap-input-border);
border-radius: var(--ap-radius-sm); padding: 6px 8px;
}
.${PREFIX}-comment-input:focus { outline: none; border-color: var(--ap-input-focus-border); }
.${PREFIX}-comment-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--ap-space-xs); }
.${PREFIX}-comment-hint { font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption); color: var(--ap-text-tertiary); }
/* ---- A form in a popover ------------------------------------------------ */
/* The "advanced settings" shape: the two or three properties you set once
and then forget, kept out of the section's everyday height. Same labelled
rows as the panel, so it reads as the same system rather than a dialog. */
.${PREFIX}-pop-form {
display: flex; flex-direction: column;
padding: var(--ap-space-sm); min-width: 236px;
}
.${PREFIX}-pop-form .${PREFIX}-row-label { flex: 0 0 60px; }
/* The honest footnote. Quiet, and wrapped rather than truncated — it is the
only place the panel explains what CSS cannot express, so it has to be
readable rather than tidy. */
.${PREFIX}-pop-note {
margin-top: var(--ap-control-row-gap);
padding-top: var(--ap-control-row-gap);
border-top: 1px solid var(--ap-border-default);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-caption);
line-height: 1.45; color: var(--ap-text-tertiary);
}
/* A control that exists to name something CSS will not do. Legible enough to
read, plainly inert. */
.${PREFIX}-pop-form [disabled],
.${PREFIX}-pop-form .${PREFIX}-ctl-input[disabled] {
cursor: default; opacity: .38;
}
/* ---- Design token picker ------------------------------------------------ */
/* A menu with a search field on top. Same width as .pop-form above — the panel
had grown three different popover widths (236, 240, 260) for three popovers
that all sit against the same 320px rail.
\`overflow: hidden\` is load-bearing, not tidiness. \`placePopover\` defaults to
\`scroll: true\` and writes a \`max-height\` measured from the shell as it stands
at open time — and this shell opens with an empty list, so that height was the
search field alone. Every row added afterwards overflowed a ~40px box that had
no \`overflow\` set, so the options painted *outside* the shell, over the page,
with no background under them; scrolling the inner list moved them back into
the painted strip, which is exactly what it looked like. The reposition after
each render fixes the height, and this makes the failure impossible rather
than merely fixed.
\`.pop\` is a scroller in its own right now, and this opts *out* of it: the
search field is pinned and only the list below it may move, which is the one
shape the shared shell cannot express. The shorthand here wins over \`.pop\`'s
two longhands at equal specificity by source order. */
.${PREFIX}-pop-token {
display: flex; flex-direction: column;
min-width: 236px; overflow: hidden;
}
.${PREFIX}-token-pick {
display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
/* ---- Colour picker ------------------------------------------------------ */
.${PREFIX}-pop-color { width: 232px; }
.${PREFIX}-pop-color-body { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
/* Saturation / value. Three stacked gradients: white to transparent across,
black to transparent up, over the current hue. Same construction a design tool uses,
and it costs no canvas and no repaint beyond one custom property. */
.${PREFIX}-pop-sv {
position: relative; height: 140px; border-radius: var(--ap-radius-xs);
cursor: crosshair; touch-action: none;
background:
linear-gradient(to top, #000, transparent),
linear-gradient(to right, #fff, transparent),
var(--${PREFIX}-hue, #f00);
}
.${PREFIX}-pop-sv:focus-visible { outline: 1px solid var(--ap-border-focus); outline-offset: 2px; }
.${PREFIX}-pop-sv-knob {
position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px;
border: 2px solid #fff; border-radius: var(--ap-radius-full);
box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none;
}
.${PREFIX}-pop-sliders { display: flex; flex-direction: column; gap: 8px; }
.${PREFIX}-pop-slider {
position: relative; height: 12px; border-radius: var(--ap-radius-full);
cursor: pointer; touch-action: none;
}
.${PREFIX}-pop-slider:focus-visible { outline: 1px solid var(--ap-border-focus); outline-offset: 2px; }
.${PREFIX}-pop-slider-hue {
background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
/* The alpha track is the checkerboard; the gradient to the current colour is a
child so it can be restyled without rebuilding the checker. */
.${PREFIX}-pop-slider-alpha {
background-image: var(--${PREFIX}-checker); background-size: 8px 8px;
}
.${PREFIX}-pop-slider-fill {
position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
}
.${PREFIX}-pop-slider-knob {
position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
background: #fff; border-radius: var(--ap-radius-full);
box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none;
}
.${PREFIX}-pop-row { display: flex; align-items: center; gap: 4px; }
.${PREFIX}-pop-fields { flex: 1 1 auto; min-width: 0; display: flex; gap: 2px; }
.${PREFIX}-pop-fields > * { flex: 1 1 0; min-width: 0; }
/* Wide enough for "100" plus the % suffix — at 58px the value clipped to "10",
which is a wrong number rather than a truncated one. */
.${PREFIX}-pop-row > .${PREFIX}-ctl-num { flex: 0 0 66px; padding-left: 6px; }
.${PREFIX}-pop-mode {
display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto;
height: var(--ap-control-height); padding: 0 2px 0 4px;
border: 0; cursor: pointer; background: transparent; color: var(--ap-text-secondary);
border-radius: var(--ap-radius-xs);
font-family: var(--ap-font-mono); font-size: var(--ap-font-size-caption);
transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-pop-mode:hover { background: var(--ap-surface-hover); color: var(--ap-text-primary); }
.${PREFIX}-pop-eyedrop {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
width: var(--ap-control-height); height: var(--ap-control-height);
padding: 0; border: 0; cursor: pointer; background: transparent;
border-radius: var(--ap-radius-xs); transition: background var(--ap-motion-dur-micro) var(--ap-motion-ease);
}
.${PREFIX}-pop-eyedrop:hover { background: var(--ap-surface-active); }
.${PREFIX}-pop-recents {
display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
padding-top: 8px; border-top: 1px solid var(--ap-border-default);
}
.${PREFIX}-pop-recents:empty { display: none; }
.${PREFIX}-pop-recents-label {
flex: 0 0 100%;
font-family: var(--ap-font-mono); text-transform: uppercase;
font-size: var(--ap-font-size-caption); letter-spacing: .6px; opacity: .5;
}
.${PREFIX}-pop-recent {
width: 18px; height: 18px; flex: 0 0 auto; padding: 0; cursor: pointer;
background-size: 6px 6px; border-radius: var(--ap-radius-xs);
border: 1px solid var(--ap-border-default);
}
.${PREFIX}-pop-recent:hover { border-color: var(--ap-border-strong); }
.${PREFIX}-pop-recent:focus-visible { outline: 1px solid var(--ap-border-focus); outline-offset: 1px; }`;
+118
View File
@@ -0,0 +1,118 @@
/*
* The only stylesheet the editor injects into more than one document.
*
* Everything else in `styles/` is scoped to `#__airship-root` and lives in the
* shell. These rules have to reach the *edited* node, which is a page node —
* inside an iframe on the canvas, and in the host app's own body inline — so the
* string is shared: `styles/index.ts` concatenates it into the overlay sheet,
* and `frame-agent.ts` concatenates it into `FRAME_CSS`.
*
* **Colours are literals read from `design`, not `var(--ap-*)`, and that is not
* laziness.** The token vars are scoped (see `VARS` in `styles/index.ts`) to the
* root, the two chrome layers and the canvas viewport — and the edited node is
* inside none of them, in *either* document. A `var(--ap-primary)` here would be
* invalid at computed-value time and drop the declaration silently, in the shell
* exactly as in a frame. Reading `design` keeps one source of truth without the
* indirection that cannot work here.
*/
import { design } from "@airship/editor-tokens";
import { PREFIX } from "../dom";
/** The attribute `TextEditor` marks the node it is editing with. */
export const TEXT_EDIT_MARK = `data-${PREFIX}-text-edit`;
/** The attribute `DragGhost` marks its wrapper with — see `drag-ghost.ts`. */
export const GHOST_MARK = `data-${PREFIX}-ghost`;
/** The class the reorder controller puts on the node currently being dragged. */
export const DRAGGING_CLASS = `${PREFIX}-dragging`;
/** The class its siblings wear while they step aside — see `displace.ts`. */
export const DISPLACING_CLASS = `${PREFIX}-displacing`;
export const css = `
/* In-place text editing. Replaces the UA focus ring rather than removing it: an
editable box with no ring at all is worse than a dark one, and the dark one is
what this is here to get rid of.
A 1px *inset* hairline, not a 2px ring. \`.__airship-sel-box\` on the chrome
layer is already drawing a 2px primary outline around this same node, and two
concentric primary rings read as a rendering bug. This one sits inside it and
says "that box is a field now".
\`user-select\` and \`cursor\` are restated because inline — and only inline —
\`base.css\`'s edit-mode block sets them with \`!important\` on a selector
carrying two ID-weight \`:not()\` arguments, which this would otherwise lose to.
That block is taught to stand down on this attribute; the declarations here
are the other half of the same handshake. */
[${TEXT_EDIT_MARK}] {
outline: 1px solid ${design.primary.primary} !important;
outline-offset: -1px !important;
caret-color: ${design.primary.primary} !important;
user-select: text !important;
cursor: text !important;
}
/* \`TextEditor.begin\` selects the whole contents, so this band is the first thing
you see. Without an explicit colour it renders in the UA's *inactive* palette —
flat grey — whenever the owning document is not the focused one, which on the
canvas is the normal case: the frame sits inert behind its capture plane and
every gesture is handled in the shell's document.
Background only. Overriding \`color\` too would fight the app's own type colour,
and the point of editing in place is that it still looks like the app. The
descendant selector is defensive — \`isEditableText\` forbids element children,
but a browser inserts a \`<br>\` as soon as you press Enter. */
[${TEXT_EDIT_MARK}]::selection,
[${TEXT_EDIT_MARK}] *::selection {
background-color: ${design.selection.fill};
}
/* The node currently being dragged.
\`visibility: hidden\` and not \`opacity: .4\`, which is what this was. Both hide
it, but only one of them keeps its box: the drag ghost shows where the element
*is*, while the siblings around it animate into the space it is leaving, and
that space has to be measurable. An element at 40% opacity still occupies its
margins, its flex basis and its grid track — so the hole never opened and every
displacement offset was computed against a layout that had not changed.
It also happens to be free: a hidden element is skipped by
\`elementFromPoint\`, which is the guarantee \`pointer-events: none\` was here to
provide. That declaration stays anyway — the two are independent in the spec,
and this one is load-bearing enough not to rest on a coincidence.
A **class**, not an inline style. The node belongs to the host app, and a
React render mid-drag rewrites inline styles while leaving class attributes it
does not know about alone. */
.${DRAGGING_CLASS} {
visibility: hidden !important;
pointer-events: none !important;
}
/* Siblings opening a hole for the dragged element to land in.
The offset itself is an inline \`transform\`, written per node by
\`displace.ts\`; all this contributes is the easing, because a duration and a
curve are the same for every sibling and do not belong in a loop.
The curve is written out rather than referenced as \`var(--ap-motion-*)\`.
These are the app's nodes, in the app's document, and the token variables are
scoped to the editor's own roots — a \`var()\` that resolves to nothing here is
invalid at computed-value time and takes the whole declaration with it,
silently. Same reason the colours above are literals. */
.${DISPLACING_CLASS} {
transition: transform ${design.motion["dur-base"]} ${design.motion["ease-out"]};
}
/* The drag ghost: a clone of the dragged element, living in that element's own
document so the page's stylesheets still reach it.
\`pointer-events\` has to be forced onto the descendants and not just the
wrapper. \`none\` is inherited, but any child the app styles with
\`pointer-events: auto\` overrides it and becomes hit-testable — and a ghost
that answers \`elementFromPoint\` would have the drag resolving drop targets
against the thing being dragged. */
[${GHOST_MARK}], [${GHOST_MARK}] * {
pointer-events: none !important;
}`;
+59
View File
@@ -0,0 +1,59 @@
import { PREFIX } from "../dom";
import { Z_TOAST } from "./const";
/*
* The toast.
*
* Its own module rather than a block in `chrome.css.ts`, where it used to live:
* that file is "the floating chrome layer" by its own doc comment, and the toast
* was the one thing in it that is not on that layer. It is a child of the
* overlay root with a declared layer of its own — see `Z_TOAST`.
*/
export const css = `
.${PREFIX}-toast-host {
position: absolute; inset: 0; z-index: ${Z_TOAST}; pointer-events: none;
}
/* The centring \`translateX(-50%)\` appears in *both* states on purpose. Written
only on the resting state, the fade-in would also slide the toast in from half
its own width — which reads as the toast arriving from the left rather than
rising into place. */
.${PREFIX}-toast {
position: fixed; left: 50%; bottom: 76px;
transform: translate(-50%, 6px); opacity: 0;
transition:
opacity var(--ap-motion-dur-base) var(--ap-motion-ease-out),
transform var(--ap-motion-dur-base) var(--ap-motion-ease-out);
pointer-events: none; display: inline-flex; align-items: center; gap: var(--ap-space-xs);
max-width: min(420px, calc(100vw - 32px));
background: var(--ap-primary); color: var(--ap-text-primary);
padding: 8px 12px; border-radius: var(--ap-radius-md); font-size: var(--ap-font-size-title);
box-shadow: var(--ap-elevation-card);
}
.${PREFIX}-toast-in { opacity: 1; transform: translate(-50%, 0); }
.${PREFIX}-toast-error { background: var(--ap-semantic-error); }
/* The repeat counter. Dimmed so a burst of undos reads as one message with a
tally rather than as a message that keeps changing. */
.${PREFIX}-toast-count { font-family: var(--ap-font-mono); opacity: .65; }
/* The affordance — the one part of a toast that takes a pointer.
The host and the box are both \`pointer-events: none\` so a receipt floating
over the canvas never eats a click meant for the app underneath. An action is
the exact exception, and it has to say so itself rather than by loosening the
box around it.
A hairline ghost rather than a filled chip, in white alpha throughout: the
toast has two backgrounds — \`--ap-primary\` and, on the error tone,
\`--ap-semantic-error\` — and any fixed colour that reads on one is wrong on
the other. \`--ap-button-ghost-*\` are defined as white alpha for exactly this,
so hover and press land correctly on both. */
.${PREFIX}-toast-action {
pointer-events: auto; cursor: pointer;
margin-left: var(--ap-space-xs); padding: 2px 8px;
background: transparent; color: var(--ap-text-primary);
border: 1px solid var(--ap-border-strong); border-radius: var(--ap-radius-xs);
font-family: var(--ap-font-sans); font-size: var(--ap-font-size-body); font-weight: 500;
}
.${PREFIX}-toast-action:hover { background: var(--ap-button-ghost-hover); }
.${PREFIX}-toast-action:active { background: var(--ap-button-ghost-pressed); }`;
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"types": [],
"strictNullChecks": true
},
"include": ["src"]
}
+24
View File
@@ -0,0 +1,24 @@
import { defineConfig } from "tsup";
export default defineConfig({
clean: true,
dts: false,
entry: { hook: "src/hook.ts", overlay: "src/index.ts" },
format: ["iife"],
globalName: "AirshipOverlay",
/*
* Stories are never *bundled* — nothing reachable from the two entries above
* imports one, exactly as with the colocated `.test.ts` files. But `dev` runs
* `tsup --watch`, which watches the project directory rather than the module
* graph, so without this every keystroke in a story rebuilt both IIFEs for
* nothing. `make dev` runs that watcher alongside the site.
*/
ignoreWatch: ["**/*.stories.ts", "**/src/stories/**"],
minify: true,
outExtension() {
return { js: ".global.js" };
},
platform: "browser",
sourcemap: true,
target: "es2020",
});
+25
View File
@@ -0,0 +1,25 @@
import { defineConfig } from "vitest/config";
/*
* A DOM for the tests that need one.
*
* The overlay is hand-rolled DOM from top to bottom — `createNumField`,
* `ChangeSet`'s previews, `History`'s replays — and until now none of it was
* reachable from a test, because the package ran vitest on its Node default and
* the first `document` reference threw. That is why the field that silently
* rewrote `50%` to `50px` on blur shipped: there was nowhere to write the test
* that would have caught it.
*
* `happy-dom` rather than `jsdom` for speed, and because nothing here needs
* layout — the modules that measure (`getBoundingClientRect`, resolved
* `getComputedStyle`) go through `realm.ts` and are stubbed per test rather than
* simulated.
*
* The pure modules (`css-length`, `css-value`, `cascade`, `gradient`, the token
* registry) do not care either way and keep running exactly as before.
*/
export default defineConfig({
test: {
environment: "happy-dom",
},
});