@glasshome/widget-sdk 1.18.1 → 1.19.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/dist/index.js CHANGED
@@ -2778,7 +2778,7 @@ function Qa() {
2778
2778
  //#region src/version.ts
2779
2779
  var $a = {
2780
2780
  name: "@glasshome/widget-sdk",
2781
- version: "1.18.1",
2781
+ version: "1.19.0",
2782
2782
  description: "SDK for building GlassHome dashboard widgets with SolidJS",
2783
2783
  keywords: [
2784
2784
  "dashboard",
@@ -2801,7 +2801,8 @@ var $a = {
2801
2801
  files: [
2802
2802
  "dist",
2803
2803
  "preview",
2804
- "tailwind-sources.css"
2804
+ "tailwind-sources.css",
2805
+ "guide"
2805
2806
  ],
2806
2807
  type: "module",
2807
2808
  sideEffects: !1,
@@ -0,0 +1,74 @@
1
+ # GlassHome widgets
2
+
3
+ Matches the installed `@glasshome/widget-sdk`. Wins over memory and older docs.
4
+
5
+ ## Loop
6
+
7
+ 1. `bun widget add --name <name>`: `src/<name>/` with a working sensor tile (`index.tsx`, `manifest.json`). Start from it.
8
+ 2. Write it. `examples` in `defineWidget` (label, size, config) are what preview renders. Demo entity ids: `node_modules/@glasshome/sync-layer/dist/demo/ids.d.ts`; a wrong id renders the empty state. Missing a kind of entity: use a stand-in and config to show each state.
9
+ 3. `bun widget build`: typecheck, bundle, validate. Fix every error before previewing.
10
+ 4. `bun widget preview <name> --sizes grid`: every example at common tile sizes, light and dark, into `preview/sweep/` with a contact sheet each. Open the images and look. First run: `bun add -d playwright && bunx playwright install chromium`. A crash fails the render with its error.
11
+ - Narrow: `--sizes 150x156,340x242`, `--theme dark`, `--example 0`.
12
+ - Change state: `--config '<json>'`, `--service '<domain.service>|<entity_id>|<json>'`, `--at 2026-06-15T21:00:00`, `--click '<selector>'`.
13
+ - Inspect: `--eval '<expr>'` prints per render (`root` = shadow root).
14
+ 5. Repeat 3-4 until 1×1, 2×2 and a big tile read right in both themes.
15
+ 6. Live: `bun widget connect <dashboard-url>`.
16
+ 7. Ship: `bun widget publish --name <name> --bump patch|minor|major`. Version lives in `manifest.json`.
17
+
18
+ ## Imports
19
+
20
+ - Everything from `@glasshome/widget-sdk`, UI primitives included.
21
+ - Never `@glasshome/ui` (unchecked version, dead tile on mismatch) or `@glasshome/sync-layer` (second store). Keep `@glasshome/ui` installed; the build reads its CSS.
22
+ - Home Assistant only via SDK hooks (`useEntity`, `useEntities`, `useService`, `useToggle`, …). Declare every read/controlled domain in manifest capabilities.
23
+ - SDK too old for something in the docs: `bun widget upgrade`.
24
+ - Edit the inline `manifest` in `defineWidget`; build copies it into `manifest.json` (name, icon, sizes, capabilities, examples, schema). `version` and `sdkVersion` live only in `manifest.json`.
25
+ - Config: `defineConfig` + `field.*`. `field.entity(domain)` stores a one-item array: read `config.entityIds[0]`.
26
+
27
+ ## Tile
28
+
29
+ Parts inside `Widget.Content`; they lay out and resize themselves. Never measure to lay out.
30
+
31
+ | Need | Part |
32
+ |---|---|
33
+ | Colour | `tone` (`accent info success warning danger neutral`) or `color` on `Widget`; `accent` on `Widget.Content` for state colour |
34
+ | Icon, name, eyebrow, chips | `Widget.Head` (`active`, `count`, `aside`) |
35
+ | Big value, unit, art | `Widget.Hero` |
36
+ | Control row | `Widget.Controls` with `Widget.Stepper`, `Widget.Choice`, `Widget.Action` |
37
+ | Stateless action | `Widget.Action`; `useConfirm()` + `<Widget confirmed>` when the whole tile runs it |
38
+ | Small fact | `Widget.Chip` |
39
+ | Photo behind tile | `Widget.Backdrop` |
40
+ | Own full-bleed layer | `Widget.Layer` |
41
+ | Faint corner icon | `Widget.Glyph` |
42
+ | Controllable continuous value | `Widget.SliderFill` |
43
+
44
+ ## Sizes
45
+
46
+ 1×1 to 8×8. Under 130px tall or 140px wide the tile is compact: `eyebrow` and `sub` hide, so carry state in `tone` and the icon. Tokens, never px: `--widget-text-value`, `--widget-text-name`, `--widget-text-meta`, `--widget-text-sub`, `--widget-text-caption`, `--widget-control-h`, `--widget-grid-pad`, `--widget-grid-gap`, `--widget-icon-box`, `--widget-icon-glyph`. Layout by container query (`@[150px]:…`, `@container widget (…)`). What renders by `useWidgetDimensions()`, inside `<Widget>` only.
47
+
48
+ ## Sheet
49
+
50
+ Render `<WidgetDialog>` next to `<Widget>`, spreading the dialog parts (`ResponsiveDialog*`, `Button`, `SchemaForm`, `Tabs*`, see the scaffold) and `useWidgetDialog().dialogProps`. Hold opens the sheet on its own once `sheet` is passed; no gesture wiring. Only what the tile lacks (group members, colours, modes, forecast). Pass `sheet` only when there is something: `{...(extras() ? { sheet: () => <MySheet /> } : {})}`. Build from `PanelSection`, `PanelRows`, `PanelRow`, `PanelEntityRow`, `PanelFacts`, `ToggleGroup`, `SwatchPicker`, `TemperatureBar`, `ColorDisc`. Never repeat the tile's value, name or art. Widget CSS does not reach it.
51
+
52
+ ## Primitives
53
+
54
+ `Badge`, `Button`, `ButtonGroup`, `CountPill`, `Icon`, `Input`, `Label`, `Progress`, `SchemaForm`, `SectionIcon`, `SectionTitle`, `Select`, `Slider`, `Switch`, `Tabs`, `Toggle`, `ToggleGroup`, `Carousel`, `ColorWheel`, `ColorSlider`, `ResponsiveDialog` + parts. `Icon`, never `iconify-icon`. Never restyle with own classes.
55
+
56
+ ## Rules
57
+
58
+ - No hand-rolling what the SDK has: sliders, steppers, dialogs, sheets, hold gestures, loading/error states.
59
+ - Theme vars only (`--foreground`, `--muted-foreground`, `--card`, `--primary`, `--border`, `--success`, `--warning`, `--destructive`, `--radius`). Never declare them on `:host`; no own colour/radius tokens; no `--color-*`.
60
+ - Own CSS = layout and bespoke art. No custom panel/row/chip/button chrome.
61
+ - Tailwind classes literal in source, never concatenated. `dark:` works; `isDark()` for the boolean.
62
+ - No dot status lamps. No thin vertical bars (read as a text caret). No all-caps. Separator ` · `.
63
+ - One icon per item, not per line. Icons, fills and pictures before text.
64
+ - Lead with the answer (value + unit, or a verdict); one small line explains it. Never show a value twice. States per device class (Open/Closed, Detected/Clear).
65
+ - Continuous values keep the full-tile slider; buttons beside it. A stepper never stands alone.
66
+ - Dialog content scrolls in `ResponsiveDialogBody`; no own `overflow`/`max-height` in a dialog.
67
+ - Groups: one tap brings all members to one state; locks never unlock in one tap; doors, gates, garage doors never join bulk actions.
68
+ - Readings update text in place; never rebuild DOM. `Index` for lists of readings. Over 20 s of changing demo data a widget adds and removes no DOM nodes.
69
+ - Everything sits on an edge; text left, values/actions right. One accent per view; defaults quiet. No card in a card.
70
+ - Motion: colours morph, never snap; time transitions with `--duration-state` / `--ease-morph` (zeroed under reduced motion). Decorative loops scale by `var(--motion-ambient, 0)`. Gate on `useReducedMotion()`; pause offscreen with `useIntersectionPause()`.
71
+
72
+ ## More
73
+
74
+ Docs as markdown: https://glasshome.app/llms.txt, `https://glasshome.app/md/widgets/<page>` (`widget-sheets`, `widget-styling`, `widget-sdk`, `widget-api-reference`, `widget-capabilities`, `widget-previews`). Official widgets as worked examples: https://github.com/glasshome/widgets (`src/button`, `src/sensor`); where they differ from this guide, the guide wins.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-sdk",
3
- "version": "1.18.1",
3
+ "version": "1.19.0",
4
4
  "description": "SDK for building GlassHome dashboard widgets with SolidJS",
5
5
  "keywords": [
6
6
  "dashboard",
@@ -25,7 +25,8 @@
25
25
  "files": [
26
26
  "dist",
27
27
  "preview",
28
- "tailwind-sources.css"
28
+ "tailwind-sources.css",
29
+ "guide"
29
30
  ],
30
31
  "type": "module",
31
32
  "sideEffects": false,