@rickycourtes/designrail 0.2.2 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,76 @@
3
3
  Every foundation release also has an entry in `kit/changes.json`, which
4
4
  `designrail upgrade` reads to move a project forward.
5
5
 
6
+ ## 0.3.0
7
+
8
+ A minor release: a config that turns a rule down now stops `check` and
9
+ `audit`, which a patch must not do.
10
+
11
+ **Rules extend, never override**
12
+ - The base design rules ship in the package and are exported as
13
+ `@rickycourtes/designrail/rules/DESIGN.md`. `init` writes a project
14
+ `DESIGN.md` that starts `Extends @rickycourtes/designrail/rules/DESIGN.md`
15
+ with an empty "Project rules" section, and the `--agents` note says to read
16
+ both.
17
+ - New `check` rule `rules-override` (error): a bullet in the project's
18
+ `DESIGN.md` tagged with a base `{id}`. A project written by an earlier
19
+ `init` holds a copy of the base: run `designrail init --force` or delete
20
+ the copied bullets.
21
+ - `check` and `audit` exit 2 on a config that loosens a foundation rule: a
22
+ `rules` level below its default, `semanticOnly: false`, an
23
+ `allowPrimitives` entry outside the default, or
24
+ `duplicates.minDeclarations` above 3. Raising a level stays allowed.
25
+
26
+ **False hits found on a real app**
27
+ - A quoted name read by script (`getPropertyValue('--x')`, `tok('--x')`)
28
+ counts as a read, so the token is not `unused`.
29
+ - With a token file named for primitives, only its literals (and the
30
+ foundation's) are primitives: a literal in the semantic file that other
31
+ tokens compose is API, not `primitive-direct`.
32
+ - `part-restyle` lets interaction properties through: `cursor`,
33
+ `user-select`, `touch-action`, `-webkit-tap-highlight-color`,
34
+ `-webkit-touch-callout`, `will-change`, `overflow`,
35
+ `overscroll-behavior` and `scroll-*`.
36
+ - `part-restyle` reads only the selector's subject: a part class inside
37
+ `:has()` or `:not()` is a condition, so `.segment:has(> .btn.glass)` no
38
+ longer counts as restyling `.btn`.
39
+
40
+ **Foundation: new knobs, same look**
41
+ - Tokens `--focus-ring` (`2px solid var(--focus)`) and `--focus-glow`
42
+ (`none`) draw `:focus-visible`. Every part honours `.is-hover`,
43
+ `.is-active` and `.is-focus`, so a specimen can pin a state.
44
+ - button: `--btn-pad-x`, `--btn-pad-y`, `--btn-font`, `--btn-lift`,
45
+ `--btn-press`, `--btn-blur`, `--btn-text-wrap`, `--btn-align`
46
+ (justify-content), `--btn-text-align`, `--btn-disabled`, an `aria-busy`
47
+ ring (`--btn-busy-size`, `--btn-busy-w`, `--btn-busy-ring: none` turns it
48
+ off), `--btn-shadow`; `.btn.small`'s hit area: `--btn-hit`, `--btn-hit-area: none` turns it
49
+ off.
50
+ `.btn` sets `appearance: none`, so a `<button>` keeps no browser style.
51
+ The height is a `min-height`, and a disabled button keeps
52
+ `pointer-events`, so `aria-disabled` still takes a click.
53
+ - field: `--input-pad-y`, `--input-pad-x`, `--input-pad-end`,
54
+ `--input-bg-hover`, `--input-bg-focus` (on `:focus-within`),
55
+ `--input-shadow`, `--input-font`, `--input-rim-style`, `--input-align`,
56
+ `--input-gap`; `.field` resets a fieldset and its
57
+ column can shrink; `.check`: `--check-gap`, `--check-pad-y`,
58
+ `--check-fg`, `--check-font`, `--check-line`.
59
+ - card: `--card-blur`, `--card-fg`, `--card-align`, `--card-align-content`,
60
+ `--card-type` (the whole font shorthand). pill: `--pill-pad-y`, `--pill-pad-x`,
61
+ `--pill-radius`, `--pill-font`, `--pill-blur`, `--pill-text-shadow`,
62
+ centred content, no browser border on a
63
+ `button.pill`; `.count`: `--count-bg`,
64
+ `--count-fg`, `--count-font`, `--count-pad-x`, `--count-h`,
65
+ `--count-radius`.
66
+ - dropdown: `--menu-gap`, `--menu-rim`, `--menu-fg`, `--menu-origin`; a
67
+ `[popover]` menu draws no browser rim. toast: `--toast-pad-y`,
68
+ `--toast-pad-start`, `--toast-pad-end`, `--toast-rim`, `--toast-shadow`,
69
+ `--toast-gap`, `--toast-font`, `--toast-type` (the whole font shorthand).
70
+ sheet: `--sheet-rim`, `--sheet-rim-w`,
71
+ `--sheet-shadow`, `--sheet-blur`, `--sheet-fg`, `--sheet-border-w` and
72
+ `--sheet-border-style` (a real border that can be top-only),
73
+ `--sheet-align-content`; the sheet's gap no longer waits for `[open]`; modal sizing applies to
74
+ `dialog.sheet` only, so a docked `.sheet` is placed by its page.
75
+
6
76
  ## 0.2.2
7
77
 
8
78
  No foundation changes. Five gaps found by auditing a real project:
package/README.md CHANGED
@@ -163,8 +163,10 @@ An unknown flag exits with code 2 and an error, rather than being guessed at.
163
163
 
164
164
  ### `init [dir] [--agents] [--force]`
165
165
 
166
- Writes `designrail.config.json` and `DESIGN.md`, the project's design rules
167
- (see [Design rules](#design-rules)). If the project already has token files
166
+ Writes `designrail.config.json` and `DESIGN.md`, the project's design rules.
167
+ That `DESIGN.md` starts `Extends @rickycourtes/designrail/rules/DESIGN.md`
168
+ and holds an empty "Project rules" section: the base rules ship in the
169
+ package and the project only appends (see [Design rules](#design-rules)). If the project already has token files
168
170
  (stylesheets that are mostly custom properties on `:root`), `init` finds them
169
171
  and points `tokens` at them. `parts` is set to `src/ui` when there is a `src/`
170
172
  folder, else `ui`. A page `designrail specimens` wrote (wherever `--out` put
@@ -326,12 +328,18 @@ The drift gate. It exits 1 if any rule set to `error` has a hit.
326
328
  | --- | --- | --- |
327
329
  | `hardcoded` | A colour, spacing, radius, font size, family or shadow typed by hand outside token files. Shows the token that holds it, if one does. | error |
328
330
  | `unresolved` | A `var(--x)` with `--x` defined nowhere and not set from JS. | error |
329
- | `primitive-direct` | A primitive read outside token files when a semantic layer exists (except `allowPrimitives` and contract names). The foundation's palette (`--gray-950`, `--blue-500`…) counts as primitives. | warn |
331
+ | `primitive-direct` | A primitive read outside token files when a semantic layer exists (except `allowPrimitives` and contract names). The foundation's palette (`--gray-950`, `--blue-500`…) counts as primitives. When a token file's name says `primitive`, only that file's literals (and the foundation's) are primitives: a literal in the semantic file that other tokens compose is API. | warn |
330
332
  | `duplicate-block` | A rule block identical to another one, at `duplicates.minDeclarations` (3) declarations or more. | error |
331
333
  | `unused` | A token nobody reads (contract names are exempt: they are the parts' API). | warn |
332
334
  | `tracked-caps` | `text-transform: uppercase` with letter-spacing. | warn |
333
335
  | `contract` | With the foundation installed: a core token (`--surface`, `--text`, `--accent`, `--text-on-accent`, `--font-ui`) the project never sets, so it shows the foundation's default. | warn |
334
- | `part-restyle` | With the foundation installed: a rule that restyles a foundation part where it is used (`.card { background: … }`) instead of setting its knobs on a variant. Layout properties (margin, grid placement, width, position, display…) are allowed. Ejected parts are exempt. | warn |
336
+ | `part-restyle` | With the foundation installed: a rule that restyles a foundation part where it is used (`.card { background: … }`) instead of setting its knobs on a variant. Layout properties (margin, grid placement, width, position, display…) and interaction properties (`cursor`, `user-select`, `touch-action`, `-webkit-tap-highlight-color`, `-webkit-touch-callout`, `will-change`, `overflow`, `overscroll-behavior`, `scroll-*`) are allowed. Ejected parts are exempt. | warn |
337
+ | `rules-override` | A bullet in the project's `DESIGN.md` tagged with an `{id}` from the base rules (`@rickycourtes/designrail/rules/DESIGN.md`). A project rule adds to the base under its own id; it never restates or overrides one. | error |
338
+
339
+ `check` and `audit` refuse a config that loosens a foundation rule: they
340
+ exit 2 with one line such as
341
+ `designrail.config.json: rules.unused "off" loosens a foundation rule`. See
342
+ [Configuration](#configuration).
335
343
 
336
344
  With the foundation installed, its tokens count as defined (a project's
337
345
  `var(--fill)` resolves), its parts' reads count as reads, and nothing inside
@@ -457,6 +465,8 @@ the project has no value of its own.
457
465
  | `--success` | colour | Something worked. | `#16a34a` |
458
466
  | `--warning` | colour | Careful. | `#d97706` |
459
467
  | `--focus` | colour | The keyboard focus ring. | `var(--accent)` |
468
+ | `--focus-ring` | colour | The focus outline (`none` for a glow only). | `2px solid var(--focus)` |
469
+ | `--focus-glow` | colour | A focus glow, as a box-shadow. | `none` |
460
470
  | `--font-ui` | type | Every label and paragraph. | `system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif` |
461
471
  | `--font-display` | type | Headings. | `var(--font-ui)` |
462
472
  | `--font-mono` | type | Code. | `ui-monospace, 'SF Mono', Menlo, Consolas, monospace` |
@@ -509,7 +519,10 @@ The page (`body` background, text, font), heading resets, and layout helpers:
509
519
  - `.stack`: a column with one gap (`--gap`, default `--space-12`)
510
520
  - `.row`: a wrapping line (default `--space-8`)
511
521
  - `.tight` / `.loose` change the gap; `.muted` and `.small` adjust text
512
- - a keyboard-only focus ring (`:focus-visible`)
522
+ - a keyboard-only focus mark (`:focus-visible`): `--focus-ring` as the
523
+ outline and `--focus-glow` as a box-shadow, both theme tokens
524
+ - state classes `.is-hover`, `.is-active` and `.is-focus`, honoured by every
525
+ part beside the pseudo-classes, so a specimen page can pin a state
513
526
  - motion stops under `prefers-reduced-motion`
514
527
 
515
528
  Knob: `--gap` on `.stack` and `.row`.
@@ -537,12 +550,26 @@ Knob: `--gap` on `.stack` and `.row`.
537
550
 
538
551
  | `.btn.outline` | A rim instead of a fill. |
539
552
 
540
- The height is `--control-h`. The side padding is derived from the height so
541
- it is twice the top padding (measured from the outer edge, rim included).
553
+ The height is `--control-h`, as a min-height, so a two-line option grows.
554
+ The side padding is derived from the height so it is twice the top padding
555
+ (measured from the outer edge, rim included). `aria-busy="true"` spins a ring
556
+ over the label. Disabled and `aria-disabled="true"` dim to `--btn-disabled`
557
+ with a default cursor, but still take a click, so an aria-disabled button
558
+ can say why it is off.
542
559
 
543
560
  Knobs: `--btn-h`, `--btn-line`, `--btn-radius`, `--btn-bg`, `--btn-bg-hover`,
544
561
  `--btn-bg-press`, `--btn-fg`, `--btn-fg-hover`, `--btn-rim`, `--btn-rim-w`,
545
- `--btn-font-size`, `--btn-gap`; on `.icon-btn`: `--icon-btn-size`,
562
+ `--btn-font-size`, `--btn-gap`, `--btn-pad-x` (default the derived side pad),
563
+ `--btn-pad-y` (`0`), `--btn-font` (default the composed shorthand),
564
+ `--btn-lift` (a hover filter, `none`), `--btn-press` (`scale(0.98)`),
565
+ `--btn-blur` (a backdrop-filter, `none`), `--btn-text-wrap` (`nowrap`),
566
+ `--btn-align` (`center`: justify-content), `--btn-text-align` (`center`:
567
+ text-align, for a label that wraps), `--btn-disabled` (`0.45`),
568
+ `--btn-busy-size` (`18px`), `--btn-busy-w` (`2px`), `--btn-busy-ring`
569
+ (`''`; `none` draws no ring, for a page with its own); on `.btn.small`:
570
+ `--btn-hit` (the hit area's height, `--control-h`), `--btn-hit-area` (`''`;
571
+ `none` draws none), `--btn-shadow` (a box-shadow, `none`; keyboard focus
572
+ shows `--focus-glow` instead); on `.icon-btn`: `--icon-btn-size`,
546
573
  `--icon-btn-fg`, `--icon-btn-bg-hover`, `--icon-btn-bg-press`; `--icon-size` for
547
574
  an svg inside either.
548
575
 
@@ -570,7 +597,15 @@ an svg inside either.
570
597
 
571
598
  Knobs: `--input-h`, `--input-line`, `--input-rim-w`, `--input-radius`,
572
599
  `--input-bg`, `--input-fg`, `--input-rim`, `--input-rim-hover`,
573
- `--input-rim-focus`; `--field-gap` on `.field`; `--tick` on a `.check` input.
600
+ `--input-rim-focus`, `--input-pad-y` (derived from the height),
601
+ `--input-pad-x` (`--space-12`), `--input-pad-end` (`--input-pad-x`),
602
+ `--input-bg-hover`, `--input-bg-focus` (on `:focus-within`, so a wrapper
603
+ `.input` lights with its `<input>`), `--input-shadow` (`none`),
604
+ `--input-font`, `--input-rim-style` (`solid`; `none` for a wrapper with no
605
+ rim, so a 0-width rim computes as no border), `--input-align` (align-items,
606
+ `normal`) and `--input-gap` (gap, `normal`) for a wrapper laid out as a row; `--field-gap` on `.field` (a `<fieldset>` works: its margin,
607
+ padding and border reset); `--check-gap`, `--check-pad-y`, `--check-fg`,
608
+ `--check-font`, `--check-line` on `.check`; `--tick` on a `.check` input.
574
609
 
575
610
  ### card
576
611
 
@@ -590,7 +625,10 @@ Knobs: `--input-h`, `--input-line`, `--input-rim-w`, `--input-radius`,
590
625
  column.
591
626
 
592
627
  Knobs: `--card-pad`, `--card-gap`, `--card-radius`, `--card-bg`,
593
- `--card-shadow`, `--card-rim`.
628
+ `--card-shadow`, `--card-rim`, `--card-blur` (a backdrop-filter, `none`),
629
+ `--card-fg` (`inherit`), `--card-align` and `--card-align-content`
630
+ (`normal`), `--card-type` (the whole font shorthand; `initial`, so the font
631
+ inherits).
594
632
 
595
633
  ### pill
596
634
 
@@ -606,7 +644,11 @@ Comments <span class="count">12</span>
606
644
  - `.count` is a number beside its label, with tabular figures.
607
645
 
608
646
  Knobs: `--pill-tone` (the colour it says; the tinted variants mix their
609
- background from it), `--pill-bg`, `--pill-fg`.
647
+ background from it), `--pill-bg`, `--pill-fg`, `--pill-pad-y`, `--pill-pad-x`,
648
+ `--pill-radius`, `--pill-font`, `--pill-blur` (a backdrop-filter, `none`),
649
+ `--pill-text-shadow` (`none`); on `.count`: `--count-bg`, `--count-fg`,
650
+ `--count-font`, `--count-pad-x`, `--count-h`, `--count-radius`. A
651
+ `button.pill` draws no browser border.
610
652
 
611
653
  ### dropdown
612
654
 
@@ -633,7 +675,11 @@ dropdowns(); // once; it delegates, so dropdowns added later work too
633
675
  - `[aria-checked='true']` marks the current item.
634
676
 
635
677
  Knobs: `--menu-pad`, `--menu-radius`, `--menu-bg`, `--menu-shadow`,
636
- `--menu-min-w`, `--menu-item-h`.
678
+ `--menu-min-w`, `--menu-item-h`, `--menu-gap` (between rows, `0`),
679
+ `--menu-rim` (an inside rim that takes no room, `transparent`), `--menu-fg`
680
+ (the text colour, `inherit`), `--menu-origin` (where it grows from,
681
+ `top left`; `.end` sets `top right`). A `.menu` that is a `[popover]` draws
682
+ no browser rim: its rim is `--menu-rim`.
637
683
 
638
684
  ### toast
639
685
 
@@ -647,7 +693,11 @@ const dismiss = toast('Link copied', { action: { label: 'Undo', onClick: undo },
647
693
  open).
648
694
  - The text is set with `textContent`, so a message is never parsed as HTML.
649
695
 
650
- Knobs: `--toast-bg`, `--toast-fg`, `--toast-radius`, `--toast-max-w`.
696
+ Knobs: `--toast-bg`, `--toast-fg`, `--toast-radius`, `--toast-max-w`,
697
+ `--toast-pad-y`, `--toast-pad-start`, `--toast-pad-end` (a toast ending in a
698
+ button sets it to `--space-8`), `--toast-rim`, `--toast-shadow`,
699
+ `--toast-gap`, `--toast-font` (the size), `--toast-type` (the whole font
700
+ shorthand, `initial` so the font inherits; set `--toast-font` to its size).
651
701
 
652
702
  ### sheet
653
703
 
@@ -663,15 +713,28 @@ Knobs: `--toast-bg`, `--toast-fg`, `--toast-radius`, `--toast-max-w`.
663
713
  - Built on the native `<dialog>`: `el.showModal()` gives a focus trap,
664
714
  Escape and an inert background.
665
715
  - At most 420px wide; on screens under 520px it becomes a bottom sheet that
666
- respects the safe area.
716
+ respects the safe area. That modal sizing applies to `dialog.sheet` only:
717
+ a `.sheet` on another element is placed by its page (a bottom dock, a
718
+ side panel).
667
719
 
668
720
  Knobs: `--sheet-pad`, `--sheet-gap`, `--sheet-width`, `--sheet-radius`,
669
- `--sheet-bg`.
721
+ `--sheet-bg`, `--sheet-rim`, `--sheet-rim-w`, `--sheet-shadow`,
722
+ `--sheet-blur`, `--sheet-fg`, `--sheet-border-w` (`0`) and
723
+ `--sheet-border-style` (`none`): a real border in `--sheet-rim` that can
724
+ leave sides out (`1px 0 0` is a top-only rim, for a sheet on the page's
725
+ foot; set `--sheet-rim-w: 0` beside it), `--sheet-align-content`
726
+ (`normal`). The gap applies to any sheet laid out as flex or grid, open or
727
+ not.
670
728
 
671
729
  ## Design rules
672
730
 
673
- `init` writes these to `DESIGN.md` for people and agents to follow. Each
674
- bullet is tagged `{id · how it is checked}`:
731
+ These are the base rules. They ship in the package as
732
+ `@rickycourtes/designrail/rules/DESIGN.md`, and every project on designrail
733
+ follows them as written. The `DESIGN.md` that `init` writes extends them:
734
+ it starts `Extends @rickycourtes/designrail/rules/DESIGN.md` and appends the
735
+ project's own rules under "Project rules". A project rule adds something
736
+ the base doesn't say; one that reuses a base `{id}` fails `check`
737
+ (`rules-override`). Each bullet is tagged `{id · how it is checked}`:
675
738
 
676
739
  - `check`: `designrail check` fails a change that breaks it.
677
740
  - `audit`: `designrail audit` reports it.
@@ -712,7 +775,8 @@ The rules came out of Popup's design system.
712
775
  - Focus glow for the keyboard only. `{motion.focus · eye}`
713
776
  - Motion uses the duration and easing tokens and stops under reduced motion. `{motion.tokens · eye}`
714
777
 
715
- Turn a checked rule off or down in the config's `rules`.
778
+ A project can turn a rule up, never down: `rules` can raise a `warn` to
779
+ `error`, and `check` and `audit` refuse a config that lowers one.
716
780
 
717
781
  ## Configuration
718
782
 
@@ -742,7 +806,8 @@ optional, and `schema.json` validates it.
742
806
  "unused": "warn",
743
807
  "tracked-caps": "warn",
744
808
  "contract": "warn",
745
- "part-restyle": "warn"
809
+ "part-restyle": "warn",
810
+ "rules-override": "error"
746
811
  },
747
812
  "duplicates": { "minDeclarations": 3 },
748
813
  "maxFileBytes": 1500000
@@ -764,10 +829,18 @@ optional, and `schema.json` validates it.
764
829
  | `semanticOnly` | Report primitives read outside token files, and keep `fix` from writing them there. |
765
830
  | `allowPrimitives` | Primitive prefixes allowed anywhere. |
766
831
  | `runtimeTokens` | Custom properties set from JS, as names or prefixes, so they count as defined. Calls like `setProperty('--x', …)` are found on their own. |
767
- | `rules` | `error`, `warn` or `off` per check rule. |
832
+ | `rules` | `error`, `warn` or `off` per check rule. A level may only rise above its default (`warn` → `error`). |
768
833
  | `duplicates.minDeclarations` | How many declarations rule blocks must share to count as identical or near duplicates (default 3, at least 2). At 2, state rules (`:hover`, `:focus`…) still need 3. |
769
834
  | `maxFileBytes` | Larger files are skipped. |
770
835
 
836
+ The foundation's rules are the floor. `check` and `audit` exit 2, naming
837
+ each key, when the config loosens one:
838
+
839
+ - a `rules` level below its default (`"unused": "off"`, `"hardcoded": "warn"`),
840
+ - `semanticOnly: false`,
841
+ - an `allowPrimitives` entry outside the default three,
842
+ - `duplicates.minDeclarations` above 3.
843
+
771
844
  To exempt a single declaration, put `/* designrail-ignore */` (or
772
845
  `/* measured */`) inside its value, before the `;`, for example
773
846
  `margin-top: -3px /* measured */;`. It is then left out of the hardcoded,
@@ -779,7 +852,7 @@ scale and duplicate counts, and `fix` leaves it alone.
779
852
  | --- | --- |
780
853
  | `.css`, `.scss`, `.less`, `.pcss` | Rules, native/SCSS/Less nesting with `&`, `@media`/`@container`/`@supports`/`@layer`. `@keyframes` and `@font-face` contents are not counted as usage. |
781
854
  | `.html`, `.vue`, `.svelte`, `.astro` | `<style>` blocks (`lang="scss"` too), `style=""` attributes, `<script>` contents, and the markup. |
782
- | `.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs` | `css`` `, `styled.x`` `, `styled(X)`` `, `createGlobalStyle`, `keyframes`; `style={{…}}`, `sx={{…}}`, `Object.assign(el.style, {…})` and `el.style.prop = '…'` (known CSS properties only, so config objects stay out); JSX markup; `var(--x)` reads and `setProperty('--x')` writes. |
855
+ | `.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs` | `css`` `, `styled.x`` `, `styled(X)`` `, `createGlobalStyle`, `keyframes`; `style={{…}}`, `sx={{…}}`, `Object.assign(el.style, {…})` and `el.style.prop = '…'` (known CSS properties only, so config objects stay out); JSX markup; `var(--x)` reads, quoted names read by script (`getPropertyValue('--x')`, `tok('--x')`, which count as reads for `unused` and are never `unresolved`), and `setProperty('--x')` writes. |
783
856
  | Class strings anywhere | Tailwind arbitrary values: `p-[13px]`, `bg-[#fafafa]`, `rounded-[10px]`, `text-[15px]`/`text-[#333]`, `shadow-[…]`, `z-[…]` and the rest. |
784
857
 
785
858
  Values are recognised in every notation:
@@ -816,7 +889,9 @@ baseline in git; there is no baseline file to maintain.
816
889
 
817
890
  `designrail init --agents` adds this to `CLAUDE.md` or `AGENTS.md`:
818
891
 
819
- > Before touching UI, read `DESIGN.md`. Build from the parts in `ui/` and the
892
+ > Before touching UI, read both rule files: designrail's base rules
893
+ > (`node_modules/@rickycourtes/designrail/rules/DESIGN.md`) and this
894
+ > project's `DESIGN.md`, which extends them. Build from the parts in `ui/` and the
820
895
  > tokens in the token files, on top of the designrail foundation
821
896
  > (`@rickycourtes/designrail/foundation.css`). Restyle a foundation part with its knobs on a
822
897
  > variant, never by editing it; never type a colour, spacing, radius or font
package/kit/changes.json CHANGED
@@ -3,28 +3,171 @@
3
3
  "version": "0.1.0",
4
4
  "notes": "First kit: tokens, base, button, field, card, pill, dropdown, toast, sheet.",
5
5
  "renamed": {},
6
- "added": { "tokens": [], "parts": ["base", "button", "field", "card", "pill", "dropdown", "toast", "sheet"] },
7
- "removed": { "tokens": [], "parts": [] }
6
+ "added": {
7
+ "tokens": [],
8
+ "parts": [
9
+ "base",
10
+ "button",
11
+ "field",
12
+ "card",
13
+ "pill",
14
+ "dropdown",
15
+ "toast",
16
+ "sheet"
17
+ ]
18
+ },
19
+ "removed": {
20
+ "tokens": [],
21
+ "parts": []
22
+ }
8
23
  },
9
24
  {
10
25
  "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`.",
26
+ "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\u2026) to restyle it without editing it. .btn.outline is new. `add` is now `eject`.",
12
27
  "renamed": {},
13
- "added": { "tokens": [], "parts": [], "classes": [".btn.outline"] },
14
- "removed": { "tokens": [], "parts": [] }
28
+ "added": {
29
+ "tokens": [],
30
+ "parts": [],
31
+ "classes": [
32
+ ".btn.outline"
33
+ ]
34
+ },
35
+ "removed": {
36
+ "tokens": [],
37
+ "parts": []
38
+ }
15
39
  },
16
40
  {
17
41
  "version": "0.2.1",
18
42
  "notes": "No foundation changes. Releases now publish through npm trusted publishing with provenance.",
19
43
  "renamed": {},
20
- "added": { "tokens": [], "parts": [], "classes": [] },
21
- "removed": { "tokens": [], "parts": [] }
44
+ "added": {
45
+ "tokens": [],
46
+ "parts": [],
47
+ "classes": []
48
+ },
49
+ "removed": {
50
+ "tokens": [],
51
+ "parts": []
52
+ }
22
53
  },
23
54
  {
24
55
  "version": "0.2.2",
25
56
  "notes": "No foundation changes. Audit and fix: exemption comments work, part families by file, a specimens config key, vendor-prefixed rules and blocks under duplicates.minDeclarations (3) are not duplicates, and fix never writes a primitive or a token from another scale.",
26
57
  "renamed": {},
27
- "added": { "tokens": [], "parts": [], "classes": [] },
28
- "removed": { "tokens": [], "parts": [] }
58
+ "added": {
59
+ "tokens": [],
60
+ "parts": [],
61
+ "classes": []
62
+ },
63
+ "removed": {
64
+ "tokens": [],
65
+ "parts": []
66
+ }
67
+ },
68
+ {
69
+ "version": "0.3.0",
70
+ "notes": "Rules extend, never loosen: the base design rules ship as @rickycourtes/designrail/rules/DESIGN.md and a project's DESIGN.md extends them (check: rules-override); check and audit refuse a config that turns a rule down. New knobs so a project can reproduce its look on the kit: focus tokens, button pads, font, lift, press, blur, wrap, align, busy, its ring, shadow, the small hit area and disabled; field pads, fills, shadow, rim style, alignment and gap; card blur, colour, alignment and font; pill and count shape, pill blur and text shadow (a button.pill drops its browser border); menu gap, rim, colour and origin; toast pads, rim, shadow, gap, font size and font; sheet rim (a ring or a top-only border), shadow, blur, colour and row packing (its gap applies closed too). .is-hover, .is-active and .is-focus pin a state. The button sets appearance: none and its height is a min-height, disabled buttons still take a click, and only dialog.sheet is sized as a modal.",
71
+ "renamed": {},
72
+ "added": {
73
+ "tokens": [
74
+ "--focus-ring",
75
+ "--focus-glow"
76
+ ],
77
+ "parts": [],
78
+ "classes": [
79
+ ".is-hover",
80
+ ".is-active",
81
+ ".is-focus"
82
+ ],
83
+ "knobs": {
84
+ "button": [
85
+ "--btn-pad-x",
86
+ "--btn-pad-y",
87
+ "--btn-font",
88
+ "--btn-lift",
89
+ "--btn-press",
90
+ "--btn-blur",
91
+ "--btn-text-wrap",
92
+ "--btn-align",
93
+ "--btn-disabled",
94
+ "--btn-busy-size",
95
+ "--btn-busy-w",
96
+ "--btn-text-align",
97
+ "--btn-busy-ring",
98
+ "--btn-hit",
99
+ "--btn-hit-area",
100
+ "--btn-shadow"
101
+ ],
102
+ "field": [
103
+ "--input-pad-y",
104
+ "--input-pad-x",
105
+ "--input-pad-end",
106
+ "--input-bg-hover",
107
+ "--input-bg-focus",
108
+ "--input-shadow",
109
+ "--input-font",
110
+ "--check-gap",
111
+ "--check-pad-y",
112
+ "--check-fg",
113
+ "--check-font",
114
+ "--check-line",
115
+ "--input-rim-style",
116
+ "--input-align",
117
+ "--input-gap"
118
+ ],
119
+ "card": [
120
+ "--card-blur",
121
+ "--card-fg",
122
+ "--card-align",
123
+ "--card-align-content",
124
+ "--card-type"
125
+ ],
126
+ "pill": [
127
+ "--pill-pad-y",
128
+ "--pill-pad-x",
129
+ "--pill-radius",
130
+ "--pill-font",
131
+ "--count-bg",
132
+ "--count-fg",
133
+ "--count-font",
134
+ "--count-pad-x",
135
+ "--count-h",
136
+ "--count-radius",
137
+ "--pill-blur",
138
+ "--pill-text-shadow"
139
+ ],
140
+ "dropdown": [
141
+ "--menu-gap",
142
+ "--menu-rim",
143
+ "--menu-fg",
144
+ "--menu-origin"
145
+ ],
146
+ "toast": [
147
+ "--toast-pad-y",
148
+ "--toast-pad-start",
149
+ "--toast-pad-end",
150
+ "--toast-rim",
151
+ "--toast-shadow",
152
+ "--toast-gap",
153
+ "--toast-font",
154
+ "--toast-type"
155
+ ],
156
+ "sheet": [
157
+ "--sheet-rim",
158
+ "--sheet-rim-w",
159
+ "--sheet-shadow",
160
+ "--sheet-blur",
161
+ "--sheet-fg",
162
+ "--sheet-border-w",
163
+ "--sheet-border-style",
164
+ "--sheet-align-content"
165
+ ]
166
+ }
167
+ },
168
+ "removed": {
169
+ "tokens": [],
170
+ "parts": []
171
+ }
29
172
  }
30
173
  ]
@@ -1,7 +1,11 @@
1
1
  /* base: the page and layout helpers every part assumes.
2
2
  Siblings get their gap from the container, never a margin of their own.
3
3
  .stack (a column) and .row (a wrapping line) take --gap; .tight and .loose
4
- step it. .muted and .small adjust text. */
4
+ step it. .muted and .small adjust text.
5
+ Focus reads --focus-ring (an outline, default 2px solid var(--focus)) and
6
+ --focus-glow (a box-shadow, default none), both set in the theme.
7
+ State classes: every part honours .is-hover, .is-active and .is-focus
8
+ beside :hover, :active and :focus-visible, so a specimen can pin a state. */
5
9
 
6
10
  @layer designrail.base {
7
11
  *, *::before, *::after { box-sizing: border-box; }
@@ -26,7 +30,7 @@
26
30
 
27
31
  /* Keyboard focus only: a pointer press never lights a ring. */
28
32
  :focus:not(:focus-visible) { outline: none; }
29
- :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
33
+ :focus-visible, .is-focus { outline: var(--focus-ring); outline-offset: 2px; box-shadow: var(--focus-glow); }
30
34
 
31
35
  @media (prefers-reduced-motion: reduce) {
32
36
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
@@ -11,6 +11,22 @@
11
11
  Knobs (set them on a variant of your own, never restyle .btn where it is used):
12
12
  --btn-h --btn-line --btn-radius --btn-bg --btn-bg-hover --btn-bg-press
13
13
  --btn-fg --btn-fg-hover --btn-rim --btn-rim-w --btn-font-size --btn-gap
14
+ --btn-pad-x (side pad; default derived from the height) --btn-pad-y (0)
15
+ --btn-font (the font shorthand; default composed from --weight-strong,
16
+ --btn-font-size, --btn-line, --font-ui) --btn-lift (a filter on hover,
17
+ none) --btn-press (the press transform, scale(0.98)) --btn-blur (a
18
+ backdrop-filter, none) --btn-text-wrap (nowrap) --btn-align (center:
19
+ justify-content) --btn-text-align (center: text-align, for a label that
20
+ wraps) --btn-disabled (opacity, 0.45)
21
+ --btn-busy-size (18px) --btn-busy-w (2px): aria-busy='true' spins a ring;
22
+ --btn-busy-ring ('' draws it, none draws none: a page with its own)
23
+ --btn-shadow (a box-shadow, none; keyboard focus shows --focus-glow
24
+ instead).
25
+ .btn.small: --btn-hit (the hit area's height, --control-h) --btn-hit-area
26
+ ('' draws it, none draws none).
27
+ The height is a min-height, so a two-line option grows. Disabled and
28
+ aria-disabled stay clickable to script (no pointer-events: none), so an
29
+ aria-disabled button can still explain itself on click.
14
30
  The side pad is twice the top pad, derived from the height, so a label
15
31
  never sits closer to a side than to the top. */
16
32
 
@@ -28,36 +44,72 @@
28
44
  --btn-rim-w: 1px;
29
45
  --btn-font-size: var(--font-size-body);
30
46
  --btn-gap: var(--space-6);
47
+ --btn-pad-x: calc(var(--btn-h) - var(--btn-line) - var(--btn-rim-w));
48
+ --btn-pad-y: 0px;
49
+ --btn-font: var(--weight-strong) var(--btn-font-size) / var(--btn-line) var(--font-ui);
50
+ --btn-lift: none;
51
+ --btn-press: scale(0.98);
52
+ --btn-blur: none;
53
+ --btn-text-wrap: nowrap;
54
+ --btn-align: center;
55
+ --btn-text-align: center;
56
+ --btn-disabled: 0.45;
57
+ --btn-busy-size: 18px;
58
+ --btn-busy-w: 2px;
59
+ --btn-busy-ring: '';
60
+ --btn-shadow: none;
31
61
  position: relative;
32
62
  display: inline-flex;
33
63
  align-items: center;
34
- justify-content: center;
64
+ justify-content: var(--btn-align);
35
65
  gap: var(--btn-gap);
36
66
  box-sizing: border-box;
37
- height: var(--btn-h);
38
- padding: 0 calc(var(--btn-h) - var(--btn-line) - var(--btn-rim-w));
67
+ appearance: none;
68
+ min-height: var(--btn-h);
69
+ padding: var(--btn-pad-y) var(--btn-pad-x);
39
70
  border: var(--btn-rim-w) solid var(--btn-rim);
40
71
  border-radius: var(--btn-radius);
41
72
  background: var(--btn-bg);
73
+ box-shadow: var(--btn-shadow);
42
74
  color: var(--btn-fg);
43
- font: var(--weight-strong) var(--btn-font-size) / var(--btn-line) var(--font-ui);
75
+ font: var(--btn-font);
76
+ text-align: var(--btn-text-align);
44
77
  text-decoration: none;
45
- white-space: nowrap;
78
+ white-space: var(--btn-text-wrap);
79
+ -webkit-backdrop-filter: var(--btn-blur);
80
+ backdrop-filter: var(--btn-blur);
46
81
  cursor: pointer;
47
82
  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);
83
+ transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out), filter var(--duration-fast) var(--ease-out);
49
84
  }
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; }
85
+ .btn:hover, .btn.is-hover { background: var(--btn-bg-hover); color: var(--btn-fg-hover); filter: var(--btn-lift); }
86
+ .btn:active, .btn.is-active { background: var(--btn-bg-press); transform: var(--btn-press); }
87
+ .btn:focus-visible, .btn.is-focus { box-shadow: var(--focus-glow); }
88
+ .btn:disabled, .btn[aria-disabled='true'] { opacity: var(--btn-disabled); cursor: default; }
89
+ .btn:disabled:is(:hover, :active, .is-hover, .is-active), .btn[aria-disabled='true']:is(:hover, :active, .is-hover, .is-active) { background: var(--btn-bg); color: var(--btn-fg); filter: none; transform: none; }
90
+ /* Busy: the label stays for its width, a ring turns over it. */
91
+ .btn[aria-busy='true'] { color: transparent; cursor: progress; }
92
+ .btn[aria-busy='true']::before {
93
+ content: var(--btn-busy-ring);
94
+ position: absolute;
95
+ inset: 0;
96
+ margin: auto;
97
+ width: var(--btn-busy-size);
98
+ height: var(--btn-busy-size);
99
+ border: var(--btn-busy-w) solid var(--btn-fg);
100
+ border-right-color: transparent;
101
+ border-radius: var(--radius-full);
102
+ animation: designrail-spin 0.8s linear infinite;
103
+ }
104
+ @keyframes designrail-spin { to { transform: rotate(1turn); } }
53
105
 
54
106
  .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
107
  .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
108
  .btn.outline { --btn-bg: transparent; --btn-rim: var(--border-strong); }
57
109
  .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); }
110
+ .btn.small { --btn-h: 32px; --btn-line: 16px; --btn-font-size: var(--font-size-small); --btn-hit: var(--control-h); --btn-hit-area: ''; }
59
111
  /* 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; }
112
+ .btn.small::after { content: var(--btn-hit-area); position: absolute; inset: calc((var(--btn-h) - var(--btn-hit)) / 2) 0; }
61
113
 
62
114
  .btn > svg, .icon-btn > svg { width: var(--icon-size, 18px); height: var(--icon-size, 18px); flex: none; }
63
115
 
@@ -80,6 +132,6 @@
80
132
  cursor: pointer;
81
133
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
82
134
  }
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); }
135
+ .icon-btn:hover, .icon-btn.is-hover { background: var(--icon-btn-bg-hover); color: var(--text); }
136
+ .icon-btn:active, .icon-btn.is-active, .icon-btn[aria-pressed='true'] { background: var(--icon-btn-bg-press); color: var(--text); }
85
137
  }