@ahrowe/ui 0.29.0 → 0.29.1
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/esm/common/card/Card.mjs +1 -1
- package/dist/esm/common/card/Card.mjs.map +1 -1
- package/dist/esm/common/chip/chip.mjs +1 -1
- package/dist/esm/common/chip/chip.mjs.map +1 -1
- package/dist/esm/common/dropZone/dropZone.mjs +1 -1
- package/dist/esm/common/dropZone/dropZone.mjs.map +1 -1
- package/dist/esm/common/flip/flip.mjs +1 -1
- package/dist/esm/common/flip/flip.mjs.map +1 -1
- package/dist/esm/common/interactableDiv/interactableDiv.mjs +1 -1
- package/dist/esm/common/interactableDiv/interactableDiv.mjs.map +1 -1
- package/dist/esm/common/planCanvas/planCanvas.module.mjs +1 -1
- package/dist/esm/common/planCanvas/planCanvas.module.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs.map +1 -1
- package/dist/esm/common/utils/activationKey.mjs +2 -0
- package/dist/esm/common/utils/activationKey.mjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/common/themeProvider/theme.types.d.ts +30 -0
- package/dist/types/common/utils/activationKey.d.ts +9 -0
- package/docs/Flip.md +1 -1
- package/docs/RoomDrawer.md +13 -5
- package/docs/RoomViewer.md +4 -0
- package/package.json +1 -1
|
@@ -128,6 +128,36 @@ export interface ThemeVariables {
|
|
|
128
128
|
'--option-picker-padding'?: string;
|
|
129
129
|
/** Track (unfilled) background colour. Falls back to --background-accent. */
|
|
130
130
|
'--progress-bar-track-color'?: string;
|
|
131
|
+
/** Canvas behind the plan. Falls back to --background. */
|
|
132
|
+
'--plan-canvas-background'?: string;
|
|
133
|
+
/** Grid lines, drawn at low opacity. Falls back to --text-color. */
|
|
134
|
+
'--plan-grid-color'?: string;
|
|
135
|
+
/** The storey below, traced under the current one. Falls back to --text-dark. */
|
|
136
|
+
'--plan-underlay-color'?: string;
|
|
137
|
+
/** Room floor. Falls back to --background-accent. */
|
|
138
|
+
'--plan-room-fill'?: string;
|
|
139
|
+
/** Room floor under the pointer. Falls back to --background-accent-light. */
|
|
140
|
+
'--plan-room-fill-hover'?: string;
|
|
141
|
+
/** Edge of the walls bounding a selected room. Falls back to --primary-color. */
|
|
142
|
+
'--plan-room-edge-selected'?: string;
|
|
143
|
+
/** Body of those same walls. Falls back to --primary-lighter. */
|
|
144
|
+
'--plan-room-edge-selected-fill'?: string;
|
|
145
|
+
/** Wall body. Falls back to --text-color mixed 58% into the canvas. */
|
|
146
|
+
'--plan-wall-fill'?: string;
|
|
147
|
+
/** Wall edge, its caps and the jamb faces. Falls back to --text-color mixed 38% in. */
|
|
148
|
+
'--plan-wall-outline'?: string;
|
|
149
|
+
/** Wall corner treatment, any `stroke-linejoin` value. Falls back to `round`. */
|
|
150
|
+
'--plan-wall-join'?: string;
|
|
151
|
+
/** How far a mitred corner may run, when --plan-wall-join is `miter`. Falls back to `4`. */
|
|
152
|
+
'--plan-wall-miter-limit'?: string;
|
|
153
|
+
/** Door leaf and swing arc. Falls back to --text-dark. */
|
|
154
|
+
'--plan-door-color'?: string;
|
|
155
|
+
/** Window pane line. Falls back to --info-color. */
|
|
156
|
+
'--plan-window-color'?: string;
|
|
157
|
+
/** RoomDrawer's snap construction lines. Falls back to --info-color. */
|
|
158
|
+
'--plan-guide-color'?: string;
|
|
159
|
+
/** RoomDrawer's ruler. Falls back to --primary-color. */
|
|
160
|
+
'--plan-measure-color'?: string;
|
|
131
161
|
[key: string]: string | undefined;
|
|
132
162
|
}
|
|
133
163
|
export interface Theme {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a keydown is a click-equivalent activation of the element the handler sits on.
|
|
4
|
+
*
|
|
5
|
+
* The target check is the important half: keydown bubbles, so without it a Space typed into a
|
|
6
|
+
* nested input activates the container and, once the container calls `preventDefault()`, never
|
|
7
|
+
* reaches the input at all.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSelfActivation(event: React.KeyboardEvent): boolean;
|
package/docs/Flip.md
CHANGED
|
@@ -67,7 +67,7 @@ import { Tilt, Flip } from '@ahrowe/ui';
|
|
|
67
67
|
|
|
68
68
|
**Motion:** the flip always animates over `flipDuration`, whether triggered by a click, a controlled prop change, or the ref API. Under `prefers-reduced-motion: reduce`, it flips instantly instead. `onFlipEnd` fires once the flip settles on its new face — after the transition completes normally, or synchronously under reduced motion, since no transition runs to wait for.
|
|
69
69
|
|
|
70
|
-
**Keyboard accessibility:** when `flipOnClick` is set, the root gets `role="button"`, `tabIndex={0}`, and `aria-pressed` reflecting the current flip state, and Enter/Space both toggle the flip the same way a click does. None of this is applied when `flipOnClick` is `false`, since the element isn't interactive.
|
|
70
|
+
**Keyboard accessibility:** when `flipOnClick` is set, the root gets `role="button"`, `tabIndex={0}`, and `aria-pressed` reflecting the current flip state, and Enter/Space both toggle the flip the same way a click does, as long as the key was pressed on the root itself so a nested input or button keeps its own keys. None of this is applied when `flipOnClick` is `false`, since the element isn't interactive.
|
|
71
71
|
|
|
72
72
|
**Key props:**
|
|
73
73
|
|
package/docs/RoomDrawer.md
CHANGED
|
@@ -323,26 +323,34 @@ ref.current?.loadJson(await file.text());
|
|
|
323
323
|
|
|
324
324
|
## Theming
|
|
325
325
|
|
|
326
|
-
All colours come from theme variables. These control the plan itself, and each falls back to a general theme colour when unset:
|
|
326
|
+
All colours come from theme variables. These control the plan itself, and each falls back to a general theme colour when unset. They are declared on `ThemeVariables`, so a `Theme` gets them with autocomplete:
|
|
327
327
|
|
|
328
328
|
| Variable | Falls back to |
|
|
329
329
|
|----------|---------------|
|
|
330
330
|
| `--plan-canvas-background` | `var(--background)` |
|
|
331
331
|
| `--plan-grid-color` | `var(--text-color)` at low opacity |
|
|
332
|
+
| `--plan-underlay-color` | `var(--text-dark)` at low opacity |
|
|
332
333
|
| `--plan-room-fill` | `var(--background-accent)` |
|
|
333
334
|
| `--plan-room-fill-hover` | `var(--background-accent-light)` |
|
|
334
335
|
| `--plan-room-edge-selected` / `--plan-room-edge-selected-fill` | `var(--primary-color)` / `var(--primary-lighter)` |
|
|
335
|
-
| `--plan-wall-fill` | `var(--text-
|
|
336
|
-
| `--plan-wall-outline` | `var(--text-color)` |
|
|
336
|
+
| `--plan-wall-fill` | `var(--text-color)` mixed 58% into the canvas |
|
|
337
|
+
| `--plan-wall-outline` | `var(--text-color)` mixed 38% into the canvas |
|
|
338
|
+
| `--plan-wall-join` | `round` (see below) |
|
|
337
339
|
| `--plan-wall-miter-limit` | `4` (see below) |
|
|
338
340
|
| `--plan-door-color` | `var(--text-dark)` |
|
|
339
341
|
| `--plan-window-color` | `var(--info-color)` |
|
|
342
|
+
| `--plan-guide-color` | `var(--info-color)` |
|
|
343
|
+
| `--plan-measure-color` | `var(--primary-color)` |
|
|
340
344
|
|
|
341
|
-
|
|
345
|
+
**Walls are drawn as mass, not as ink.** Both wall tones are mixed towards the canvas rather than set to the text colour, so a wall reads as a solid body sitting on the floor and its edge as a soft rim rather than a drafted hairline. The pair must stay two distinct values: the outline pass is only visible where the fill pass does not cover it. The jamb faces at an opening take the *body* tone, since at a doorway they are the only thing standing in for the wall.
|
|
346
|
+
|
|
347
|
+
**`--plan-wall-join`** is the corner treatment, `round` by default: the outer corners of the building come out softened, and an acute corner cannot throw a mitre spike out of the junction at all. Set it to `miter` for the drafting corner, and `--plan-wall-miter-limit` then governs how far that spike may run. The selection highlight always uses whichever join the walls use, because it is drawn over the same geometry and a different join would leave crescents of wall showing round the corners.
|
|
348
|
+
|
|
349
|
+
**`--plan-wall-miter-limit`** applies when `--plan-wall-join` is `miter`. It is how sharp a corner may get before it is cut flat rather than run to a point. A mitred join extends to `1 / sin(angle / 2)` times the wall thickness, so it grows without bound as the angle closes: at 10 degrees that is eleven times the wall's own thickness, which reads as a spike fired out of the corner. The default of `4` keeps a true mitred point down to about 29 degrees and caps it at twice the wall's own thickness; sharper than that the corner is cut flat instead. Acute rooms bottom out around 45 degrees in practice and anything under 30 is not a room, so the corners that keep their point are the ones a building actually has. Raise it if you are drawing something genuinely needle-shaped and want the point kept. It governs the corners at a junction too, on the rare occasion one needs filling: where three or more walls meet, the corners between them are normally closed already, except when every wall at the node points into the same half-plane.
|
|
342
350
|
|
|
343
351
|
**Hover tints the room's floor; selection colours the walls that bound it.** They answer different questions, so they get different channels and can be read at the same time without being confused. Hover is fleeting and asks *which room is under the pointer*, where a faint fill is instant and unambiguous — a wall is not, being shared between the rooms on either side of it. Selection is state you then work inside, where a wash over the room would bury its doors and its label.
|
|
344
352
|
|
|
345
|
-
The selection highlight is built from **the same geometry as the walls themselves** and drawn in the same two passes, so it inherits their
|
|
353
|
+
The selection highlight is built from **the same geometry as the walls themselves** and drawn in the same two passes, so it inherits their corners and their gaps at openings: a door in the boundary stays a doorway rather than being painted over, and the wall keeps a crisp edge instead of turning into a flat slab. Where two selected rooms share a wall it is drawn once, so it never comes out twice as strong as its neighbours. The room fill carries `data-state="selected" | "hovered"` if you want to style either state further.
|
|
346
354
|
|
|
347
355
|
## Accessibility
|
|
348
356
|
|
package/docs/RoomViewer.md
CHANGED
|
@@ -54,6 +54,10 @@ A plan holds a stack of storeys and the viewer shows one at a time, with a tab p
|
|
|
54
54
|
|
|
55
55
|
Drag to pan, wheel or pinch to zoom, and the controls in the corner zoom and fit. The plan fits itself to the viewport on mount, and refits when the floor or the canvas size changes — **until the viewer pans or zooms**, after which the view is theirs and the component stops moving it. `pannable={false}` freezes it.
|
|
56
56
|
|
|
57
|
+
## Theming the plan
|
|
58
|
+
|
|
59
|
+
Walls are drawn as mass rather than as ink: the body is `var(--text-color)` mixed 58% into the canvas, its edge the same colour at 38%, and the corners are rounded. Override with `--plan-wall-fill`, `--plan-wall-outline` and `--plan-wall-join: miter`. The full list of plan variables is in [RoomDrawer.md](RoomDrawer.md#theming), and both components read the same ones.
|
|
60
|
+
|
|
57
61
|
## Key props
|
|
58
62
|
|
|
59
63
|
| Prop | Type | Description |
|