@rickycourtes/designrail 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../src/cli.js';
3
+
4
+ // Piped into head or less and closed early: stop quietly.
5
+ process.stdout.on('error', (e) => { if (e.code === 'EPIPE') process.exit(0); throw e; });
6
+
7
+ main(process.argv.slice(2)).catch((e) => {
8
+ process.stderr.write(`\x1b[31merror\x1b[0m ${e.message}\n`);
9
+ if (process.env.DESIGNRAIL_DEBUG) process.stderr.write(e.stack + '\n');
10
+ process.exit(1);
11
+ });
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "version": "0.1.0",
4
+ "notes": "First kit: tokens, base, button, field, card, pill, dropdown, toast, sheet.",
5
+ "renamed": {},
6
+ "added": { "tokens": [], "parts": ["base", "button", "field", "card", "pill", "dropdown", "toast", "sheet"] },
7
+ "removed": { "tokens": [], "parts": [] }
8
+ },
9
+ {
10
+ "version": "0.2.0",
11
+ "notes": "The kit becomes the foundation: one import (@rickycourtes/designrail/foundation.css), cascade layers so a project's own CSS always wins, and knobs on every part (--btn-bg, --card-pad, --input-rim…) to restyle it without editing it. .btn.outline is new. `add` is now `eject`.",
12
+ "renamed": {},
13
+ "added": { "tokens": [], "parts": [], "classes": [".btn.outline"] },
14
+ "removed": { "tokens": [], "parts": [] }
15
+ }
16
+ ]
@@ -0,0 +1,24 @@
1
+ /* Designrail foundation: the default theme, the base and every part.
2
+ Import it first; then the project's theme (its own token values) and its
3
+ own parts. Everything here sits in cascade layers, so anything a project
4
+ writes outside a layer wins over it, whatever the specificity:
5
+
6
+ @import '@rickycourtes/designrail/foundation.css';
7
+ @import './tokens/primitives.css';
8
+ @import './tokens/semantic.css'; (re-points the contract: your look)
9
+ @import './ui/index.css'; (your parts and variants)
10
+
11
+ Restyle a part with its knobs (--btn-bg, --card-pad…) on a variant class
12
+ of your own, never by editing it: then a foundation update reaches you. */
13
+
14
+ @layer designrail.tokens, designrail.base, designrail.parts;
15
+
16
+ @import './tokens.css';
17
+ @import './parts/base.css';
18
+ @import './parts/button.css';
19
+ @import './parts/field.css';
20
+ @import './parts/card.css';
21
+ @import './parts/pill.css';
22
+ @import './parts/dropdown.css';
23
+ @import './parts/toast.css';
24
+ @import './parts/sheet.css';
@@ -0,0 +1,4 @@
1
+ // Designrail foundation: the behaviour the parts need, and nothing else.
2
+ // import { dropdowns, toast } from '@rickycourtes/designrail/foundation.js';
3
+ export { dropdowns } from './parts/dropdown.js';
4
+ export { toast } from './parts/toast.js';
@@ -0,0 +1,34 @@
1
+ /* base: the page and layout helpers every part assumes.
2
+ Siblings get their gap from the container, never a margin of their own.
3
+ .stack (a column) and .row (a wrapping line) take --gap; .tight and .loose
4
+ step it. .muted and .small adjust text. */
5
+
6
+ @layer designrail.base {
7
+ *, *::before, *::after { box-sizing: border-box; }
8
+
9
+ body {
10
+ margin: 0;
11
+ background: var(--surface);
12
+ color: var(--text);
13
+ font: var(--font-size-body) / 1.5 var(--font-ui);
14
+ -webkit-font-smoothing: antialiased;
15
+ }
16
+
17
+ :where(h1, h2, h3) { font-family: var(--font-display); line-height: 1.2; margin: 0; }
18
+ :where(p) { margin: 0; }
19
+
20
+ .stack { display: flex; flex-direction: column; gap: var(--gap, var(--space-12)); }
21
+ .row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--space-8)); }
22
+ .stack.tight, .row.tight { --gap: var(--space-4); }
23
+ .stack.loose, .row.loose { --gap: var(--space-24); }
24
+ .muted { color: var(--text-muted); }
25
+ .small { font-size: var(--font-size-small); }
26
+
27
+ /* Keyboard focus only: a pointer press never lights a ring. */
28
+ :focus:not(:focus-visible) { outline: none; }
29
+ :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
30
+
31
+ @media (prefers-reduced-motion: reduce) {
32
+ *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
33
+ }
34
+ }
@@ -0,0 +1,85 @@
1
+ /* button: a choice, not a word on a surface. Every one has a shape and a
2
+ label that names its result.
3
+ .btn default: a fill one shade off its surface
4
+ .btn.primary the one accent action per view
5
+ .btn.danger loses something
6
+ .btn.outline a rim instead of a fill
7
+ .btn.quiet the third choice, beside a default or primary, never alone
8
+ .btn.small a denser row (still a full touch target via its hit area)
9
+ .icon-btn a 1:1 circle, clear at rest; needs aria-label
10
+ .actions a row of buttons, --space-8 apart
11
+ Knobs (set them on a variant of your own, never restyle .btn where it is used):
12
+ --btn-h --btn-line --btn-radius --btn-bg --btn-bg-hover --btn-bg-press
13
+ --btn-fg --btn-fg-hover --btn-rim --btn-rim-w --btn-font-size --btn-gap
14
+ The side pad is twice the top pad, derived from the height, so a label
15
+ never sits closer to a side than to the top. */
16
+
17
+ @layer designrail.parts {
18
+ .btn {
19
+ --btn-h: var(--control-h);
20
+ --btn-line: 20px;
21
+ --btn-radius: var(--radius-control);
22
+ --btn-bg: var(--fill);
23
+ --btn-bg-hover: var(--fill-hover);
24
+ --btn-bg-press: var(--fill-press);
25
+ --btn-fg: var(--text);
26
+ --btn-fg-hover: var(--btn-fg);
27
+ --btn-rim: transparent;
28
+ --btn-rim-w: 1px;
29
+ --btn-font-size: var(--font-size-body);
30
+ --btn-gap: var(--space-6);
31
+ position: relative;
32
+ display: inline-flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ gap: var(--btn-gap);
36
+ box-sizing: border-box;
37
+ height: var(--btn-h);
38
+ padding: 0 calc(var(--btn-h) - var(--btn-line) - var(--btn-rim-w));
39
+ border: var(--btn-rim-w) solid var(--btn-rim);
40
+ border-radius: var(--btn-radius);
41
+ background: var(--btn-bg);
42
+ color: var(--btn-fg);
43
+ font: var(--weight-strong) var(--btn-font-size) / var(--btn-line) var(--font-ui);
44
+ text-decoration: none;
45
+ white-space: nowrap;
46
+ cursor: pointer;
47
+ user-select: none;
48
+ transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
49
+ }
50
+ .btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg-hover); }
51
+ .btn:active { background: var(--btn-bg-press); transform: scale(0.98); }
52
+ .btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; pointer-events: none; }
53
+
54
+ .btn.primary { --btn-bg: var(--accent); --btn-bg-hover: var(--accent-hover); --btn-bg-press: var(--accent-hover); --btn-fg: var(--text-on-accent); }
55
+ .btn.danger { --btn-bg: var(--danger); --btn-bg-hover: color-mix(in oklab, var(--danger), var(--text) 12%); --btn-bg-press: var(--btn-bg-hover); --btn-fg: var(--text-on-accent); }
56
+ .btn.outline { --btn-bg: transparent; --btn-rim: var(--border-strong); }
57
+ .btn.quiet { --btn-bg: transparent; --btn-bg-hover: var(--fill); --btn-bg-press: var(--fill-hover); --btn-fg: var(--text-muted); --btn-fg-hover: var(--text); }
58
+ .btn.small { --btn-h: 32px; --btn-line: 16px; --btn-font-size: var(--font-size-small); }
59
+ /* A small button keeps a 44px hit area. */
60
+ .btn.small::after { content: ''; position: absolute; inset: calc((var(--btn-h) - var(--control-h)) / 2) 0; }
61
+
62
+ .btn > svg, .icon-btn > svg { width: var(--icon-size, 18px); height: var(--icon-size, 18px); flex: none; }
63
+
64
+ .actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-8); }
65
+
66
+ .icon-btn {
67
+ --icon-btn-size: var(--control-h);
68
+ --icon-btn-fg: var(--text-muted);
69
+ --icon-btn-bg-hover: var(--fill);
70
+ --icon-btn-bg-press: var(--fill-hover);
71
+ display: inline-grid;
72
+ place-items: center;
73
+ width: var(--icon-btn-size);
74
+ height: var(--icon-btn-size);
75
+ padding: 0;
76
+ border: 0;
77
+ border-radius: var(--radius-full);
78
+ background: transparent;
79
+ color: var(--icon-btn-fg);
80
+ cursor: pointer;
81
+ transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
82
+ }
83
+ .icon-btn:hover { background: var(--icon-btn-bg-hover); color: var(--text); }
84
+ .icon-btn:active, .icon-btn[aria-pressed='true'] { background: var(--icon-btn-bg-press); color: var(--text); }
85
+ }
@@ -0,0 +1,35 @@
1
+ /* card: a raised box that stacks what it holds with one gap.
2
+ .card padded surface; .card.flat drops the shadow for a rim
3
+ .card > .inset a box inside: its corner is concentric (outer radius − padding)
4
+ .card-head a title and its line, tighter than the gap to the body
5
+ A box is only as big as what it holds: it never stretches to a column.
6
+ Knobs: --card-pad --card-gap --card-radius --card-bg --card-shadow --card-rim */
7
+
8
+ @layer designrail.parts {
9
+ .card {
10
+ --card-pad: var(--space-16);
11
+ --card-gap: var(--space-16);
12
+ --card-radius: var(--radius-card);
13
+ --card-bg: var(--surface-raised);
14
+ --card-shadow: var(--shadow-raised);
15
+ --card-rim: transparent;
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: var(--card-gap);
19
+ padding: var(--card-pad);
20
+ border: 1px solid var(--card-rim);
21
+ border-radius: var(--card-radius);
22
+ background: var(--card-bg);
23
+ box-shadow: var(--card-shadow);
24
+ align-self: start;
25
+ }
26
+ .card.flat { --card-shadow: none; --card-rim: var(--border); }
27
+ .card > .inset {
28
+ padding: var(--space-12);
29
+ border-radius: max(var(--space-4), calc(var(--card-radius) - var(--card-pad)));
30
+ background: var(--surface-sunken);
31
+ }
32
+ .card-head { display: grid; gap: var(--space-4); }
33
+ .card-head > h3, .card-title { margin: 0; font: var(--weight-strong) var(--font-size-title) / 1.25 var(--font-display); }
34
+ .card-head > p { margin: 0; color: var(--text-muted); font-size: var(--font-size-small); }
35
+ }
@@ -0,0 +1,55 @@
1
+ /* dropdown: a choice from a list. Never a native <select> drawn by hand per page.
2
+ <div class="dropdown">
3
+ <button class="btn" aria-haspopup="menu" aria-expanded="false">Sort</button>
4
+ <div class="menu" role="menu" hidden>
5
+ <button class="menu-item" role="menuitem">Newest</button>
6
+ </div>
7
+ </div>
8
+ dropdown.js wires opening, arrow keys, Escape and outside clicks.
9
+ The menu's corner is concentric with its rows: radius − padding.
10
+ Knobs: --menu-pad --menu-radius --menu-bg --menu-shadow --menu-min-w --menu-item-h */
11
+
12
+ @layer designrail.parts {
13
+ .dropdown { position: relative; display: inline-block; }
14
+ .menu {
15
+ --menu-pad: var(--space-6);
16
+ --menu-radius: var(--radius-card);
17
+ --menu-bg: var(--surface-raised);
18
+ --menu-shadow: var(--shadow-overlay);
19
+ --menu-min-w: 220px;
20
+ --menu-item-h: 40px;
21
+ position: absolute;
22
+ z-index: 50;
23
+ top: calc(100% + var(--space-6));
24
+ left: 0;
25
+ display: grid;
26
+ min-width: var(--menu-min-w);
27
+ padding: var(--menu-pad);
28
+ border-radius: var(--menu-radius);
29
+ background: var(--menu-bg);
30
+ box-shadow: var(--menu-shadow);
31
+ transform-origin: top left;
32
+ animation: dr-menu-in var(--duration-fast) var(--ease-out);
33
+ }
34
+ .menu[hidden] { display: none; }
35
+ .menu.end { left: auto; right: 0; transform-origin: top right; }
36
+ .menu-item {
37
+ display: flex;
38
+ align-items: center;
39
+ gap: var(--space-8);
40
+ min-height: var(--menu-item-h);
41
+ padding: 0 var(--space-12);
42
+ border: 0;
43
+ border-radius: max(var(--space-4), calc(var(--menu-radius) - var(--menu-pad)));
44
+ background: transparent;
45
+ color: var(--text);
46
+ font: var(--font-size-body) / 20px var(--font-ui);
47
+ text-align: start;
48
+ cursor: pointer;
49
+ }
50
+ .menu-item:hover, .menu-item:focus-visible { background: var(--fill); outline: none; }
51
+ .menu-item[aria-checked='true'] { color: var(--accent); }
52
+ .menu-sep { height: 1px; margin: var(--space-4) 0; background: var(--border); }
53
+
54
+ @keyframes dr-menu-in { from { opacity: 0; transform: scale(0.97) translateY(-4px); } }
55
+ }
@@ -0,0 +1,38 @@
1
+ // dropdown: open, close and keyboard for every .dropdown on the page.
2
+ // Call once: dropdowns(); it delegates, so dropdowns added later work too.
3
+ export function dropdowns(root = document) {
4
+ const close = (dd, focus) => {
5
+ const btn = dd.querySelector('[aria-haspopup]');
6
+ const menu = dd.querySelector('.menu');
7
+ if (!menu || menu.hidden) return;
8
+ menu.hidden = true;
9
+ btn.setAttribute('aria-expanded', 'false');
10
+ if (focus) btn.focus();
11
+ };
12
+ const open = (dd) => {
13
+ const btn = dd.querySelector('[aria-haspopup]');
14
+ const menu = dd.querySelector('.menu');
15
+ root.querySelectorAll('.dropdown').forEach((o) => o !== dd && close(o));
16
+ menu.hidden = false;
17
+ btn.setAttribute('aria-expanded', 'true');
18
+ menu.querySelector('.menu-item')?.focus();
19
+ };
20
+ root.addEventListener('click', (e) => {
21
+ const btn = e.target.closest('.dropdown > [aria-haspopup]');
22
+ if (btn) { const dd = btn.parentElement; dd.querySelector('.menu').hidden ? open(dd) : close(dd); return; }
23
+ const item = e.target.closest('.menu-item');
24
+ root.querySelectorAll('.dropdown').forEach((dd) => { if (!dd.contains(e.target) || item) close(dd, !!item && dd.contains(item)); });
25
+ });
26
+ root.addEventListener('keydown', (e) => {
27
+ const dd = e.target.closest?.('.dropdown');
28
+ if (!dd) return;
29
+ const items = [...dd.querySelectorAll('.menu-item:not([disabled])')];
30
+ const i = items.indexOf(document.activeElement);
31
+ if (e.key === 'Escape') { close(dd, true); e.preventDefault(); }
32
+ else if (e.key === 'ArrowDown') { if (dd.querySelector('.menu').hidden) open(dd); else items[(i + 1) % items.length]?.focus(); e.preventDefault(); }
33
+ else if (e.key === 'ArrowUp') { items[(i - 1 + items.length) % items.length]?.focus(); e.preventDefault(); }
34
+ else if (e.key === 'Home') { items[0]?.focus(); e.preventDefault(); }
35
+ else if (e.key === 'End') { items[items.length - 1]?.focus(); e.preventDefault(); }
36
+ else if (e.key === 'Tab') close(dd);
37
+ });
38
+ }
@@ -0,0 +1,67 @@
1
+ /* field: a label, the control, and its hint, in one column.
2
+ <label class="field">
3
+ <span class="label">Email</span>
4
+ <input class="input" type="email">
5
+ <span class="hint">We never share it.</span>
6
+ </label>
7
+ .input covers input, textarea and select. A field pads its top pad on
8
+ every side (unlike a button). Focus turns the rim to the accent; the ring
9
+ is for the keyboard only. .check is a checkbox or radio with its label.
10
+ Knobs: --input-h --input-line --input-rim-w --input-radius --input-bg
11
+ --input-fg --input-rim --input-rim-hover --input-rim-focus --field-gap */
12
+
13
+ @layer designrail.parts {
14
+ .field { --field-gap: var(--space-6); display: grid; gap: var(--field-gap); align-content: start; }
15
+ .field > .label { font-size: var(--font-size-small); font-weight: var(--weight-strong); color: var(--text); }
16
+ .field > .hint { font-size: var(--font-size-small); color: var(--text-muted); }
17
+ .field.invalid > .hint { color: var(--danger); }
18
+
19
+ .input {
20
+ --input-h: var(--control-h);
21
+ --input-line: 20px;
22
+ --input-rim-w: 1px;
23
+ --input-radius: var(--radius-control);
24
+ --input-bg: var(--surface);
25
+ --input-fg: var(--text);
26
+ --input-rim: var(--border-strong);
27
+ --input-rim-hover: var(--text-faint);
28
+ --input-rim-focus: var(--accent);
29
+ box-sizing: border-box;
30
+ width: 100%;
31
+ min-height: var(--input-h);
32
+ padding: calc((var(--input-h) - var(--input-line)) / 2 - var(--input-rim-w)) var(--space-12);
33
+ border: var(--input-rim-w) solid var(--input-rim);
34
+ border-radius: var(--input-radius);
35
+ background: var(--input-bg);
36
+ color: var(--input-fg);
37
+ font: var(--font-size-body) / var(--input-line) var(--font-ui);
38
+ transition: border-color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
39
+ }
40
+ .input::placeholder { color: var(--text-faint); }
41
+ .input:hover { border-color: var(--input-rim-hover); }
42
+ .input:focus { border-color: var(--input-rim-focus); outline: none; }
43
+ .input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
44
+ .field.invalid .input { --input-rim: var(--danger); --input-rim-hover: var(--danger); }
45
+ .input:disabled { --input-bg: var(--surface-sunken); --input-fg: var(--text-faint); }
46
+ textarea.input { min-height: calc(var(--input-h) * 2); resize: vertical; }
47
+ select.input {
48
+ appearance: none;
49
+ padding-right: calc(var(--space-24) + var(--space-8));
50
+ background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
51
+ background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
52
+ background-size: 5px 5px;
53
+ background-repeat: no-repeat;
54
+ }
55
+ .input[type='search']::-webkit-search-cancel-button { display: none; }
56
+
57
+ /* A tick leads its label's first line: top-aligned, centred on that line. */
58
+ .check { display: flex; align-items: flex-start; gap: var(--space-8); cursor: pointer; line-height: 1.5; }
59
+ .check > input {
60
+ --tick: 18px;
61
+ flex: none;
62
+ width: var(--tick);
63
+ height: var(--tick);
64
+ margin: calc((1.5em - var(--tick)) / 2) 0 0;
65
+ accent-color: var(--accent);
66
+ }
67
+ }
@@ -0,0 +1,40 @@
1
+ /* pill: a short status or tag. .pill.accent / .danger / .success / .warning
2
+ tint it by what it says. .pill .dot leads with a mark --space-6 from the words.
3
+ .count is a number beside its label, never run into the text.
4
+ Knobs: --pill-tone (the colour it says) --pill-bg --pill-fg */
5
+
6
+ @layer designrail.parts {
7
+ .pill {
8
+ --pill-tone: var(--text-muted);
9
+ --pill-bg: var(--fill);
10
+ --pill-fg: var(--pill-tone);
11
+ display: inline-flex;
12
+ align-items: center;
13
+ gap: var(--space-6);
14
+ padding: var(--space-4) var(--space-8);
15
+ border-radius: var(--radius-full);
16
+ background: var(--pill-bg);
17
+ color: var(--pill-fg);
18
+ font: var(--weight-strong) var(--font-size-small) / 16px var(--font-ui);
19
+ white-space: nowrap;
20
+ }
21
+ .pill > .dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }
22
+ .pill:is(.accent, .danger, .success, .warning) { --pill-bg: color-mix(in srgb, var(--pill-tone) 14%, transparent); }
23
+ .pill.accent { --pill-tone: var(--accent); }
24
+ .pill.danger { --pill-tone: var(--danger); }
25
+ .pill.success { --pill-tone: var(--success); }
26
+ .pill.warning { --pill-tone: var(--warning); }
27
+
28
+ .count {
29
+ display: inline-grid;
30
+ place-items: center;
31
+ min-width: 20px;
32
+ height: 20px;
33
+ padding: 0 var(--space-6);
34
+ border-radius: var(--radius-full);
35
+ background: var(--fill-hover);
36
+ color: var(--text);
37
+ font: var(--weight-strong) var(--font-size-small) / 1 var(--font-ui);
38
+ font-variant-numeric: tabular-nums;
39
+ }
40
+ }
@@ -0,0 +1,43 @@
1
+ /* sheet: a dialog over the page, on the native <dialog> (focus trap, Escape
2
+ and inert background come free). On a phone it rises from the bottom.
3
+ <dialog class="sheet">
4
+ <header class="sheet-head"><h2>Title</h2><button class="icon-btn sheet-close" aria-label="Close">×</button></header>
5
+ …
6
+ <footer class="actions"><button class="btn quiet">Cancel</button><button class="btn primary">Save</button></footer>
7
+ </dialog>
8
+ el.showModal() opens it. Nothing sits under the close button: the title
9
+ row stops a gap short of it.
10
+ Knobs: --sheet-pad --sheet-width --sheet-radius --sheet-bg --sheet-gap */
11
+
12
+ @layer designrail.parts {
13
+ .sheet {
14
+ --sheet-pad: var(--space-24);
15
+ --sheet-gap: var(--space-16);
16
+ --sheet-width: 420px;
17
+ --sheet-radius: var(--radius-card);
18
+ --sheet-bg: var(--surface-raised);
19
+ box-sizing: border-box;
20
+ width: min(var(--sheet-width), calc(100vw - 2 * var(--space-16)));
21
+ max-height: calc(100dvh - 2 * var(--space-16));
22
+ padding: var(--sheet-pad);
23
+ border: 0;
24
+ border-radius: var(--sheet-radius);
25
+ background: var(--sheet-bg);
26
+ color: var(--text);
27
+ box-shadow: var(--shadow-overlay);
28
+ overflow: auto;
29
+ }
30
+ .sheet[open] { display: flex; flex-direction: column; gap: var(--sheet-gap); animation: dr-sheet-in var(--duration-base) var(--ease-out); }
31
+ .sheet::backdrop { background: var(--surface-scrim); animation: dr-scrim-in var(--duration-base) var(--ease-out); }
32
+ .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); margin: calc(var(--space-8) * -1) calc(var(--space-12) * -1) 0 0; }
33
+ .sheet-head > h2 { margin: 0; font: var(--weight-strong) var(--font-size-title) / 1.25 var(--font-display); }
34
+
35
+ @media (max-width: 520px) {
36
+ .sheet { width: 100vw; max-width: none; margin: auto 0 0; border-end-start-radius: 0; border-end-end-radius: 0; padding-bottom: max(var(--sheet-pad), env(safe-area-inset-bottom)); }
37
+ .sheet[open] { animation-name: dr-sheet-up; }
38
+ }
39
+
40
+ @keyframes dr-sheet-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
41
+ @keyframes dr-sheet-up { from { transform: translateY(100%); } }
42
+ @keyframes dr-scrim-in { from { opacity: 0; } }
43
+ }
@@ -0,0 +1,40 @@
1
+ /* toast: a short note that something happened, with at most one action.
2
+ toast.js builds them in one polite live region at the bottom of the page.
3
+ A filled box pads every side equally; an end that holds a button drops to
4
+ the top pad, so the button sits as far from the edge as from the top.
5
+ Knobs: --toast-bg --toast-fg --toast-radius --toast-max-w */
6
+
7
+ @layer designrail.parts {
8
+ .toasts {
9
+ position: fixed;
10
+ z-index: 100;
11
+ inset: auto var(--space-16) var(--space-16) var(--space-16);
12
+ display: grid;
13
+ justify-items: center;
14
+ gap: var(--space-8);
15
+ pointer-events: none;
16
+ }
17
+ .toast {
18
+ --toast-bg: var(--text);
19
+ --toast-fg: var(--surface);
20
+ --toast-radius: var(--radius-card);
21
+ --toast-max-w: 420px;
22
+ display: flex;
23
+ align-items: center;
24
+ gap: var(--space-12);
25
+ max-width: var(--toast-max-w);
26
+ padding: var(--space-12) var(--space-16);
27
+ border-radius: var(--toast-radius);
28
+ background: var(--toast-bg);
29
+ color: var(--toast-fg);
30
+ box-shadow: var(--shadow-overlay);
31
+ font-size: var(--font-size-body);
32
+ pointer-events: auto;
33
+ animation: dr-toast-in var(--duration-base) var(--ease-out);
34
+ }
35
+ .toast:has(> .btn:last-child) { padding-right: var(--space-8); }
36
+ .toast > .btn { --btn-h: 32px; --btn-line: 16px; --btn-bg: color-mix(in srgb, var(--toast-fg) 14%, transparent); --btn-bg-hover: color-mix(in srgb, var(--toast-fg) 22%, transparent); --btn-fg: var(--toast-fg); }
37
+ .toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out); }
38
+
39
+ @keyframes dr-toast-in { from { opacity: 0; transform: translateY(12px); } }
40
+ }
@@ -0,0 +1,32 @@
1
+ // toast(message, { action: { label, onClick }, timeout }) → dismiss()
2
+ export function toast(message, { action, timeout = 4000 } = {}) {
3
+ let region = document.querySelector('.toasts');
4
+ if (!region) {
5
+ region = document.createElement('div');
6
+ region.className = 'toasts';
7
+ region.setAttribute('role', 'status');
8
+ region.setAttribute('aria-live', 'polite');
9
+ document.body.append(region);
10
+ }
11
+ const el = document.createElement('div');
12
+ el.className = 'toast';
13
+ const text = document.createElement('span');
14
+ text.textContent = message;
15
+ el.append(text);
16
+ const dismiss = () => {
17
+ if (!el.isConnected) return;
18
+ el.classList.add('leaving');
19
+ el.addEventListener('transitionend', () => el.remove(), { once: true });
20
+ setTimeout(() => el.remove(), 400);
21
+ };
22
+ if (action) {
23
+ const btn = document.createElement('button');
24
+ btn.className = 'btn';
25
+ btn.textContent = action.label;
26
+ btn.addEventListener('click', () => { action.onClick?.(); dismiss(); });
27
+ el.append(btn);
28
+ }
29
+ region.append(el);
30
+ if (timeout) setTimeout(dismiss, timeout);
31
+ return dismiss;
32
+ }
package/kit/tokens.css ADDED
@@ -0,0 +1,110 @@
1
+ /* Designrail kit tokens: a complete default theme for the contract every part
2
+ reads. A project that ran `designrail extract` already has these names
3
+ pointed at its own values; this file is the foundation's default theme.
4
+ It sits in the designrail.tokens layer, so any value a project sets on
5
+ :root (unlayered) wins, whatever the specificity.
6
+ Primitives are what a value IS; semantic tokens say what it is FOR. Parts
7
+ read semantic tokens and the --space-* steps only. */
8
+
9
+ @layer designrail.tokens {
10
+ :root {
11
+ /* --- primitives: colour ----------------------------------------------- */
12
+ --white: #ffffff;
13
+ --gray-50: #f7f7f8;
14
+ --gray-100: #efeff1;
15
+ --gray-200: #e2e2e6;
16
+ --gray-300: #c9c9d0;
17
+ --gray-500: #7a7a85;
18
+ --gray-700: #46464f;
19
+ --gray-800: #2a2a31;
20
+ --gray-900: #1b1b20;
21
+ --gray-950: #111114;
22
+ --blue-500: #2f6bff;
23
+ --blue-600: #1f57e6;
24
+ --blue-400: #5b8bff;
25
+ --red-500: #e5484d;
26
+ --green-500: #2fa86a;
27
+ --amber-500: #e09b1a;
28
+
29
+ /* --- primitives: space, shape, type ----------------------------------- */
30
+ --space-2: 2px;
31
+ --space-4: 4px;
32
+ --space-6: 6px;
33
+ --space-8: 8px;
34
+ --space-12: 12px;
35
+ --space-16: 16px;
36
+ --space-24: 24px;
37
+ --space-32: 32px;
38
+ --space-48: 48px;
39
+ --radius-8: 8px;
40
+ --radius-14: 14px;
41
+ --radius-full: 999px;
42
+ --font-size-13: 13px;
43
+ --font-size-15: 15px;
44
+ --font-size-20: 20px;
45
+
46
+ /* --- semantic: colour -------------------------------------------------- */
47
+ /* Core: the values that make a project look like itself. A theme sets
48
+ these; everything below them is derived, so it follows any theme. */
49
+ --surface: var(--white);
50
+ --text: var(--gray-950);
51
+ --accent: var(--blue-500);
52
+ --text-on-accent: var(--white);
53
+ /* A raised box steps lighter by how dark the page is: nothing on a white
54
+ page (a card lifts with its shadow), a visible step on a dark one. */
55
+ --surface-raised: oklch(from var(--surface) calc(l + (1 - l) * (1 - l) * 0.12) c h);
56
+ --surface-sunken: color-mix(in oklab, var(--surface), var(--text) 4%);
57
+ --surface-scrim: color-mix(in srgb, #000 45%, transparent);
58
+ --fill: color-mix(in srgb, var(--text) 6%, transparent);
59
+ --fill-hover: color-mix(in srgb, var(--text) 10%, transparent);
60
+ --fill-press: color-mix(in srgb, var(--text) 14%, transparent);
61
+ --text-muted: color-mix(in oklab, var(--text) 70%, var(--surface));
62
+ --text-faint: color-mix(in oklab, var(--text) 45%, var(--surface));
63
+ --border: color-mix(in oklab, var(--text) 13%, var(--surface));
64
+ --border-strong: color-mix(in oklab, var(--text) 25%, var(--surface));
65
+ --accent-hover: color-mix(in oklab, var(--accent), var(--text) 14%);
66
+ --danger: var(--red-500);
67
+ --success: var(--green-500);
68
+ --warning: var(--amber-500);
69
+ --focus: var(--accent);
70
+
71
+ /* --- semantic: type ---------------------------------------------------- */
72
+ --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
73
+ --font-display: var(--font-ui);
74
+ --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
75
+ --font-size-small: var(--font-size-13);
76
+ --font-size-body: var(--font-size-15);
77
+ --font-size-title: var(--font-size-20);
78
+ --weight-strong: 600;
79
+
80
+ /* --- semantic: shape and motion --------------------------------------- */
81
+ --radius-control: var(--radius-8);
82
+ --radius-card: var(--radius-14);
83
+ --control-h: 44px;
84
+ --shadow-raised: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.05);
85
+ --shadow-overlay: 0 12px 40px rgb(0 0 0 / 0.18), 0 2px 6px rgb(0 0 0 / 0.08);
86
+ --duration-fast: 120ms;
87
+ --duration-base: 220ms;
88
+ --ease-out: cubic-bezier(0.2, 0, 0, 1);
89
+ }
90
+
91
+ /* Dark: re-point the core; everything derived follows, parts never change.
92
+ A project that sets its own core on :root keeps its own look here too. */
93
+ :root[data-theme='dark'] {
94
+ --surface: var(--gray-950);
95
+ --text: var(--gray-50);
96
+ --accent: var(--blue-400);
97
+ --shadow-raised: 0 1px 2px rgb(0 0 0 / 0.4);
98
+ --shadow-overlay: 0 12px 40px rgb(0 0 0 / 0.5);
99
+ }
100
+
101
+ @media (prefers-color-scheme: dark) {
102
+ :root:not([data-theme='light']) {
103
+ --surface: var(--gray-950);
104
+ --text: var(--gray-50);
105
+ --accent: var(--blue-400);
106
+ --shadow-raised: 0 1px 2px rgb(0 0 0 / 0.4);
107
+ --shadow-overlay: 0 12px 40px rgb(0 0 0 / 0.5);
108
+ }
109
+ }
110
+ }