@wintermuted/ui-theme 0.21.6 → 0.22.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 (2) hide show
  1. package/README.md +15 -270
  2. package/package.json +20 -31
package/README.md CHANGED
@@ -1,298 +1,43 @@
1
1
  # `@wintermuted/ui-theme`
2
2
 
3
- Shared design tokens and base component styles for Wintermuted projects.
4
-
5
- The package is derived from the styling language introduced in the CV project and extracts the reusable parts of that system so application repositories can depend on a single source of truth instead of copying CSS.
3
+ Shared plain-CSS design tokens, resets, component styles, and light/dark themes for Wintermuted projects.
6
4
 
7
5
  ## Install
8
6
 
9
- ### npmjs
10
-
11
- ```bash
7
+ ```sh
12
8
  npm install @wintermuted/ui-theme
13
9
  ```
14
10
 
15
- ### GitHub repository release
16
-
17
- If you prefer to consume the package directly from GitHub without GitHub Packages auth, install from a tagged release:
18
-
19
- ```bash
20
- npm install github:wintermuted/wintermuted-ui#v0.1.0
21
- ```
22
-
23
- ## Includes
24
-
25
- - Core color, spacing, radius, shadow, and typography tokens
26
- - Base document and form-control styling
27
- - Shared surface, button, badge, tag, list, separator, and side-nav primitives
28
- - Light and dark theme variables via `[data-theme="dark"]`
29
-
30
11
  ## Usage
31
12
 
32
- ### Full Theme (single import)
13
+ Import the complete theme through your application's bundler:
33
14
 
34
- ```ts
15
+ ```js
35
16
  import "@wintermuted/ui-theme";
36
17
  ```
37
18
 
38
- Then use the exported CSS variables in application styles:
39
-
40
- ```css
41
- .app-shell {
42
- color: var(--wm-color-text);
43
- background: var(--wm-color-surface);
44
- border: 1px solid var(--wm-color-border);
45
- }
46
- ```
47
-
48
- ### Modular Imports (factor by need)
49
-
50
- Import only the slices you need. Most component files require tokens, and many apps also want base element styles.
19
+ Or load only the CSS you need:
51
20
 
52
- ```ts
21
+ ```js
53
22
  import "@wintermuted/ui-theme/styles/tokens.css";
54
23
  import "@wintermuted/ui-theme/styles/base.css";
55
24
  import "@wintermuted/ui-theme/styles/components/button.css";
56
- import "@wintermuted/ui-theme/styles/components/card.css";
57
- ```
58
-
59
- Available modular entry points:
60
-
61
- - `@wintermuted/ui-theme/styles/tokens.css`
62
- - `@wintermuted/ui-theme/styles/base.css`
63
- - `@wintermuted/ui-theme/styles/components.css` (all components)
64
- - `@wintermuted/ui-theme/styles/components/button.css`
65
- - `@wintermuted/ui-theme/styles/components/card.css`
66
- - `@wintermuted/ui-theme/styles/components/badge.css`
67
- - `@wintermuted/ui-theme/styles/components/tag.css`
68
- - `@wintermuted/ui-theme/styles/components/list.css`
69
- - `@wintermuted/ui-theme/styles/components/separator.css`
70
- - `@wintermuted/ui-theme/styles/components/side-nav.css`
71
-
72
-
73
- ## Static Design System Test Page
74
-
75
- This repo includes a static showcase app for validating common component scenarios.
76
-
77
- The optional React examples run through the local Vite development server; the existing HTML pages stay static.
78
-
79
- ```bash
80
- npm run showcase:serve
81
- ```
82
-
83
- Then open `http://localhost:4174/showcase/`.
84
-
85
- ### GitHub Copilot app
86
-
87
- Review and accept `.github/github-app.yml` when prompted by the app. Node.js 22
88
- and npm must be available locally.
89
-
90
- The **Install dependencies** script runs `npm ci --no-audit --no-fund` when a
91
- session is created and can also be rerun manually. **Run showcase** starts the
92
- existing Vite development server on port 4174.
93
-
94
- Open `http://127.0.0.1:4174/showcase/` to view the documentation and React examples.
95
- Automatic browser opening is disabled because Vite reports the repository root
96
- URL, while the showcase lives under `/showcase/`. Stop the run script before
97
- starting the showcase in another session, since the server requires port 4174.
98
-
99
- Helpful local viewing scripts:
100
-
101
- ```bash
102
- npm run showcase:open
103
- npm run showcase:open:sample-data
104
- npm run showcase:open:forms
105
25
  ```
106
26
 
107
- The showcase includes:
108
-
109
- - Light and dark theme toggle
110
- - Buttons, badges, cards, and alerts
111
- - Form controls and focus states
112
- - A representative data table
113
- - A sample-data page that renders stats, chart bars, and table rows from one dataset
114
-
115
- Files:
116
-
117
- - `showcase/index.html`
118
- - `showcase/sample-data.html`
119
- - `showcase/showcase.css`
120
-
121
- ## GitHub Pages Deployments
122
-
123
- The showcase is deployed with a preview/main pattern:
124
-
125
- - Pushes to `main` publish production content to the root Pages site.
126
- - Pull requests to `main` publish isolated previews under `previews/pr-<number>/showcase/`.
127
- - Closing a pull request removes its preview folder from `gh-pages`.
128
-
129
- Workflows:
130
-
131
- - `.github/workflows/deploy-showcase-pages.yml`
132
- - `.github/workflows/cleanup-showcase-preview.yml`
27
+ The package exports `index.css`, `styles/tokens.css`, `styles/base.css`, `styles/components.css`, and individual component stylesheets. Use `--wm-*` custom properties in application styles. Set `data-theme="dark"` on the document root to select the dark theme.
133
28
 
134
- ## Local Symlink Workflow (No Publish Step)
29
+ This package lives in `packages/ui-theme` within the [Wintermuted UI monorepo](https://github.com/wintermuted/wintermuted-ui). New monorepo tags are not directly installable as the theme through a GitHub-source npm dependency; use npm releases or a tarball produced by `npm pack --workspace=@wintermuted/ui-theme`.
135
30
 
136
- Use npm link to symlink this theme into local consuming apps so style changes appear immediately.
31
+ ## Existing React entry points
137
32
 
138
- From this repo:
33
+ The optional React API remains available for existing consumers:
139
34
 
140
- ```bash
141
- npm run link:local -- <consumer-path> [consumer-path-2 ...]
142
- ```
143
-
144
- Workspace example:
145
-
146
- ```bash
147
- npm run link:local -- ../sub-killer ../cv
148
- ```
149
-
150
- When done testing, revert consumers back to normal package resolution:
151
-
152
- ```bash
153
- npm run unlink:local -- ../sub-killer ../cv
154
- ```
155
-
156
- Scripts:
157
-
158
- - `scripts/link-local.sh`
159
- - `scripts/unlink-local.sh`
160
- ## Publishing
161
-
162
- - Merges to main trigger auto-release, which bumps the minor version in package.json, creates a matching vX.Y.Z tag, and creates a GitHub release.
163
- - Tag pushes matching v* trigger the publish workflow, which publishes to npmjs using npm provenance.
164
- - Set the NPM_TOKEN repository secret with an npm automation token before running the workflow.
165
-
166
- ## Notes
167
-
168
- - The package intentionally avoids application-specific layout opinions.
169
- - Projects should keep product-specific selectors and layout rules in their own repositories.
170
- - Publishing is handled through GitHub Actions to npmjs.
171
-
172
- ## Optional React components
173
-
174
- The CSS/root entry points are unchanged and do not load or install React. Install React
175
- and ReactDOM 18.3+ (or 19) only for the React API. Add react-select 5.8+ only when using
176
- the separate select adapter:
177
-
178
- ```powershell
179
- npm install @wintermuted/ui-theme react react-dom
180
- npm install react-select
181
- ```
182
-
183
- ```tsx
184
- import "@wintermuted/ui-theme/index.css";
185
- import { createRoot } from "react-dom/client";
186
- import {
187
- Button, Card, CardHeader, CardTitle, CardBody, CardText, FieldGroup,
188
- Input, ThemeProvider, ThemeSelect,
189
- } from "@wintermuted/ui-theme/react";
190
- import { initTheme } from "@wintermuted/ui-theme/theme";
191
-
192
- initTheme({ storageKey: "my-app:theme" });
193
- createRoot(document.getElementById("root")!).render(
194
- <ThemeProvider storageKey="my-app:theme">
195
- <ThemeSelect />
196
- <Card>
197
- <CardHeader><CardTitle>Departures</CardTitle></CardHeader>
198
- <CardBody>
199
- <CardText>Select stops to see arrivals.</CardText>
200
- <FieldGroup label="Stop name" hint="Enter part of a name."><Input /></FieldGroup>
201
- <Button onClick={refresh}>Refresh arrivals</Button>
202
- </CardBody>
203
- </Card>
204
- </ThemeProvider>
205
- );
206
- ```
207
-
208
- These are distributable ES modules, not TSX source, with separate declaration files.
209
- No application compiler needs to transpile JSX inside this package. React is never bundled.
210
- The `typesVersions` entries support TypeScript 4.9's legacy `moduleResolution: node`;
211
- conditional exports support newer resolvers. CI checks packed-package React 18,
212
- TypeScript 4.9, Vite 5 and Webpack 5 consumers, plus CSS-only installation without peers.
213
- For CRA 5/Jest consumers, allow this ESM package through Babel's dependency transform:
214
-
215
- ```json
216
- {
217
- "jest": {
218
- "transformIgnorePatterns": ["node_modules/(?!@wintermuted/ui-theme/)"]
219
- }
220
- }
221
- ```
222
-
223
- ### Component contracts
224
-
225
- All components come from `@wintermuted/ui-theme/react` except `MultiSelect`.
226
- Primitives preserve native attributes, `className`, `style`, children and refs.
227
-
228
- | Export | Contract |
229
- | --- | --- |
230
- | `Button` | Native button; defaults to `type="button"`. `variant`: primary, secondary, ghost, danger, success, warning, link. Optional `size="sm"` and decorative `icon`. Supply an accessible name for icon-only buttons. |
231
- | `Badge`, `Alert` | `tone`: neutral, info, success, warning, danger. Alert defaults to `role="status"`; opt into `role="alert"` for urgent messages. |
232
- | `Card`, `CardHeader`, `CardBody`, `CardTitle`, `CardText`, `CardFooter` | Semantic section/header/div/h3/p/footer slots; `as` selects an element or custom component. |
233
- | `ListGroup`, `ListItem`, `Nav` | Semantic ul/li/nav; `as` supports other elements or router links without a router dependency. Label navigation regions and use `aria-current="page"` on active links. Compose grid/flex layout in your application. |
234
- | `Input`, `Select` | Native input/select attributes and refs, including controlled or default values. Select takes native option children. |
235
- | `FieldGroup` | Required `label` and one control element; optional `htmlFor`, `hint`, `error`. Generates IDs and merges `aria-describedby`; errors set `aria-invalid`. Custom controls must forward the supplied ID/ARIA props to their input. |
236
- | `Table` | Native table attributes/ref, optional `responsive` overflow region. Provide a caption or `aria-label`, and native thead/tbody/th scope markup. |
237
- | `Spinner` | `label` defaults to Loading; status text stays available with reduced motion. |
238
- | `ProgressBar` | Native progress element, numeric `value`/`max` (defaults 0/100), accessible `label` or native label/ARIA association. Values clamp to range; nonfinite inputs or nonpositive max throw. |
239
- | `Accordion` | Native details attributes with `title` as summary; supports `open`, `onToggle` and normal keyboard behavior. |
240
- | `Tabs` | Required `label` and `items: {id,label,content,disabled?}[]`; optional controlled `value`, uncontrolled `defaultValue`, `onValueChange(id)`. Unique stable IDs required. Arrow Left/Right, Home/End skip disabled tabs. Inactive panels stay mounted and hidden. |
241
- | `Menu` | `label` trigger; `items: {id,label,onSelect?,href?,disabled?}[]`. Arrow Up/Down, Home/End, Escape and Tab; closes on selection, outside click or focus leaving. For router navigation use `onSelect` or compose ordinary links in Nav. |
242
- | `Tooltip` | `text` and one focusable element child that forwards ARIA props. Visible on focus/hover, Escape dismisses, descriptions are merged. Do not put interactive content in tooltips or use a tooltip as the only accessible name. |
243
- | `Dialog` | Required controlled `open`, `onClose()` and `title`. Uses native `dialog.showModal()` for top-layer modality and Escape, plus explicit Tab/Shift+Tab wrapping. Focus returns to the opener on close/unmount. Caller must set open=false in onClose. Native dialog-capable browsers required; no silent non-modal fallback. |
244
- | `ThemeProvider`, `useTheme`, `ThemeSelect` | See theme preferences below. |
245
-
246
- ### Searchable select
247
-
248
- ```tsx
35
+ ```js
36
+ import { Button, ThemeProvider } from "@wintermuted/ui-theme/react";
249
37
  import { MultiSelect } from "@wintermuted/ui-theme/react/select";
250
-
251
- const options = [{ value: 1, label: "North at Main", stop: { id: 1 } }];
252
- <MultiSelect
253
- options={options}
254
- defaultValue={[options[0]]}
255
- onChange={values => values.map(option => option.stop.id)}
256
- />;
38
+ import { initTheme } from "@wintermuted/ui-theme/theme";
257
39
  ```
258
40
 
259
- The adapter preserves react-select `Props<Option, IsMulti, Group>` inference, option objects,
260
- `defaultValue`, `value`, `onChange`, formatted labels, menu portals and callbacks. `isMulti`
261
- defaults to true; set `isMulti={false}` for a single value. `styles` overrides merge over
262
- token-based defaults; application-specific behavior remains in the application. Provide
263
- an accessible name with `aria-label`, `inputId` plus a label, or `FieldGroup`.
264
- Portals inherit document-level theme tokens; nested scoped themes need a portal target
265
- inside that scope.
266
-
267
- ### Theme preferences
268
-
269
- `useTheme()` returns `{ preference, setPreference, resolvedTheme }`. Preference is
270
- `"system" | "light" | "dark"` and defaults to System. Overrides persist under
271
- `wintermuted:theme` by default; pass a namespaced `storageKey` to both initialization
272
- and provider to isolate applications. Returning to System follows OS changes immediately.
273
- Cross-tab storage changes synchronize. Storage failures warn explicitly while the current
274
- selection still works in memory.
275
-
276
- For client rendering, call `initTheme({ storageKey })` from the React-free
277
- `@wintermuted/ui-theme/theme` entry **before mounting React**. For SSR or first paint of
278
- server HTML, emit `getThemeScript(storageKey)` in a synchronous inline `<head>` script
279
- before styles, with the appropriate CSP nonce. Never interpolate an unsanitized key into
280
- your own script. The helper safely escapes `<` in serialized keys. Hydration markup should
281
- not branch on the client preference on the server; theme-dependent UI should render after
282
- mount. Importing the React-free helper on the server is safe.
283
-
284
- Only `document.documentElement.dataset.theme` and `style.colorScheme` are updated.
285
- Map styles, tile sources, transit data and application state are not changed.
286
- Use one document-level ThemeProvider per app. `ThemeSelect` defaults to label Appearance
287
- with System, Light and Dark options and must be inside a provider.
288
-
289
- ### Development and release
41
+ Install React/React DOM 18.3 or 19 for the React API, and react-select 5.8 or newer only for the select adapter. These peers remain optional for CSS-only consumers.
290
42
 
291
- Run `npm test` for DOM behavior/package contracts and `npm run test:browser` for native
292
- Chromium keyboard/focus/theme checks (`npx playwright install chromium` once if needed).
293
- Open `/showcase/react.html` with `npm run showcase:serve` for live examples.
294
- CI alone runs builds/type checks via `npm run test:consumers` and bundles the React
295
- showcase for Pages. Existing CSS pages are copied unchanged alongside it.
296
- Publication is still the automated release process; an unpublished source tarball with
297
- unchanged version metadata is an integration artifact, not proof that the registry version
298
- has these APIs. Do not commit machine-local tarball dependencies to consumers.
43
+ The canonical implementation lives in the separate `@wintermuted/ui-react` workspace. Theme packaging includes compatibility copies, preserving runtime exports and legacy TypeScript declaration mappings without maintaining two implementations. Standalone React publication is deferred.
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@wintermuted/ui-theme",
3
- "version": "0.21.6",
3
+ "version": "0.22.0",
4
4
  "description": "Shared Wintermuted UI theme (design tokens, base resets, and component styles) derived from the CV styling language.",
5
5
  "type": "module",
6
+ "volta": {
7
+ "node": "22.23.5"
8
+ },
6
9
  "main": "./index.js",
7
10
  "license": "MIT",
8
11
  "keywords": [
@@ -22,7 +25,8 @@
22
25
  ],
23
26
  "repository": {
24
27
  "type": "git",
25
- "url": "git+https://github.com/wintermuted/wintermuted-ui.git"
28
+ "url": "git+https://github.com/wintermuted/wintermuted-ui.git",
29
+ "directory": "packages/ui-theme"
26
30
  },
27
31
  "bugs": {
28
32
  "url": "https://github.com/wintermuted/ui-theme/issues"
@@ -116,36 +120,21 @@
116
120
  }
117
121
  },
118
122
  "scripts": {
119
- "test": "node --test tests/*.test.js",
120
- "test:browser": "node --test browser-tests/*.test.js",
121
- "test:pack": "node tests/consumers.mjs --package-only",
122
- "test:consumers": "node tests/consumers.mjs",
123
- "showcase:serve": "vite --host 127.0.0.1 --port 4174 --strictPort",
124
- "showcase:build": "vite build --config showcase/vite.config.js",
125
- "showcase:open": "sh -c 'command -v open >/dev/null 2>&1 && open http://localhost:4174/showcase/ || xdg-open http://localhost:4174/showcase/'",
126
- "showcase:open:sample-data": "sh -c 'command -v open >/dev/null 2>&1 && open http://localhost:4174/showcase/sample-data.html || xdg-open http://localhost:4174/showcase/sample-data.html'",
127
- "showcase:open:forms": "sh -c 'command -v open >/dev/null 2>&1 && open http://localhost:4174/showcase/forms.html || xdg-open http://localhost:4174/showcase/forms.html'",
128
- "showcase:view": "npm run showcase:serve",
129
- "link:local": "bash scripts/link-local.sh",
130
- "unlink:local": "bash scripts/unlink-local.sh",
123
+ "prepack": "node ../../scripts/prepare-theme-react.mjs",
131
124
  "lint": "stylelint \"styles/**/*.css\" \"index.css\""
132
125
  },
133
- "devDependencies": {
134
- "@testing-library/react": "^16.3.0",
135
- "@testing-library/user-event": "^14.6.1",
136
- "playwright": "^1.56.1",
137
- "@types/react": "^18.3.0",
138
- "@types/react-dom": "^18.3.0",
139
- "jsdom": "^26.1.0",
140
- "css-loader": "^7.1.2",
141
- "style-loader": "^4.0.0",
142
- "react": "^18.3.1",
143
- "react-dom": "^18.3.1",
144
- "react-select": "^5.10.2",
145
- "typescript": "~4.9.5",
146
- "vite": "^5.4.21",
147
- "webpack": "^5.102.1",
148
- "stylelint": "^17.10.0",
149
- "stylelint-config-standard": "^40.0.0"
126
+ "nx": {
127
+ "name": "ui-theme",
128
+ "tags": ["type:library"],
129
+ "implicitDependencies": ["ui-react"],
130
+ "targets": {
131
+ "pack": {
132
+ "command": "npm pack --workspace=@wintermuted/ui-theme"
133
+ },
134
+ "nx-release-publish": {
135
+ "executor": "@nx/js:release-publish",
136
+ "options": { "packageRoot": "packages/ui-theme" }
137
+ }
138
+ }
150
139
  }
151
140
  }