@whatsaaaa/design-system 0.5.0 → 0.6.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/README.md +17 -17
- package/dist/tailwind/theme.css +206 -0
- package/dist/tailwind/variants.css +43 -0
- package/dist/tailwind.css +42 -0
- package/docs/usage.md +65 -0
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -28,21 +28,21 @@ pnpm install
|
|
|
28
28
|
pnpm styleguide:dev # builds the package and starts the style guide
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
| Command | What it does
|
|
32
|
-
| -------------------------- |
|
|
33
|
-
| `pnpm build` | Builds the package into `dist/`: tokens, fonts, stylesheets and modules
|
|
34
|
-
| `pnpm assets` | Regenerates the asset kit in `assets/` from its sources
|
|
35
|
-
| `pnpm styleguide:dev` | Starts the style guide
|
|
36
|
-
| `pnpm styleguide:build` | Builds the style guide
|
|
37
|
-
| `pnpm test` | Runs the unit tests, the contrast checks among them
|
|
38
|
-
| `pnpm test:browser` | Builds the style guide and runs the browser tests against it. The screenshot tests skip outside Linux |
|
|
39
|
-
| `pnpm test:browser:docker` | Runs the browser tests in the Playwright container, screenshots included, as CI does
|
|
40
|
-
| `pnpm test:browser:update` | Takes the screenshots again, in the container
|
|
41
|
-
| `pnpm lint` | Checks the tokens, the code, the stylesheets and the package
|
|
42
|
-
| `pnpm type-check` | Type-checks everything
|
|
43
|
-
| `pnpm format` | Formats everything
|
|
44
|
-
| `pnpm contrast` | Prints the contrast of every pair the system relies on
|
|
45
|
-
| `pnpm changeset` | Records a change to the package for the next release
|
|
31
|
+
| Command | What it does |
|
|
32
|
+
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `pnpm build` | Builds the package into `dist/`: tokens, fonts, stylesheets and modules |
|
|
34
|
+
| `pnpm assets` | Regenerates the asset kit in `assets/` from its sources |
|
|
35
|
+
| `pnpm styleguide:dev` | Starts the style guide |
|
|
36
|
+
| `pnpm styleguide:build` | Builds the style guide |
|
|
37
|
+
| `pnpm test` | Runs the unit tests, the contrast checks among them |
|
|
38
|
+
| `pnpm test:browser` | Builds the style guide and runs the browser tests against it and an app on the Tailwind entry. The screenshot tests skip outside Linux |
|
|
39
|
+
| `pnpm test:browser:docker` | Runs the browser tests in the Playwright container, screenshots included, as CI does |
|
|
40
|
+
| `pnpm test:browser:update` | Takes the screenshots again, in the container |
|
|
41
|
+
| `pnpm lint` | Checks the tokens, the code, the stylesheets and the package |
|
|
42
|
+
| `pnpm type-check` | Type-checks everything |
|
|
43
|
+
| `pnpm format` | Formats everything |
|
|
44
|
+
| `pnpm contrast` | Prints the contrast of every pair the system relies on |
|
|
45
|
+
| `pnpm changeset` | Records a change to the package for the next release |
|
|
46
46
|
|
|
47
47
|
Every script builds what it needs first, so each one works on a fresh checkout.
|
|
48
48
|
|
|
@@ -65,7 +65,7 @@ CI runs on every pull request:
|
|
|
65
65
|
- the unit tests, with the contrast of every role pair in both themes,
|
|
66
66
|
- that `assets/` is what the sources produce,
|
|
67
67
|
- that the package and the style guide build,
|
|
68
|
-
- the browser tests: no page overflows sideways at phone, tablet and desktop width in either theme, no page logs an error when it loads, the easter egg works with the mouse, the keyboard and reduced motion, the keys of the status line work and their switch turns them off, the path of the status line gives way at every width from 320 px and the theme button switches the theme, a `dark` or `light` class chooses the theme as `data-theme` does, an element for one theme shows only in it, the browser's theme-color follows the theme, a control that takes the focus is not left under the status line and no bar or corner of the window cuts off its focus ring, the first tab starts on the border of the sidebar, the pieces of a form fit every width from 320 px (a segmented control works with the keyboard, stands out at 3:1 and takes the selection colors in forced colors, amounts line up at the right in figures of one width, a number field has no spin buttons and its arrow keys step it, wrapped code hangs and stays inside its block, a long email breaks after its @, and the check icon and the ghost files draw), both fonts draw Serbian Latin, and the pages of the style guide look like their stored screenshots.
|
|
68
|
+
- the browser tests: no page overflows sideways at phone, tablet and desktop width in either theme, no page logs an error when it loads, the easter egg works with the mouse, the keyboard and reduced motion, the keys of the status line work and their switch turns them off, the path of the status line gives way at every width from 320 px and the theme button switches the theme, a `dark` or `light` class chooses the theme as `data-theme` does, an element for one theme shows only in it, the browser's theme-color follows the theme, a control that takes the focus is not left under the status line and no bar or corner of the window cuts off its focus ring, the first tab starts on the border of the sidebar, the pieces of a form fit every width from 320 px (a segmented control works with the keyboard, stands out at 3:1 and takes the selection colors in forced colors, amounts line up at the right in figures of one width, a number field has no spin buttons and its arrow keys step it, wrapped code hangs and stays inside its block, a long email breaks after its @, and the check icon and the ghost files draw), both fonts draw Serbian Latin, an app built on the Tailwind entry takes its utilities, layers and `dark:` and `light:` from the tokens and their theme, and the pages of the style guide look like their stored screenshots.
|
|
69
69
|
|
|
70
70
|
The screenshots are in `tests/browser/__screenshots__/` and are taken on Linux, in the Playwright container, so they are the same on every machine. After a change that is meant to be seen, update them:
|
|
71
71
|
|
|
@@ -107,7 +107,7 @@ scripts/ the builds and the asset generator
|
|
|
107
107
|
assets/ the generated asset kit
|
|
108
108
|
styleguide/ the style guide
|
|
109
109
|
tests/ unit tests, and browser tests in tests/browser/
|
|
110
|
-
docs/ the usage guide,
|
|
110
|
+
docs/ the usage guide, the decisions behind the build, and follow-ups
|
|
111
111
|
licenses/ licenses of what the system builds on
|
|
112
112
|
```
|
|
113
113
|
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The tokens as Tailwind's theme, for tailwind.css. Written by the token build from the tokens,
|
|
3
|
+
* so every token of a group mapped here is here. Left out:
|
|
4
|
+
*
|
|
5
|
+
* palette a palette color never colors interface
|
|
6
|
+
* code code blocks are dark in both themes and read their own variables
|
|
7
|
+
* syntax code blocks are dark in both themes and read their own variables
|
|
8
|
+
* mark the colors of the ghost are its own
|
|
9
|
+
* font.size text takes a text style, not a size
|
|
10
|
+
* motion.duration Tailwind's duration-* takes milliseconds, and transitions take the fast one
|
|
11
|
+
*
|
|
12
|
+
* Inline: a utility reads the token itself, where it is used. So bg-surface follows the theme
|
|
13
|
+
* of the part of the page it is in, as the tokens do.
|
|
14
|
+
*/
|
|
15
|
+
@theme inline {
|
|
16
|
+
/*
|
|
17
|
+
* Colors are the roles and nothing else: Tailwind's palette is taken out, as the system
|
|
18
|
+
* never colors interface with a palette color. The token --ws-color-<role> is the color
|
|
19
|
+
* <role>: bg-surface, text-text-secondary, border-field-border, bg-danger-tint.
|
|
20
|
+
*/
|
|
21
|
+
--color-*: initial;
|
|
22
|
+
--color-bg: var(--ws-color-bg);
|
|
23
|
+
--color-border: var(--ws-color-border);
|
|
24
|
+
--color-border-strong: var(--ws-color-border-strong);
|
|
25
|
+
--color-brand: var(--ws-color-brand);
|
|
26
|
+
--color-brand-fill: var(--ws-color-brand-fill);
|
|
27
|
+
--color-danger: var(--ws-color-danger);
|
|
28
|
+
--color-danger-text: var(--ws-color-danger-text);
|
|
29
|
+
--color-danger-tint: var(--ws-color-danger-tint);
|
|
30
|
+
--color-field-border: var(--ws-color-field-border);
|
|
31
|
+
--color-interactive: var(--ws-color-interactive);
|
|
32
|
+
--color-interactive-active: var(--ws-color-interactive-active);
|
|
33
|
+
--color-interactive-hover: var(--ws-color-interactive-hover);
|
|
34
|
+
--color-note: var(--ws-color-note);
|
|
35
|
+
--color-note-text: var(--ws-color-note-text);
|
|
36
|
+
--color-note-tint: var(--ws-color-note-tint);
|
|
37
|
+
--color-on-brand: var(--ws-color-on-brand);
|
|
38
|
+
--color-on-interactive: var(--ws-color-on-interactive);
|
|
39
|
+
--color-raised: var(--ws-color-raised);
|
|
40
|
+
--color-selection: var(--ws-color-selection);
|
|
41
|
+
--color-surface: var(--ws-color-surface);
|
|
42
|
+
--color-tag-bg: var(--ws-color-tag-bg);
|
|
43
|
+
--color-tag-text: var(--ws-color-tag-text);
|
|
44
|
+
--color-text: var(--ws-color-text);
|
|
45
|
+
--color-text-faint: var(--ws-color-text-faint);
|
|
46
|
+
--color-text-secondary: var(--ws-color-text-secondary);
|
|
47
|
+
--color-tip: var(--ws-color-tip);
|
|
48
|
+
--color-tip-text: var(--ws-color-tip-text);
|
|
49
|
+
--color-tip-tint: var(--ws-color-tip-tint);
|
|
50
|
+
--color-warning: var(--ws-color-warning);
|
|
51
|
+
--color-warning-text: var(--ws-color-warning-text);
|
|
52
|
+
--color-warning-tint: var(--ws-color-warning-tint);
|
|
53
|
+
|
|
54
|
+
/* The two families, and no others: font-mono and font-sans. */
|
|
55
|
+
--font-*: initial;
|
|
56
|
+
--font-mono: var(--ws-font-family-mono);
|
|
57
|
+
--font-sans: var(--ws-font-family-sans);
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* The text styles, as font sizes that bring their line height, letter spacing and weight:
|
|
61
|
+
* text-h1, text-body-sm. A style's family does not come with it, so set it with font-mono or
|
|
62
|
+
* font-sans, as the style says, and text-overline with uppercase. Tailwind's own sizes stay
|
|
63
|
+
* for code that expects them.
|
|
64
|
+
*/
|
|
65
|
+
--text-body: var(--ws-text-body-font-size);
|
|
66
|
+
--text-body--line-height: var(--ws-text-body-line-height);
|
|
67
|
+
--text-body--letter-spacing: var(--ws-text-body-letter-spacing);
|
|
68
|
+
--text-body--font-weight: var(--ws-text-body-font-weight);
|
|
69
|
+
--text-body-sm: var(--ws-text-body-sm-font-size);
|
|
70
|
+
--text-body-sm--line-height: var(--ws-text-body-sm-line-height);
|
|
71
|
+
--text-body-sm--letter-spacing: var(--ws-text-body-sm-letter-spacing);
|
|
72
|
+
--text-body-sm--font-weight: var(--ws-text-body-sm-font-weight);
|
|
73
|
+
--text-caption: var(--ws-text-caption-font-size);
|
|
74
|
+
--text-caption--line-height: var(--ws-text-caption-line-height);
|
|
75
|
+
--text-caption--letter-spacing: var(--ws-text-caption-letter-spacing);
|
|
76
|
+
--text-caption--font-weight: var(--ws-text-caption-font-weight);
|
|
77
|
+
--text-code: var(--ws-text-code-font-size);
|
|
78
|
+
--text-code--line-height: var(--ws-text-code-line-height);
|
|
79
|
+
--text-code--letter-spacing: var(--ws-text-code-letter-spacing);
|
|
80
|
+
--text-code--font-weight: var(--ws-text-code-font-weight);
|
|
81
|
+
--text-display: var(--ws-text-display-font-size);
|
|
82
|
+
--text-display--line-height: var(--ws-text-display-line-height);
|
|
83
|
+
--text-display--letter-spacing: var(--ws-text-display-letter-spacing);
|
|
84
|
+
--text-display--font-weight: var(--ws-text-display-font-weight);
|
|
85
|
+
--text-display-compact: var(--ws-text-display-compact-font-size);
|
|
86
|
+
--text-display-compact--line-height: var(--ws-text-display-compact-line-height);
|
|
87
|
+
--text-display-compact--letter-spacing: var(--ws-text-display-compact-letter-spacing);
|
|
88
|
+
--text-display-compact--font-weight: var(--ws-text-display-compact-font-weight);
|
|
89
|
+
--text-h1: var(--ws-text-h1-font-size);
|
|
90
|
+
--text-h1--line-height: var(--ws-text-h1-line-height);
|
|
91
|
+
--text-h1--letter-spacing: var(--ws-text-h1-letter-spacing);
|
|
92
|
+
--text-h1--font-weight: var(--ws-text-h1-font-weight);
|
|
93
|
+
--text-h1-compact: var(--ws-text-h1-compact-font-size);
|
|
94
|
+
--text-h1-compact--line-height: var(--ws-text-h1-compact-line-height);
|
|
95
|
+
--text-h1-compact--letter-spacing: var(--ws-text-h1-compact-letter-spacing);
|
|
96
|
+
--text-h1-compact--font-weight: var(--ws-text-h1-compact-font-weight);
|
|
97
|
+
--text-h2: var(--ws-text-h2-font-size);
|
|
98
|
+
--text-h2--line-height: var(--ws-text-h2-line-height);
|
|
99
|
+
--text-h2--letter-spacing: var(--ws-text-h2-letter-spacing);
|
|
100
|
+
--text-h2--font-weight: var(--ws-text-h2-font-weight);
|
|
101
|
+
--text-h2-compact: var(--ws-text-h2-compact-font-size);
|
|
102
|
+
--text-h2-compact--line-height: var(--ws-text-h2-compact-line-height);
|
|
103
|
+
--text-h2-compact--letter-spacing: var(--ws-text-h2-compact-letter-spacing);
|
|
104
|
+
--text-h2-compact--font-weight: var(--ws-text-h2-compact-font-weight);
|
|
105
|
+
--text-h3: var(--ws-text-h3-font-size);
|
|
106
|
+
--text-h3--line-height: var(--ws-text-h3-line-height);
|
|
107
|
+
--text-h3--letter-spacing: var(--ws-text-h3-letter-spacing);
|
|
108
|
+
--text-h3--font-weight: var(--ws-text-h3-font-weight);
|
|
109
|
+
--text-h4: var(--ws-text-h4-font-size);
|
|
110
|
+
--text-h4--line-height: var(--ws-text-h4-line-height);
|
|
111
|
+
--text-h4--letter-spacing: var(--ws-text-h4-letter-spacing);
|
|
112
|
+
--text-h4--font-weight: var(--ws-text-h4-font-weight);
|
|
113
|
+
--text-label: var(--ws-text-label-font-size);
|
|
114
|
+
--text-label--line-height: var(--ws-text-label-line-height);
|
|
115
|
+
--text-label--letter-spacing: var(--ws-text-label-letter-spacing);
|
|
116
|
+
--text-label--font-weight: var(--ws-text-label-font-weight);
|
|
117
|
+
--text-label-sm: var(--ws-text-label-sm-font-size);
|
|
118
|
+
--text-label-sm--line-height: var(--ws-text-label-sm-line-height);
|
|
119
|
+
--text-label-sm--letter-spacing: var(--ws-text-label-sm-letter-spacing);
|
|
120
|
+
--text-label-sm--font-weight: var(--ws-text-label-sm-font-weight);
|
|
121
|
+
--text-lead: var(--ws-text-lead-font-size);
|
|
122
|
+
--text-lead--line-height: var(--ws-text-lead-line-height);
|
|
123
|
+
--text-lead--letter-spacing: var(--ws-text-lead-letter-spacing);
|
|
124
|
+
--text-lead--font-weight: var(--ws-text-lead-font-weight);
|
|
125
|
+
--text-overline: var(--ws-text-overline-font-size);
|
|
126
|
+
--text-overline--line-height: var(--ws-text-overline-line-height);
|
|
127
|
+
--text-overline--letter-spacing: var(--ws-text-overline-letter-spacing);
|
|
128
|
+
--text-overline--font-weight: var(--ws-text-overline-font-weight);
|
|
129
|
+
--text-tagline: var(--ws-text-tagline-font-size);
|
|
130
|
+
--text-tagline--line-height: var(--ws-text-tagline-line-height);
|
|
131
|
+
--text-tagline--letter-spacing: var(--ws-text-tagline-letter-spacing);
|
|
132
|
+
--text-tagline--font-weight: var(--ws-text-tagline-font-weight);
|
|
133
|
+
--text-tagline-compact: var(--ws-text-tagline-compact-font-size);
|
|
134
|
+
--text-tagline-compact--line-height: var(--ws-text-tagline-compact-line-height);
|
|
135
|
+
--text-tagline-compact--letter-spacing: var(--ws-text-tagline-compact-letter-spacing);
|
|
136
|
+
--text-tagline-compact--font-weight: var(--ws-text-tagline-compact-font-weight);
|
|
137
|
+
|
|
138
|
+
/* The line heights and weights under Tailwind's names: leading-normal, font-semibold. */
|
|
139
|
+
--leading-*: initial;
|
|
140
|
+
--leading-loose: var(--ws-font-line-height-loose);
|
|
141
|
+
--leading-none: var(--ws-font-line-height-none);
|
|
142
|
+
--leading-normal: var(--ws-font-line-height-normal);
|
|
143
|
+
--leading-relaxed: var(--ws-font-line-height-relaxed);
|
|
144
|
+
--leading-snug: var(--ws-font-line-height-snug);
|
|
145
|
+
--leading-tight: var(--ws-font-line-height-tight);
|
|
146
|
+
--font-weight-*: initial;
|
|
147
|
+
--font-weight-bold: var(--ws-font-weight-bold);
|
|
148
|
+
--font-weight-extrabold: var(--ws-font-weight-extrabold);
|
|
149
|
+
--font-weight-medium: var(--ws-font-weight-medium);
|
|
150
|
+
--font-weight-normal: var(--ws-font-weight-regular);
|
|
151
|
+
--font-weight-semibold: var(--ws-font-weight-semibold);
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
* Space: every --ws-space-<px> is on Tailwind's scale, four pixels to a step, so p-4 is
|
|
155
|
+
* --ws-space-16 and gap-2.5 is --ws-space-10. The sizes are named steps of the same
|
|
156
|
+
* scale, for any width, height, padding or gap: h-tab-bar, max-w-content.
|
|
157
|
+
*/
|
|
158
|
+
--spacing: var(--ws-space-4);
|
|
159
|
+
--spacing-check: var(--ws-size-check);
|
|
160
|
+
--spacing-content: var(--ws-size-content);
|
|
161
|
+
--spacing-control: var(--ws-size-control);
|
|
162
|
+
--spacing-frame: var(--ws-size-frame);
|
|
163
|
+
--spacing-outline: var(--ws-size-outline);
|
|
164
|
+
--spacing-sidebar: var(--ws-size-sidebar);
|
|
165
|
+
--spacing-status-line: var(--ws-size-status-line);
|
|
166
|
+
--spacing-step: var(--ws-size-step);
|
|
167
|
+
--spacing-tab-bar: var(--ws-size-tab-bar);
|
|
168
|
+
|
|
169
|
+
/* The radii by their names: rounded-md is --ws-radius-md. rounded-full is Tailwind's own. */
|
|
170
|
+
--radius-*: initial;
|
|
171
|
+
--radius-lg: var(--ws-radius-lg);
|
|
172
|
+
--radius-md: var(--ws-radius-md);
|
|
173
|
+
--radius-sm: var(--ws-radius-sm);
|
|
174
|
+
--radius-xl: var(--ws-radius-xl);
|
|
175
|
+
--radius-xs: var(--ws-radius-xs);
|
|
176
|
+
|
|
177
|
+
/*
|
|
178
|
+
* Borders, not shadows. The widths by their names, border-thin and border-b-medium,
|
|
179
|
+
* next to Tailwind's border-2, and no shadow utilities.
|
|
180
|
+
*/
|
|
181
|
+
--border-width-medium: var(--ws-border-width-medium);
|
|
182
|
+
--border-width-thick: var(--ws-border-width-thick);
|
|
183
|
+
--border-width-thin: var(--ws-border-width-thin);
|
|
184
|
+
--shadow-*: initial;
|
|
185
|
+
--inset-shadow-*: initial;
|
|
186
|
+
--drop-shadow-*: initial;
|
|
187
|
+
--text-shadow-*: initial;
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* Motion. ease-standard is most movement, and Tailwind's ease-in-out is it too.
|
|
191
|
+
* Transitions take the fast duration. Movement still goes in motion-safe:, which is
|
|
192
|
+
* prefers-reduced-motion: no-preference.
|
|
193
|
+
*/
|
|
194
|
+
--ease-*: initial;
|
|
195
|
+
--ease-in: var(--ws-motion-easing-in);
|
|
196
|
+
--ease-out: var(--ws-motion-easing-out);
|
|
197
|
+
--ease-standard: var(--ws-motion-easing-standard);
|
|
198
|
+
--ease-in-out: var(--ws-motion-easing-standard);
|
|
199
|
+
--default-transition-duration: var(--ws-motion-duration-fast);
|
|
200
|
+
--default-transition-timing-function: var(--ws-motion-easing-standard);
|
|
201
|
+
|
|
202
|
+
/*
|
|
203
|
+
* The one breakpoint is Tailwind's lg, 64rem: max-lg: is the system's compact width,
|
|
204
|
+
* width < 64rem. The other breakpoints stay for code that expects them.
|
|
205
|
+
*/
|
|
206
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* dark: and light: follow the theme as the tokens do. The theme of an element is the nearest
|
|
3
|
+
* choice around it, made with data-theme="dark" or "light" or with a dark or light class, on
|
|
4
|
+
* <html> or on any element around a part of the page. On one element data-theme wins over the
|
|
5
|
+
* class, and both classes together choose nothing. With no choice around it the system decides:
|
|
6
|
+
* dark, unless it asks for light.
|
|
7
|
+
*
|
|
8
|
+
* Written by the token build from the selectors the tokens use, scripts/lib/theme-selectors.ts.
|
|
9
|
+
* Like the rules of ws-theme-dark and ws-theme-light, they follow a choice on <html> and three
|
|
10
|
+
* parts held in a theme, one inside the other.
|
|
11
|
+
*
|
|
12
|
+
* tailwind.css brings them. A library that defines its own dark: or light: after it, as Nuxt UI
|
|
13
|
+
* does, replaces them: import this file again after the library.
|
|
14
|
+
*/
|
|
15
|
+
@custom-variant dark {
|
|
16
|
+
&:where(
|
|
17
|
+
:where(:is([data-theme='dark'], .dark:where(:not([data-theme], .light))), :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) *):not(:is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))), :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) *),
|
|
18
|
+
:where(:is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))), :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) *):not(:is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))), :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) *)
|
|
19
|
+
) {
|
|
20
|
+
@slot;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@media not (prefers-color-scheme: light) {
|
|
24
|
+
&:where(:not([data-theme], .dark:where(:not(.light)), .light:where(:not(.dark)), :is([data-theme], .dark:where(:not(.light)), .light:where(:not(.dark))) *)) {
|
|
25
|
+
@slot;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@custom-variant light {
|
|
31
|
+
&:where(
|
|
32
|
+
:where(:is([data-theme='light'], .light:where(:not([data-theme], .dark))), :is([data-theme='light'], .light:where(:not([data-theme], .dark))) *):not(:is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))), :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) *),
|
|
33
|
+
:where(:is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))), :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) *):not(:is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))), :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) :is([data-theme='light'], .light:where(:not([data-theme], .dark))) :is([data-theme='dark'], .dark:where(:not([data-theme], .light))) *)
|
|
34
|
+
) {
|
|
35
|
+
@slot;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@media (prefers-color-scheme: light) {
|
|
39
|
+
&:where(:not([data-theme], .dark:where(:not(.light)), .light:where(:not(.dark)), :is([data-theme], .dark:where(:not(.light)), .light:where(:not(.dark))) *)) {
|
|
40
|
+
@slot;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The design system for Tailwind CSS v4. Import it instead of tailwindcss, as the first import of
|
|
3
|
+
* the app's stylesheet, and instead of index.css:
|
|
4
|
+
*
|
|
5
|
+
* @import '@whatsaaaa/design-system/tailwind.css';
|
|
6
|
+
*
|
|
7
|
+
* It brings Tailwind and everything index.css brings, in cascade layers, gives Tailwind the
|
|
8
|
+
* system's tokens as its theme, and brings the dark: and light: variants of tailwind/variants.css.
|
|
9
|
+
* Written by the CSS build from the imports of index.css.
|
|
10
|
+
*
|
|
11
|
+
* The layers, in the order they win:
|
|
12
|
+
*
|
|
13
|
+
* theme Tailwind's theme variables, then the tokens and the icons
|
|
14
|
+
* base Tailwind's preflight, then the system's base.css: its page defaults, focus
|
|
15
|
+
* ring and selection win over the preflight, and every utility wins over both
|
|
16
|
+
* components the rest of index.css, the system's classes: ws-prose, the terminal frame
|
|
17
|
+
* and every other piece
|
|
18
|
+
* utilities Tailwind's utilities
|
|
19
|
+
*
|
|
20
|
+
* CSS outside any layer wins over all of them. The fonts are @font-face rules, which no layer
|
|
21
|
+
* orders.
|
|
22
|
+
*/
|
|
23
|
+
@layer theme, base, components, utilities;
|
|
24
|
+
|
|
25
|
+
/* Within a layer the later wins: Tailwind's theme and preflight come before the system's. */
|
|
26
|
+
@import 'tailwindcss/theme.css' layer(theme);
|
|
27
|
+
@import 'tailwindcss/preflight.css' layer(base);
|
|
28
|
+
@import './fonts.css';
|
|
29
|
+
@import './tokens.css' layer(theme);
|
|
30
|
+
@import './css/icons.css' layer(theme);
|
|
31
|
+
@import './css/base.css' layer(base);
|
|
32
|
+
@import './css/theme.css' layer(components);
|
|
33
|
+
@import './css/prose.css' layer(components);
|
|
34
|
+
@import './css/code.css' layer(components);
|
|
35
|
+
@import './css/callout.css' layer(components);
|
|
36
|
+
@import './css/segmented.css' layer(components);
|
|
37
|
+
@import './css/pairs.css' layer(components);
|
|
38
|
+
@import './css/terminal.css' layer(components);
|
|
39
|
+
@import './css/ghost.css' layer(components);
|
|
40
|
+
@import 'tailwindcss/utilities.css' layer(utilities);
|
|
41
|
+
@import './tailwind/theme.css';
|
|
42
|
+
@import './tailwind/variants.css';
|
package/docs/usage.md
CHANGED
|
@@ -35,6 +35,71 @@ Or take pieces. `tokens.css` and `fonts.css` first, then what you use:
|
|
|
35
35
|
|
|
36
36
|
Everything is prefixed: classes with `ws-`, variables with `--ws-`.
|
|
37
37
|
|
|
38
|
+
### With Tailwind CSS
|
|
39
|
+
|
|
40
|
+
An app on Tailwind CSS v4, such as one on Nuxt UI, imports the Tailwind entry in place of both `tailwindcss` and `index.css`. It goes first in the app's stylesheet, before the app's other imports and its own rules:
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
@import '@whatsaaaa/design-system/tailwind.css';
|
|
44
|
+
@import '@nuxt/ui'; /* a library on Tailwind, if the app has one */
|
|
45
|
+
@import '@whatsaaaa/design-system/tailwind/variants.css'; /* after a library with its own dark: and light: */
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Install `tailwindcss` 4.3.5 or a later 4.x next to the package. Only this entry needs it.
|
|
49
|
+
|
|
50
|
+
The entry gives Nuxt UI the system's fonts, weights, radii and spacing, but not its colors. Nuxt UI takes its colors from its own `--ui-*` variables, which fall back to its green and slate, and without `--ui-bg` it paints the body in its own background. Pointing them at the roles is the app's job, in its stylesheet outside any layer. A variable takes the role's value where it is set, so set it on `:root`, which follows the system, and on every element that chooses a theme, with `data-theme` or the `dark` or `light` class:
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
:root,
|
|
54
|
+
[data-theme],
|
|
55
|
+
.dark,
|
|
56
|
+
.light {
|
|
57
|
+
--ui-primary: var(--ws-color-interactive);
|
|
58
|
+
--ui-bg: var(--ws-color-bg);
|
|
59
|
+
--ui-text: var(--ws-color-text);
|
|
60
|
+
--ui-border: var(--ws-color-border);
|
|
61
|
+
/* and the rest of Nuxt UI's colors, such as --ui-error and --ui-bg-elevated */
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The entry brings Tailwind and everything `index.css` brings, in cascade layers, so a utility wins over a class of the system and the app's rules outside any layer win over both:
|
|
66
|
+
|
|
67
|
+
| Layer | What it has, the later winning |
|
|
68
|
+
| ------------ | ----------------------------------------------------------------- |
|
|
69
|
+
| `theme` | Tailwind's theme variables, then the tokens |
|
|
70
|
+
| `base` | Tailwind's preflight, then the page defaults of `base.css` |
|
|
71
|
+
| `components` | The system's classes: `ws-prose`, the terminal frame and the rest |
|
|
72
|
+
| `utilities` | Tailwind's utilities |
|
|
73
|
+
|
|
74
|
+
The tokens are Tailwind's theme, and a utility reads its token where it is used, so it follows the theme as the token does:
|
|
75
|
+
|
|
76
|
+
| Utilities | Tokens |
|
|
77
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
78
|
+
| `bg-surface`, `text-text-secondary`, `border-field-border` | The color roles. Tailwind's palette is taken out |
|
|
79
|
+
| `font-mono`, `font-sans` | The two families, and no others |
|
|
80
|
+
| `text-h1`, `text-body-sm` | The text styles, without their family: write `font-mono text-h1` |
|
|
81
|
+
| `leading-normal`, `font-semibold` | Line heights and weights |
|
|
82
|
+
| `p-4`, `gap-2.5` | Space, four pixels to a step: `p-4` is `--ws-space-16` |
|
|
83
|
+
| `h-tab-bar`, `max-w-content` | The sizes, by name, for any width, height or space |
|
|
84
|
+
| `rounded-md` | The radii, by name only, so no bare `rounded`. `rounded-full` is Tailwind's own |
|
|
85
|
+
| `border-thin` | The border widths. There are no shadow utilities |
|
|
86
|
+
| `ease-standard`, `transition` | The easings. A transition takes `--ws-motion-duration-fast` |
|
|
87
|
+
| `max-lg:` | The one breakpoint: below 64rem |
|
|
88
|
+
|
|
89
|
+
The entry takes out Tailwind's defaults that no token stands behind, as the system colors interface with its roles only and draws edges with borders, not shadows. As classes their utilities compile to nothing, with no error. In `@apply`, in the app's CSS or a component's `<style>` block, one fails the build with `Cannot apply unknown utility class`:
|
|
90
|
+
|
|
91
|
+
| Taken out | Utilities that compile to nothing | Use instead |
|
|
92
|
+
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
93
|
+
| Tailwind's palette, white and black included | `bg-white`, `text-black`, `text-red-500`, `border-slate-200` | A role: `bg-surface`, `text-text` |
|
|
94
|
+
| Shadows | `shadow`, `shadow-lg`, `inset-shadow-sm`, `drop-shadow`, `text-shadow-md` | A border: `border-thin border-border` |
|
|
95
|
+
| The serif family | `font-serif` | `font-sans` or `font-mono` |
|
|
96
|
+
| The weights with no token | `font-thin`, `font-extralight`, `font-light`, `font-black` | `font-normal` to `font-extrabold` |
|
|
97
|
+
| The radii with no token | `rounded` and its sides and corners, such as `rounded-t` and `rounded-tl`, and `rounded-2xl` to `rounded-4xl` | `rounded-sm`, the same 4px, for `rounded`. `rounded-xs` to `rounded-xl`, `rounded-full` |
|
|
98
|
+
|
|
99
|
+
A library imported after the entry loses them too, by design: the overlays of Nuxt UI, for example, have no shadow on the entry.
|
|
100
|
+
|
|
101
|
+
`dark:` and `light:` follow the theme as the tokens do: the nearest `data-theme` or `dark` or `light` class around the element, then the system, by the rules of section 3, Theme. The roles already switch, so use them only for what the roles do not cover. A library that defines its own `dark:` or `light:` after the entry, as Nuxt UI does, replaces the system's: import them again after it, with `@import '@whatsaaaa/design-system/tailwind/variants.css';`.
|
|
102
|
+
|
|
38
103
|
## 2. Colors
|
|
39
104
|
|
|
40
105
|
Use the role tokens. Never write a hex value, and never use a `--ws-palette-*` color for interface: a role changes with the theme and carries the contrast rules, the palette does not.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatsaaaa/design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Whatsaaaa's design system: brand identity, design tokens, typography, docs theme and asset kit",
|
|
5
5
|
"homepage": "https://github.com/whatsaaaa/design-system#readme",
|
|
6
6
|
"bugs": "https://github.com/whatsaaaa/design-system/issues",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"./index.css": "./dist/index.css",
|
|
28
28
|
"./tokens.css": "./dist/tokens.css",
|
|
29
29
|
"./fonts.css": "./dist/fonts.css",
|
|
30
|
+
"./tailwind.css": "./dist/tailwind.css",
|
|
31
|
+
"./tailwind/variants.css": "./dist/tailwind/variants.css",
|
|
30
32
|
"./css/*.css": "./dist/css/*.css",
|
|
31
33
|
"./fonts/*": "./dist/fonts/*",
|
|
32
34
|
"./tokens": {
|
|
@@ -78,6 +80,7 @@
|
|
|
78
80
|
"@playwright/test": "^1.65.0",
|
|
79
81
|
"@resvg/resvg-js": "^2.6.2",
|
|
80
82
|
"@rose-pine/palette": "^4.0.1",
|
|
83
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
81
84
|
"@terrazzo/cli": "^2.10.0",
|
|
82
85
|
"@terrazzo/plugin-css": "^2.10.0",
|
|
83
86
|
"@terrazzo/plugin-js": "^2.10.0",
|
|
@@ -107,7 +110,9 @@
|
|
|
107
110
|
"stylelint": "^18.0.0",
|
|
108
111
|
"stylelint-config-standard": "^41.0.0",
|
|
109
112
|
"stylelint-value-no-unknown-custom-properties": "^6.1.1",
|
|
113
|
+
"tailwindcss": "^4.3.5",
|
|
110
114
|
"typescript": "~6.0.3",
|
|
115
|
+
"vite": "^8.3.8",
|
|
111
116
|
"vitepress": "^1.6.4",
|
|
112
117
|
"vitest": "^5.1.0",
|
|
113
118
|
"vue": "^3.5.45",
|
|
@@ -116,10 +121,14 @@
|
|
|
116
121
|
"yaml": "^2.9.1"
|
|
117
122
|
},
|
|
118
123
|
"peerDependencies": {
|
|
124
|
+
"tailwindcss": "^4.3.5",
|
|
119
125
|
"vitepress": "^1.6.4",
|
|
120
126
|
"vue": "^3.5.0"
|
|
121
127
|
},
|
|
122
128
|
"peerDependenciesMeta": {
|
|
129
|
+
"tailwindcss": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
123
132
|
"vitepress": {
|
|
124
133
|
"optional": true
|
|
125
134
|
},
|