@valiify/dashboard-ui 0.2.0 → 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.
Files changed (35) hide show
  1. package/CHANGELOG.md +174 -2
  2. package/CLAUDE.md +124 -3
  3. package/GETTING_STARTED.md +87 -0
  4. package/README.md +49 -3
  5. package/TROUBLESHOOTING.md +40 -0
  6. package/dist/dashboard-ui.css +501 -507
  7. package/examples/README.md +42 -0
  8. package/examples/daisyui-starter/README.md +47 -24
  9. package/examples/daisyui-starter/check-no-bleed.mjs +216 -48
  10. package/examples/daisyui-starter/index.html +44 -17
  11. package/examples/daisyui-starter/linked.html +74 -0
  12. package/examples/daisyui-starter/package.json +1 -1
  13. package/examples/daisyui-starter/src/host.css +14 -0
  14. package/examples/daisyui-starter/src/only-import.css +4 -0
  15. package/examples/daisyui-starter/src/styles.css +21 -5
  16. package/examples/daisyui-starter/tailwind.config.js +7 -6
  17. package/examples/postcss-starter/package.json +1 -1
  18. package/examples/sveltekit-starter/README.md +32 -0
  19. package/examples/sveltekit-starter/check-scoped-styles.mjs +103 -0
  20. package/examples/sveltekit-starter/package-lock.json +1300 -0
  21. package/examples/sveltekit-starter/package.json +24 -0
  22. package/examples/sveltekit-starter/src/app.css +17 -0
  23. package/examples/sveltekit-starter/src/app.html +11 -0
  24. package/examples/sveltekit-starter/src/lib/GlobalReset.svelte +20 -0
  25. package/examples/sveltekit-starter/src/lib/ScopedRemedy.svelte +27 -0
  26. package/examples/sveltekit-starter/src/lib/ScopedReset.svelte +22 -0
  27. package/examples/sveltekit-starter/src/routes/+layout.svelte +6 -0
  28. package/examples/sveltekit-starter/src/routes/+page.svelte +10 -0
  29. package/examples/sveltekit-starter/svelte.config.js +4 -0
  30. package/examples/sveltekit-starter/vite.config.js +6 -0
  31. package/examples/vite-starter/package.json +1 -1
  32. package/package.json +6 -2
  33. package/src/build/components.css +6 -0
  34. package/src/build/utilities.css +6 -2
  35. package/src/reset.css +213 -0
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "valiify-dashboard-ui-sveltekit-starter",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite dev",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
10
+ "prepare": "svelte-kit sync || echo ''",
11
+ "check": "node check-scoped-styles.mjs"
12
+ },
13
+ "devDependencies": {
14
+ "@sveltejs/adapter-auto": "^7.0.1",
15
+ "@sveltejs/kit": "^2.63.0",
16
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
17
+ "playwright": "1.62.1",
18
+ "svelte": "^5.56.1",
19
+ "vite": "^8.0.16"
20
+ },
21
+ "dependencies": {
22
+ "@valiify/dashboard-ui": "^0.3.0"
23
+ }
24
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * The app shell's load path — the prebuilt entry, standalone.
3
+ *
4
+ * Only the bundle. dashboard-ui ships no reset.css and no document default: the
5
+ * `./styles.css` entry carries no preflight and no `html` rule, so the host paints
6
+ * its own page (below) and owns its own reset. Import ONE of the library's three
7
+ * style entries, never two — `@valiify/dashboard-ui` (dist/index.css) would bring
8
+ * Tailwind 4's preflight into a host that did not ask for it.
9
+ */
10
+ @import "@valiify/dashboard-ui/styles.css";
11
+
12
+ body {
13
+ margin: 0;
14
+ padding: 32px;
15
+ color: var(--color-content-primary);
16
+ background: var(--color-surface-frame);
17
+ }
@@ -0,0 +1,11 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ %sveltekit.head%
7
+ </head>
8
+ <body>
9
+ <div style="display: contents">%sveltekit.body%</div>
10
+ </body>
11
+ </html>
@@ -0,0 +1,20 @@
1
+ <!--
2
+ Case 1 — a :global element reset from a Svelte component.
3
+ Compiles to a bare, UNLAYERED `button { border: 0 }` (0,0,1). This is the shape
4
+ of a house reset written inside a component, and it is the case the unlayered
5
+ bundle defends against: our class (0,1,0) beats it on specificity.
6
+ -->
7
+ <div class="row">
8
+ <button id="global-reset-trigger" class="vd-dropdown-field" type="button" aria-haspopup="listbox" aria-expanded="false">
9
+ <span class="vd-dropdown-field-placeholder">:global(button) reset in scope</span>
10
+ </button>
11
+ </div>
12
+
13
+ <style>
14
+ :global(button) {
15
+ border: 0;
16
+ }
17
+ .row {
18
+ margin-bottom: 24px;
19
+ }
20
+ </style>
@@ -0,0 +1,27 @@
1
+ <!--
2
+ Case 3 — the remedy for case 2. Exclude library controls from the scoped element
3
+ selector: `button:not([class*="vd-"])`. The dev's own plain button still gets the
4
+ reset; ours is never matched, so specificity never enters into it. (Scoping the
5
+ reset by class — `.plain { }` — works the same way and reads better; this form
6
+ is shown because it is the mechanical edit to an existing element reset.)
7
+ -->
8
+ <div class="row">
9
+ <button id="remedy-trigger" class="vd-dropdown-field" type="button" aria-haspopup="listbox" aria-expanded="false">
10
+ <span class="vd-dropdown-field-placeholder">scoped reset that excludes [class*="vd-"]</span>
11
+ </button>
12
+ <button id="remedy-plain" type="button">the component's own plain button</button>
13
+ <button id="remedy-primary" class="vd-btn vd-btn-primary" type="button">Continue</button>
14
+ </div>
15
+
16
+ <style>
17
+ button:not([class*="vd-"]) {
18
+ border: 0;
19
+ padding: 0;
20
+ }
21
+ .row {
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: 12px;
25
+ align-items: flex-start;
26
+ }
27
+ </style>
@@ -0,0 +1,22 @@
1
+ <!--
2
+ Case 2 — a SCOPED element selector. THE CASE THE BUNDLE CANNOT DEFEND AGAINST.
3
+ Svelte scopes `button { }` to `button.svelte-<hash>` — specificity 0,1,1, which
4
+ outranks our single-class rule (0,1,0) whether or not the bundle is layered.
5
+ check-scoped-styles.mjs asserts that our border is LOST here on purpose: this
6
+ pins the contract's second clause (a host rule at higher specificity wins) to a
7
+ measurement, so the README / GETTING_STARTED text cannot drift from what is true.
8
+ -->
9
+ <div class="row">
10
+ <button id="scoped-trigger" class="vd-dropdown-field" type="button" aria-haspopup="listbox" aria-expanded="false">
11
+ <span class="vd-dropdown-field-placeholder">scoped element reset — wins over us</span>
12
+ </button>
13
+ </div>
14
+
15
+ <style>
16
+ button {
17
+ border: 0;
18
+ }
19
+ .row {
20
+ margin-bottom: 24px;
21
+ }
22
+ </style>
@@ -0,0 +1,6 @@
1
+ <script>
2
+ import "../app.css";
3
+ let { children } = $props();
4
+ </script>
5
+
6
+ {@render children?.()}
@@ -0,0 +1,10 @@
1
+ <script>
2
+ import GlobalReset from "$lib/GlobalReset.svelte";
3
+ import ScopedReset from "$lib/ScopedReset.svelte";
4
+ import ScopedRemedy from "$lib/ScopedRemedy.svelte";
5
+ </script>
6
+
7
+ <h1>dashboard-ui inside SvelteKit — scoped styles vs component rules</h1>
8
+ <GlobalReset />
9
+ <ScopedReset />
10
+ <ScopedRemedy />
@@ -0,0 +1,4 @@
1
+ import adapter from "@sveltejs/adapter-auto";
2
+
3
+ /** @type {import('@sveltejs/kit').Config} */
4
+ export default { kit: { adapter: adapter() } };
@@ -0,0 +1,6 @@
1
+ import { sveltekit } from "@sveltejs/kit/vite";
2
+ import { defineConfig } from "vite";
3
+
4
+ // No Tailwind in this host at all. The library's prebuilt bundle is a plain
5
+ // stylesheet, and the thing under test is what SvelteKit itself does to CSS.
6
+ export default defineConfig({ plugins: [sveltekit()] });
@@ -9,7 +9,7 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@valiify/dashboard-ui": "^0.2.0"
12
+ "@valiify/dashboard-ui": "^0.3.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@tailwindcss/vite": "^4.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valiify/dashboard-ui",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Tailwind CSS component library for Valiify Dashboard applications",
5
5
  "style": "dist/index.css",
6
6
  "types": "types/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  ".": "./dist/index.css",
12
12
  "./index.css": "./dist/index.css",
13
13
  "./styles.css": "./dist/dashboard-ui.css",
14
+ "./reset.css": "./src/reset.css",
14
15
  "./fonts": "./src/fonts.css",
15
16
  "./source": "./src/library.css",
16
17
  "./icons/sprite.svg": "./src/icons/sprite.svg",
@@ -49,8 +50,11 @@
49
50
  "new:component": "node scripts/new-component.mjs",
50
51
  "verify:component": "node scripts/verify-component.mjs",
51
52
  "verify:layers": "node scripts/verify-layers.mjs",
53
+ "verify:layer-defeat": "node scripts/verify-layer-defeat.mjs",
54
+ "verify:utility-precedence": "node scripts/verify-utility-precedence.mjs",
52
55
  "verify:vocabulary": "node scripts/verify-vocabulary.mjs",
53
56
  "verify:bundle": "node scripts/verify-bundle.mjs",
57
+ "verify:reset": "node scripts/verify-reset.mjs",
54
58
  "verify:markup": "node scripts/verify-markup.mjs",
55
59
  "verify:package": "node scripts/verify-package.mjs",
56
60
  "storybook": "storybook dev -p 6006",
@@ -89,7 +93,7 @@
89
93
  "@storybook/addon-themes": "^10.5.10",
90
94
  "@storybook/html-vite": "^10.5.10",
91
95
  "@tailwindcss/postcss": "^4.3.3",
92
- "@valiify/val-core": "^0.2.0",
96
+ "@valiify/val-core": "^0.7.0",
93
97
  "chromatic": "^18.7.2",
94
98
  "lucide-static": "^1.33.0",
95
99
  "pixelmatch": "^7.2.0",
@@ -20,6 +20,12 @@
20
20
  * No utilities.css import either, so this pass emits ZERO utility classes — the
21
21
  * prefixed ones come from pass B. theme.css does not declare the layer order, so it
22
22
  * is declared here.
23
+ *
24
+ * The components then land in `@layer components`, which scripts/build-styles.mjs
25
+ * UNWRAPS — see there for why a layer is the bug in a bundle shipped into a foreign
26
+ * app. Source, ./source and dist/index.css keep their layers. Because ../base is not
27
+ * imported, there is no `@layer base` block to deal with; build-styles.mjs fails the
28
+ * build if one ever appears.
23
29
  */
24
30
  @layer theme, base, components, utilities;
25
31
 
@@ -28,8 +28,12 @@
28
28
  * `@layer utilities`. Unlayered is the safer shape for a layer shipped INTO a foreign
29
29
  * app: unlayered rules beat layered ones before specificity is consulted, so a layered
30
30
  * `vd:flex` would silently lose to any unlayered host rule touching the same property
31
- * (daisyUI 4 is entirely unlayered). Our component classes stay in @layer components,
32
- * so the host's own utilities still win over them — what a consumer expects.
31
+ * (daisyUI 4 is entirely unlayered). The SAME sentence governs pass A: build-styles.mjs
32
+ * unwraps the component classes too, because inside @layer components they lost to
33
+ * the host's preflight and to daisyUI (the 0.2.0 bug, scripts/verify-layer-defeat.mjs).
34
+ * With both passes unlayered, a vd: utility beats a component rule of equal specificity
35
+ * by source order (pass B follows pass A) and loses to a compound component selector —
36
+ * scripts/verify-utility-precedence.mjs asserts no generated markup relies on the latter.
33
37
  */
34
38
  @layer theme, base, components, utilities;
35
39
 
package/src/reset.css ADDED
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Minimal reset for the prebuilt bundle — OPTIONAL and opt-in.
3
+ *
4
+ * @import "@valiify/dashboard-ui/reset.css"; <- FIRST
5
+ * @import "@valiify/dashboard-ui/styles.css";
6
+ *
7
+ * dist/dashboard-ui.css deliberately ships no preflight and no `html` rule, so it
8
+ * cannot fight the reset of a host that already has one (Tailwind 3 + daisyUI 4, a
9
+ * Svelte :global() reset, a house stylesheet). verify:bundle asserts that absence on
10
+ * every build and nothing here changes it — this is a SEPARATE file the bundle never
11
+ * imports and no entry pulls in for you.
12
+ *
13
+ * The cost of shipping no reset is that a page with no other stylesheet gets the
14
+ * browser defaults, and those break this library's geometry and typography. Measured
15
+ * on a bare page loading only the bundle, over every ```html example in CLAUDE.md
16
+ * plus tests/fixtures/generated-page.html — 479 of 582 elements rendered content-box,
17
+ * and 53 of 146 Figma-pinned dimensions were wrong:
18
+ *
19
+ * .vd-input-field.vd-input-sm 25px designed -> 38px (+11 padding, +2 hairline)
20
+ * .vd-toast-simple (height) 35px -> 57px
21
+ * .vd-data-row 38px -> 63px
22
+ * .vd-chip 20px -> 30px
23
+ * .vd-avatar-md 20px -> 22px
24
+ * .vd-switch 32x18 -> 36x22
25
+ * .vd-modal 480px wide -> 546px
26
+ * .vd-alert (height) 88.5px -> 137.5px (UA <p> margins)
27
+ * .vd-tooltip (height) 106.5px -> 190.5px
28
+ * .vd-tab-underline (width) 96.1px -> 100.1px (UA <button> border)
29
+ * html font-family Inter -> Times
30
+ * .vd-btn font-family Inter -> Arial
31
+ * a.vd-nav-title colour Content/Primary-> link blue
32
+ *
33
+ * This file is that floor and nothing more. It is NOT preflight. Every rule exists
34
+ * because a measured value was wrong without it, and the set was derived by rendering
35
+ * the documented markup against this bundle and against dist/index.css — the entry
36
+ * that DOES carry preflight — and keeping only the rules that closed a real gap.
37
+ * scripts/verify-reset.mjs re-measures the whole thing.
38
+ *
39
+ * What it deliberately does NOT touch, because nothing measured wrong: lists and
40
+ * their markers, tables, images, fieldsets, form-control appearance and placeholder
41
+ * colour (.vd-input and .vd-textarea zero their own), blockquote/figure/dl margins,
42
+ * b/strong weight, code family, sub/sup, [hidden] (.vd-dropdown-panel ships its own
43
+ * guard). A host is entitled to own all of it.
44
+ *
45
+ * Use it when the bundle is the ONLY stylesheet on the page. Inside an app that
46
+ * already resets, skip it — rules 1-7 would be redundant, and rule 8 would repaint a
47
+ * page the host owns.
48
+ *
49
+ * THIS FILE IS SUBJECT TO THE CASCADE LIKE ANY HOST RESET, and that is the whole
50
+ * risk. Every rule here is an unlayered element selector (0,0,1). Our sibling
51
+ * @valiify/shortapp-ui shipped the same file in 1.0.0 while its bundle's component
52
+ * rules still sat inside `@layer components` — and unlayered beats layered before
53
+ * specificity is consulted, so rule 4's `button { color: inherit }` beat
54
+ * `.va-btn-primary`'s white ink and every button-based component lost its font-size,
55
+ * line-height, letter-spacing and colour. 50 defeats; the fix for one problem was a
56
+ * live instance of the problem, and nothing they had could see it. This bundle has
57
+ * been unlayered since 0.2.1 (scripts/build-styles.mjs), so its classes (0,1,0)
58
+ * outrank these element rules (0,0,1) on specificity — but that is an invariant to be
59
+ * asserted, not assumed. scripts/verify-reset.mjs measures computed styles in a
60
+ * browser and fails if any rule here overrides a property the bundle declares on the
61
+ * same element. Do not add a rule to this file without running it.
62
+ */
63
+
64
+ /*
65
+ * 1. border-box. The single load-bearing rule.
66
+ *
67
+ * Every fixed dimension in this library is authored border-box. Component heights
68
+ * include their own hairline — CLAUDE.md's rule is "size bordered components with
69
+ * `height`, not `min-height`", because Chrome rounds the 0.5px `--border-thin` up to
70
+ * a full 1px and a hairline therefore adds 2px. Under content-box each of those
71
+ * renders larger than designed by its own padding plus border: the sm input lands at
72
+ * 38px against a designed 25. Form controls already default to border-box in the UA
73
+ * stylesheet, which is why .vd-btn measured right and .vd-input-field did not.
74
+ */
75
+ *,
76
+ ::before,
77
+ ::after {
78
+ box-sizing: border-box;
79
+ }
80
+
81
+ /*
82
+ * 2. The body's 8px UA margin. dist/index.css zeroes it through Preflight, so without
83
+ * this the two prebuilt entries lay out differently at the page edge. NavigationRail
84
+ * is the component that notices: it is `h-full` and expects a sized parent, not one
85
+ * inset from the viewport.
86
+ */
87
+ body {
88
+ margin: 0;
89
+ }
90
+
91
+ /*
92
+ * 3. Document font and line box.
93
+ *
94
+ * The bundle defines --font-sans as a token but binds it to nothing — Preflight's
95
+ * `--default-font-family` is what normally applies it, and the bundle has no
96
+ * preflight — so text falls back to the UA serif. Measured: the document rendered in
97
+ * Times. Bound to the token rather than a literal, so a consumer overriding
98
+ * --font-sans still wins.
99
+ *
100
+ * The 1.5 line-height is Tailwind's document default, not a Figma value, and is here
101
+ * for parity with dist/index.css: every text style in the library carries its own
102
+ * line-height, so this governs only text the consumer writes. Without it bare copy
103
+ * sets at `normal` and lands ~6px shorter per line than on the preflight entry.
104
+ */
105
+ html {
106
+ font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
107
+ line-height: 1.5;
108
+ }
109
+
110
+ /*
111
+ * 4. Form controls do not inherit font or colour from their ancestors; the UA gives
112
+ * them its own. Our component classes set size and weight but never family, because
113
+ * preflight normally supplies the inheritance. Measured: .vd-btn rendered in Arial
114
+ * while the document was in Times — neither of them Inter.
115
+ *
116
+ * This is the rule that cost the sibling library 50 defeats. It is safe here only
117
+ * because the bundle is unlayered; verify:reset is what keeps it safe.
118
+ */
119
+ button,
120
+ input,
121
+ optgroup,
122
+ select,
123
+ textarea {
124
+ font-family: inherit;
125
+ font-size: 100%;
126
+ line-height: inherit;
127
+ letter-spacing: inherit;
128
+ color: inherit;
129
+ }
130
+
131
+ /*
132
+ * 5. The UA's 2px outset border on <button>.
133
+ *
134
+ * CLAUDE.md already records this dependency from the other side: ".vd-tab must not set
135
+ * `border-none` … Preflight already gives buttons a 0-width border." Without preflight
136
+ * that is false, and the components which rely on it leak the UA frame — measured, an
137
+ * underline tab rendered 100.14px against a designed 96.14, and every segment and
138
+ * filter segment gained 2px per unstyled side.
139
+ *
140
+ * Scoped to <button> alone: input, select and textarea have the same UA border, but
141
+ * .vd-input and .vd-textarea zero their own, so a rule for them would be a defeat
142
+ * surface with nothing to fix.
143
+ */
144
+ button {
145
+ border: 0 solid;
146
+ }
147
+
148
+ /*
149
+ * 6. Block margins on the elements the documented markup puts INSIDE components.
150
+ *
151
+ * Alert, Toast, Modal, Tooltip, Pagination, Stepper and Card all use <p> for their
152
+ * text parts and <h2> for their titles, and the UA gives each a 1em block margin that
153
+ * the component has no padding to absorb. Measured: .vd-alert 88.5px -> 137.5px,
154
+ * .vd-modal 288.5 -> 377.8, .vd-tooltip 106.5 -> 190.5.
155
+ *
156
+ * Headings are zeroed as a family rather than just h2: the slot takes whichever level
157
+ * the consumer's document outline needs, and a modal titled with an <h3> is correct
158
+ * markup.
159
+ */
160
+ p,
161
+ h1,
162
+ h2,
163
+ h3,
164
+ h4,
165
+ h5,
166
+ h6,
167
+ hr {
168
+ margin: 0;
169
+ }
170
+
171
+ /*
172
+ * 7. <hr>'s own UA chrome. .vd-divider zeroes its border and margin; .vd-tooltip-divider
173
+ * zeroes only its border, and the UA's `color: gray` reaches both. Rules in this
174
+ * library are drawn as a 1px box with a background, never a border, so an inherited
175
+ * grey does nothing visible today — it is zeroed because an <hr> that carries UA ink
176
+ * into a component is a trap waiting for the first rule that uses currentColor.
177
+ */
178
+ hr {
179
+ border: 0;
180
+ color: inherit;
181
+ }
182
+
183
+ /*
184
+ * 8. Anchor colour. Components built on <a> — .vd-nav-title, .vd-nav-item,
185
+ * .vd-breadcrumb — inherit the document ink; the UA gives them link blue instead.
186
+ * Measured: a.vd-nav-title rendered rgb(0, 0, 238). text-decoration needs no rule,
187
+ * measured: every link-shaped component already sets its own.
188
+ */
189
+ a {
190
+ color: inherit;
191
+ }
192
+
193
+ /*
194
+ * 9. Document ink and ground — Content/Primary on Surface/Frame.
195
+ *
196
+ * This is the one rule the bundle could never carry. src/base/index.css sets exactly
197
+ * these two declarations, dist/index.css ships them, and dist/dashboard-ui.css is
198
+ * built without ../base precisely so it never repaints a host's page — verify:bundle
199
+ * fails the build on a single bare `html` rule in the bundle. None of that argues
200
+ * against the default existing SOMEWHERE for a page with no host, which is what this
201
+ * file is for. Measured without it: ink rgb(0, 0, 0) against Content/Primary #16161a,
202
+ * and a transparent ground where the surface stack's back layer is #f0f3f7 — so every
203
+ * Surface/Paper panel (.vd-dropdown-menu, .vd-modal, .vd-pagination-item) rendered
204
+ * white-on-white and lost its figure against the page.
205
+ *
206
+ * It is also why this file is not merely redundant inside a host: a host that paints
207
+ * its own page must either skip reset.css or load its own `html` rule after it, since
208
+ * the two have equal specificity and source order decides.
209
+ */
210
+ html {
211
+ color: var(--color-content-primary);
212
+ background-color: var(--color-surface-frame);
213
+ }