@rickycourtes/designrail 0.2.2 → 0.3.1
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 +74 -0
- package/README.md +100 -23
- package/kit/changes.json +165 -9
- package/kit/parts/base.css +6 -2
- package/kit/parts/button.css +65 -13
- package/kit/parts/card.css +16 -1
- package/kit/parts/dropdown.css +16 -5
- package/kit/parts/field.css +48 -9
- package/kit/parts/pill.css +35 -11
- package/kit/parts/sheet.css +36 -9
- package/kit/parts/toast.css +22 -6
- package/kit/tokens.css +3 -0
- package/package.json +2 -1
- package/rules/DESIGN.md +7 -2
- package/schema.json +2 -1
- package/src/check.js +45 -4
- package/src/cli.js +7 -0
- package/src/contract.js +2 -0
- package/src/init.js +20 -3
- package/src/model.js +2 -2
- package/src/project.js +25 -1
- package/src/sources.js +7 -1
- package/src/tokens.js +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,80 @@
|
|
|
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.1
|
|
7
|
+
|
|
8
|
+
- README: a screenshot of the kit in the default theme and a five-token theme. No changes to the foundation.
|
|
9
|
+
|
|
10
|
+
## 0.3.0
|
|
11
|
+
|
|
12
|
+
A minor release: a config that turns a rule down now stops `check` and
|
|
13
|
+
`audit`, which a patch must not do.
|
|
14
|
+
|
|
15
|
+
**Rules extend, never override**
|
|
16
|
+
- The base design rules ship in the package and are exported as
|
|
17
|
+
`@rickycourtes/designrail/rules/DESIGN.md`. `init` writes a project
|
|
18
|
+
`DESIGN.md` that starts `Extends @rickycourtes/designrail/rules/DESIGN.md`
|
|
19
|
+
with an empty "Project rules" section, and the `--agents` note says to read
|
|
20
|
+
both.
|
|
21
|
+
- New `check` rule `rules-override` (error): a bullet in the project's
|
|
22
|
+
`DESIGN.md` tagged with a base `{id}`. A project written by an earlier
|
|
23
|
+
`init` holds a copy of the base: run `designrail init --force` or delete
|
|
24
|
+
the copied bullets.
|
|
25
|
+
- `check` and `audit` exit 2 on a config that loosens a foundation rule: a
|
|
26
|
+
`rules` level below its default, `semanticOnly: false`, an
|
|
27
|
+
`allowPrimitives` entry outside the default, or
|
|
28
|
+
`duplicates.minDeclarations` above 3. Raising a level stays allowed.
|
|
29
|
+
|
|
30
|
+
**False hits found on a real app**
|
|
31
|
+
- A quoted name read by script (`getPropertyValue('--x')`, `tok('--x')`)
|
|
32
|
+
counts as a read, so the token is not `unused`.
|
|
33
|
+
- With a token file named for primitives, only its literals (and the
|
|
34
|
+
foundation's) are primitives: a literal in the semantic file that other
|
|
35
|
+
tokens compose is API, not `primitive-direct`.
|
|
36
|
+
- `part-restyle` lets interaction properties through: `cursor`,
|
|
37
|
+
`user-select`, `touch-action`, `-webkit-tap-highlight-color`,
|
|
38
|
+
`-webkit-touch-callout`, `will-change`, `overflow`,
|
|
39
|
+
`overscroll-behavior` and `scroll-*`.
|
|
40
|
+
- `part-restyle` reads only the selector's subject: a part class inside
|
|
41
|
+
`:has()` or `:not()` is a condition, so `.segment:has(> .btn.glass)` no
|
|
42
|
+
longer counts as restyling `.btn`.
|
|
43
|
+
|
|
44
|
+
**Foundation: new knobs, same look**
|
|
45
|
+
- Tokens `--focus-ring` (`2px solid var(--focus)`) and `--focus-glow`
|
|
46
|
+
(`none`) draw `:focus-visible`. Every part honours `.is-hover`,
|
|
47
|
+
`.is-active` and `.is-focus`, so a specimen can pin a state.
|
|
48
|
+
- button: `--btn-pad-x`, `--btn-pad-y`, `--btn-font`, `--btn-lift`,
|
|
49
|
+
`--btn-press`, `--btn-blur`, `--btn-text-wrap`, `--btn-align`
|
|
50
|
+
(justify-content), `--btn-text-align`, `--btn-disabled`, an `aria-busy`
|
|
51
|
+
ring (`--btn-busy-size`, `--btn-busy-w`, `--btn-busy-ring: none` turns it
|
|
52
|
+
off), `--btn-shadow`; `.btn.small`'s hit area: `--btn-hit`, `--btn-hit-area: none` turns it
|
|
53
|
+
off.
|
|
54
|
+
`.btn` sets `appearance: none`, so a `<button>` keeps no browser style.
|
|
55
|
+
The height is a `min-height`, and a disabled button keeps
|
|
56
|
+
`pointer-events`, so `aria-disabled` still takes a click.
|
|
57
|
+
- field: `--input-pad-y`, `--input-pad-x`, `--input-pad-end`,
|
|
58
|
+
`--input-bg-hover`, `--input-bg-focus` (on `:focus-within`),
|
|
59
|
+
`--input-shadow`, `--input-font`, `--input-rim-style`, `--input-align`,
|
|
60
|
+
`--input-gap`; `.field` resets a fieldset and its
|
|
61
|
+
column can shrink; `.check`: `--check-gap`, `--check-pad-y`,
|
|
62
|
+
`--check-fg`, `--check-font`, `--check-line`.
|
|
63
|
+
- card: `--card-blur`, `--card-fg`, `--card-align`, `--card-align-content`,
|
|
64
|
+
`--card-type` (the whole font shorthand). pill: `--pill-pad-y`, `--pill-pad-x`,
|
|
65
|
+
`--pill-radius`, `--pill-font`, `--pill-blur`, `--pill-text-shadow`,
|
|
66
|
+
centred content, no browser border on a
|
|
67
|
+
`button.pill`; `.count`: `--count-bg`,
|
|
68
|
+
`--count-fg`, `--count-font`, `--count-pad-x`, `--count-h`,
|
|
69
|
+
`--count-radius`.
|
|
70
|
+
- dropdown: `--menu-gap`, `--menu-rim`, `--menu-fg`, `--menu-origin`; a
|
|
71
|
+
`[popover]` menu draws no browser rim. toast: `--toast-pad-y`,
|
|
72
|
+
`--toast-pad-start`, `--toast-pad-end`, `--toast-rim`, `--toast-shadow`,
|
|
73
|
+
`--toast-gap`, `--toast-font`, `--toast-type` (the whole font shorthand).
|
|
74
|
+
sheet: `--sheet-rim`, `--sheet-rim-w`,
|
|
75
|
+
`--sheet-shadow`, `--sheet-blur`, `--sheet-fg`, `--sheet-border-w` and
|
|
76
|
+
`--sheet-border-style` (a real border that can be top-only),
|
|
77
|
+
`--sheet-align-content`; the sheet's gap no longer waits for `[open]`; modal sizing applies to
|
|
78
|
+
`dialog.sheet` only, so a docked `.sheet` is placed by its page.
|
|
79
|
+
|
|
6
80
|
## 0.2.2
|
|
7
81
|
|
|
8
82
|
No foundation changes. Five gaps found by auditing a real project:
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# designrail
|
|
1
|
+
# <sup><img src="assets/icon.svg" width="48" height="48" alt="" align="texttop"></sup> designrail
|
|
2
2
|
|
|
3
3
|
The design foundation for any web project. Every project installs it and
|
|
4
4
|
builds on top of it, and one update to designrail reaches all of them.
|
|
5
5
|
|
|
6
|
+
<img src="assets/screenshot.jpg" alt="Screenshot of designrail" width="720">
|
|
7
|
+
|
|
6
8
|
designrail has two halves:
|
|
7
9
|
|
|
8
10
|
- **The foundation**: a set of token names (the contract), a default theme,
|
|
@@ -163,8 +165,10 @@ An unknown flag exits with code 2 and an error, rather than being guessed at.
|
|
|
163
165
|
|
|
164
166
|
### `init [dir] [--agents] [--force]`
|
|
165
167
|
|
|
166
|
-
Writes `designrail.config.json` and `DESIGN.md`, the project's design rules
|
|
167
|
-
|
|
168
|
+
Writes `designrail.config.json` and `DESIGN.md`, the project's design rules.
|
|
169
|
+
That `DESIGN.md` starts `Extends @rickycourtes/designrail/rules/DESIGN.md`
|
|
170
|
+
and holds an empty "Project rules" section: the base rules ship in the
|
|
171
|
+
package and the project only appends (see [Design rules](#design-rules)). If the project already has token files
|
|
168
172
|
(stylesheets that are mostly custom properties on `:root`), `init` finds them
|
|
169
173
|
and points `tokens` at them. `parts` is set to `src/ui` when there is a `src/`
|
|
170
174
|
folder, else `ui`. A page `designrail specimens` wrote (wherever `--out` put
|
|
@@ -326,12 +330,18 @@ The drift gate. It exits 1 if any rule set to `error` has a hit.
|
|
|
326
330
|
| --- | --- | --- |
|
|
327
331
|
| `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
332
|
| `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 |
|
|
333
|
+
| `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
334
|
| `duplicate-block` | A rule block identical to another one, at `duplicates.minDeclarations` (3) declarations or more. | error |
|
|
331
335
|
| `unused` | A token nobody reads (contract names are exempt: they are the parts' API). | warn |
|
|
332
336
|
| `tracked-caps` | `text-transform: uppercase` with letter-spacing. | warn |
|
|
333
337
|
| `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 |
|
|
338
|
+
| `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 |
|
|
339
|
+
| `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 |
|
|
340
|
+
|
|
341
|
+
`check` and `audit` refuse a config that loosens a foundation rule: they
|
|
342
|
+
exit 2 with one line such as
|
|
343
|
+
`designrail.config.json: rules.unused "off" loosens a foundation rule`. See
|
|
344
|
+
[Configuration](#configuration).
|
|
335
345
|
|
|
336
346
|
With the foundation installed, its tokens count as defined (a project's
|
|
337
347
|
`var(--fill)` resolves), its parts' reads count as reads, and nothing inside
|
|
@@ -457,6 +467,8 @@ the project has no value of its own.
|
|
|
457
467
|
| `--success` | colour | Something worked. | `#16a34a` |
|
|
458
468
|
| `--warning` | colour | Careful. | `#d97706` |
|
|
459
469
|
| `--focus` | colour | The keyboard focus ring. | `var(--accent)` |
|
|
470
|
+
| `--focus-ring` | colour | The focus outline (`none` for a glow only). | `2px solid var(--focus)` |
|
|
471
|
+
| `--focus-glow` | colour | A focus glow, as a box-shadow. | `none` |
|
|
460
472
|
| `--font-ui` | type | Every label and paragraph. | `system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif` |
|
|
461
473
|
| `--font-display` | type | Headings. | `var(--font-ui)` |
|
|
462
474
|
| `--font-mono` | type | Code. | `ui-monospace, 'SF Mono', Menlo, Consolas, monospace` |
|
|
@@ -509,7 +521,10 @@ The page (`body` background, text, font), heading resets, and layout helpers:
|
|
|
509
521
|
- `.stack`: a column with one gap (`--gap`, default `--space-12`)
|
|
510
522
|
- `.row`: a wrapping line (default `--space-8`)
|
|
511
523
|
- `.tight` / `.loose` change the gap; `.muted` and `.small` adjust text
|
|
512
|
-
- a keyboard-only focus
|
|
524
|
+
- a keyboard-only focus mark (`:focus-visible`): `--focus-ring` as the
|
|
525
|
+
outline and `--focus-glow` as a box-shadow, both theme tokens
|
|
526
|
+
- state classes `.is-hover`, `.is-active` and `.is-focus`, honoured by every
|
|
527
|
+
part beside the pseudo-classes, so a specimen page can pin a state
|
|
513
528
|
- motion stops under `prefers-reduced-motion`
|
|
514
529
|
|
|
515
530
|
Knob: `--gap` on `.stack` and `.row`.
|
|
@@ -537,12 +552,26 @@ Knob: `--gap` on `.stack` and `.row`.
|
|
|
537
552
|
|
|
538
553
|
| `.btn.outline` | A rim instead of a fill. |
|
|
539
554
|
|
|
540
|
-
The height is `--control-h
|
|
541
|
-
|
|
555
|
+
The height is `--control-h`, as a min-height, so a two-line option grows.
|
|
556
|
+
The side padding is derived from the height so it is twice the top padding
|
|
557
|
+
(measured from the outer edge, rim included). `aria-busy="true"` spins a ring
|
|
558
|
+
over the label. Disabled and `aria-disabled="true"` dim to `--btn-disabled`
|
|
559
|
+
with a default cursor, but still take a click, so an aria-disabled button
|
|
560
|
+
can say why it is off.
|
|
542
561
|
|
|
543
562
|
Knobs: `--btn-h`, `--btn-line`, `--btn-radius`, `--btn-bg`, `--btn-bg-hover`,
|
|
544
563
|
`--btn-bg-press`, `--btn-fg`, `--btn-fg-hover`, `--btn-rim`, `--btn-rim-w`,
|
|
545
|
-
`--btn-font-size`, `--btn-gap
|
|
564
|
+
`--btn-font-size`, `--btn-gap`, `--btn-pad-x` (default the derived side pad),
|
|
565
|
+
`--btn-pad-y` (`0`), `--btn-font` (default the composed shorthand),
|
|
566
|
+
`--btn-lift` (a hover filter, `none`), `--btn-press` (`scale(0.98)`),
|
|
567
|
+
`--btn-blur` (a backdrop-filter, `none`), `--btn-text-wrap` (`nowrap`),
|
|
568
|
+
`--btn-align` (`center`: justify-content), `--btn-text-align` (`center`:
|
|
569
|
+
text-align, for a label that wraps), `--btn-disabled` (`0.45`),
|
|
570
|
+
`--btn-busy-size` (`18px`), `--btn-busy-w` (`2px`), `--btn-busy-ring`
|
|
571
|
+
(`''`; `none` draws no ring, for a page with its own); on `.btn.small`:
|
|
572
|
+
`--btn-hit` (the hit area's height, `--control-h`), `--btn-hit-area` (`''`;
|
|
573
|
+
`none` draws none), `--btn-shadow` (a box-shadow, `none`; keyboard focus
|
|
574
|
+
shows `--focus-glow` instead); on `.icon-btn`: `--icon-btn-size`,
|
|
546
575
|
`--icon-btn-fg`, `--icon-btn-bg-hover`, `--icon-btn-bg-press`; `--icon-size` for
|
|
547
576
|
an svg inside either.
|
|
548
577
|
|
|
@@ -570,7 +599,15 @@ an svg inside either.
|
|
|
570
599
|
|
|
571
600
|
Knobs: `--input-h`, `--input-line`, `--input-rim-w`, `--input-radius`,
|
|
572
601
|
`--input-bg`, `--input-fg`, `--input-rim`, `--input-rim-hover`,
|
|
573
|
-
`--input-rim-focus
|
|
602
|
+
`--input-rim-focus`, `--input-pad-y` (derived from the height),
|
|
603
|
+
`--input-pad-x` (`--space-12`), `--input-pad-end` (`--input-pad-x`),
|
|
604
|
+
`--input-bg-hover`, `--input-bg-focus` (on `:focus-within`, so a wrapper
|
|
605
|
+
`.input` lights with its `<input>`), `--input-shadow` (`none`),
|
|
606
|
+
`--input-font`, `--input-rim-style` (`solid`; `none` for a wrapper with no
|
|
607
|
+
rim, so a 0-width rim computes as no border), `--input-align` (align-items,
|
|
608
|
+
`normal`) and `--input-gap` (gap, `normal`) for a wrapper laid out as a row; `--field-gap` on `.field` (a `<fieldset>` works: its margin,
|
|
609
|
+
padding and border reset); `--check-gap`, `--check-pad-y`, `--check-fg`,
|
|
610
|
+
`--check-font`, `--check-line` on `.check`; `--tick` on a `.check` input.
|
|
574
611
|
|
|
575
612
|
### card
|
|
576
613
|
|
|
@@ -590,7 +627,10 @@ Knobs: `--input-h`, `--input-line`, `--input-rim-w`, `--input-radius`,
|
|
|
590
627
|
column.
|
|
591
628
|
|
|
592
629
|
Knobs: `--card-pad`, `--card-gap`, `--card-radius`, `--card-bg`,
|
|
593
|
-
`--card-shadow`, `--card-rim
|
|
630
|
+
`--card-shadow`, `--card-rim`, `--card-blur` (a backdrop-filter, `none`),
|
|
631
|
+
`--card-fg` (`inherit`), `--card-align` and `--card-align-content`
|
|
632
|
+
(`normal`), `--card-type` (the whole font shorthand; `initial`, so the font
|
|
633
|
+
inherits).
|
|
594
634
|
|
|
595
635
|
### pill
|
|
596
636
|
|
|
@@ -606,7 +646,11 @@ Comments <span class="count">12</span>
|
|
|
606
646
|
- `.count` is a number beside its label, with tabular figures.
|
|
607
647
|
|
|
608
648
|
Knobs: `--pill-tone` (the colour it says; the tinted variants mix their
|
|
609
|
-
background from it), `--pill-bg`, `--pill-fg
|
|
649
|
+
background from it), `--pill-bg`, `--pill-fg`, `--pill-pad-y`, `--pill-pad-x`,
|
|
650
|
+
`--pill-radius`, `--pill-font`, `--pill-blur` (a backdrop-filter, `none`),
|
|
651
|
+
`--pill-text-shadow` (`none`); on `.count`: `--count-bg`, `--count-fg`,
|
|
652
|
+
`--count-font`, `--count-pad-x`, `--count-h`, `--count-radius`. A
|
|
653
|
+
`button.pill` draws no browser border.
|
|
610
654
|
|
|
611
655
|
### dropdown
|
|
612
656
|
|
|
@@ -633,7 +677,11 @@ dropdowns(); // once; it delegates, so dropdowns added later work too
|
|
|
633
677
|
- `[aria-checked='true']` marks the current item.
|
|
634
678
|
|
|
635
679
|
Knobs: `--menu-pad`, `--menu-radius`, `--menu-bg`, `--menu-shadow`,
|
|
636
|
-
`--menu-min-w`, `--menu-item-h
|
|
680
|
+
`--menu-min-w`, `--menu-item-h`, `--menu-gap` (between rows, `0`),
|
|
681
|
+
`--menu-rim` (an inside rim that takes no room, `transparent`), `--menu-fg`
|
|
682
|
+
(the text colour, `inherit`), `--menu-origin` (where it grows from,
|
|
683
|
+
`top left`; `.end` sets `top right`). A `.menu` that is a `[popover]` draws
|
|
684
|
+
no browser rim: its rim is `--menu-rim`.
|
|
637
685
|
|
|
638
686
|
### toast
|
|
639
687
|
|
|
@@ -647,7 +695,11 @@ const dismiss = toast('Link copied', { action: { label: 'Undo', onClick: undo },
|
|
|
647
695
|
open).
|
|
648
696
|
- The text is set with `textContent`, so a message is never parsed as HTML.
|
|
649
697
|
|
|
650
|
-
Knobs: `--toast-bg`, `--toast-fg`, `--toast-radius`, `--toast-max-w
|
|
698
|
+
Knobs: `--toast-bg`, `--toast-fg`, `--toast-radius`, `--toast-max-w`,
|
|
699
|
+
`--toast-pad-y`, `--toast-pad-start`, `--toast-pad-end` (a toast ending in a
|
|
700
|
+
button sets it to `--space-8`), `--toast-rim`, `--toast-shadow`,
|
|
701
|
+
`--toast-gap`, `--toast-font` (the size), `--toast-type` (the whole font
|
|
702
|
+
shorthand, `initial` so the font inherits; set `--toast-font` to its size).
|
|
651
703
|
|
|
652
704
|
### sheet
|
|
653
705
|
|
|
@@ -663,15 +715,28 @@ Knobs: `--toast-bg`, `--toast-fg`, `--toast-radius`, `--toast-max-w`.
|
|
|
663
715
|
- Built on the native `<dialog>`: `el.showModal()` gives a focus trap,
|
|
664
716
|
Escape and an inert background.
|
|
665
717
|
- At most 420px wide; on screens under 520px it becomes a bottom sheet that
|
|
666
|
-
respects the safe area.
|
|
718
|
+
respects the safe area. That modal sizing applies to `dialog.sheet` only:
|
|
719
|
+
a `.sheet` on another element is placed by its page (a bottom dock, a
|
|
720
|
+
side panel).
|
|
667
721
|
|
|
668
722
|
Knobs: `--sheet-pad`, `--sheet-gap`, `--sheet-width`, `--sheet-radius`,
|
|
669
|
-
`--sheet-bg
|
|
723
|
+
`--sheet-bg`, `--sheet-rim`, `--sheet-rim-w`, `--sheet-shadow`,
|
|
724
|
+
`--sheet-blur`, `--sheet-fg`, `--sheet-border-w` (`0`) and
|
|
725
|
+
`--sheet-border-style` (`none`): a real border in `--sheet-rim` that can
|
|
726
|
+
leave sides out (`1px 0 0` is a top-only rim, for a sheet on the page's
|
|
727
|
+
foot; set `--sheet-rim-w: 0` beside it), `--sheet-align-content`
|
|
728
|
+
(`normal`). The gap applies to any sheet laid out as flex or grid, open or
|
|
729
|
+
not.
|
|
670
730
|
|
|
671
731
|
## Design rules
|
|
672
732
|
|
|
673
|
-
|
|
674
|
-
|
|
733
|
+
These are the base rules. They ship in the package as
|
|
734
|
+
`@rickycourtes/designrail/rules/DESIGN.md`, and every project on designrail
|
|
735
|
+
follows them as written. The `DESIGN.md` that `init` writes extends them:
|
|
736
|
+
it starts `Extends @rickycourtes/designrail/rules/DESIGN.md` and appends the
|
|
737
|
+
project's own rules under "Project rules". A project rule adds something
|
|
738
|
+
the base doesn't say; one that reuses a base `{id}` fails `check`
|
|
739
|
+
(`rules-override`). Each bullet is tagged `{id · how it is checked}`:
|
|
675
740
|
|
|
676
741
|
- `check`: `designrail check` fails a change that breaks it.
|
|
677
742
|
- `audit`: `designrail audit` reports it.
|
|
@@ -712,7 +777,8 @@ The rules came out of Popup's design system.
|
|
|
712
777
|
- Focus glow for the keyboard only. `{motion.focus · eye}`
|
|
713
778
|
- Motion uses the duration and easing tokens and stops under reduced motion. `{motion.tokens · eye}`
|
|
714
779
|
|
|
715
|
-
|
|
780
|
+
A project can turn a rule up, never down: `rules` can raise a `warn` to
|
|
781
|
+
`error`, and `check` and `audit` refuse a config that lowers one.
|
|
716
782
|
|
|
717
783
|
## Configuration
|
|
718
784
|
|
|
@@ -742,7 +808,8 @@ optional, and `schema.json` validates it.
|
|
|
742
808
|
"unused": "warn",
|
|
743
809
|
"tracked-caps": "warn",
|
|
744
810
|
"contract": "warn",
|
|
745
|
-
"part-restyle": "warn"
|
|
811
|
+
"part-restyle": "warn",
|
|
812
|
+
"rules-override": "error"
|
|
746
813
|
},
|
|
747
814
|
"duplicates": { "minDeclarations": 3 },
|
|
748
815
|
"maxFileBytes": 1500000
|
|
@@ -764,10 +831,18 @@ optional, and `schema.json` validates it.
|
|
|
764
831
|
| `semanticOnly` | Report primitives read outside token files, and keep `fix` from writing them there. |
|
|
765
832
|
| `allowPrimitives` | Primitive prefixes allowed anywhere. |
|
|
766
833
|
| `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. |
|
|
834
|
+
| `rules` | `error`, `warn` or `off` per check rule. A level may only rise above its default (`warn` → `error`). |
|
|
768
835
|
| `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
836
|
| `maxFileBytes` | Larger files are skipped. |
|
|
770
837
|
|
|
838
|
+
The foundation's rules are the floor. `check` and `audit` exit 2, naming
|
|
839
|
+
each key, when the config loosens one:
|
|
840
|
+
|
|
841
|
+
- a `rules` level below its default (`"unused": "off"`, `"hardcoded": "warn"`),
|
|
842
|
+
- `semanticOnly: false`,
|
|
843
|
+
- an `allowPrimitives` entry outside the default three,
|
|
844
|
+
- `duplicates.minDeclarations` above 3.
|
|
845
|
+
|
|
771
846
|
To exempt a single declaration, put `/* designrail-ignore */` (or
|
|
772
847
|
`/* measured */`) inside its value, before the `;`, for example
|
|
773
848
|
`margin-top: -3px /* measured */;`. It is then left out of the hardcoded,
|
|
@@ -779,7 +854,7 @@ scale and duplicate counts, and `fix` leaves it alone.
|
|
|
779
854
|
| --- | --- |
|
|
780
855
|
| `.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
856
|
| `.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. |
|
|
857
|
+
| `.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
858
|
| Class strings anywhere | Tailwind arbitrary values: `p-[13px]`, `bg-[#fafafa]`, `rounded-[10px]`, `text-[15px]`/`text-[#333]`, `shadow-[…]`, `z-[…]` and the rest. |
|
|
784
859
|
|
|
785
860
|
Values are recognised in every notation:
|
|
@@ -816,7 +891,9 @@ baseline in git; there is no baseline file to maintain.
|
|
|
816
891
|
|
|
817
892
|
`designrail init --agents` adds this to `CLAUDE.md` or `AGENTS.md`:
|
|
818
893
|
|
|
819
|
-
> Before touching UI, read
|
|
894
|
+
> Before touching UI, read both rule files: designrail's base rules
|
|
895
|
+
> (`node_modules/@rickycourtes/designrail/rules/DESIGN.md`) and this
|
|
896
|
+
> project's `DESIGN.md`, which extends them. Build from the parts in `ui/` and the
|
|
820
897
|
> tokens in the token files, on top of the designrail foundation
|
|
821
898
|
> (`@rickycourtes/designrail/foundation.css`). Restyle a foundation part with its knobs on a
|
|
822
899
|
> variant, never by editing it; never type a colour, spacing, radius or font
|
package/kit/changes.json
CHANGED
|
@@ -3,28 +3,184 @@
|
|
|
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": {
|
|
7
|
-
|
|
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
|
|
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": {
|
|
14
|
-
|
|
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": {
|
|
21
|
-
|
|
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": {
|
|
28
|
-
|
|
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
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"version": "0.3.1",
|
|
175
|
+
"notes": "README screenshot only; the foundation is unchanged.",
|
|
176
|
+
"renamed": {},
|
|
177
|
+
"added": {
|
|
178
|
+
"tokens": [],
|
|
179
|
+
"parts": []
|
|
180
|
+
},
|
|
181
|
+
"removed": {
|
|
182
|
+
"tokens": [],
|
|
183
|
+
"parts": []
|
|
184
|
+
}
|
|
29
185
|
}
|
|
30
186
|
]
|
package/kit/parts/base.css
CHANGED
|
@@ -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:
|
|
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; }
|