@valiify/dashboard-ui 0.2.0 → 0.2.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/CLAUDE.md +78 -3
  3. package/GETTING_STARTED.md +49 -0
  4. package/README.md +20 -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 +4 -2
  33. package/src/build/components.css +6 -0
  34. package/src/build/utilities.css +6 -2
@@ -17,6 +17,6 @@
17
17
  "vite": "^5.4.11"
18
18
  },
19
19
  "dependencies": {
20
- "@valiify/dashboard-ui": "^0.2.0"
20
+ "@valiify/dashboard-ui": "^0.2.1"
21
21
  }
22
22
  }
@@ -0,0 +1,14 @@
1
+ /*
2
+ * The host's stylesheet ALONE — no @import of ours. linked.html pairs this with a
3
+ * <link> to the bundle file, so the bundle reaches the browser exactly as shipped:
4
+ * the host's Tailwind never sees it and cannot strip its cascade layers.
5
+ */
6
+ @tailwind base;
7
+ @tailwind components;
8
+ @tailwind utilities;
9
+
10
+ body {
11
+ font-size: 17px;
12
+ line-height: 2;
13
+ color: rebeccapurple;
14
+ }
@@ -0,0 +1,4 @@
1
+ /* Probe: our bundle as a SEPARATE file through the host's PostCSS — no @tailwind
2
+ directives in this file. Does Tailwind 3 strip the layers, pass them through, or
3
+ refuse? check-no-bleed.mjs reads the answer off the served CSS. */
4
+ @import "@valiify/dashboard-ui/styles.css";
@@ -7,14 +7,30 @@
7
7
  * pass here: daisyUI rendered correctly while every vd- class fell back to unstyled,
8
8
  * which reads exactly like a namespace failure and is not one.
9
9
  *
10
- * Loading ours first does NOT make this a soft test. daisyUI 4 is unlayered and our
11
- * component rules live in @layer components, and an unlayered rule beats a layered one
12
- * before specificity or order is consulted. On any name the two libraries shared,
13
- * daisyUI would win no matter which file came first. Order cannot rescue us here; only
14
- * the vd- namespace can.
10
+ * That order is also what makes this the honest test. `@tailwind base` expands to
11
+ * Tailwind 3's preflight, UNLAYERED and AFTER our bundle: `*, ::before, ::after {
12
+ * border-width: 0 }`, `button { background-color: transparent }`, `button, input,
13
+ * textarea { font-size: 100%; line-height: inherit; color: inherit; padding: 0 }`.
14
+ * A component rule that sits inside a cascade layer loses to every one of those
15
+ * before specificity or source order is consulted. A component rule that is
16
+ * unlayered wins on specificity (a class beats an element and beats `*`).
17
+ * check-no-bleed.mjs measures which of the two the shipped bundle is.
15
18
  */
16
19
  @import "@valiify/dashboard-ui/styles.css";
17
20
 
18
21
  @tailwind base;
19
22
  @tailwind components;
20
23
  @tailwind utilities;
24
+
25
+ /*
26
+ * The host's own body type — deliberately NOT the library's defaults. Preflight
27
+ * makes form controls inherit font-size, line-height and color from here; if our
28
+ * input rule loses, the input reads 17px / 34px / purple instead of the designed
29
+ * 13px / 19.5px / Content-Primary, and the check can see it. With the library's own
30
+ * values here, the defeat would be invisible by coincidence.
31
+ */
32
+ body {
33
+ font-size: 17px;
34
+ line-height: 2;
35
+ color: rebeccapurple;
36
+ }
@@ -1,12 +1,13 @@
1
1
  /**
2
- * Tailwind 3 + daisyUI 4 — the host app's stack, not ours.
2
+ * Tailwind 3 + daisyUI 4 — the host app's stack (the dashboard app), not ours.
3
3
  *
4
- * This example exists to prove the two can share a document. The library ships
5
- * dist/dashboard-ui.css, which is compiled by Tailwind 4 and imported as a plain
6
- * stylesheet; this config never sees it. That is the point: a consumer's Tailwind
7
- * major is irrelevant to a prebuilt bundle.
4
+ * The library ships dist/dashboard-ui.css, compiled by Tailwind 4 and imported here
5
+ * as a plain stylesheet; this config never sees it. That is the point: a consumer's
6
+ * Tailwind major is irrelevant to a prebuilt bundle. What this config DOES do is
7
+ * emit Tailwind 3's preflight — `@tailwind base` — unlayered and after our import,
8
+ * which is exactly the host reset check-no-bleed.mjs measures our components under.
8
9
  */
9
10
  export default {
10
- content: ["./index.html", "./src/**/*.{js,ts}"],
11
+ content: ["./index.html", "./linked.html", "./src/**/*.{js,ts}"],
11
12
  plugins: [require("daisyui")],
12
13
  };
@@ -8,7 +8,7 @@
8
8
  "serve": "npm run build && npx serve ."
9
9
  },
10
10
  "dependencies": {
11
- "@valiify/dashboard-ui": "^0.2.0"
11
+ "@valiify/dashboard-ui": "^0.2.1"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@tailwindcss/postcss": "^4.0.0",
@@ -0,0 +1,32 @@
1
+ # dashboard-ui + SvelteKit (Svelte 5)
2
+
3
+ The scoped-style test. A Svelte component's `<style>` compiles to **unlayered**
4
+ CSS that Vite injects after the app stylesheet — a second source of the
5
+ cascade-layer defeat that `examples/daisyui-starter` measures with Tailwind 3
6
+ preflight, and one a plain Vite page never reproduces. A SvelteKit host has it.
7
+
8
+ No Tailwind here at all. The shell imports `styles.css` and nothing else; the
9
+ thing under test is what SvelteKit does to component CSS. (dashboard-ui ships no
10
+ reset.css — the host paints its own page in `src/app.css`.)
11
+
12
+ `npm run check` starts the dev server, renders the page and asserts computed
13
+ styles for three components in `src/lib`, reading the compiled selectors off the
14
+ served stylesheets rather than assuming them:
15
+
16
+ | case | scoped source | compiles to | bundle |
17
+ | --- | --- | --- | --- |
18
+ | 1 | `:global(button) { border: 0 }` | `button` — 0,0,1, unlayered | **must win** (this is the fix) |
19
+ | 2 | `button { border: 0 }` | `button.svelte-hash` — 0,1,1 | **cannot win** — asserted as a loss |
20
+ | 3 | `button:not([class*="vd-"]) { border: 0 }` | never matches ours | must win; the dev's plain button still resets |
21
+
22
+ Case 2 is the honest one. Unlayering the bundle fixes preflight, daisyUI and any
23
+ `:global` reset; it does not fix a host rule at higher specificity, and a scoped
24
+ element selector on the same element is exactly that. The remedy is case 3, or
25
+ scoping the reset by class. The assertion pins the limit to a measurement so the
26
+ README and GETTING_STARTED contract's second clause cannot drift from what is true.
27
+
28
+ ```bash
29
+ npm install
30
+ npm run check
31
+ npm run dev
32
+ ```
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Scoped-style assertion: dashboard-ui inside SvelteKit + Svelte 5.
4
+ *
5
+ * npm run check
6
+ *
7
+ * A Svelte component's <style> compiles to UNLAYERED CSS that Vite injects after
8
+ * the app's stylesheet. That is a second source of the cascade-layer defeat the
9
+ * daisyui-starter measures — one a plain Vite page never reproduces, and one a
10
+ * SvelteKit host has. Three cases, each a real component in src/lib, each
11
+ * measured against the compiled output rather than the source:
12
+ *
13
+ * 1 :global(button) { border: 0 } → bare `button`, 0,0,1. Bundle MUST win.
14
+ * 2 button { border: 0 } → `button.svelte-h`, 0,1,1. Bundle CANNOT win.
15
+ * Asserted as a loss on purpose — see below.
16
+ * 3 button:not([class*="vd-"]) → never matches ours. Bundle MUST win,
17
+ * and the dev's plain button MUST still reset.
18
+ *
19
+ * Case 2 is asserted in the direction that is TRUE: our border is lost. Unlayering
20
+ * the bundle fixes preflight, daisyUI and case 1; it does not and cannot fix a host
21
+ * rule at higher specificity. Pinning that to a measurement keeps the docs' second
22
+ * clause honest — if this assertion ever flips, the contract text is stale.
23
+ *
24
+ * The scoping shape itself is read from the served CSS, not assumed.
25
+ */
26
+ import { chromium } from "playwright";
27
+ import { createServer } from "vite";
28
+
29
+ const RED = "\x1b[31m", GRN = "\x1b[32m", DIM = "\x1b[2m", BOLD = "\x1b[1m", OFF = "\x1b[0m";
30
+ const server = await createServer({ server: { port: 5198 }, logLevel: "silent" });
31
+ await server.listen();
32
+ const browser = await chromium.launch();
33
+ const page = await browser.newPage();
34
+ await page.goto("http://localhost:5198/", { waitUntil: "networkidle" });
35
+
36
+ const style = (sel, prop) =>
37
+ page.evaluate(([s, p]) => {
38
+ const el = document.querySelector(s);
39
+ return el ? getComputedStyle(el).getPropertyValue(p) : null;
40
+ }, [sel, prop]);
41
+ const token = (name) =>
42
+ page.evaluate((n) => {
43
+ const probe = document.createElement("span");
44
+ probe.style.color = `var(${n})`;
45
+ document.body.append(probe);
46
+ const v = getComputedStyle(probe).color;
47
+ probe.remove();
48
+ return v;
49
+ }, name);
50
+
51
+ // Evidence, not assumption: how did Svelte actually scope the element selector?
52
+ const scoped = await page.evaluate(() => {
53
+ const out = [];
54
+ for (const sheet of document.styleSheets) {
55
+ let rules; try { rules = sheet.cssRules; } catch { continue; }
56
+ for (const r of rules) if (r.selectorText && /^button\.svelte-|^button:not|^button$/.test(r.selectorText)) out.push(r.selectorText);
57
+ }
58
+ return out;
59
+ });
60
+
61
+ const results = [];
62
+ const check = async (label, sel, prop, want, why) => {
63
+ const got = await style(sel, prop);
64
+ results.push({ label, prop, got, want, ok: got === want, why });
65
+ };
66
+
67
+ // The hairline is authored 0.5px; Chrome computes it as 1px (CLAUDE.md). 0px is the loss.
68
+ await check("case 1 · :global(button) reset — our hairline survives",
69
+ "#global-reset-trigger", "border-top-width", "1px",
70
+ "a bare unlayered `button { border: 0 }` beat our class. The bundle's rule is inside a cascade layer; unlayered, 0,1,0 beats 0,0,1.");
71
+ await check("case 2 · scoped button { } — our hairline is LOST (documented limit)",
72
+ "#scoped-trigger", "border-top-width", "0px",
73
+ "our border SURVIVED a 0,1,1 scoped element rule. That is not possible under CSS specificity — either Svelte changed its scoping (check the selectors printed below) or the bundle grew specificity. Update the docs' second clause; do not just flip this assertion.");
74
+ await check("case 3 · button:not([class*=\"vd-\"]) — our hairline survives",
75
+ "#remedy-trigger", "border-top-width", "1px",
76
+ "the excluded selector matched our control, or the bundle's rule lost anyway (layered).");
77
+ // Measured on padding, which only the remedy rule sets (case 1's :global reset touches
78
+ // border on every button on the page, so border alone could not tell the two apart).
79
+ await check("case 3 · the component's own plain button is still reset (padding, UA default 6px)",
80
+ "#remedy-plain", "padding-left", "0px",
81
+ "the remedy stopped resetting the dev's own controls — it must not be a no-op.");
82
+ await check("case 3 · our trigger keeps its 12px padding under the same rule",
83
+ "#remedy-trigger", "padding-left", "12px",
84
+ "the excluded selector matched our control.");
85
+ const contrast = await token("--color-content-contrast");
86
+ await check("case 3 · .vd-btn-primary keeps its Content/Contrast ink beside the :global reset",
87
+ "#remedy-primary", "color", contrast,
88
+ "the label inherited the page ink onto the blue fill — a `button { color: inherit }`-shaped host rule beat .vd-btn-primary.");
89
+
90
+ await browser.close();
91
+ await server.close();
92
+
93
+ console.log(`\n${BOLD}dashboard-ui inside SvelteKit + Svelte 5${OFF}\n`);
94
+ console.log(` ${DIM}compiled element selectors served to the page:${OFF}`);
95
+ for (const s of scoped) console.log(` ${DIM} ${s}${OFF}`);
96
+ console.log();
97
+ for (const r of results) {
98
+ console.log(` ${r.ok ? GRN + "PASS" : RED + "FAIL"}${OFF} ${r.label} ${DIM}${r.prop}=${r.got} (want ${r.want})${OFF}`);
99
+ if (!r.ok && r.why) for (const l of r.why.split("\n")) console.log(`${DIM} ${l}${OFF}`);
100
+ }
101
+ const failed = results.filter((r) => !r.ok);
102
+ console.log(`\n ${failed.length ? RED : GRN}${results.length - failed.length}/${results.length} passed${OFF}\n`);
103
+ process.exit(failed.length ? 1 : 0);