@deepfuture/dui-theme-default 0.0.1 → 0.0.4

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 (63) hide show
  1. package/README.md +191 -0
  2. package/components/accordion-item.js +11 -10
  3. package/components/alert-dialog-popup.js +9 -17
  4. package/components/avatar.js +2 -2
  5. package/components/badge.js +55 -29
  6. package/components/breadcrumb-ellipsis.js +1 -1
  7. package/components/breadcrumb-link.js +2 -2
  8. package/components/breadcrumb-page.js +1 -1
  9. package/components/breadcrumb-separator.js +1 -1
  10. package/components/breadcrumb.js +3 -2
  11. package/components/button.js +88 -51
  12. package/components/calendar.js +24 -21
  13. package/components/checkbox-group.js +1 -1
  14. package/components/checkbox.js +10 -9
  15. package/components/collapsible.js +11 -10
  16. package/components/combobox.js +65 -19
  17. package/components/command-empty.js +3 -2
  18. package/components/command-group.js +3 -2
  19. package/components/command-input.js +4 -3
  20. package/components/command-item.js +6 -5
  21. package/components/command-list.js +1 -1
  22. package/components/command-separator.js +1 -1
  23. package/components/command-shortcut.js +3 -2
  24. package/components/command.js +2 -2
  25. package/components/data-table.js +20 -19
  26. package/components/dialog-popup.js +9 -17
  27. package/components/dropzone.js +10 -9
  28. package/components/input.js +13 -12
  29. package/components/menu-item.js +11 -9
  30. package/components/menu.js +19 -1
  31. package/components/number-field.js +13 -11
  32. package/components/popover-popup.js +25 -1
  33. package/components/preview-card-popup.js +26 -1
  34. package/components/progress.js +2 -2
  35. package/components/radio.js +11 -10
  36. package/components/scroll-area.js +9 -9
  37. package/components/select.js +62 -10
  38. package/components/sidebar-group-label.js +2 -2
  39. package/components/sidebar-menu-button.js +6 -14
  40. package/components/sidebar-provider.js +6 -14
  41. package/components/sidebar.js +1 -1
  42. package/components/slider.js +8 -7
  43. package/components/switch.js +12 -11
  44. package/components/tab.js +10 -9
  45. package/components/tabs-indicator.js +3 -3
  46. package/components/tabs-panel.js +3 -2
  47. package/components/textarea.js +11 -10
  48. package/components/toggle-group.js +0 -1
  49. package/components/toggle.js +28 -11
  50. package/components/tooltip-popup.js +29 -1
  51. package/components/trunc.js +3 -3
  52. package/index.d.ts +4 -0
  53. package/index.js +6 -0
  54. package/package.json +17 -4
  55. package/prose.d.ts +2 -0
  56. package/prose.js +4 -0
  57. package/tokens-raw.js +1 -1
  58. package/tokens.css +95 -72
  59. package/tokens.js +3 -2
  60. package/types.d.ts +18 -0
  61. package/types.js +8 -0
  62. package/typography.d.ts +104 -0
  63. package/typography.js +103 -0
package/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # DUI
2
+
3
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
+ [![npm](https://img.shields.io/npm/v/@deepfuture/dui-core.svg)](https://www.npmjs.com/package/@deepfuture/dui-core)
5
+
6
+ Unstyled [Lit](https://lit.dev) web component library with composable themes.
7
+
8
+ Components provide structure and behavior with zero visual opinions. Themes provide all aesthetics — colors, spacing, typography, borders. Swap the theme to completely change the look without touching component code.
9
+
10
+ **[Live Docs & Demos →](https://deepfuturenow.github.io/dui/)**
11
+
12
+ ## Install
13
+
14
+ **npm / pnpm / yarn:**
15
+
16
+ ```bash
17
+ npm install @deepfuture/dui-core @deepfuture/dui-components @deepfuture/dui-theme-default
18
+ ```
19
+
20
+ **Deno:**
21
+
22
+ ```typescript
23
+ import { applyTheme } from "npm:@deepfuture/dui-core/apply-theme";
24
+ import { defaultTheme } from "npm:@deepfuture/dui-theme-default";
25
+ import { allComponents } from "npm:@deepfuture/dui-components/all";
26
+ ```
27
+
28
+ **CDN (zero setup):**
29
+
30
+ ```html
31
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@deepfuture/dui-cdn/dui.min.js"></script>
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```typescript
37
+ import { applyTheme } from "@deepfuture/dui-core/apply-theme";
38
+ import { defaultTheme } from "@deepfuture/dui-theme-default";
39
+ import { DuiButton } from "@deepfuture/dui-components/button";
40
+ import { DuiDialog, DuiDialogTrigger, DuiDialogPopup, DuiDialogClose } from "@deepfuture/dui-components/dialog";
41
+
42
+ // Register components with a theme — this is the only setup needed
43
+ applyTheme({
44
+ theme: defaultTheme,
45
+ components: [DuiButton, DuiDialog, DuiDialogTrigger, DuiDialogPopup, DuiDialogClose],
46
+ });
47
+ ```
48
+
49
+ ```html
50
+ <dui-dialog>
51
+ <dui-dialog-trigger>
52
+ <dui-button>Open Dialog</dui-button>
53
+ </dui-dialog-trigger>
54
+ <dui-dialog-popup>
55
+ <h2>Hello</h2>
56
+ <p>This is a dialog.</p>
57
+ <dui-dialog-close>
58
+ <dui-button variant="outline">Close</dui-button>
59
+ </dui-dialog-close>
60
+ </dui-dialog-popup>
61
+ </dui-dialog>
62
+ ```
63
+
64
+ Or register everything at once:
65
+
66
+ ```typescript
67
+ import { applyTheme } from "@deepfuture/dui-core/apply-theme";
68
+ import { defaultTheme } from "@deepfuture/dui-theme-default";
69
+ import { allComponents } from "@deepfuture/dui-components/all";
70
+
71
+ applyTheme({ theme: defaultTheme, components: allComponents });
72
+ ```
73
+
74
+ ## How It Works
75
+
76
+ `applyTheme()` takes unstyled component classes and a theme, creates themed subclasses with composed styles, and registers them as custom elements.
77
+
78
+ ```
79
+ Component structural CSS → Theme base styles → Theme component styles
80
+ ```
81
+
82
+ No build step, no decorators, no code generation — just a function call. Components are standard web components that work in any framework or plain HTML.
83
+
84
+ ## Components
85
+
86
+ 43 component families, 85+ elements total.
87
+
88
+ | Category | Components |
89
+ |----------|-----------|
90
+ | **Actions** | Button, Link, Toggle, Toggle Group, Toolbar |
91
+ | **Forms** | Input, Textarea, Select, Combobox, Checkbox, Checkbox Group, Radio, Radio Group, Switch, Slider, Number Field, Dropzone |
92
+ | **Data Display** | Badge, Avatar, Calendar, Data Table, Progress, Spinner, Separator, Trunc |
93
+ | **Overlays** | Dialog, Alert Dialog, Popover, Tooltip, Menu, Menubar, Preview Card, Command |
94
+ | **Disclosure** | Accordion, Collapsible, Tabs |
95
+ | **Navigation** | Breadcrumb, Sidebar (with 12 sub-components) |
96
+ | **Layout** | HStack, VStack, Center, Page Inset, Scroll Area, Portal |
97
+ | **Utility** | Icon |
98
+
99
+ ## Styling
100
+
101
+ DUI uses a two-layer styling approach:
102
+
103
+ ### CSS Variables — for the variant system
104
+
105
+ Variables control values that variants, sizes, and states toggle:
106
+
107
+ ```css
108
+ /* Override variant colors */
109
+ dui-button {
110
+ --button-bg: linear-gradient(135deg, pink, purple);
111
+ --button-radius: var(--radius-full);
112
+ }
113
+ ```
114
+
115
+ ### `::part(root)` — for everything else
116
+
117
+ Every component exposes a `root` CSS part for full CSS expressiveness:
118
+
119
+ ```css
120
+ /* Frosted glass effect */
121
+ dui-dialog-popup::part(root) {
122
+ backdrop-filter: blur(12px);
123
+ }
124
+
125
+ /* Custom hover animation */
126
+ dui-button::part(root):hover {
127
+ filter: brightness(1.25);
128
+ transform: translateY(-1px);
129
+ }
130
+
131
+ /* Glow shadow */
132
+ dui-badge::part(root) {
133
+ box-shadow: 0 0 16px oklch(0.7 0.2 280 / 0.4);
134
+ }
135
+ ```
136
+
137
+ No need for the library to anticipate every CSS property — `::part()` gives you direct access.
138
+
139
+ ## Dark Mode
140
+
141
+ DUI uses CSS custom properties for theming. Toggle dark mode by adding `class="dark"` to a parent element:
142
+
143
+ ```html
144
+ <body class="dark">
145
+ <!-- All DUI components render in dark mode -->
146
+ </body>
147
+ ```
148
+
149
+ ## Packages
150
+
151
+ | Package | Purpose |
152
+ |---------|---------|
153
+ | [`@deepfuture/dui-core`](https://www.npmjs.com/package/@deepfuture/dui-core) | `applyTheme()`, event factory, base styles |
154
+ | [`@deepfuture/dui-components`](https://www.npmjs.com/package/@deepfuture/dui-components) | Unstyled component classes |
155
+ | [`@deepfuture/dui-theme-default`](https://www.npmjs.com/package/@deepfuture/dui-theme-default) | Design tokens + aesthetic styles |
156
+ | [`@deepfuture/dui-cdn`](https://www.npmjs.com/package/@deepfuture/dui-cdn) | Pre-bundled CDN build (all deps inlined) |
157
+
158
+ ## Dev Tools
159
+
160
+ ### Theme Editor
161
+
162
+ A visual editor for design tokens. Edit colors with OKLCH sliders, tweak spacing and typography, and export your customized `tokens.css`.
163
+
164
+ ### Inspector
165
+
166
+ A runtime inspector and mutation API for DUI components. Two interfaces:
167
+
168
+ - **Visual UI** (Ctrl+Shift+I) — hover-highlight components, inspect properties/tokens/styles, edit theme CSS and design tokens live
169
+ - **Console API** — `window.__dui_inspect()`, `window.__dui_mutate.*`, `window.__dui_export()` for programmatic access by agents or scripts
170
+
171
+ Both share a changelog, so agent and human edits are visible to each other. Changes can be exported as structured source file diffs.
172
+
173
+ See **[Inspector docs](docs/inspector.md)** for the full API reference and usage guide.
174
+
175
+ ## Documentation
176
+
177
+ - **[Live Docs](https://deepfuturenow.github.io/dui/)** — interactive demos for every component
178
+ - [Architecture](docs/architecture.md) — mental model, package responsibilities, design decisions
179
+ - [Creating Components](docs/creating-components.md) — guide for adding new components
180
+ - [Theming](docs/theming.md) — theme system, design tokens, writing component styles
181
+ - [Consuming](docs/consuming.md) — integrating DUI into an app
182
+ - [Inspector](docs/inspector.md) — runtime inspection, mutation API, and visual editor
183
+ - [Accessibility](docs/accessibility.md) — accessibility patterns and guidelines
184
+
185
+ ## Contributing
186
+
187
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, code conventions, and PR guidelines.
188
+
189
+ ## License
190
+
191
+ [MIT](LICENSE)
@@ -1,4 +1,5 @@
1
1
  import { css } from "lit";
2
+ import { type } from "../typography.js";
2
3
  export const accordionItemStyles = css `
3
4
  /* ── Item ── */
4
5
 
@@ -15,32 +16,32 @@ export const accordionItemStyles = css `
15
16
  gap: var(--space-4);
16
17
  padding-block: var(--space-2);
17
18
  padding-inline: 0;
18
- color: var(--foreground);
19
+ color: var(--text-1);
19
20
  font-family: var(--font-sans);
20
21
  font-weight: var(--font-weight-semibold);
21
- font-size: var(--font-size-sm);
22
+ ${type("sm")}
22
23
  height: var(--component-height-md);
23
- line-height: var(--line-height-normal);
24
24
  border-radius: var(--radius-sm);
25
+ transition-property: background, box-shadow, filter, transform;
25
26
  transition-duration: var(--duration-fast);
26
27
  transition-timing-function: var(--ease-out-3);
27
28
  }
28
29
 
29
30
  @media (hover: hover) {
30
31
  [part="trigger"]:hover {
31
- background: color-mix(in oklch, var(--muted) 50%, transparent);
32
+ background: oklch(from var(--foreground) l c h / 0.05);
32
33
  }
33
34
  }
34
35
 
35
36
  [part="trigger"]:focus-visible {
36
37
  box-shadow:
37
- 0 0 0 var(--space-0_5) var(--background),
38
- 0 0 0 var(--space-1) var(--ring);
38
+ 0 0 0 var(--focus-ring-offset) var(--background),
39
+ 0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
39
40
  z-index: 1;
40
41
  }
41
42
 
42
43
  [part="trigger"][data-disabled] {
43
- opacity: 0.5;
44
+ opacity: 0.4;
44
45
  }
45
46
 
46
47
  /* ── Indicator ── */
@@ -48,6 +49,7 @@ export const accordionItemStyles = css `
48
49
  [part="indicator"] {
49
50
  width: var(--space-4);
50
51
  height: var(--space-4);
52
+ transition-property: transform;
51
53
  transition-duration: var(--duration-fast);
52
54
  transition-timing-function: var(--ease-out-3);
53
55
  }
@@ -71,10 +73,9 @@ export const accordionItemStyles = css `
71
73
  [part="content"] {
72
74
  padding: 0 0 var(--space-3);
73
75
  font-family: var(--font-sans);
74
- font-size: var(--font-size-sm);
76
+ ${type("sm")}
75
77
  font-weight: var(--font-weight-regular);
76
- line-height: var(--line-height-normal);
77
- color: color-mix(in oklch, var(--foreground) 80%, transparent);
78
+ color: var(--text-2);
78
79
  }
79
80
 
80
81
  /* ── Reduced motion ── */
@@ -1,19 +1,13 @@
1
1
  import { css } from "lit";
2
+ import { type } from "../typography.js";
2
3
  export const alertDialogPopupStyles = css `
3
4
  /* ── Backdrop ── */
4
5
 
5
6
  [part="backdrop"] {
6
- background: black;
7
- opacity: 0.2;
7
+ background: var(--scrim);
8
8
  transition: opacity var(--duration-fast) var(--ease-out-3);
9
9
  }
10
10
 
11
- @container style(--theme: dark) {
12
- [part="backdrop"] {
13
- opacity: 0.7;
14
- }
15
- }
16
-
17
11
  [part="backdrop"][data-starting-style],
18
12
  [part="backdrop"][data-ending-style] {
19
13
  opacity: 0;
@@ -26,9 +20,10 @@ export const alertDialogPopupStyles = css `
26
20
  padding: var(--space-6);
27
21
  border-radius: var(--radius-lg);
28
22
  border: var(--border-width-thin) solid var(--border);
29
- background: var(--card);
30
- color: var(--card-foreground);
23
+ background: var(--surface-2);
24
+ color: var(--text-1);
31
25
  font-family: var(--font-sans);
26
+ box-shadow: var(--shadow-lg);
32
27
  transition-duration: var(--duration-fast);
33
28
  }
34
29
 
@@ -44,11 +39,9 @@ export const alertDialogPopupStyles = css `
44
39
  margin-top: calc(-1 * var(--space-1));
45
40
  margin-bottom: var(--space-1);
46
41
  font-family: var(--font-sans);
47
- font-size: var(--font-size-lg);
48
- letter-spacing: var(--letter-spacing-tighter);
49
- line-height: var(--line-height-tight);
42
+ ${type("lg", { letterSpacing: "var(--letter-spacing-tighter)", lineHeight: "var(--line-height-tight)" })}
50
43
  font-weight: var(--font-weight-medium);
51
- color: var(--foreground);
44
+ color: var(--text-1);
52
45
  }
53
46
 
54
47
  /* ── Description ── */
@@ -56,9 +49,8 @@ export const alertDialogPopupStyles = css `
56
49
  [part="description"] {
57
50
  margin: 0 0 var(--space-6);
58
51
  font-family: var(--font-sans);
59
- font-size: var(--font-size-md);
60
- line-height: var(--line-height-normal);
61
- color: var(--muted-foreground);
52
+ ${type("md")}
53
+ color: var(--text-2);
62
54
  }
63
55
 
64
56
  /* ── Reduced motion ── */
@@ -1,8 +1,8 @@
1
1
  import { css } from "lit";
2
2
  export const avatarStyles = css `
3
3
  :host {
4
- --avatar-bg: var(--muted);
5
- --avatar-fg: var(--muted-foreground);
4
+ --avatar-bg: var(--surface-1);
5
+ --avatar-fg: var(--text-2);
6
6
  }
7
7
 
8
8
  [part="root"] {
@@ -1,43 +1,71 @@
1
1
  import { css } from "lit";
2
+ import { type } from "../typography.js";
2
3
  export const badgeStyles = css `
3
- :host {
4
- --badge-bg: var(--primary);
5
- --badge-fg: var(--primary-foreground);
6
- --badge-border: transparent;
7
- --badge-icon-size: var(--space-3);
8
- --icon-size: var(--badge-icon-size);
9
- --icon-color: var(--badge-fg);
4
+ /* =================================================================
5
+ * Two-axis variant system:
6
+ * variant semantic intent (neutral, accent, danger)
7
+ * appearance → visual treatment (filled, outline, ghost)
8
+ * ================================================================= */
9
+
10
+ /* ---------------------------------------------------------------
11
+ * Layer 1 — Intent (sets --_intent-* private tokens)
12
+ * --------------------------------------------------------------- */
13
+
14
+ :host,
15
+ :host([variant=""]),
16
+ :host([variant="neutral"]) {
17
+ --_intent-base: var(--foreground);
18
+ --_intent-base-fg: var(--background);
19
+ --_intent-subtle: oklch(from var(--foreground) l c h / 0.08);
20
+ --_intent-subtle-fg: var(--text-1);
10
21
  }
11
22
 
12
- :host([variant="secondary"]) {
13
- --badge-bg: var(--secondary);
14
- --badge-fg: var(--secondary-foreground);
23
+ :host([variant="primary"]) {
24
+ --_intent-base: var(--accent);
25
+ --_intent-base-fg: oklch(from var(--accent) 0.98 0.01 h);
26
+ --_intent-subtle: var(--accent-subtle);
27
+ --_intent-subtle-fg: var(--accent-text);
15
28
  }
16
29
 
17
- :host([variant="destructive"]) {
18
- --badge-bg: var(--destructive);
19
- --badge-fg: var(--destructive-foreground);
30
+ :host([variant="danger"]) {
31
+ --_intent-base: var(--destructive);
32
+ --_intent-base-fg: oklch(from var(--destructive) 0.98 0.01 h);
33
+ --_intent-subtle: var(--destructive-subtle);
34
+ --_intent-subtle-fg: var(--destructive-text);
20
35
  }
21
36
 
22
- :host([variant="outline"]) {
23
- --badge-bg: transparent;
24
- --badge-fg: var(--primary);
25
- --badge-border: color-mix(in oklch, var(--primary) 25%, transparent);
37
+ /* ---------------------------------------------------------------
38
+ * Layer 2 — Appearance (maps --_intent-* to --badge-*)
39
+ * --------------------------------------------------------------- */
40
+
41
+ :host,
42
+ :host([appearance=""]),
43
+ :host([appearance="filled"]) {
44
+ --badge-bg: var(--_intent-base);
45
+ --badge-fg: var(--_intent-base-fg);
46
+ --badge-border: transparent;
26
47
  }
27
48
 
28
- :host([variant="success"]) {
29
- --badge-bg: var(--success);
30
- --badge-fg: var(--success-foreground);
49
+ :host([appearance="outline"]) {
50
+ --badge-bg: transparent;
51
+ --badge-fg: var(--_intent-subtle-fg);
52
+ --badge-border: var(--border);
31
53
  }
32
54
 
33
- :host([variant="warning"]) {
34
- --badge-bg: var(--warning);
35
- --badge-fg: var(--warning-foreground);
55
+ :host([appearance="ghost"]) {
56
+ --badge-bg: var(--_intent-subtle);
57
+ --badge-fg: var(--_intent-subtle-fg);
58
+ --badge-border: transparent;
36
59
  }
37
60
 
38
- :host([variant="info"]) {
39
- --badge-bg: var(--info);
40
- --badge-fg: var(--info-foreground);
61
+ /* ---------------------------------------------------------------
62
+ * Sizing & base appearance
63
+ * --------------------------------------------------------------- */
64
+
65
+ :host {
66
+ --badge-icon-size: var(--space-3);
67
+ --icon-size: var(--badge-icon-size);
68
+ --icon-color: var(--badge-fg);
41
69
  }
42
70
 
43
71
  [part="root"] {
@@ -48,10 +76,8 @@ export const badgeStyles = css `
48
76
  background: var(--badge-bg);
49
77
  color: var(--badge-fg);
50
78
  font-family: var(--font-sans);
51
- font-size: var(--font-size-xs);
52
- letter-spacing: var(--letter-spacing-normal);
79
+ ${type("xs", { letterSpacing: "var(--letter-spacing-normal)", lineHeight: "var(--line-height-snug)" })}
53
80
  font-weight: var(--font-weight-medium);
54
- line-height: var(--line-height-snug);
55
81
  white-space: nowrap;
56
82
  border: var(--border-width-thin) solid var(--badge-border);
57
83
  }
@@ -1,7 +1,7 @@
1
1
  import { css } from "lit";
2
2
  export const breadcrumbEllipsisStyles = css `
3
3
  [part="root"] {
4
- color: var(--muted-foreground);
4
+ color: var(--text-2);
5
5
  width: var(--space-4);
6
6
  }
7
7
  `;
@@ -1,7 +1,7 @@
1
1
  import { css } from "lit";
2
2
  export const breadcrumbLinkStyles = css `
3
3
  [part="root"] {
4
- color: var(--muted-foreground);
4
+ color: var(--text-2);
5
5
  }
6
6
 
7
7
  [part="root"] ::slotted(a) {
@@ -11,6 +11,6 @@ export const breadcrumbLinkStyles = css `
11
11
  }
12
12
 
13
13
  [part="root"] ::slotted(a:hover) {
14
- color: var(--foreground);
14
+ color: var(--text-1);
15
15
  }
16
16
  `;
@@ -1,7 +1,7 @@
1
1
  import { css } from "lit";
2
2
  export const breadcrumbPageStyles = css `
3
3
  [part="root"] {
4
- color: var(--foreground);
4
+ color: var(--text-1);
5
5
  font-weight: var(--font-weight-regular);
6
6
  }
7
7
  `;
@@ -2,6 +2,6 @@ import { css } from "lit";
2
2
  export const breadcrumbSeparatorStyles = css `
3
3
  [part="root"] {
4
4
  --icon-size: var(--space-3_5);
5
- color: color-mix(in oklch, var(--muted-foreground) 50%, transparent);
5
+ color: color-mix(in oklch, var(--text-2) 50%, transparent);
6
6
  }
7
7
  `;
@@ -1,9 +1,10 @@
1
1
  import { css } from "lit";
2
+ import { type } from "../typography.js";
2
3
  export const breadcrumbStyles = css `
3
4
  [part="root"] {
4
5
  gap: var(--space-2);
5
- font-size: var(--font-size-sm);
6
+ ${type("sm")}
6
7
  font-family: var(--font-sans);
7
- color: var(--muted-foreground);
8
+ color: var(--text-2);
8
9
  }
9
10
  `;