@hussmartinez/ui 0.10.0 → 0.12.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 +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +507 -0
- package/dist/react.js +1036 -28
- package/dist/react.js.map +1 -1
- package/dist/styles.css +350 -0
- package/dist/ui.d.ts +507 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,16 @@ With `styles.css` loaded, the built-in light and dark themes follow the operatin
|
|
|
69
69
|
|
|
70
70
|
`data-hm-theme` takes `light`, `dark` or `system`, and `data-hm-density` takes `comfortable` (the default) or `compact`. On touch screens, targets are 44 px in either density. A themed subtree also sets its text colour to `--hm-color-text`, in the lowest-priority layer, so your own CSS still wins. Backgrounds are left to you: paint them with `--hm-color-bg` or `--hm-color-surface`.
|
|
71
71
|
|
|
72
|
+
### Text outside components
|
|
73
|
+
|
|
74
|
+
Components set their own font and colour. Text you render yourself, such as an editor's own labels, values and status lines, takes the page's font unless you say otherwise. Put **`hm-text`** on its root, usually your editor's or application's outermost element:
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<div class="hm-text my-editor">…</div>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
It sets `font-family`, `font-size`, `font-weight`, `letter-spacing`, `line-height` and `color` from the tokens (`--hm-font-family`, `--hm-font-size-body`, `--hm-font-weight-regular`, `--hm-letter-spacing`, `--hm-line-height-body`, `--hm-color-text`), and everything inside inherits them. It's opt-in, so ui never restyles a page that didn't ask, and it's in the lowest-priority layer, so an SDK's rules in `hm.sdk` and your own CSS still win. It follows `data-hm-theme` and `data-hm-density` like everything else.
|
|
81
|
+
|
|
72
82
|
### Custom themes
|
|
73
83
|
|
|
74
84
|
`createTheme` validates a set of token values. Extend a built-in theme and change only what you need, or set every semantic token to replace the look entirely.
|
|
@@ -169,6 +179,7 @@ Every component follows one contract ([ADR 0003](https://github.com/ie-huss-mart
|
|
|
169
179
|
| `usePlatform` | The platform for keyboard shortcuts: `"apple"` on macOS, iOS and iPadOS, where `Mod` is ⌘, otherwise `"other"`. It's `"other"` on the server and during hydration, then Apple devices switch right after, so hydration never mismatches. Pass it to sdk-core's `createShortcutRegistry({ platform })`, and never read `navigator` during render for this |
|
|
170
180
|
| `Tooltip` | Short text about a control, shown on hover and on keyboard focus; Escape closes it (WCAG 1.4.13). While it's open, the first Escape closes only the tooltip, so an editor's own Escape action, such as cancelling a crop, runs on the second press; Escape handlers should skip events with `defaultPrevented`. `type="label"` makes it an icon-only button's name, and `description`, the default, describes the button. `shortcut` takes sdk-core's `registry.describe(toolId)[0]`, shows it in the platform's notation (⌘⇧Z or Ctrl+Shift+Z) and sets `aria-keyshortcuts`. It's in the top layer, so no stacking context hides it. Disabled triggers need `focusableWhenDisabled` |
|
|
171
181
|
| `ReorderableList` and `ReorderableListItem` | A list whose items the user selects, reorders and removes, such as layers, tracks or pages: one Tab stop for the whole list, and room for `controls` in each row, such as a visibility toggle. ↑ and ↓ move between rows and select (with Ctrl or ⌘, without selecting); ← and → move between a row's cells; Alt+↑ and Alt+↓ (Option on macOS) move the focused item through `onMove(id, toIndex)`; Delete and Backspace remove it through `onRemove(id)`. You own the order and render the result; focus stays with a moved item, and moves are announced through `AnnouncerProvider` unless `announceMoves` is `false`. **Also render buttons that move the selected item**, with `aria-keyshortcuts`, for touch and for people who don't know the keys. It's a WAI-ARIA grid ([ADR 0009](https://github.com/ie-huss-martinez/ui/blob/main/docs/adr/0009-reorderable-list.md)) |
|
|
182
|
+
| `Timeline`, `TimelineLane`, `TimelineClips`, `TimelinePlayhead` and `TimelineLayer` | A timeline over whole units, such as frames or samples ([ADR 0011](https://github.com/ie-huss-martinez/ui/blob/main/docs/adr/0011-timeline.md)): a scrolling track as wide as `length` at the current `zoom`, where 1 fits it to the width and `onMaxZoomChange` says where zooming stops. `TimelineClips` is the clip track, a horizontal listbox with one Tab stop: each clip is `{ key, length, label, content }`, as wide as its length; ← and → move between clips and select; with `selectionMode="multiple"`, Shift extends, Ctrl or ⌘ moves without selecting, Space adds or removes, and Ctrl or ⌘+A selects all. Give each clip a `label` with its place and range. `TimelinePlayhead` is a slider over the units with a line at its `position`; a press on the track moves it, snapping to the clips' boundaries and `snapTargets` within 8 px unless Alt is held, and `following` keeps it in view. `TimelineLayer` holds your own drawing, such as a waveform, and `useTimelineScale()` gives it the same mapping: `toPixels`, `unitAt`, `snap` and `visibleRange`. It formats no time: pass `formatValue` and the labels. **Editing is reported, not done:** `onMove(keys, direction)` for Alt+← and Alt+→ (Option on macOS), which the track always takes so the browser never goes back; `onTrim(key, edge, delta)` for Alt+`[` and Alt+`]` (with Shift, outward) and for dragging a clip's edge, which snaps, shows the new length as it goes and reports once on release; `onTrimToPlayhead(key, edge)` for `[` and `]`. Render the result. **Also render buttons that move and trim the selected clips**, with `aria-keyshortcuts`, and **offer zoom**: a clip narrower than 24 px is a small target, and zooming is how a pointer reaches it. **Several tracks are lanes:** wrap each track's layers and clips in a `TimelineLane` with an `id`, a `label` and a `header`, its controls, which the lane renders as a toolbar that stays in view as time scrolls. Lanes stack under one playhead; ↑ and ↓ on a clip go to the clip nearest in time on the next lane. **Give every lane's `TimelineClips` the same `selectedKeys`:** it's the timeline's selection, a plain choice replaces it on every lane, and adding or removing keeps the other lanes' clips. A layer written outside the lanes covers them all, and `useTimelineLanes()` tells it the lane under a pointer. Below 720 px of the timeline's width, headers sit above their lanes. A timeline without lanes works as before. **Clips can have a start:** give every clip of a track `at`, in time order and without overlap, and each is placed there, with room wherever no clip is; give it to none, and they lie back to back. The two kinds share a timeline, a lane each, and every lane's clip edges are snap targets for all of them. When clips run past `length`, pass `extent`: the track is drawn that far, the playhead still ends at `length`, and those clips carry `data-hm-past-end` for you to dim. **Moving clips:** with `onDrop`, a clip is dragged with a mouse or pen, along time and to another lane, snapping its start or end to other clips; it's reported once, on release, as `{ by, lane }`, and `canDrop` lets you refuse a place, such as an overlap. Alt+↑ and Alt+↓ (Option on macOS) move clips to the lane above or below, through `onMoveLane`. `moveHandle="title"` makes only a clip's title the handle, so a press on the rest reaches a layer beneath, such as a range selection. **Also render buttons that move clips earlier, later and between lanes:** on a touch screen, they're the way to move a clip |
|
|
172
183
|
|
|
173
184
|
```tsx
|
|
174
185
|
import { Button, DownloadIcon, IconButton, RotateLeftIcon } from "@hussmartinez/ui/react";
|
package/dist/index.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare type CompleteThemeTokens = ThemeTokens & {
|
|
|
61
61
|
*
|
|
62
62
|
* @public
|
|
63
63
|
*/
|
|
64
|
-
export declare type ComponentTokenName = "button-height" | "button-small-height" | "button-padding-x" | "button-gap" | "button-icon-size" | "button-radius" | "button-font-weight" | "button-bg" | "button-bg-hover" | "button-bg-active" | "button-fg" | "button-border-color" | "button-primary-bg" | "button-primary-bg-hover" | "button-primary-bg-active" | "button-primary-fg" | "button-quiet-bg-hover" | "button-quiet-bg-active" | "button-danger-bg" | "button-danger-bg-hover" | "button-danger-fg" | "button-pressed-bg" | "button-pressed-border-color" | "button-pressed-fg" | "toolbar-bg" | "toolbar-border-color" | "toolbar-radius" | "toolbar-padding" | "toolbar-gap" | "toolbar-group-gap" | "toolbar-separator-color" | "segmented-control-height" | "segmented-control-small-height" | "segmented-control-padding" | "segmented-control-gap" | "segmented-control-radius" | "segmented-control-bg" | "segmented-control-border-color" | "segmented-control-option-padding-x" | "segmented-control-option-fg" | "segmented-control-option-bg-hover" | "segmented-control-option-checked-bg" | "segmented-control-option-checked-fg" | "segmented-control-option-checked-border-color" | "dialog-bg" | "dialog-fg" | "dialog-border-color" | "dialog-radius" | "dialog-shadow" | "dialog-padding" | "dialog-gap" | "dialog-backdrop" | "dialog-title-font-size" | "dialog-small-width" | "dialog-width" | "dialog-large-width" | "spinner-size" | "spinner-thickness" | "spinner-color" | "spinner-track-color" | "spinner-duration" | "progress-height" | "progress-radius" | "progress-track-color" | "progress-fill-color" | "progress-duration" | "slider-track-size" | "slider-track-color" | "slider-radius" | "slider-thumb-size" | "slider-thumb-color" | "slider-thumb-color-hover" | "slider-thumb-color-active" | "field-gap" | "field-label-fg" | "field-label-font-weight" | "field-description-fg" | "field-error-fg" | "field-message-font-size" | "number-field-height" | "number-field-padding-x" | "number-field-radius" | "number-field-bg" | "number-field-fg" | "number-field-border-color" | "number-field-invalid-border-color" | "file-drop-zone-gap" | "file-drop-zone-padding" | "file-drop-zone-radius" | "file-drop-zone-border-color" | "file-drop-zone-dragging-border-color" | "file-drop-zone-dragging-bg" | "file-drop-zone-hint-fg" | "tooltip-bg" | "tooltip-fg" | "tooltip-radius" | "tooltip-padding" | "tooltip-font-size" | "tooltip-shadow" | "tooltip-max-width" | "tooltip-offset" | "text-field-height" | "text-field-padding-x" | "text-field-radius" | "text-field-bg" | "text-field-fg" | "text-field-placeholder-fg" | "text-field-border-color" | "text-field-invalid-border-color" | "text-area-padding-y" | "reorderable-list-gap" | "reorderable-list-row-height" | "reorderable-list-row-padding-x" | "reorderable-list-row-radius" | "reorderable-list-row-fg" | "reorderable-list-row-bg-hover" | "reorderable-list-row-selected-bg" | "reorderable-list-row-selected-border-color" | "color-field-gap" | "color-field-swatch-size" | "color-field-swatch-radius" | "color-field-swatch-border-color" | "color-field-swatch-checked-border-color";
|
|
64
|
+
export declare type ComponentTokenName = "button-height" | "button-small-height" | "button-padding-x" | "button-gap" | "button-icon-size" | "button-radius" | "button-font-weight" | "button-bg" | "button-bg-hover" | "button-bg-active" | "button-fg" | "button-border-color" | "button-primary-bg" | "button-primary-bg-hover" | "button-primary-bg-active" | "button-primary-fg" | "button-quiet-bg-hover" | "button-quiet-bg-active" | "button-danger-bg" | "button-danger-bg-hover" | "button-danger-fg" | "button-pressed-bg" | "button-pressed-border-color" | "button-pressed-fg" | "toolbar-bg" | "toolbar-border-color" | "toolbar-radius" | "toolbar-padding" | "toolbar-gap" | "toolbar-group-gap" | "toolbar-separator-color" | "segmented-control-height" | "segmented-control-small-height" | "segmented-control-padding" | "segmented-control-gap" | "segmented-control-radius" | "segmented-control-bg" | "segmented-control-border-color" | "segmented-control-option-padding-x" | "segmented-control-option-fg" | "segmented-control-option-bg-hover" | "segmented-control-option-checked-bg" | "segmented-control-option-checked-fg" | "segmented-control-option-checked-border-color" | "dialog-bg" | "dialog-fg" | "dialog-border-color" | "dialog-radius" | "dialog-shadow" | "dialog-padding" | "dialog-gap" | "dialog-backdrop" | "dialog-title-font-size" | "dialog-small-width" | "dialog-width" | "dialog-large-width" | "spinner-size" | "spinner-thickness" | "spinner-color" | "spinner-track-color" | "spinner-duration" | "progress-height" | "progress-radius" | "progress-track-color" | "progress-fill-color" | "progress-duration" | "slider-track-size" | "slider-track-color" | "slider-radius" | "slider-thumb-size" | "slider-thumb-color" | "slider-thumb-color-hover" | "slider-thumb-color-active" | "field-gap" | "field-label-fg" | "field-label-font-weight" | "field-description-fg" | "field-error-fg" | "field-message-font-size" | "number-field-height" | "number-field-padding-x" | "number-field-radius" | "number-field-bg" | "number-field-fg" | "number-field-border-color" | "number-field-invalid-border-color" | "file-drop-zone-gap" | "file-drop-zone-padding" | "file-drop-zone-radius" | "file-drop-zone-border-color" | "file-drop-zone-dragging-border-color" | "file-drop-zone-dragging-bg" | "file-drop-zone-hint-fg" | "tooltip-bg" | "tooltip-fg" | "tooltip-radius" | "tooltip-padding" | "tooltip-font-size" | "tooltip-shadow" | "tooltip-max-width" | "tooltip-offset" | "text-field-height" | "text-field-padding-x" | "text-field-radius" | "text-field-bg" | "text-field-fg" | "text-field-placeholder-fg" | "text-field-border-color" | "text-field-invalid-border-color" | "text-area-padding-y" | "reorderable-list-gap" | "reorderable-list-row-height" | "reorderable-list-row-padding-x" | "reorderable-list-row-radius" | "reorderable-list-row-fg" | "reorderable-list-row-bg-hover" | "reorderable-list-row-selected-bg" | "reorderable-list-row-selected-border-color" | "timeline-track-bg" | "timeline-track-radius" | "timeline-lane-height" | "timeline-playhead-color" | "timeline-clip-bg" | "timeline-clip-fg" | "timeline-clip-border-color" | "timeline-clip-radius" | "timeline-clip-padding-x" | "timeline-clip-selected-bg" | "timeline-clip-selected-border-color" | "timeline-clip-edge-size" | "timeline-header-max-width" | "timeline-header-bg" | "timeline-lane-border-color" | "timeline-clip-moving-shadow" | "timeline-clip-refused-border-color" | "color-field-gap" | "color-field-swatch-size" | "color-field-swatch-radius" | "color-field-swatch-border-color" | "color-field-swatch-checked-border-color";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Component tokens from SDKs, such as `pdf-thumb-radius`. `ui`'s own
|
package/dist/index.js
CHANGED
|
@@ -1138,6 +1138,23 @@ var component = {
|
|
|
1138
1138
|
"reorderable-list-row-bg-hover": { fallback: "color-control-hover" },
|
|
1139
1139
|
"reorderable-list-row-selected-bg": { fallback: "color-accent-subtle" },
|
|
1140
1140
|
"reorderable-list-row-selected-border-color": { fallback: "color-accent" },
|
|
1141
|
+
"timeline-track-bg": { fallback: "color-surface-sunken" },
|
|
1142
|
+
"timeline-track-radius": { fallback: "radius-control" },
|
|
1143
|
+
"timeline-lane-height": { fallback: "control-height" },
|
|
1144
|
+
"timeline-playhead-color": { fallback: "color-accent" },
|
|
1145
|
+
"timeline-clip-bg": { fallback: "color-control" },
|
|
1146
|
+
"timeline-clip-fg": { fallback: "color-text" },
|
|
1147
|
+
"timeline-clip-border-color": { fallback: "color-border-strong" },
|
|
1148
|
+
"timeline-clip-radius": { fallback: "radius-control" },
|
|
1149
|
+
"timeline-clip-padding-x": { fallback: "gap-tight" },
|
|
1150
|
+
"timeline-clip-selected-bg": { fallback: "color-accent-subtle" },
|
|
1151
|
+
"timeline-clip-selected-border-color": { fallback: "color-accent" },
|
|
1152
|
+
"timeline-clip-edge-size": { fallback: "gap-normal" },
|
|
1153
|
+
"timeline-header-max-width": { fallback: "surface-width-small" },
|
|
1154
|
+
"timeline-header-bg": { fallback: "color-surface" },
|
|
1155
|
+
"timeline-lane-border-color": { fallback: "color-border" },
|
|
1156
|
+
"timeline-clip-moving-shadow": { fallback: "shadow-raised" },
|
|
1157
|
+
"timeline-clip-refused-border-color": { fallback: "color-danger-text" },
|
|
1141
1158
|
"color-field-gap": { fallback: "gap-tight" },
|
|
1142
1159
|
"color-field-swatch-size": { fallback: "control-height-small" },
|
|
1143
1160
|
"color-field-swatch-radius": { fallback: "radius-control" },
|