@valiify/dashboard-ui 0.3.0 → 0.5.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.
- package/CHANGELOG.md +948 -10
- package/COMPONENTS.md +199 -79
- package/GETTING_STARTED.md +116 -54
- package/QUICK_REFERENCE.md +48 -30
- package/README.md +107 -85
- package/TROUBLESHOOTING.md +52 -34
- package/class-manifest.json +141 -71
- package/design-methodology/dashboard.md +92 -80
- package/dist/dashboard-ui.css +1529 -1078
- package/dist/index.css +1250 -732
- package/package.json +17 -10
- package/scripts/codemods/0.5.0-chip-sizes.mjs +437 -0
- package/src/build/utilities.css +7 -10
- package/src/components/_template.css +12 -8
- package/src/components/alert.css +35 -8
- package/src/components/avatar.css +42 -30
- package/src/components/breadcrumbs.css +39 -22
- package/src/components/button.css +84 -14
- package/src/components/card.css +2 -2
- package/src/components/checkbox.css +16 -11
- package/src/components/chip.css +155 -79
- package/src/components/composer.css +145 -0
- package/src/components/data-row.css +10 -6
- package/src/components/divider.css +17 -22
- package/src/components/dropdown-field.css +83 -43
- package/src/components/dropdown-menu.css +80 -14
- package/src/components/field-verification.css +21 -5
- package/src/components/filter-segment.css +27 -8
- package/src/components/icon-button.css +49 -10
- package/src/components/index.css +2 -0
- package/src/components/input.css +88 -32
- package/src/components/link.css +27 -16
- package/src/components/loading-inline.css +15 -21
- package/src/components/menu-item.css +149 -49
- package/src/components/modal.css +8 -5
- package/src/components/navigation-rail.css +67 -31
- package/src/components/pagination-item.css +29 -28
- package/src/components/pagination.css +9 -14
- package/src/components/pill.css +16 -10
- package/src/components/progress-bar.css +8 -10
- package/src/components/radio-select.css +9 -2
- package/src/components/recipient-input.css +119 -0
- package/src/components/section-marker.css +5 -5
- package/src/components/segment-selector.css +9 -3
- package/src/components/sensitive-data.css +7 -5
- package/src/components/skeleton.css +18 -6
- package/src/components/step.css +15 -4
- package/src/components/stepper.css +3 -2
- package/src/components/switch.css +7 -0
- package/src/components/tabs.css +122 -28
- package/src/components/tag.css +156 -51
- package/src/components/text-button.css +54 -59
- package/src/components/textarea.css +87 -22
- package/src/components/toast.css +41 -15
- package/src/components/tooltip.css +13 -2
- package/src/fonts.css +2 -1
- package/src/library.css +1 -1
- package/src/reset.css +1 -1
- package/src/themes/valiify-tokens.css +101 -126
- package/src/themes/valiify.css +258 -157
- package/src/utility-surface.css +51 -49
- package/types/components.d.ts +145 -25
- package/CLAUDE.md +0 -3740
- package/examples/README.md +0 -198
- package/examples/basic/index.html +0 -155
- package/examples/daisyui-starter/README.md +0 -58
- package/examples/daisyui-starter/check-no-bleed.mjs +0 -249
- package/examples/daisyui-starter/index.html +0 -72
- package/examples/daisyui-starter/linked.html +0 -74
- package/examples/daisyui-starter/package-lock.json +0 -2221
- package/examples/daisyui-starter/package.json +0 -22
- package/examples/daisyui-starter/postcss.config.js +0 -1
- package/examples/daisyui-starter/src/host.css +0 -14
- package/examples/daisyui-starter/src/only-import.css +0 -4
- package/examples/daisyui-starter/src/styles.css +0 -36
- package/examples/daisyui-starter/tailwind.config.js +0 -13
- package/examples/postcss-starter/README.md +0 -47
- package/examples/postcss-starter/index.html +0 -54
- package/examples/postcss-starter/package.json +0 -19
- package/examples/postcss-starter/postcss.config.js +0 -5
- package/examples/postcss-starter/src/styles.css +0 -17
- package/examples/sveltekit-starter/README.md +0 -32
- package/examples/sveltekit-starter/check-scoped-styles.mjs +0 -103
- package/examples/sveltekit-starter/package-lock.json +0 -1300
- package/examples/sveltekit-starter/package.json +0 -24
- package/examples/sveltekit-starter/src/app.css +0 -17
- package/examples/sveltekit-starter/src/app.html +0 -11
- package/examples/sveltekit-starter/src/lib/GlobalReset.svelte +0 -20
- package/examples/sveltekit-starter/src/lib/ScopedRemedy.svelte +0 -27
- package/examples/sveltekit-starter/src/lib/ScopedReset.svelte +0 -22
- package/examples/sveltekit-starter/src/routes/+layout.svelte +0 -6
- package/examples/sveltekit-starter/src/routes/+page.svelte +0 -10
- package/examples/sveltekit-starter/svelte.config.js +0 -4
- package/examples/sveltekit-starter/vite.config.js +0 -6
- package/examples/vite-starter/README.md +0 -125
- package/examples/vite-starter/index.html +0 -12
- package/examples/vite-starter/package.json +0 -19
- package/examples/vite-starter/src/main.js +0 -188
- package/examples/vite-starter/src/styles.css +0 -22
- package/examples/vite-starter/vite.config.js +0 -6
- package/src/themes/valiify-type-prefixed.css +0 -37
package/GETTING_STARTED.md
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
# Getting Started with @valiify/dashboard-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Installation guide for every supported setup. **The default is a Tailwind 4 app**,
|
|
4
|
+
which is what production uses; the Tailwind 3 and no-Tailwind paths are
|
|
5
|
+
[alternatives](#alternative-tailwind-3-or-a-host-with-its-own-reset) further down.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
| Your setup | Import | Section |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| **Tailwind 4** (default) | `@import "tailwindcss";` then `@import "@valiify/dashboard-ui/source";` | [Manual Installation](#manual-installation) |
|
|
10
|
+
| Tailwind 3, or any app with its own reset | `@import "@valiify/dashboard-ui/styles.css";` as the **first** line | [Alternative: Tailwind 3](#alternative-tailwind-3-or-a-host-with-its-own-reset) |
|
|
11
|
+
| No Tailwind, the bundle is the only stylesheet | `./reset.css` then `./styles.css` | [Alternative: no Tailwind](#alternative-no-tailwind-the-bundle-is-the-only-stylesheet) |
|
|
12
|
+
|
|
13
|
+
**`./source` requires Tailwind 4.** Tailwind is an optional peer dependency
|
|
14
|
+
(`>=3.0.0`): the prebuilt entries need none.
|
|
15
|
+
|
|
16
|
+
## Prerequisites (Tailwind 4)
|
|
6
17
|
|
|
7
18
|
- Node.js 18+ and npm
|
|
8
19
|
- A project (or create one with `npm init`)
|
|
9
|
-
- **A
|
|
20
|
+
- **A build integration** — one of Vite, webpack, PostCSS or the Tailwind CLI
|
|
10
21
|
|
|
11
|
-
> **⚠️ IMPORTANT**: Tailwind CSS v4
|
|
22
|
+
> **⚠️ IMPORTANT**: Tailwind CSS v4 needs an integration package to do anything. Installing only `tailwindcss` and `@valiify/dashboard-ui` fails silently, with no styles applied. You **must** install one of the integration packages below.
|
|
12
23
|
|
|
13
|
-
## Quick Start (
|
|
24
|
+
## Quick Start (Tailwind 4 + Vite)
|
|
14
25
|
|
|
15
|
-
The fastest way to get started.
|
|
26
|
+
The fastest way to get started. Copy the starter, which depends on the published
|
|
27
|
+
`@valiify/dashboard-ui@^0.5.0`:
|
|
16
28
|
|
|
17
29
|
```bash
|
|
18
30
|
# Copy the starter template
|
|
@@ -34,22 +46,22 @@ That's it. Open [http://localhost:5173](http://localhost:5173) to see a working
|
|
|
34
46
|
|
|
35
47
|
**For Vite:**
|
|
36
48
|
```bash
|
|
37
|
-
npm install @valiify/dashboard-ui tailwindcss @tailwindcss/vite
|
|
49
|
+
npm install @valiify/dashboard-ui tailwindcss@4 @tailwindcss/vite
|
|
38
50
|
```
|
|
39
51
|
|
|
40
52
|
**For webpack:**
|
|
41
53
|
```bash
|
|
42
|
-
npm install @valiify/dashboard-ui tailwindcss @tailwindcss/webpack
|
|
54
|
+
npm install @valiify/dashboard-ui tailwindcss@4 @tailwindcss/webpack
|
|
43
55
|
```
|
|
44
56
|
|
|
45
57
|
**For PostCSS (including Next.js):**
|
|
46
58
|
```bash
|
|
47
|
-
npm install @valiify/dashboard-ui tailwindcss @tailwindcss/postcss
|
|
59
|
+
npm install @valiify/dashboard-ui tailwindcss@4 @tailwindcss/postcss
|
|
48
60
|
```
|
|
49
61
|
|
|
50
62
|
**For Tailwind standalone CLI:**
|
|
51
63
|
```bash
|
|
52
|
-
npm install @valiify/dashboard-ui tailwindcss @tailwindcss/cli
|
|
64
|
+
npm install @valiify/dashboard-ui tailwindcss@4 @tailwindcss/cli
|
|
53
65
|
```
|
|
54
66
|
|
|
55
67
|
> **Why three packages?** `tailwindcss` alone doesn't process CSS in v4. You need **both** `tailwindcss` and one of the `@tailwindcss/*` integration packages for anything to work.
|
|
@@ -121,7 +133,7 @@ Create a CSS file (e.g., `src/styles.css`):
|
|
|
121
133
|
|
|
122
134
|
```css
|
|
123
135
|
/* Optional: Load fonts (or self-host for better performance) */
|
|
124
|
-
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");
|
|
136
|
+
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");
|
|
125
137
|
|
|
126
138
|
/* Required: Tailwind CSS */
|
|
127
139
|
@import "tailwindcss";
|
|
@@ -134,6 +146,35 @@ Create a CSS file (e.g., `src/styles.css`):
|
|
|
134
146
|
|
|
135
147
|
> **⚠️ CRITICAL**: Import the library from CSS, never from JavaScript. See [Common Mistakes](#common-mistakes) below.
|
|
136
148
|
|
|
149
|
+
> **⚠️ Don't disable Preflight.** In a Tailwind 4 app, Tailwind's Preflight *is*
|
|
150
|
+
> the reset these components are sized against. Importing only Tailwind's theme and
|
|
151
|
+
> utilities (leaving out `tailwindcss/preflight.css`) leaves elements `content-box`
|
|
152
|
+
> with the browser's margins and fonts, and components render the wrong size with no
|
|
153
|
+
> error. If you must turn Preflight off, load the library's reset into Tailwind's
|
|
154
|
+
> `base` layer in its place:
|
|
155
|
+
>
|
|
156
|
+
> ```css
|
|
157
|
+
> @layer theme, base, components, utilities;
|
|
158
|
+
> @import "tailwindcss/theme.css" layer(theme);
|
|
159
|
+
> @import "@valiify/dashboard-ui/reset.css" layer(base);
|
|
160
|
+
> @import "tailwindcss/utilities.css" layer(utilities);
|
|
161
|
+
> @import "@valiify/dashboard-ui/source";
|
|
162
|
+
> ```
|
|
163
|
+
>
|
|
164
|
+
> **Not a plain `@import "@valiify/dashboard-ui/reset.css";`.** `./source` keeps its
|
|
165
|
+
> component rules in `@layer components`, and an unlayered rule beats every layered
|
|
166
|
+
> one, so the reset's element rules would override the components' own styling. In
|
|
167
|
+
> `layer(base)` the reset sits beneath the components, where a reset belongs.
|
|
168
|
+
>
|
|
169
|
+
> Measured on 0.5.0 in Chromium, with the documented markup and an 828px-wide Alert:
|
|
170
|
+
>
|
|
171
|
+
> | Tailwind 4 setup | Small input | Alert | Font |
|
|
172
|
+
> | --- | --- | --- | --- |
|
|
173
|
+
> | Documented (`@import "tailwindcss";`, Preflight on) | **24** | **98** | Inter |
|
|
174
|
+
> | Preflight off (theme + utilities only) | 26 | 152 | Times |
|
|
175
|
+
> | Preflight off + plain `reset.css` import | 24 | 106 | Inter |
|
|
176
|
+
> | Preflight off + `reset.css` in `layer(base)` | **24** | **98** | Inter |
|
|
177
|
+
|
|
137
178
|
### Step 4: Import Your Stylesheet
|
|
138
179
|
|
|
139
180
|
In your JavaScript entry point:
|
|
@@ -187,12 +228,13 @@ fetch(spriteUrl)
|
|
|
187
228
|
|
|
188
229
|
See [COMPONENTS.md](COMPONENTS.md) for complete markup examples of every component.
|
|
189
230
|
|
|
190
|
-
##
|
|
231
|
+
## Alternative: Tailwind 3, or a host with its own reset
|
|
191
232
|
|
|
192
|
-
If your
|
|
193
|
-
|
|
194
|
-
`@valiify/dashboard-ui` (`dist/index.css`),
|
|
195
|
-
an `html` rule and fights your reset
|
|
233
|
+
If your app has no Tailwind 4 pipeline — Tailwind 3 + daisyUI, or a framework's
|
|
234
|
+
own base styles — import the prebuilt, host-safe bundle instead of `./source`
|
|
235
|
+
(which needs Tailwind 4), and **not** `@valiify/dashboard-ui` (`dist/index.css`),
|
|
236
|
+
which ships Tailwind's Preflight and an `html` rule and fights your reset. Install
|
|
237
|
+
the package alone: `npm install @valiify/dashboard-ui`.
|
|
196
238
|
|
|
197
239
|
```css
|
|
198
240
|
/* app.css — inside the file that carries your @tailwind directives */
|
|
@@ -227,30 +269,31 @@ checkable, in two clauses:
|
|
|
227
269
|
and never write a bare `button` / `input` / `textarea` selector inside a
|
|
228
270
|
component that renders a `vd-` control.
|
|
229
271
|
|
|
230
|
-
Both clauses are measured, not asserted
|
|
231
|
-
daisyUI, three load paths) and
|
|
232
|
-
clause 2 asserted as a loss)
|
|
272
|
+
Both clauses are measured, not asserted, by two host checks in the repository:
|
|
273
|
+
`examples/daisyui-starter` (Tailwind 3 + daisyUI, three load paths) and
|
|
274
|
+
`examples/sveltekit-starter` (scoped styles, including clause 2 asserted as a loss).
|
|
233
275
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
Everything above is about coexisting with a host's reset. If there is no host —
|
|
237
|
-
a standalone page, a static export, a demo — there is no reset either, and the
|
|
238
|
-
browser's own defaults break the library. Measured over the documented markup with
|
|
239
|
-
only the bundle loaded: 479 of 582 elements were `content-box`, so every padded
|
|
240
|
-
component rendered larger than designed (`.vd-input-field.vd-input-sm` at 38px
|
|
241
|
-
against a designed 25, `.vd-modal` 546px wide against 480); `<p>` and `<h2>` carried
|
|
242
|
-
their 1em UA margin inside Alert, Toast, Modal and Tooltip (`.vd-alert` 137.5px
|
|
243
|
-
against 88.5); `<button>` carried its 2px UA border, so every underline tab was 4px
|
|
244
|
-
too wide; and the document rendered in Times, because the bundle defines
|
|
245
|
-
`--font-sans` but has no Preflight to bind it.
|
|
276
|
+
## Alternative: no Tailwind (the bundle is the only stylesheet)
|
|
246
277
|
|
|
247
|
-
|
|
278
|
+
**Step 1 — required: load the reset first, then the bundle.** On this path the
|
|
279
|
+
reset is not optional; without it every component renders the wrong size.
|
|
248
280
|
|
|
249
281
|
```css
|
|
250
|
-
@import "@valiify/dashboard-ui/reset.css"; /* first */
|
|
282
|
+
@import "@valiify/dashboard-ui/reset.css"; /* first — required */
|
|
251
283
|
@import "@valiify/dashboard-ui/styles.css";
|
|
252
284
|
```
|
|
253
285
|
|
|
286
|
+
Everything above is about coexisting with a host's reset. If there is no host —
|
|
287
|
+
a standalone page, a static export, a demo — there is no reset either, and the
|
|
288
|
+
browser's own defaults break the library. Measured on 0.5.0 with only the bundle
|
|
289
|
+
loaded: elements are `content-box`, so padded components render larger than
|
|
290
|
+
designed (`.vd-input-field.vd-input-sm` at 26px against a designed 24, `.vd-modal`
|
|
291
|
+
546px wide against 480); `<p>` and `<h2>` carry their 1em UA margin inside Alert,
|
|
292
|
+
Toast, Modal and Tooltip (`.vd-alert` 152px against 98); `<button>` carries its 2px
|
|
293
|
+
UA border; and the document renders in Times, because the bundle defines
|
|
294
|
+
`--font-sans` but has no Preflight to bind it. With the reset loaded first, all of
|
|
295
|
+
those measure exactly as designed — which is why Step 1 is required.
|
|
296
|
+
|
|
254
297
|
Order matters. The reset is unlayered element selectors (0,0,1) and the bundle's
|
|
255
298
|
component classes are (0,1,0), so specificity settles it either way — but loading
|
|
256
299
|
the reset second would put a UA-default rule after the classes it is meant to sit
|
|
@@ -266,8 +309,13 @@ stylesheet unsafe to drop into a host.
|
|
|
266
309
|
It is about twenty lines and deliberately not a Preflight. It leaves lists, tables,
|
|
267
310
|
images, fieldsets, form-control appearance, placeholder colour and
|
|
268
311
|
`blockquote`/`figure`/`dl` margins alone — a host is entitled to own all of that.
|
|
269
|
-
Every rule exists because a measured value was wrong without it, and
|
|
270
|
-
|
|
312
|
+
Every rule exists because a measured value was wrong without it, and the library's
|
|
313
|
+
CI re-measures the whole file in a browser on every run.
|
|
314
|
+
|
|
315
|
+
**No build step at all?** A single `<link>` to the prebuilt file that carries its
|
|
316
|
+
own Preflight works on a standalone page:
|
|
317
|
+
`<link rel="stylesheet" href="node_modules/@valiify/dashboard-ui/dist/index.css">`.
|
|
318
|
+
Don't use it inside an app that has its own reset.
|
|
271
319
|
|
|
272
320
|
## Common Mistakes
|
|
273
321
|
|
|
@@ -297,7 +345,7 @@ Your dev server returns HTTP 200, the page loads, and all library styles are mis
|
|
|
297
345
|
import "./styles.css";
|
|
298
346
|
```
|
|
299
347
|
|
|
300
|
-
### ❌ Missing Integration Package
|
|
348
|
+
### ❌ Missing Integration Package (Tailwind 4)
|
|
301
349
|
|
|
302
350
|
**This also breaks silently:**
|
|
303
351
|
|
|
@@ -311,6 +359,10 @@ Without `@tailwindcss/vite` (or postcss/webpack), `@import "tailwindcss"` does n
|
|
|
311
359
|
|
|
312
360
|
### ❌ Wrong Import Order
|
|
313
361
|
|
|
362
|
+
On the prebuilt `./styles.css`, its `@import` must be the **first** line of the file — CSS discards an `@import` that follows any other rule.
|
|
363
|
+
|
|
364
|
+
On Tailwind 4:
|
|
365
|
+
|
|
314
366
|
**This fails:**
|
|
315
367
|
|
|
316
368
|
```css
|
|
@@ -434,25 +486,35 @@ Needs:
|
|
|
434
486
|
**Minimal example:**
|
|
435
487
|
|
|
436
488
|
```js
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
trigger.
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
489
|
+
// One handler per dropdown on the page. Each .vd-dropdown wraps a trigger
|
|
490
|
+
// (aria-haspopup + aria-expanded) and a .vd-dropdown-panel that starts `hidden`.
|
|
491
|
+
for (const dropdown of document.querySelectorAll(".vd-dropdown")) {
|
|
492
|
+
const trigger = dropdown.querySelector("[aria-haspopup]");
|
|
493
|
+
const panel = dropdown.querySelector(".vd-dropdown-panel");
|
|
494
|
+
|
|
495
|
+
const setOpen = (open) => {
|
|
496
|
+
trigger.setAttribute("aria-expanded", String(open));
|
|
497
|
+
panel.hidden = !open;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
trigger.addEventListener("click", () =>
|
|
501
|
+
setOpen(trigger.getAttribute("aria-expanded") !== "true"),
|
|
502
|
+
);
|
|
445
503
|
|
|
446
|
-
// Close on outside click
|
|
447
|
-
document.addEventListener("click", (e) => {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
504
|
+
// Close on an outside click, and on Escape (returning focus to the trigger).
|
|
505
|
+
document.addEventListener("click", (e) => {
|
|
506
|
+
if (!dropdown.contains(e.target)) setOpen(false);
|
|
507
|
+
});
|
|
508
|
+
dropdown.addEventListener("keydown", (e) => {
|
|
509
|
+
if (e.key === "Escape") {
|
|
510
|
+
setOpen(false);
|
|
511
|
+
trigger.focus();
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
453
515
|
```
|
|
454
516
|
|
|
455
|
-
|
|
517
|
+
Option selection (writing the chosen value back into the trigger) is the remaining piece; see [examples/vite-starter/src/main.js](https://github.com/BubbaCoop/Valiify-dashboard-ui/blob/main/examples/vite-starter/src/main.js) (in the repository; examples are not part of the npm package) for a complete implementation.
|
|
456
518
|
|
|
457
519
|
### Tabs
|
|
458
520
|
|
|
@@ -492,13 +554,13 @@ To verify your installation is working:
|
|
|
492
554
|
|
|
493
555
|
1. **Styles apply** - Buttons should have colored backgrounds and rounded corners
|
|
494
556
|
2. **Icons render** - If you see `#icon-name` text, the sprite didn't load
|
|
495
|
-
3. **Token utilities work** - Try `<div class="bg-approved">` - it should have a green background
|
|
557
|
+
3. **Token utilities work** (Tailwind 4 / `./source` only) - Try `<div class="bg-approved">` - it should have a green background. The prebuilt bundles don't carry token utilities; `./styles.css` ships a closed `vd:` set instead (`vd:bg-approved`)
|
|
496
558
|
4. **No console errors** - Check for 404s on sprite.svg or CSS files
|
|
497
559
|
|
|
498
560
|
## Next Steps
|
|
499
561
|
|
|
500
562
|
- Browse components in [COMPONENTS.md](COMPONENTS.md)
|
|
501
|
-
- See working
|
|
563
|
+
- See the working starters in the repository: [examples/vite-starter](https://github.com/BubbaCoop/Valiify-dashboard-ui/tree/main/examples/vite-starter) and [examples/postcss-starter](https://github.com/BubbaCoop/Valiify-dashboard-ui/tree/main/examples/postcss-starter)
|
|
502
564
|
- Read the [README](README.md) for architecture and development info
|
|
503
565
|
- Check [TROUBLESHOOTING.md](TROUBLESHOOTING.md) if you hit issues
|
|
504
566
|
|
package/QUICK_REFERENCE.md
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
**One-page reference for common tasks.**
|
|
4
4
|
|
|
5
|
-
## Installation (Vite)
|
|
5
|
+
## Installation (Tailwind 4 + Vite — the default)
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @valiify/dashboard-ui tailwindcss @tailwindcss/vite
|
|
8
|
+
npm install @valiify/dashboard-ui tailwindcss@4 @tailwindcss/vite
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
**`./source` requires Tailwind 4.** Alternatives (no `tailwindcss` install needed):
|
|
12
|
+
Tailwind 3 or an app with its own reset — `@import "@valiify/dashboard-ui/styles.css";`
|
|
13
|
+
as the **first** line; no Tailwind and no other stylesheet — `@import
|
|
14
|
+
"@valiify/dashboard-ui/reset.css";` then `./styles.css`. See
|
|
15
|
+
[GETTING_STARTED.md](GETTING_STARTED.md).
|
|
16
|
+
|
|
11
17
|
**vite.config.js:**
|
|
12
18
|
```js
|
|
13
19
|
import tailwindcss from "@tailwindcss/vite";
|
|
@@ -24,7 +30,7 @@ export default { plugins: [tailwindcss()] };
|
|
|
24
30
|
```js
|
|
25
31
|
import "./styles.css";
|
|
26
32
|
|
|
27
|
-
// Load sprite
|
|
33
|
+
// Load sprite (`?url` is Vite's syntax; other bundlers expose asset URLs their own way)
|
|
28
34
|
import spriteUrl from "@valiify/dashboard-ui/icons/sprite.svg?url";
|
|
29
35
|
fetch(spriteUrl).then(r => r.text()).then(svg => {
|
|
30
36
|
const host = document.createElement("div");
|
|
@@ -79,7 +85,6 @@ fetch(spriteUrl).then(r => r.text()).then(svg => {
|
|
|
79
85
|
```html
|
|
80
86
|
<div class="vd-dropdown">
|
|
81
87
|
<button
|
|
82
|
-
id="trigger"
|
|
83
88
|
class="vd-dropdown-field"
|
|
84
89
|
aria-haspopup="listbox"
|
|
85
90
|
aria-expanded="false"
|
|
@@ -89,9 +94,9 @@ fetch(spriteUrl).then(r => r.text()).then(svg => {
|
|
|
89
94
|
<use href="#chevron-down" />
|
|
90
95
|
</svg>
|
|
91
96
|
</button>
|
|
92
|
-
<div
|
|
97
|
+
<div class="vd-dropdown-panel" hidden>
|
|
93
98
|
<div class="vd-dropdown-menu" role="listbox">
|
|
94
|
-
<button class="vd-menu-item" role="option" data-value="1">
|
|
99
|
+
<button class="vd-menu-item" role="option" aria-selected="false" data-value="1">
|
|
95
100
|
<span class="vd-menu-item-text">
|
|
96
101
|
<span class="vd-menu-item-title">Option 1</span>
|
|
97
102
|
</span>
|
|
@@ -100,36 +105,48 @@ fetch(spriteUrl).then(r => r.text()).then(svg => {
|
|
|
100
105
|
</div>
|
|
101
106
|
</div>
|
|
102
107
|
|
|
103
|
-
|
|
104
|
-
const trigger = document.getElementById("trigger");
|
|
105
|
-
const panel = document.getElementById("panel");
|
|
106
|
-
|
|
107
|
-
trigger.addEventListener("click", () => {
|
|
108
|
-
const isOpen = trigger.getAttribute("aria-expanded") === "true";
|
|
109
|
-
trigger.setAttribute("aria-expanded", !isOpen);
|
|
110
|
-
panel.hidden = isOpen;
|
|
111
|
-
});
|
|
108
|
+
```
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
```js
|
|
111
|
+
// One handler per dropdown on the page. Each .vd-dropdown wraps a trigger
|
|
112
|
+
// (aria-haspopup + aria-expanded) and a .vd-dropdown-panel that starts `hidden`.
|
|
113
|
+
for (const dropdown of document.querySelectorAll(".vd-dropdown")) {
|
|
114
|
+
const trigger = dropdown.querySelector("[aria-haspopup]");
|
|
115
|
+
const panel = dropdown.querySelector(".vd-dropdown-panel");
|
|
116
|
+
|
|
117
|
+
const setOpen = (open) => {
|
|
118
|
+
trigger.setAttribute("aria-expanded", String(open));
|
|
119
|
+
panel.hidden = !open;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
trigger.addEventListener("click", () =>
|
|
123
|
+
setOpen(trigger.getAttribute("aria-expanded") !== "true"),
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Close on an outside click, and on Escape (returning focus to the trigger).
|
|
127
|
+
document.addEventListener("click", (e) => {
|
|
128
|
+
if (!dropdown.contains(e.target)) setOpen(false);
|
|
129
|
+
});
|
|
130
|
+
dropdown.addEventListener("keydown", (e) => {
|
|
131
|
+
if (e.key === "Escape") {
|
|
132
|
+
setOpen(false);
|
|
133
|
+
trigger.focus();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
120
137
|
```
|
|
121
138
|
|
|
122
139
|
## Token Utilities
|
|
123
140
|
|
|
124
|
-
**
|
|
141
|
+
**Tailwind 4 / `./source` only.** The prebuilt bundles don't carry token utilities; `./styles.css` ships a closed set spelled `vd:` (`vd:bg-approved`).
|
|
125
142
|
|
|
126
143
|
```html
|
|
127
144
|
<div class="bg-approved text-content-contrast rounded-control">
|
|
128
145
|
Approved background
|
|
129
146
|
</div>
|
|
130
147
|
|
|
131
|
-
<p class="text-content-secondary
|
|
132
|
-
|
|
148
|
+
<p class="text-content-secondary text-label-compact">
|
|
149
|
+
Section label
|
|
133
150
|
</p>
|
|
134
151
|
|
|
135
152
|
<div class="shadow-panel rounded-surface">
|
|
@@ -140,15 +157,16 @@ document.addEventListener("click", (e) => {
|
|
|
140
157
|
## Troubleshooting
|
|
141
158
|
|
|
142
159
|
**No styles:**
|
|
143
|
-
1.
|
|
144
|
-
2.
|
|
145
|
-
3.
|
|
160
|
+
1. Tailwind 4: install `@tailwindcss/vite` (or postcss/webpack) and register it
|
|
161
|
+
2. Import from CSS, not JS
|
|
162
|
+
3. Prebuilt `./styles.css`: its `@import` must be the first line
|
|
146
163
|
|
|
147
164
|
**No icons:**
|
|
148
165
|
- Add sprite loading code (see Installation above)
|
|
149
166
|
|
|
150
167
|
**No utilities:**
|
|
151
|
-
-
|
|
168
|
+
- Tailwind 4: use `@import "@valiify/dashboard-ui/source"`, not `@import "@valiify/dashboard-ui"`
|
|
169
|
+
- Tailwind 3 / no Tailwind: use the `vd:` spelling `./styles.css` ships
|
|
152
170
|
|
|
153
171
|
**Component broken:**
|
|
154
172
|
- Check [COMPONENTS.md](COMPONENTS.md) for required wrapper elements
|
|
@@ -158,4 +176,4 @@ document.addEventListener("click", (e) => {
|
|
|
158
176
|
- [Complete Installation](GETTING_STARTED.md)
|
|
159
177
|
- [All Components](COMPONENTS.md)
|
|
160
178
|
- [Troubleshooting](TROUBLESHOOTING.md)
|
|
161
|
-
- [Examples](examples
|
|
179
|
+
- [Examples](https://github.com/BubbaCoop/Valiify-dashboard-ui/tree/main/examples) (in the repository)
|