Skip to content

Commit 05c1505

Browse files
authored
refactor(react-ui): move density tokens into react-ui for a valid default (#296)
1 parent a158f93 commit 05c1505

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

packages/react-ui/src/styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
@import "tailwindcss" prefix(zd);
22
@config "../tailwind.config.ts";
3+
4+
/* Density base. --zd-density is a unitless multiplier (1 = default) that the
5+
spacing base and the font tokens (see tailwind.config.ts) derive from, so the
6+
whole design system scales from one variable. Defined here so react-ui is
7+
self-contained — its own tokens read --zd-density, so its Storybook and any
8+
standalone consumer get a valid default. Consumers (e.g. @zerodev/wallet-react-ui)
9+
override --zd-density per subtree to produce size variants. */
10+
:root {
11+
--zd-density: 1;
12+
--zd-spacing: calc(0.25rem * var(--zd-density));
13+
}

packages/wallet-react-ui/src/shared/components/Screen/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ export function Screen({
5252
<div
5353
className={cn(
5454
// m-1.5 = calc(var(--zd-spacing) * 1.5) = 6px at density 1, so the
55-
// gradient border ring thins with the size variants — matching the
56-
// now-scaling corner radius, keeping the whole frame proportional.
55+
// gradient border ring thins with the size variants. (Corner radii
56+
// stay fixed, so at smaller sizes the ring is marginally non-uniform
57+
// at the corners — a minor cosmetic trade-off.)
5758
'zd:flex zd:flex-1 zd:flex-col zd:m-1.5 zd:px-4 zd:overflow-hidden zd:rounded-4xl zd:relative',
5859
contentClassName,
5960
)}

packages/wallet-react-ui/src/styles.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
steps (see react-ui/tailwind.config.ts) — so one variable rescales spacing,
1515
padding, gaps, control heights, and the frame width together. Font sizes also
1616
multiply by --zd-density (see the fontSize tokens), so type scales too — a
17-
true proportional zoom. Corner radii, borders, and icon sizes stay fixed.
17+
true proportional zoom. Icons sized with spacing utilities (w-6/h-6, h-4.5)
18+
scale with it as well. Corner radii, borders, and any icon pinned to an
19+
arbitrary px size (e.g. the signing h-[18px] glyphs) stay fixed.
1820
1921
Consumers set the density via the Screen/AuthFlow `size` prop, which writes
2022
`data-zd-size` on the Screen root; the scale below maps size → density.

0 commit comments

Comments
 (0)