Skip to content

Commit c729591

Browse files
authored
docs(skill): say what the reset leaves alone, and how a token takes alpha (#671)
Two things readers worked out the hard way, both from the same project. `@devup-ui/reset-css` is a normalize, not a preflight, and for form controls it does exactly two things: `margin: 0`, and `-webkit-appearance: button` — which *preserves* the native control appearance rather than removing it. Button `padding`, `border` and `appearance` are deliberately untouched, so a button still carries the UA defaults. That is invisible until a button is sized in design units. Because `box-sizing: border-box` is global, an explicit `8px` width cannot shrink below the `6 + 6 + 2 + 2 = 16px` that Chrome's default `padding: 1px 6px` and `border: 2px outset` already occupy, and an 8x8 button from a design renders 16x8. Nothing is broken and no token is wrong; the reset never claimed those properties. The section now says so and shows the call-site fix. The other is alpha. A token *is* a CSS custom property, which the `$token Scope` section already says two paragraphs above — so a token at partial opacity is `color-mix()` over `var(--token)`, with no alpha token to define and no hardcoded copy of the colour to keep in sync. Not knowing that, a screen hardcoded `#F7F3EC66` beside a `$bg` that was already the same colour. That is not merely redundant: `$bg` follows the active theme and the literal does not, so the surface stays light in dark mode. `opacity` is not a substitute either, since it fades the element together with everything inside it while `color-mix()` fades only the paint.
1 parent 1020168 commit c729591

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎SKILL.md‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,34 @@ Do not add `include`, `optimizeDeps.exclude` or `ssr.noExternal` entries for it.
506506
They are redundant, and writing them suggests to the next reader that a devup-ui
507507
package needs wiring when none does.
508508

509+
**It is a normalize, not a preflight.** It sets `box-sizing: border-box`
510+
globally and zeroes a few margins, but for form controls it does exactly two
511+
things:
512+
513+
```ts
514+
':where(button,input,select)': { m: 0 },
515+
':where(button,[type=button i],[type=reset i],[type=submit i])': {
516+
WebkitAppearance: 'button',
517+
},
518+
```
519+
520+
The second *preserves* the native control appearance rather than removing it.
521+
Button `padding`, `border` and `appearance` are deliberately left alone, so a
522+
button still carries the UA defaults — in Chrome `padding: 1px 6px` and
523+
`border: 2px outset`.
524+
525+
That floor shows up the moment a button is sized in design units. Because
526+
`box-sizing: border-box` is global, an explicit `8px` width cannot shrink below
527+
the `6 + 6 + 2 + 2 = 16px` the horizontal padding and border already occupy, so
528+
an 8x8 button from a design renders 16x8. Nothing is broken and no token is
529+
wrong; the reset never claimed those properties.
530+
531+
When a button is meant to be a plain box, remove them at the call site:
532+
533+
```tsx
534+
<Box as="button" appearance="none" border="none" p={0} w="8px" h="8px" />
535+
```
536+
509537
## What Decides Static Extraction
510538

511539
One rule explains `Dynamic Values = CSS Variables`, `$token Scope` and
@@ -570,6 +598,25 @@ const colors = { active: 'var(--primary)' }
570598
<Box bg={colors.active} />
571599
```
572600

601+
### Token With Alpha
602+
603+
Because a token *is* a CSS custom property, a token at partial opacity is
604+
`color-mix()` over `var(--token)`. There is no separate alpha token to define
605+
and no hardcoded copy of the colour to keep in sync.
606+
607+
```tsx
608+
// CORRECT - 40% of the theme's own background, still theme-reactive
609+
<Box bg="color-mix(in srgb, var(--bg) 40%, transparent)" />
610+
611+
// WRONG - a literal copy, frozen at whatever the token was that day
612+
<Box bg="#F7F3EC66" />
613+
```
614+
615+
The literal is not merely redundant, it is wrong under theming: `$bg` follows
616+
the active theme and `#F7F3EC66` does not, so the surface stays light in dark
617+
mode. `opacity` is not a substitute either — it fades the element together
618+
with everything inside it, while `color-mix()` fades only the paint.
619+
573620
## Inline Variant Pattern (Preferred)
574621

575622
Use inline object indexing instead of external config objects:

0 commit comments

Comments
 (0)