@k8ordo/color-scheme 3.0.0 → 4.0.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.
package/README.md CHANGED
@@ -31,7 +31,7 @@ pnpm add @k8ordo/color-scheme @k8ordo/state zod
31
31
 
32
32
  | Package | Version | Required | Needed for |
33
33
  | --------------- | ------- | -------- | ------------------------------------------ |
34
- | `@k8ordo/state` | ^3.0.0 | yes | where the preference lives (localStorage) |
34
+ | `@k8ordo/state` | ^4.0.0 | yes | where the preference lives (localStorage) |
35
35
  | `react` | ≥19.3.0 | yes | the provider and the hook |
36
36
  | `zod` | ^4.6.6 | yes | the one-field schema `@k8ordo/state` reads |
37
37
  | `typescript` | ≥7.0.0 | optional | the shipped type declarations |
package/docs/GUIDE.md CHANGED
@@ -34,9 +34,13 @@ legacy fallbacks.
34
34
  - **Contrast.** `prefers-contrast: more` and `forced-colors: active` are
35
35
  settings the visitor makes in the OS, not something an application stores
36
36
  or toggles, so neither is a preference here. `@k8ordo/ui`'s stylesheet
37
- follows both on its own, in either scheme — its high-contrast values are
38
- declared for `:root` and for `.dark` — so a visitor who chose dark and asks
39
- the OS for more contrast gets the dark high-contrast values.
37
+ follows both on its own, in either scheme: its high-contrast values are
38
+ declared once, on `:root` inside `@media (prefers-contrast: more)`, each as
39
+ a `light-dark()` pair, and the pair resolves by the `color-scheme` the
40
+ stylesheet sets from the class. A visitor who chose dark and asks the OS
41
+ for more contrast gets the dark high-contrast values. A stylesheet of your
42
+ own does the same: `light-dark()` pairs under the media query, with
43
+ `color-scheme` declared by the class.
40
44
  - **Where the preference lives.** That is `@k8ordo/state`'s
41
45
  `defineLocalState`; this package declares one and reads and writes
42
46
  through it, so the localStorage key and the row's JSON are never spelled
@@ -163,6 +167,7 @@ import { themeColor } from './src/lib/theme-color';
163
167
 
164
168
  framework({
165
169
  mode: 'static',
170
+ site: 'https://example.com',
166
171
  csp: {
167
172
  'script-src': ["'self'", await colorSchemeScriptHash({ themeColor })],
168
173
  },
@@ -241,7 +246,10 @@ every visitor who never chose.
241
246
  - **Other preferences beside it.** A display preference of the
242
247
  application's own is a `defineLocalState` under another key, in a module
243
248
  without `'use client'`. Never define another `'color-scheme'`: stores are
244
- shared by key, and the two definitions would fight over one row.
249
+ shared by key, and the two definitions would fight over one row. One the
250
+ server has to act on belongs in a cookie instead; `@k8ordo/framework`'s
251
+ guide (`node_modules/@k8ordo/framework/docs/GUIDE.md`, "Preferences") sets
252
+ out which preference goes where.
245
253
 
246
254
  ## What it guarantees
247
255
 
@@ -283,8 +291,8 @@ every visitor who never chose.
283
291
  ## Testing
284
292
 
285
293
  Under a browser, `localStorage.clear()`, remove the class from
286
- `document.documentElement`, and `resetStateRegistry()` from `@k8ordo/state`
287
- between tests; render the hook under `<ColorSchemeProvider>` (a `wrapper`),
294
+ `document.documentElement`, and `resetStateRegistry()` from
295
+ `@k8ordo/state/testing` between tests; render the hook under `<ColorSchemeProvider>` (a `wrapper`),
288
296
  and leave `ColorSchemeScript` out: React never executes an inline
289
297
  `<script>` it creates in the browser (in development it logs an error
290
298
  saying so), so the class a test sees is the one the provider's effect
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k8ordo/color-scheme",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "The colour-scheme axis of an application, owned: the visitor's light / dark / system preference, kept in localStorage, resolved against the system, put on <html> before the first paint and kept there.",
5
5
  "keywords": [
6
6
  "color-scheme",
@@ -39,23 +39,23 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@arethetypeswrong/cli": "0.18.5",
42
- "@k8ordo/state": "^3.0.0",
42
+ "@k8ordo/state": "^4.0.0",
43
43
  "@types/react": "19.3.0",
44
44
  "@types/react-dom": "19.3.0",
45
- "@vitejs/plugin-react": "6.2.1",
46
- "@vitest/browser-playwright": "5.1.0",
45
+ "@vitejs/plugin-react": "6.3.0",
46
+ "@vitest/browser-playwright": "5.1.1",
47
47
  "publint": "0.3.25",
48
48
  "react": "19.3.1",
49
49
  "react-dom": "19.3.1",
50
50
  "typescript": "7.0.2",
51
- "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
52
- "vite-plus": "1.4.0",
53
- "vitest": "5.1.0",
51
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8000",
52
+ "vite-plus": "1.7.0",
53
+ "vitest": "5.1.1",
54
54
  "vitest-browser-react": "2.3.0",
55
55
  "zod": "4.6.7"
56
56
  },
57
57
  "peerDependencies": {
58
- "@k8ordo/state": "^3.0.0",
58
+ "@k8ordo/state": "^4.0.0",
59
59
  "@types/react": ">=19.3.0",
60
60
  "react": ">=19.3.0",
61
61
  "typescript": ">=7.0.0",