@dashspec/renderer 0.1.39 → 0.1.41

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/docs/theming.md CHANGED
@@ -308,3 +308,60 @@ createTheme({
308
308
  ```
309
309
 
310
310
  Use `widgets` css only for what is specific to one kind or variant of your dashboards.
311
+
312
+
313
+ ## Light and dark
314
+
315
+ Every theme has both colour sets (`light` and `dark`), and every built-in widget reads only theme tokens, so all of
316
+ them work in both modes. Who decides the mode, strongest first:
317
+
318
+ 1. The host: `colorMode="light" | "dark" | "auto"` on `DashSpecProvider` or `DashboardRenderer` (e.g. your app's
319
+ dark-mode switch). `auto` follows the viewer's system setting.
320
+ 2. The document: `"display": { "theme": "dark" }`.
321
+ 3. The theme's own `mode`.
322
+
323
+ ```tsx
324
+ <DashSpecProvider themes={{ acme: acmeTheme }} colorMode={isDark ? "dark" : "light"}>
325
+ ```
326
+
327
+ Your own values per mode:
328
+
329
+ ```ts
330
+ createTheme({
331
+ light: { surface: { card: "#ffffff" }, text: { primary: "#1a1a1a" } },
332
+ dark: { surface: { card: "#1e1e1e" }, text: { primary: "#f2f2f2" } },
333
+ scale: { parts: { title: { color: { light: "#0d0d0d", dark: "#f5f5f5" } } } }, // any part colour
334
+ widgets: { Kpi: { css: "…", dark: { css: "…" } } }, // dark-only additions
335
+ });
336
+ ```
337
+
338
+ ### Refer to the current theme's values
339
+
340
+ `token` gives references to the active theme's values. They are CSS variables, so they follow the theme and switch by
341
+ themselves between light and dark; there is nothing to write twice:
342
+
343
+ ```ts
344
+ import { createTheme, token } from "@dashspec/renderer";
345
+
346
+ createTheme({
347
+ scale: {
348
+ parts: {
349
+ title: { color: token.color("text.primary") },
350
+ meta: { color: token.color("text.secondary") },
351
+ tile: { border: token.color("border.default"), padding: 12 },
352
+ },
353
+ },
354
+ widgets: { Kpi: { css: { "& .ds-kpi-label": { color: token.color("status.good.fg") } } } },
355
+ });
356
+ ```
357
+
358
+ `token.color(path)` autocompletes every colour (`"surface.card"`, `"status.bad.bg"`…); also `token.space("md")`,
359
+ `token.radius("card")`, `token.font("heading")`.
360
+
361
+ To build on a theme's actual values, pass a function: it receives the base theme (the default, or the one you pass
362
+ second) and returns your changes.
363
+
364
+ ```ts
365
+ const acme = createTheme((base) => ({ dark: { surface: { card: base.dark.surface.sunken } } }));
366
+ const acmeCompact = createTheme((base) => ({ scale: { radius: { ...base.scale.radius, card: 6 } } }), acme);
367
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashspec/renderer",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "Draws a dashboard from DashSpec JSON: widgets, data, events, state.",
5
5
  "keywords": [
6
6
  "dashboard",