@hashsome/ui 0.5.0 → 0.7.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/.tsbuildinfo +1 -1
- package/dist/debug.d.ts +27 -0
- package/dist/debug.js +95 -0
- package/dist/entities/artwork-ring.d.ts +4 -2
- package/dist/entities/artwork-ring.js +78 -61
- package/dist/entities/climate-tile.js +2 -1
- package/dist/entities/media-browser.d.ts +3 -1
- package/dist/entities/media-browser.js +41 -15
- package/dist/entities/media-player-bar.js +1 -1
- package/dist/entities/media-player-column.d.ts +5 -2
- package/dist/entities/media-player-column.js +33 -5
- package/dist/entities/media-player-full.d.ts +12 -2
- package/dist/entities/media-player-full.js +45 -3
- package/dist/entities/now-playing.d.ts +3 -1
- package/dist/entities/now-playing.js +8 -3
- package/dist/entities/sensor-readout.js +8 -4
- package/dist/entities/top-bar.js +6 -2
- package/dist/gallery/gallery.js +13 -1
- package/dist/gallery/props-data.js +125 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/layout/animated-number.d.ts +15 -0
- package/dist/layout/animated-number.js +53 -0
- package/dist/layout/board.d.ts +26 -0
- package/dist/layout/board.js +85 -0
- package/dist/layout/debug-menu.d.ts +11 -0
- package/dist/layout/debug-menu.js +99 -0
- package/dist/layout/drawer-controls.js +18 -6
- package/dist/layout/energy-chart.js +2 -3
- package/dist/layout/grid-overlay.d.ts +6 -0
- package/dist/layout/grid-overlay.js +143 -0
- package/dist/layout/page.d.ts +7 -1
- package/dist/layout/page.js +43 -6
- package/dist/layout/room-header.js +1 -1
- package/dist/layout/tile.js +10 -2
- package/dist/layout/top-row.d.ts +9 -0
- package/dist/layout/top-row.js +10 -0
- package/dist/provider.d.ts +7 -3
- package/dist/provider.js +39 -21
- package/dist/theme/grid.d.ts +30 -0
- package/dist/theme/grid.js +38 -0
- package/package.json +2 -2
|
@@ -1,19 +1,61 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { Box, Flex } from 'e-prim';
|
|
2
|
+
import { Box, Flex, Typography } from 'e-prim';
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
import { useId, useState } from 'react';
|
|
3
5
|
import { fallbackName } from '../entity-handle.js';
|
|
4
6
|
import { useEntityHandle } from '../hooks.js';
|
|
5
7
|
import { useDetail } from '../layout/detail-provider.js';
|
|
8
|
+
import { Icon } from '../icon.js';
|
|
6
9
|
import { NowPlaying } from './now-playing.js';
|
|
7
10
|
/** The artwork ring's diameter in a full-size player, against the usual 168px. */
|
|
8
11
|
const FULL_SIZE = 260;
|
|
12
|
+
const TAB_HEIGHT = 40;
|
|
13
|
+
/** Library and Queue, as text with an underline (not the pills the library's own categories are, so the
|
|
14
|
+
* two rows read as different things). */
|
|
15
|
+
function ListTabs({ value, onChange }) {
|
|
16
|
+
// One line that slides between the tabs; its own id, so two players on a page do not share it.
|
|
17
|
+
const line = useId();
|
|
18
|
+
const tabs = [
|
|
19
|
+
{ id: 'library', label: 'Library', icon: 'lu:library' },
|
|
20
|
+
{ id: 'queue', label: 'Queue', icon: 'lu:list-music' },
|
|
21
|
+
];
|
|
22
|
+
return (_jsx(Flex, { role: "tablist", "aria-label": "Library or queue", gap: 5, css: ({ palette }) => ({ flexShrink: 0, borderBottom: `1px solid ${palette.border}` }), children: tabs.map((tab) => {
|
|
23
|
+
const selected = tab.id === value;
|
|
24
|
+
return (_jsxs(Flex, { as: "button", type: "button", role: "tab", "aria-selected": selected, onClick: () => onChange(tab.id), align: "center", justify: "center", gap: 2, height: TAB_HEIGHT, cursor: "pointer", color: selected ? 'text' : 'textMuted', css: {
|
|
25
|
+
flex: 1,
|
|
26
|
+
background: 'none',
|
|
27
|
+
border: 0,
|
|
28
|
+
padding: 0,
|
|
29
|
+
position: 'relative',
|
|
30
|
+
marginBottom: -1,
|
|
31
|
+
}, children: [selected ? (_jsx(Box, { as: motion.span, layoutId: line, position: "absolute", background: "accent", transition: { duration: 0.2, ease: 'easeOut' }, css: { left: 0, right: 0, bottom: 0, height: 2 } })) : null, _jsx(Icon, { name: tab.icon, size: 16 }), _jsx(Typography, { as: "span", variant: selected ? 'bodyStrong' : 'body', children: tab.label })] }, tab.id));
|
|
32
|
+
}) }));
|
|
33
|
+
}
|
|
9
34
|
/** The big player: the player centered at the top, and the library (or whatever `browser` is) below
|
|
10
35
|
* it. It is what the media cards' drawers show, at every width, and it is the widget a dashboard puts
|
|
11
36
|
* in a page of its own, around it whatever it likes (a surface that fills the space and scrolls, a
|
|
12
37
|
* heading, other cards beside it). It fills the height it is given, so the page that holds it
|
|
13
38
|
* decides how tall that is. */
|
|
14
|
-
export function MediaPlayerFull({ entity, browser, queue, wide, name }) {
|
|
39
|
+
export function MediaPlayerFull({ entity, browser, queue, wide, name, tabs = true, defaultTab = 'library', tab, onTabChange, }) {
|
|
15
40
|
const handle = useEntityHandle('mediaPlayer', entity);
|
|
16
41
|
const { detail } = useDetail();
|
|
17
42
|
const full = wide ?? detail?.expanded === true;
|
|
18
|
-
|
|
43
|
+
// Narrow, the queue and the library take turns in the one space below the player.
|
|
44
|
+
const [kept, setKept] = useState(defaultTab);
|
|
45
|
+
const hasQueue = queue !== undefined && handle.entity?.capabilities.queue === true;
|
|
46
|
+
const lists = [
|
|
47
|
+
...(browser !== undefined ? ['library'] : []),
|
|
48
|
+
...(!full && tabs && hasQueue ? ['queue'] : []),
|
|
49
|
+
];
|
|
50
|
+
const wanted = tab ?? kept;
|
|
51
|
+
const open = lists.includes(wanted) ? wanted : lists[0];
|
|
52
|
+
const choose = (next) => {
|
|
53
|
+
setKept(next);
|
|
54
|
+
onTabChange?.(next);
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs(Flex, { direction: "column", gap: 5, grow: 1, minHeight: 0, children: [_jsxs(Flex, { align: "stretch", justify: "center", gap: 6, ...(full ? { grow: 1 } : {}), css: { flexShrink: 0 }, children: [_jsx(Flex, { align: "center", justify: "center", grow: 1, minWidth: 0, children: _jsx(Box, { width: "100%", maxWidth: full ? 560 : 420, children: _jsx(NowPlaying, { handle: handle, fallback: fallbackName(entity), ...(name !== undefined ? { name } : {}), shuffle: "title", ...(full ? { size: FULL_SIZE } : {}) }) }) }), full && queue !== undefined && handle.entity?.capabilities.queue === true ? (_jsx(Flex, { position: "relative", width: 400, css: ({ palette }) => ({ flex: 'none', borderLeft: `1px solid ${palette.border}` }), children: _jsx(Flex, { direction: "column", position: "absolute", pl: 5, css: { inset: 0 }, children: queue }) })) : null] }), open !== undefined ? (_jsxs(_Fragment, { children: [lists.length > 1 ? (_jsx(ListTabs, { value: open, onChange: choose })) : (_jsx(Box, { height: 1, background: "border", css: { flexShrink: 0 } })), _jsx(Flex
|
|
57
|
+
// Another list fades in where the last one was, so a tab does not cut from one to the other.
|
|
58
|
+
, {
|
|
59
|
+
// Another list fades in where the last one was, so a tab does not cut from one to the other.
|
|
60
|
+
as: motion.div, initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.15, ease: 'easeOut' }, direction: "column", width: "100%", minHeight: 0, ...(full ? {} : { maxWidth: 960, mx: 'auto' }), children: open === 'queue' ? queue : browser }, open)] })) : null] }));
|
|
19
61
|
}
|
|
@@ -3,7 +3,7 @@ import type { EntityHandle } from '../entity-handle.ts';
|
|
|
3
3
|
/** The upright "now playing" panel the media column and page share: the artwork on a record, what is playing, how
|
|
4
4
|
* far along it is, the transport buttons and a volume bar that is always there. Not exported from
|
|
5
5
|
* the package; `MediaPlayerColumn` and `MediaPlayerFull` are its public forms. */
|
|
6
|
-
export declare function NowPlaying({ handle, fallback, name, extra, onOpenArtwork, size, shuffle: shufflePlacement, }: {
|
|
6
|
+
export declare function NowPlaying({ handle, fallback, name, extra, leading, onOpenArtwork, size, shuffle: shufflePlacement, }: {
|
|
7
7
|
handle: EntityHandle<'mediaPlayer'>;
|
|
8
8
|
/** What to call the player before it reports a name. */
|
|
9
9
|
fallback: string;
|
|
@@ -11,6 +11,8 @@ export declare function NowPlaying({ handle, fallback, name, extra, onOpenArtwor
|
|
|
11
11
|
name?: string;
|
|
12
12
|
/** One more button, to the right of the transport (the browse button). Shuffle takes the slot on the left, unless it sits by the title. */
|
|
13
13
|
extra?: ReactNode;
|
|
14
|
+
/** One more button, to the left of the transport, in the slot shuffle has when it sits by the title. Not shown while shuffle is in the row. */
|
|
15
|
+
leading?: ReactNode;
|
|
14
16
|
/** Makes the artwork a button that calls this (opens the library). */
|
|
15
17
|
onOpenArtwork?: () => void;
|
|
16
18
|
/** The artwork ring's diameter in px, for a roomier player. Default 168. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { useTheme } from '@emotion/react';
|
|
3
4
|
import { Flex, Grid, Typography } from 'e-prim';
|
|
4
5
|
import { Icon } from '../icon.js';
|
|
5
6
|
import { ValueBar } from '../layout/drawer-controls.js';
|
|
@@ -13,8 +14,10 @@ import { ArtworkRing } from './artwork-ring.js';
|
|
|
13
14
|
/** The upright "now playing" panel the media column and page share: the artwork on a record, what is playing, how
|
|
14
15
|
* far along it is, the transport buttons and a volume bar that is always there. Not exported from
|
|
15
16
|
* the package; `MediaPlayerColumn` and `MediaPlayerFull` are its public forms. */
|
|
16
|
-
export function NowPlaying({ handle, fallback, name, extra, onOpenArtwork, size, shuffle: shufflePlacement = 'transport', }) {
|
|
17
|
+
export function NowPlaying({ handle, fallback, name, extra, leading, onOpenArtwork, size, shuffle: shufflePlacement = 'transport', }) {
|
|
17
18
|
const player = handle.entity;
|
|
19
|
+
const { iconCircle, space } = useTheme().density;
|
|
20
|
+
const transportWidth = 5 * iconCircle + 4 * space;
|
|
18
21
|
const { status } = handle;
|
|
19
22
|
const ready = status === 'ready';
|
|
20
23
|
const caps = player?.capabilities;
|
|
@@ -25,10 +28,12 @@ export function NowPlaying({ handle, fallback, name, extra, onOpenArtwork, size,
|
|
|
25
28
|
const duration = ready ? player?.duration : undefined;
|
|
26
29
|
// The ring and the time under the title share one position, so dragging the ring moves both.
|
|
27
30
|
const seek = useSeekHold(ready ? position : undefined, caps?.seek ? (next) => void handle.command('seek', { position: next }) : undefined);
|
|
28
|
-
return (_jsxs(Flex, { direction: "column", gap: 4, "data-status": status, children: [_jsx(ArtworkRing, { artworkUrl: player?.media?.artworkUrl, seek: seek, duration: duration, seekable: caps?.seek === true, onOpen: onOpenArtwork, ...(size !== undefined ? { size } : {})
|
|
31
|
+
return (_jsxs(Flex, { direction: "column", gap: 4, "data-status": status, css: { minHeight: 0 }, children: [_jsx(ArtworkRing, { artworkUrl: player?.media?.artworkUrl, seek: seek, duration: duration, seekable: caps?.seek === true, onOpen: onOpenArtwork, ...(size !== undefined ? { size } : {}),
|
|
32
|
+
// No wider than the row of five buttons under it (268px: five circles and the gaps between them).
|
|
33
|
+
maxSize: transportWidth }), _jsxs(Flex, { direction: "column", align: "center", gap: 0.5, color: ready ? 'text' : 'textMuted', children: [_jsxs(Flex, { align: "center", justify: "center", gap: 2, maxWidth: "100%", children: [_jsx(Typography, { as: "h2", variant: "title", noWrap: true, textOverflow: "ellipsis", overflow: "hidden", m: 0, minWidth: 0, children: ready
|
|
29
34
|
? (player?.media?.title ?? 'Nothing playing')
|
|
30
35
|
: statusLabels[status] }), caps?.shuffle && shufflePlacement === 'title' ? (_jsx(IconButton, { icon: "lu:shuffle", label: "Shuffle", size: 14, active: player?.shuffle === true, pressed: player?.shuffle === true, disabled: !ready, onClick: () => void handle.command('setShuffle', { shuffle: player?.shuffle !== true }) })) : null] }), ready && player?.media?.artist ? (_jsx(Typography, { as: "span", variant: "body", color: "textMuted", noWrap: true, textOverflow: "ellipsis", overflow: "hidden", children: [player.media.artist, player.media.album].filter(Boolean).join(' · ') })) : (_jsx(Typography, { as: "span", variant: "body", color: "textMuted", noWrap: true, textOverflow: "ellipsis", overflow: "hidden", children: name ?? player?.name ?? fallback }))] }), seek.shown !== undefined && duration ? (_jsxs(Typography, { as: "span", variant: "secondary", color: "textMuted", align: "center", css: { fontVariantNumeric: 'tabular-nums' }, children: [formatDuration(seek.shown), " / ", formatDuration(duration)] })) : null, _jsxs(Grid, { gap: 3, css: ({ density }) => ({
|
|
31
36
|
gridTemplateColumns: `repeat(5, ${density.iconCircle}px)`,
|
|
32
37
|
justifyContent: 'center',
|
|
33
|
-
}), children: [caps?.shuffle && shufflePlacement === 'transport' ? (_jsx(IconButton, { icon: "lu:shuffle", label: "Shuffle", glyph: 18, active: player?.shuffle === true, pressed: player?.shuffle === true, disabled: !ready, onClick: () => void handle.command('setShuffle', { shuffle: player?.shuffle !== true }) })) : (_jsx("span", {})), _jsx(IconButton, { icon: "lu:skip-back", label: "Previous", glyph: 18, disabled: !ready || caps?.previous === false, feedback: feedbackFor('previous'), onClick: () => press('previous', () => handle.command('previous')) }), _jsx(IconButton, { icon: playing ? 'lu:pause' : 'lu:play', label: playing ? 'Pause' : 'Play', glyph: 18, disabled: !ready, primary: true, onClick: () => void handle.command('togglePlay') }), _jsx(IconButton, { icon: "lu:skip-forward", label: "Next", glyph: 18, disabled: !ready || caps?.next === false, feedback: feedbackFor('next'), onClick: () => press('next', () => handle.command('next')) }), extra ?? _jsx("span", {})] }), caps?.volume !== false || caps.mute ? (_jsxs(Flex, { align: "center", gap: 2, children: [_jsx(PlainButton, { "aria-label": volume.muted ? 'Unmute' : 'Mute', "aria-pressed": volume.muted, title: volume.muted ? 'Unmute' : 'Mute', disabled: !ready || caps?.mute === false, onClick: volume.toggleMute, center: true, color: volume.muted ? 'accent' : 'textMuted', css: { flex: 'none' }, children: _jsx(Icon, { name: volume.muted ? 'lu:volume-x' : 'lu:volume-2', size: 16 }) }), _jsx(ValueBar, { label: "Volume level", value: volume.shown, min: 0, max: 100, keyStep: 5, height: 10, onDrag: volume.drag, onCommit: volume.commit }), _jsxs(Typography, { as: "span", variant: "secondary", color: "textMuted", minWidth: 32, align: "right", css: { flex: 'none', fontVariantNumeric: 'tabular-nums' }, children: [volume.shown, "%"] })] })) : null] }));
|
|
38
|
+
}), children: [caps?.shuffle && shufflePlacement === 'transport' ? (_jsx(IconButton, { icon: "lu:shuffle", label: "Shuffle", glyph: 18, active: player?.shuffle === true, pressed: player?.shuffle === true, disabled: !ready, onClick: () => void handle.command('setShuffle', { shuffle: player?.shuffle !== true }) })) : shufflePlacement === 'title' ? ((leading ?? _jsx("span", {}))) : (_jsx("span", {})), _jsx(IconButton, { icon: "lu:skip-back", label: "Previous", glyph: 18, disabled: !ready || caps?.previous === false, feedback: feedbackFor('previous'), onClick: () => press('previous', () => handle.command('previous')) }), _jsx(IconButton, { icon: playing ? 'lu:pause' : 'lu:play', label: playing ? 'Pause' : 'Play', glyph: 18, disabled: !ready, primary: true, onClick: () => void handle.command('togglePlay') }), _jsx(IconButton, { icon: "lu:skip-forward", label: "Next", glyph: 18, disabled: !ready || caps?.next === false, feedback: feedbackFor('next'), onClick: () => press('next', () => handle.command('next')) }), extra ?? _jsx("span", {})] }), caps?.volume !== false || caps.mute ? (_jsxs(Flex, { align: "center", gap: 2, children: [_jsx(PlainButton, { "aria-label": volume.muted ? 'Unmute' : 'Mute', "aria-pressed": volume.muted, title: volume.muted ? 'Unmute' : 'Mute', disabled: !ready || caps?.mute === false, onClick: volume.toggleMute, center: true, color: volume.muted ? 'accent' : 'textMuted', css: { flex: 'none' }, children: _jsx(Icon, { name: volume.muted ? 'lu:volume-x' : 'lu:volume-2', size: 16 }) }), _jsx(ValueBar, { label: "Volume level", value: volume.shown, min: 0, max: 100, keyStep: 5, height: 10, onDrag: volume.drag, onCommit: volume.commit }), _jsxs(Typography, { as: "span", variant: "secondary", color: "textMuted", minWidth: 32, align: "right", css: { flex: 'none', fontVariantNumeric: 'tabular-nums' }, children: [volume.shown, "%"] })] })) : null] }));
|
|
34
39
|
}
|
|
@@ -3,6 +3,7 @@ import { Flex, Typography } from 'e-prim';
|
|
|
3
3
|
import { Icon } from '../icon.js';
|
|
4
4
|
import { fallbackName } from '../entity-handle.js';
|
|
5
5
|
import { useEntityHandle } from '../hooks.js';
|
|
6
|
+
import { AnimatedNumber } from '../layout/animated-number.js';
|
|
6
7
|
import { SensorHistory } from '../layout/sensor-history.js';
|
|
7
8
|
import { PlainButton } from '../layout/plain-button.js';
|
|
8
9
|
import { DrawerTrigger } from '../layout/use-drawer.js';
|
|
@@ -62,20 +63,23 @@ export function SensorReadout({ entity, icon, name, battery, history, safeRange,
|
|
|
62
63
|
const level = ready ? rangeLevel(sensor.value, range) : undefined;
|
|
63
64
|
const label = name ?? sensor?.name ?? fallbackName(entity);
|
|
64
65
|
const valueText = ready ? `${formatValue(sensor.value)}${unit ? ` ${unit}` : ''}` : '';
|
|
66
|
+
// A number that changes moves to its new value; written to one decimal, as `valueText` is.
|
|
67
|
+
const reading = (n) => `${formatValue(String(n))}${unit ? ` ${unit}` : ''}`;
|
|
68
|
+
const moving = ready && sensor.numeric !== undefined ? Math.round(sensor.numeric * 10) / 10 : undefined;
|
|
65
69
|
const warning = level === 'low' || level === 'high';
|
|
66
70
|
const hint = warning && range
|
|
67
71
|
? `${label} is too ${level} (safe range ${describeRange(range, unit)})`
|
|
68
72
|
: undefined;
|
|
69
|
-
const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: resolvedIcon, size: 16 }), _jsx(Typography, { as: "span", variant: "body", noWrap: true, children: ready ? valueText : statusLabels[status] }), warning ? _jsx(Icon, { name: "lu:triangle-alert", size: 16 }) : null] }));
|
|
73
|
+
const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: resolvedIcon, size: 16 }), _jsx(Typography, { as: "span", variant: "body", noWrap: true, children: ready ? (moving !== undefined ? (_jsx(AnimatedNumber, { value: moving, format: reading })) : (valueText)) : (statusLabels[status]) }), warning ? _jsx(Icon, { name: "lu:triangle-alert", size: 16 }) : null] }));
|
|
70
74
|
const numeric = ready && sensor.numeric !== undefined;
|
|
71
75
|
if (drawer && numeric) {
|
|
72
|
-
return (_jsx(DrawerTrigger, { icon: resolvedIcon, label: label, kind: deviceClass ? capitalize(deviceClass) : 'Sensor', body: _jsx(SensorDetailBody, { valueText: valueText, level: level, range: range, unit: unit, ...(battery ? { battery } : {}), ...(typeof entity === 'string' ? { entity } : {}), ...(history ? { history } : {}) }), children: (open) => (_jsx(PlainButton, { inline: true, align: "center", gap: 1, css: readoutStates, "data-status": status, "data-range": level, "aria-label": `${label}: ${valueText}${hint ? `. ${hint}` : ''}`, title: hint, onClick: open, children: content })) }));
|
|
76
|
+
return (_jsx(DrawerTrigger, { icon: resolvedIcon, label: label, kind: deviceClass ? capitalize(deviceClass) : 'Sensor', body: _jsx(SensorDetailBody, { valueText: valueText, ...(moving !== undefined ? { moving, reading } : {}), level: level, range: range, unit: unit, ...(battery ? { battery } : {}), ...(typeof entity === 'string' ? { entity } : {}), ...(history ? { history } : {}) }), children: (open) => (_jsx(PlainButton, { inline: true, align: "center", gap: 1, css: readoutStates, "data-status": status, "data-range": level, "aria-label": `${label}: ${valueText}${hint ? `. ${hint}` : ''}`, title: hint, onClick: open, children: content })) }));
|
|
73
77
|
}
|
|
74
78
|
return (_jsx(Flex, { as: "span", inline: true, align: "center", gap: 1, css: readoutStates, "data-status": status, "data-range": level, title: hint, children: content }));
|
|
75
79
|
}
|
|
76
|
-
function SensorDetailBody({ valueText, level, range, unit, entity, battery, history, }) {
|
|
80
|
+
function SensorDetailBody({ valueText, moving, reading, level, range, unit, entity, battery, history, }) {
|
|
77
81
|
const warning = level === 'low' || level === 'high';
|
|
78
|
-
return (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsxs(Flex, { direction: "column", background: "surfaceRaised", radius: "row", py: 3.5, px: 4, children: [_jsx(Typography, { as: "span", variant: "secondary", color: "textMuted", children: "Now" }), _jsx(Typography, { as: "span", variant: "stat", children: valueText }), range ? (_jsxs(Flex, { align: "center", gap: 1.5, css: ({ palette }) => ({ color: warning ? palette.danger : palette.textMuted }), children: [warning ? _jsx(Icon, { name: "lu:triangle-alert", size: 14 }) : null, _jsx(Typography, { as: "span", variant: "secondary", children: warning
|
|
82
|
+
return (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsxs(Flex, { direction: "column", background: "surfaceRaised", radius: "row", py: 3.5, px: 4, children: [_jsx(Typography, { as: "span", variant: "secondary", color: "textMuted", children: "Now" }), _jsx(Typography, { as: "span", variant: "stat", children: moving !== undefined && reading ? (_jsx(AnimatedNumber, { value: moving, format: reading })) : (valueText) }), range ? (_jsxs(Flex, { align: "center", gap: 1.5, css: ({ palette }) => ({ color: warning ? palette.danger : palette.textMuted }), children: [warning ? _jsx(Icon, { name: "lu:triangle-alert", size: 14 }) : null, _jsx(Typography, { as: "span", variant: "secondary", children: warning
|
|
79
83
|
? `Too ${level} · safe range ${describeRange(range, unit)}`
|
|
80
84
|
: `Within the safe range (${describeRange(range, unit)})` })] })) : null] }), battery ? _jsx(BatteryLevel, { entity: battery }) : null, _jsx(SensorHistory, { ...(history ? { samples: history } : entity ? { entity } : {}), unit: unit })] }));
|
|
81
85
|
}
|
package/dist/entities/top-bar.js
CHANGED
|
@@ -7,6 +7,7 @@ import { fallbackName } from '../entity-handle.js';
|
|
|
7
7
|
import { useConnectionStatus, useEntity, useEntityHandle, useIntegrationStatuses, } from '../hooks.js';
|
|
8
8
|
import { Icon } from '../icon.js';
|
|
9
9
|
import { statusLabels } from '../status.js';
|
|
10
|
+
import { TOP_ROW } from '../theme/grid.js';
|
|
10
11
|
import { DrawerTrigger } from '../layout/use-drawer.js';
|
|
11
12
|
import { useWeatherForecast } from '../use-weather-forecast.js';
|
|
12
13
|
import { SensorReadout } from './sensor-readout.js';
|
|
@@ -54,7 +55,10 @@ function useDismiss(open, close, ref) {
|
|
|
54
55
|
* shortcuts, and live status (weather, presence, a clock). Composes freely — every prop but
|
|
55
56
|
* `title` is optional. */
|
|
56
57
|
export function TopBar({ title, dashboards, scenes, weather, extra, presence, people, presenceColors, showClock = true, showDate = true, clockFormat = 'auto', showStatus = true, }) {
|
|
57
|
-
return (_jsxs(Flex, { align: "center", justify: "space-between", gap: 4,
|
|
58
|
+
return (_jsxs(Flex, { align: "center", justify: "space-between", gap: 4,
|
|
59
|
+
// A whole number of grid modules whatever is in it, so what is under it starts on the grid, and
|
|
60
|
+
// no padding of its own, so its content is as far from the page's edge as the rest.
|
|
61
|
+
css: { minHeight: TOP_ROW }, children: [_jsxs(Flex, { align: "center", gap: 3, children: [dashboards && dashboards.length > 1 ? (_jsx(DashboardSwitcher, { title: title, dashboards: dashboards })) : (_jsx(Typography, { as: "h1", variant: "title", children: title })), scenes?.length ? (_jsx(Flex, { align: "center", gap: 2.5, children: scenes.map((scene) => {
|
|
58
62
|
const { entity, icon, color } = typeof scene === 'string' ? { entity: scene } : scene;
|
|
59
63
|
return (_jsx(SceneDot, { entity: entity, ...(color ? { color } : {}), ...(icon ? { icon } : {}) }, entity));
|
|
60
64
|
}) })) : null] }), _jsxs(Flex, { align: "center", gap: 3, children: [showDate ? _jsx(DateChip, {}) : null, weather ? _jsx(WeatherChip, { entity: weather }) : null, extra, presence ? (_jsx(StatusChip, { children: _jsx(SensorReadout, { entity: presence, drawer: false }) })) : null, people?.length ? (_jsx(PresenceStack, { entities: people, ...(presenceColors ? { colors: presenceColors } : {}) })) : null, showClock ? _jsx(Clock, { format: clockFormat }) : null, showStatus ? _jsx(SystemStatus, {}) : null] })] }));
|
|
@@ -258,5 +262,5 @@ export function DateChip() {
|
|
|
258
262
|
export function Clock({ format = 'auto' }) {
|
|
259
263
|
const now = useNow(30_000);
|
|
260
264
|
const { time, dayPeriod } = formatClock(now, format);
|
|
261
|
-
return (_jsxs(Flex, { align: "flex-start", gap: 1, children: [_jsx(Typography, { as: "span", variant: "clock", children: time }), dayPeriod ? (_jsx(Typography, { as: "span", variant: "label", css: { textTransform: 'uppercase' }, children: dayPeriod })) : null] }));
|
|
265
|
+
return (_jsxs(Flex, { align: "flex-start", gap: 1, children: [_jsx(Typography, { as: "span", variant: "clock", css: { lineHeight: `${TOP_ROW}px` }, children: time }), dayPeriod ? (_jsx(Typography, { as: "span", variant: "label", css: { textTransform: 'uppercase' }, children: dayPeriod })) : null] }));
|
|
262
266
|
}
|
package/dist/gallery/gallery.js
CHANGED
|
@@ -22,10 +22,13 @@ import { SensorReadout } from '../entities/sensor-readout.js';
|
|
|
22
22
|
import { Clock, DateChip, PresenceStack, SystemStatus, TopBar, WeatherChip, } from '../entities/top-bar.js';
|
|
23
23
|
import { Icon } from '../icon.js';
|
|
24
24
|
import { EnergyChart, } from '../layout/energy-chart.js';
|
|
25
|
+
import { AnimatedNumber } from '../layout/animated-number.js';
|
|
26
|
+
import { Board, Cell } from '../layout/board.js';
|
|
25
27
|
import { Grid } from '../layout/grid.js';
|
|
26
28
|
import { HistorySection } from '../layout/history-section.js';
|
|
27
29
|
import { RoomHeader } from '../layout/room-header.js';
|
|
28
30
|
import { Tile } from '../layout/tile.js';
|
|
31
|
+
import { TopRow } from '../layout/top-row.js';
|
|
29
32
|
import { HashsomeProvider } from '../provider.js';
|
|
30
33
|
import { createGalleryIntegration } from './fixtures.js';
|
|
31
34
|
import { COMPONENT_PROPS } from './props-data.js';
|
|
@@ -72,6 +75,15 @@ function PropsTable({ name }) {
|
|
|
72
75
|
function ComponentDoc({ title, description, components, children, }) {
|
|
73
76
|
return (_jsxs("section", { css: { marginBottom: 40 }, children: [_jsxs(Flex, { direction: "column", gap: 1, maxWidth: "60ch", mb: 4, children: [_jsx(Typography, { as: "h2", variant: "heading", children: title }), _jsx(Typography, { as: "p", variant: "body", color: "textMuted", children: description })] }), _jsx(Stage, { children: children }), components.map((name) => (_jsx(PropsTable, { name: name }, name)))] }));
|
|
74
77
|
}
|
|
78
|
+
/** A reading that changes every time the button is pressed, to see it move. */
|
|
79
|
+
function AnimatedNumberDemo() {
|
|
80
|
+
const [watts, setWatts] = useState(40.1);
|
|
81
|
+
return (_jsxs(Flex, { align: "center", gap: 4, children: [_jsx(Typography, { as: "span", variant: "stat", children: _jsx(AnimatedNumber, { value: watts, format: (n) => `${n.toFixed(1)} W` }) }), _jsx(ActionButton, { label: "Change the reading", icon: "lu:refresh-cw", onPress: () => {
|
|
82
|
+
// Down to a few watts, then back up to the lamp's own.
|
|
83
|
+
setWatts((current) => (current > 20 ? 3.2 : 38) + Math.round(Math.random() * 60) / 10);
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
} })] }));
|
|
86
|
+
}
|
|
75
87
|
/** Plain dimmable tile whose fill follows a local value, since `Tile` itself is controlled. */
|
|
76
88
|
function TileFillDemo() {
|
|
77
89
|
const [fill, setFill] = useState(0.6);
|
|
@@ -362,7 +374,7 @@ export function Gallery({ density = 'comfortable' }) {
|
|
|
362
374
|
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.25)',
|
|
363
375
|
transform: mode === 'dark' ? 'translate(28px, -50%)' : 'translateY(-50%)',
|
|
364
376
|
transition: 'transform 0.2s ease',
|
|
365
|
-
}) }), _jsx(Icon, { name: "lu:sun", size: 14 }), _jsx(Icon, { name: "lu:moon", size: 14 })] })] }), _jsx(ComponentDoc, { title: "Grid", components: ['Grid'], description: "Lays tiles out in equal-width columns (`columns`, default 2). Cells share the width and never overflow it.", children: _jsxs(Flex, { direction: "column", gap: 5, children: [_jsxs(Grid, { columns: 2, children: [_jsx(Tile, { label: "Two", icon: "lu:layout-grid", secondary: "columns={2}" }), _jsx(Tile, { label: "Columns", icon: "lu:layout-grid", secondary: "equal width" })] }), _jsxs(Grid, { columns: 3, children: [_jsx(Tile, { label: "Three", icon: "lu:layout-grid", secondary: "columns={3}" }), _jsx(Tile, { label: "Columns", icon: "lu:layout-grid", secondary: "equal width" }), _jsx(Tile, { label: "Wide", icon: "lu:layout-grid", secondary: "fits the row" })] })] }) }), _jsx(ComponentDoc, { title: "Room Header", components: ['RoomHeader'], description: "The header that starts a room: a muted icon and title, a hairline and readouts on the right, placed above a Grid (or any tiles). It adds its own space above, so consecutive rooms read as groups.", children: _jsxs(Flex, { direction: "column", gap: 4, children: [_jsx(RoomHeader, { title: "Kitchen", icon: "lu:utensils-crossed" }), _jsx(RoomHeader, { title: "Porch", icon: "lu:house", readouts: _jsxs(_Fragment, { children: [_jsx(SensorReadout, { entity: "ha:sensor.temperature" }), _jsx(SensorReadout, { entity: "ha:sensor.humidity" })] }) })] }) }), _jsx(ComponentDoc, { title: "Tile", components: ['Tile'], description: "The base card every entity tile is built from: icon, label, status line, optional fill bar (drag to change it), trailing controls, a hold-to-open drawer and pending / done / error feedback. Use it directly for something that isn't an entity.", children: _jsxs(Grid, { children: [_jsx(Tile, { label: "Plain", icon: "lu:lamp", secondary: "Off" }), _jsx(Tile, { label: "Active", icon: "lu:lamp", active: true }), _jsx(TileFillDemo, {}), _jsx(Tile, { label: "With controls", icon: "lu:fan", trailing: _jsx(Typography, { as: "span", variant: "secondary", color: "textMuted", children: "trailing" }) }), _jsx(Tile, { label: "Pending", icon: "lu:lamp", feedback: "pending" }), _jsx(Tile, { label: "Error", icon: "lu:lamp", feedback: "error" }), _jsx(Tile, { label: "Unavailable", icon: "lu:lamp", status: "unavailable" }), _jsx(Tile, { label: "Not found", icon: "lu:lamp", status: "missing" })] }) }), _jsx(ComponentDoc, { title: "Icon", components: ['Icon'], description: "A plain prefixed string, no import: `lu:` is Lucide, `tb:` is Tabler outline. It takes the surrounding text color and scales with `size` (default 24px).", children: _jsxs(Flex, { direction: "column", gap: 4, children: [_jsxs(Flex, { align: "center", gap: 4, children: [_jsx(Icon, { name: "lu:lightbulb" }), _jsx(Icon, { name: "lu:thermometer", size: 16 }), _jsx(Icon, { name: "lu:sofa", size: 32 }), _jsx(Icon, { name: "tb:vacuum-cleaner" }), _jsx(Icon, { name: "tb:car-fan", size: 16 })] }), _jsxs(Flex, { align: "center", gap: 4, css: { flexWrap: 'wrap' }, children: [_jsx(Typography, { as: "span", variant: "body", color: "textMuted", children: "Find an icon:" }), ICON_PACKS.map((pack) => (_jsx(Typography, { as: "span", variant: "body", children: _jsxs("a", { css: ({ palette }) => ({ color: palette.accent, textUnderlineOffset: 3 }), href: pack.href, target: "_blank", rel: "noreferrer", children: ["Search ", pack.name, " icons (", _jsxs("span", { css: codeStyles, children: [pack.prefix, ":"] }), ")"] }) }, pack.prefix)))] })] }) }), _jsx(ComponentDoc, { title: "Energy Chart", components: ['EnergyChart'], description: "A power section for a drawer, which tiles pass through `energy`: a live power reading, usage tiles and a sparkline. Expanded in a drawer it becomes the full chart with a range switcher.", children: _jsx(EnergyChart, { power: "ha:sensor.heater_power", energy: "ha:sensor.heater_energy", usage: heaterUsage, seriesByRange: heaterSeries }) }), _jsx(ComponentDoc, { title: "History Section", components: ['HistorySection'], description: "Recent activity for a drawer, which tiles pass through `history`: who or what changed the entity, and when. An empty list renders nothing.", children: _jsx(HistorySection, { entries: lampHistory }) }), _jsx(ComponentDoc, { title: "Light Tile", components: ['LightTile'], description: "Tap to toggle, hold to open its detail drawer. Dimmable lights drag to set brightness; color-capable lights add a palette button that opens swatches in the card (white temperatures by default, overridable with `colors`), and the card's icon shows the light's current color. The drawer has the full temperature and hue bars.", children: _jsxs(Grid, { children: [_jsx(LightTile, { entity: "ha:light.plain_on", energy: lampEnergy, history: lampHistory }), _jsx(LightTile, { entity: "ha:light.plain_off", history: stairsHistory }), _jsx(LightTile, { entity: "ha:light.dimmable", icon: "lu:sparkles", energy: ledEnergy, history: ledHistory }), _jsx(LightTile, { entity: "ha:light.color", icon: "lu:lamp-desk", history: nightLampHistory }), _jsx(LightTile, { entity: "ha:light.cct", icon: "lu:lamp-desk" }), _jsx(LightTile, { entity: "ha:light.unavailable" }), _jsx(LightTile, { entity: "ha:light.missing" })] }) }), _jsx(ComponentDoc, { title: "Climate Tile", components: ['ClimateTile'], description: "A heater/thermostat tile: a mode button that opens mode swatches in the card (like light colors), plus a target-temperature stepper. Hold for the drawer: modes, a target bar with fine +/- (hold to repeat), presets, energy and history.", children: _jsxs(Grid, { columns: 1, children: [_jsx(ClimateTile, { entity: "ha:climate.heater", energy: heaterEnergy, history: heaterHistory }), _jsx(ClimateTile, { entity: "ha:climate.off", energy: thermostatEnergy, history: heaterHistory }), _jsx(ClimateTile, { entity: "ha:climate.unavailable" })] }) }), _jsx(ComponentDoc, { title: "Sensor Readout", components: ['SensorReadout'], description: "An inline value with icon and unit, defaulting its icon by device class. Readings outside a safe range get a warning (humidity defaults to 30\u201360 %; override with `safeRange`). Pass `history` to make it tappable: the drawer charts it with min/max for today, this week and this month, and a custom date and time range when expanded.", children: _jsxs(Grid, { columns: 3, children: [_jsx(SensorReadout, { entity: "ha:sensor.temperature", history: temperatureHistory }), _jsx(SensorReadout, { entity: "ha:sensor.humidity", history: humidityHistory }), _jsx(SensorReadout, { entity: "ha:sensor.bedroom_humidity", history: bedroomHumidityHistory }), _jsx(SensorReadout, { entity: "ha:sensor.office_humidity", history: officeHumidityHistory }), _jsx(SensorReadout, { entity: "ha:sensor.unavailable" }), _jsx(SensorReadout, { entity: "ha:sensor.unknown" })] }) }), _jsx(ComponentDoc, { title: "Scene Button & Action Button", components: ['SceneButton', 'ActionButton'], description: "A scene is just an action entity. An action button triggers an action (or flips a switch) and shows pending / done / error feedback after a press; `onPress` runs your own logic instead.", children: _jsxs(Grid, { columns: 3, children: [_jsx(SceneButton, { entity: "ha:scene.tv_time" }), _jsx(ActionButton, { label: "Shower", icon: "tb:bath", entity: "ha:script.shower" }), _jsx(ActionButton, { label: "Always Fails", onPress: () => Promise.reject(new Error('That went wrong')) })] }) }), _jsx(ComponentDoc, { title: "Media Player Bar", components: ['MediaPlayerBar'], description: "Track info (with a small shuffle toggle by the title) and the time beside it, then volume, browse, previous, play/pause and next (the artwork opens the browser too), with a thin progress line along the bottom while something plays. The browse button opens the player's own library in the drawer; pass `browse` content to replace it, or `false` for no button. The volume button opens a volume slider in the bar (with a mute swatch, like the light colors and climate modes). Shows album art, or a note glyph when there is none. In a space narrower than 560px, or with `rows={2}`, the controls move to a second row under the track.", children: _jsxs(Flex, { direction: "column", gap: 3, children: [_jsx(MediaPlayerBar, { entity: "ha:media_player.living_room" }), _jsx(MediaPlayerBar, { entity: "ha:media_player.off" }), _jsx(Flex, { width: 380, children: _jsx(MediaPlayerBar, { entity: "ha:media_player.living_room", rows: 2 }) })] }) }), _jsx(ComponentDoc, { title: "Media Player Column", components: ['MediaPlayerColumn'], description: "The player as an upright card for a narrow column beside a dashboard: the artwork in a ring that shows how far along playback is (drag around it to seek), title, transport, and a volume bar that is always visible. The browse button opens the library in the drawer.", children: _jsx(Flex, { width: 320, children: _jsx(MediaPlayerColumn, { entity: "ha:media_player.living_room" }) }) }), _jsx(ComponentDoc, { title: "Media Player Full", components: ['MediaPlayerFull', 'MediaQueue'], description: "The big player: the player centered with its queue beside it (`MediaQueue`: tap a track to jump to it, the cross takes it out, Clear empties it), and its library below, where every track can be played, played next or added to the queue, and an open album or playlist can be played, shuffled or added whole. The media cards' drawers show the player and library too. A dashboard puts it in a page of its own, around it whatever it likes.", children: _jsx(Flex, { direction: "column", children: _jsx(MediaPlayerFull, { entity: "ha:media_player.living_room", wide: true, queue: _jsx(MediaQueue, { entity: "ha:media_player.living_room" }), browser: _jsx(MediaBrowser, { entity: "ha:media_player.living_room", layout: "theater" }) }) }) }), _jsx(ComponentDoc, { title: "Weather Forecast", components: ['WeatherForecast'], description: "A weather entity's forecast: the weather now, the next 24 hours as a chart (hover it for everything about an hour) and the days ahead. The top bar's weather chip shows it in a drawer; a dashboard can put it in a page of its own. Narrow, then with `expanded` (readings tiles, a card for each hour).", children: _jsxs(Flex, { direction: "column", gap: 6, children: [_jsx(Flex, { direction: "column", width: 380, children: _jsx(WeatherForecast, { entity: "ha:weather.home", expanded: false }) }), _jsx(WeatherForecast, { entity: "ha:weather.home", expanded: true })] }) }), _jsx(ComponentDoc, { title: "Media Browser", components: ['MediaBrowser'], description: "A player's own library in the app's style: tap a folder to open it, a track or station to play it, or the play button on an album, playlist or artist for all of it. The search box appears when the library can be searched. The `theater` layout (second demo) is one row of large cards that scrolls sideways, for a wide space; `list` is the compact default. While a shelf loads, placeholders take the room the cards will (third demo, a shelf that never arrives), so nothing moves.", children: _jsxs(Flex, { direction: "column", gap: 6, children: [_jsx(Flex, { direction: "column", maxHeight: 420, overflow: "auto", children: _jsx(MediaBrowser, { entity: "ha:media_player.living_room" }) }), _jsx(MediaBrowser, { entity: "ha:media_player.living_room", layout: "theater" }), _jsx(MediaBrowser, { entity: "ha:media_player.loading", layout: "theater" })] }) }), _jsx(ComponentDoc, { title: "Navigation", components: ['NavRail', 'NavDock', 'Page'], description: "Routes within one dashboard. A dashboard includes one itself, usually in its layout route: NavRail is fixed to the left and NavDock floats at the bottom, and both reserve the space they take in the Page around them, which pads so content never sits under them.", children: _jsxs(Flex, { direction: "column", gap: 5, children: [_jsx(SubPreview, { label: "NavRail, in a Page", height: 240, children: _jsxs(Page, { height: "100%", children: [_jsx(NavRail, { base: "/gallery", items: NAV_ITEMS }), _jsx(Typography, { as: "p", variant: "body", color: "textMuted", children: "Page content, padded clear of the rail." })] }) }), _jsx(SubPreview, { label: "NavDock", height: 140, children: _jsx(NavDock, { base: "/gallery", items: NAV_ITEMS }) })] }) }), _jsx(ComponentDoc, { title: "Animated Outlet", components: ['AnimatedOutlet'], description: "A dashboard layout's `Outlet` with a transition between its pages: the page that was showing fades out, then the new one fades in, sliding from the side it sits on in the nav (a later page from the right, an earlier one from the left) when you give it the nav's `items`. Without them the pages only fade. It does nothing for a visitor who prefers reduced motion. Try the links.", children: _jsx(AnimatedOutletDemo, {}) }), _jsx(ComponentDoc, { title: "Top Bar", components: ['TopBar'], description: "Page chrome above a dashboard's content: a title (a dropdown to switch dashboards, once there's more than one to switch to), scene shortcuts, weather (tap it for the forecast), presence, and a clock.", children: _jsx(TopBar, { title: "Living Room", dashboards: [
|
|
377
|
+
}) }), _jsx(Icon, { name: "lu:sun", size: 14 }), _jsx(Icon, { name: "lu:moon", size: 14 })] })] }), _jsx(ComponentDoc, { title: "Board & Cell", components: ['Board', 'Cell'], description: "A page for one known device, laid out on a grid. Each cell says only how big it is (`cols` wide, `rows` tall); the board places them in order, in the first spot they fit. Rows are as tall as their content, so a cell of `rows={2}` ends where the second row does, and `rows='fill'` runs from where the cell is placed down to the bottom of the page, whatever rows are beside it. Every card is a whole number of grid modules tall, the gap between columns and inside a cell is three modules and between rows six, so the result stays on the grid (turn on the debug menu's Show grid to see it).", children: _jsxs(Flex, { direction: "column", gap: 5, children: [_jsxs(Board, { children: [_jsxs(Cell, { cols: 8, children: [_jsx(RoomHeader, { title: "Kitchen", icon: "lu:utensils-crossed" }), _jsxs(Grid, { columns: 2, children: [_jsx(Tile, { label: "Lamp", icon: "lu:lightbulb" }), _jsx(Tile, { label: "Ceiling", icon: "lu:lightbulb" })] })] }), _jsx(Cell, { cols: 4, rows: 2, children: _jsx(MediaPlayerColumn, { entity: "ha:media_player.off" }) }), _jsxs(Cell, { cols: 8, children: [_jsx(RoomHeader, { title: "Stairs", icon: "lu:footprints" }), _jsxs(Grid, { columns: 2, children: [_jsx(Tile, { label: "Lamp", icon: "lu:lightbulb" }), _jsx(Tile, { label: "Spotlights", icon: "lu:lightbulb" })] })] })] }), _jsx(Flex, { direction: "column", height: 460, css: { outline: '1px dashed currentColor' }, children: _jsxs(Board, { children: [_jsx(Cell, { children: _jsxs(TopRow, { children: [_jsx(DateChip, {}), _jsx(Clock, { format: "24h" })] }) }), _jsxs(Cell, { cols: 8, children: [_jsx(RoomHeader, { title: "Kitchen", icon: "lu:utensils-crossed" }), _jsxs(Grid, { columns: 2, children: [_jsx(Tile, { label: "Lamp", icon: "lu:lightbulb" }), _jsx(Tile, { label: "Ceiling", icon: "lu:lightbulb" })] })] }), _jsx(Cell, { cols: 4, rows: "fill", children: _jsx(MediaPlayerColumn, { entity: "ha:media_player.off" }) })] }) })] }) }), _jsx(ComponentDoc, { title: "Top Row", components: ['TopRow'], description: "The row along the top of a page you build yourself instead of with `TopBar`: the date, the weather, the clock and the status in a line at the right, in the height the grid gives the top row (40px), with no padding of its own.", children: _jsxs(TopRow, { children: [_jsx(DateChip, {}), _jsx(Clock, { format: "24h" })] }) }), _jsx(ComponentDoc, { title: "Grid", components: ['Grid'], description: "Lays tiles out in equal-width columns (`columns`, default 2). Cells share the width and never overflow it.", children: _jsxs(Flex, { direction: "column", gap: 5, children: [_jsxs(Grid, { columns: 2, children: [_jsx(Tile, { label: "Two", icon: "lu:layout-grid", secondary: "columns={2}" }), _jsx(Tile, { label: "Columns", icon: "lu:layout-grid", secondary: "equal width" })] }), _jsxs(Grid, { columns: 3, children: [_jsx(Tile, { label: "Three", icon: "lu:layout-grid", secondary: "columns={3}" }), _jsx(Tile, { label: "Columns", icon: "lu:layout-grid", secondary: "equal width" }), _jsx(Tile, { label: "Wide", icon: "lu:layout-grid", secondary: "fits the row" })] })] }) }), _jsx(ComponentDoc, { title: "Room Header", components: ['RoomHeader'], description: "The header that starts a room: a muted icon and title, a hairline and readouts on the right, placed above a Grid (or any tiles). It adds its own space above, so consecutive rooms read as groups.", children: _jsxs(Flex, { direction: "column", gap: 4, children: [_jsx(RoomHeader, { title: "Kitchen", icon: "lu:utensils-crossed" }), _jsx(RoomHeader, { title: "Porch", icon: "lu:house", readouts: _jsxs(_Fragment, { children: [_jsx(SensorReadout, { entity: "ha:sensor.temperature" }), _jsx(SensorReadout, { entity: "ha:sensor.humidity" })] }) })] }) }), _jsx(ComponentDoc, { title: "Tile", components: ['Tile'], description: "The base card every entity tile is built from: icon, label, status line, optional fill bar (drag to change it), trailing controls, a hold-to-open drawer and pending / done / error feedback. Use it directly for something that isn't an entity.", children: _jsxs(Grid, { children: [_jsx(Tile, { label: "Plain", icon: "lu:lamp", secondary: "Off" }), _jsx(Tile, { label: "Active", icon: "lu:lamp", active: true }), _jsx(TileFillDemo, {}), _jsx(Tile, { label: "With controls", icon: "lu:fan", trailing: _jsx(Typography, { as: "span", variant: "secondary", color: "textMuted", children: "trailing" }) }), _jsx(Tile, { label: "Pending", icon: "lu:lamp", feedback: "pending" }), _jsx(Tile, { label: "Error", icon: "lu:lamp", feedback: "error" }), _jsx(Tile, { label: "Unavailable", icon: "lu:lamp", status: "unavailable" }), _jsx(Tile, { label: "Not found", icon: "lu:lamp", status: "missing" })] }) }), _jsx(ComponentDoc, { title: "Icon", components: ['Icon'], description: "A plain prefixed string, no import: `lu:` is Lucide, `tb:` is Tabler outline. It takes the surrounding text color and scales with `size` (default 24px).", children: _jsxs(Flex, { direction: "column", gap: 4, children: [_jsxs(Flex, { align: "center", gap: 4, children: [_jsx(Icon, { name: "lu:lightbulb" }), _jsx(Icon, { name: "lu:thermometer", size: 16 }), _jsx(Icon, { name: "lu:sofa", size: 32 }), _jsx(Icon, { name: "tb:vacuum-cleaner" }), _jsx(Icon, { name: "tb:car-fan", size: 16 })] }), _jsxs(Flex, { align: "center", gap: 4, css: { flexWrap: 'wrap' }, children: [_jsx(Typography, { as: "span", variant: "body", color: "textMuted", children: "Find an icon:" }), ICON_PACKS.map((pack) => (_jsx(Typography, { as: "span", variant: "body", children: _jsxs("a", { css: ({ palette }) => ({ color: palette.accent, textUnderlineOffset: 3 }), href: pack.href, target: "_blank", rel: "noreferrer", children: ["Search ", pack.name, " icons (", _jsxs("span", { css: codeStyles, children: [pack.prefix, ":"] }), ")"] }) }, pack.prefix)))] })] }) }), _jsx(ComponentDoc, { title: "Energy Chart", components: ['EnergyChart'], description: "A power section for a drawer, which tiles pass through `energy`: a live power reading, usage tiles and a sparkline. Expanded in a drawer it becomes the full chart with a range switcher.", children: _jsx(EnergyChart, { power: "ha:sensor.heater_power", energy: "ha:sensor.heater_energy", usage: heaterUsage, seriesByRange: heaterSeries }) }), _jsx(ComponentDoc, { title: "History Section", components: ['HistorySection'], description: "Recent activity for a drawer, which tiles pass through `history`: who or what changed the entity, and when. An empty list renders nothing.", children: _jsx(HistorySection, { entries: lampHistory }) }), _jsx(ComponentDoc, { title: "Light Tile", components: ['LightTile'], description: "Tap to toggle, hold to open its detail drawer. Dimmable lights drag to set brightness; color-capable lights add a palette button that opens swatches in the card (white temperatures by default, overridable with `colors`), and the card's icon shows the light's current color. The drawer has the full temperature and hue bars.", children: _jsxs(Grid, { children: [_jsx(LightTile, { entity: "ha:light.plain_on", energy: lampEnergy, history: lampHistory }), _jsx(LightTile, { entity: "ha:light.plain_off", history: stairsHistory }), _jsx(LightTile, { entity: "ha:light.dimmable", icon: "lu:sparkles", energy: ledEnergy, history: ledHistory }), _jsx(LightTile, { entity: "ha:light.color", icon: "lu:lamp-desk", history: nightLampHistory }), _jsx(LightTile, { entity: "ha:light.cct", icon: "lu:lamp-desk" }), _jsx(LightTile, { entity: "ha:light.unavailable" }), _jsx(LightTile, { entity: "ha:light.missing" })] }) }), _jsx(ComponentDoc, { title: "Climate Tile", components: ['ClimateTile'], description: "A heater/thermostat tile: a mode button that opens mode swatches in the card (like light colors), plus a target-temperature stepper. Hold for the drawer: modes, a target bar with fine +/- (hold to repeat), presets, energy and history.", children: _jsxs(Grid, { columns: 1, children: [_jsx(ClimateTile, { entity: "ha:climate.heater", energy: heaterEnergy, history: heaterHistory }), _jsx(ClimateTile, { entity: "ha:climate.off", energy: thermostatEnergy, history: heaterHistory }), _jsx(ClimateTile, { entity: "ha:climate.unavailable" })] }) }), _jsx(ComponentDoc, { title: "Animated Number", components: ['AnimatedNumber'], description: "A number that moves to its new value instead of jumping: a power reading, a temperature. The first value is shown at once; a new one is moved to from what is shown now, even if the last move has not finished. The text is changed directly, with no render for each step, so many of them cost little, and nothing moves when the app is set to reduced motion. `format` writes a number with its unit and should round, as it is called for each step. The drawer's power reading, the sensor readouts and a thermostat's current temperature use it.", children: _jsx(AnimatedNumberDemo, {}) }), _jsx(ComponentDoc, { title: "Sensor Readout", components: ['SensorReadout'], description: "An inline value with icon and unit, defaulting its icon by device class. Readings outside a safe range get a warning (humidity defaults to 30\u201360 %; override with `safeRange`). Pass `history` to make it tappable: the drawer charts it with min/max for today, this week and this month, and a custom date and time range when expanded.", children: _jsxs(Grid, { columns: 3, children: [_jsx(SensorReadout, { entity: "ha:sensor.temperature", history: temperatureHistory }), _jsx(SensorReadout, { entity: "ha:sensor.humidity", history: humidityHistory }), _jsx(SensorReadout, { entity: "ha:sensor.bedroom_humidity", history: bedroomHumidityHistory }), _jsx(SensorReadout, { entity: "ha:sensor.office_humidity", history: officeHumidityHistory }), _jsx(SensorReadout, { entity: "ha:sensor.unavailable" }), _jsx(SensorReadout, { entity: "ha:sensor.unknown" })] }) }), _jsx(ComponentDoc, { title: "Scene Button & Action Button", components: ['SceneButton', 'ActionButton'], description: "A scene is just an action entity. An action button triggers an action (or flips a switch) and shows pending / done / error feedback after a press; `onPress` runs your own logic instead.", children: _jsxs(Grid, { columns: 3, children: [_jsx(SceneButton, { entity: "ha:scene.tv_time" }), _jsx(ActionButton, { label: "Shower", icon: "tb:bath", entity: "ha:script.shower" }), _jsx(ActionButton, { label: "Always Fails", onPress: () => Promise.reject(new Error('That went wrong')) })] }) }), _jsx(ComponentDoc, { title: "Media Player Bar", components: ['MediaPlayerBar'], description: "Track info (with a small shuffle toggle by the title) and the time beside it, then volume, browse, previous, play/pause and next (the artwork opens the browser too), with a thin progress line along the bottom while something plays. The browse button opens the player's own library in the drawer; pass `browse` content to replace it, or `false` for no button. The volume button opens a volume slider in the bar (with a mute swatch, like the light colors and climate modes). Shows album art, or a note glyph when there is none. In a space narrower than 560px, or with `rows={2}`, the controls move to a second row under the track.", children: _jsxs(Flex, { direction: "column", gap: 3, children: [_jsx(MediaPlayerBar, { entity: "ha:media_player.living_room" }), _jsx(MediaPlayerBar, { entity: "ha:media_player.off" }), _jsx(Flex, { width: 380, children: _jsx(MediaPlayerBar, { entity: "ha:media_player.living_room", rows: 2 }) })] }) }), _jsx(ComponentDoc, { title: "Media Player Column", components: ['MediaPlayerColumn'], description: "The player as an upright card for a narrow column beside a dashboard: the artwork in a ring that shows how far along playback is (drag around it to seek), title, transport, and a volume bar that is always visible. The browse button opens the library in the drawer.", children: _jsx(Flex, { width: 320, children: _jsx(MediaPlayerColumn, { entity: "ha:media_player.living_room" }) }) }), _jsx(ComponentDoc, { title: "Media Player Full", components: ['MediaPlayerFull', 'MediaQueue'], description: "The big player: the player centered with its queue beside it (`MediaQueue`: tap a track to jump to it, the cross takes it out, Clear empties it), and its library below, where every track can be played, played next or added to the queue, and an open album or playlist can be played, shuffled or added whole. The media cards' drawers show the player and library too. Where the queue has no room beside the player (a narrow column, the side drawer), Library and Queue are tabs above the list; `tabs={false}` leaves only the library, `defaultTab` and `tab` / `onTabChange` choose which is open. A dashboard puts it in a page of its own, around it whatever it likes.", children: _jsx(Flex, { direction: "column", children: _jsx(MediaPlayerFull, { entity: "ha:media_player.living_room", wide: true, queue: _jsx(MediaQueue, { entity: "ha:media_player.living_room" }), browser: _jsx(MediaBrowser, { entity: "ha:media_player.living_room", layout: "theater" }) }) }) }), _jsx(ComponentDoc, { title: "Weather Forecast", components: ['WeatherForecast'], description: "A weather entity's forecast: the weather now, the next 24 hours as a chart (hover it for everything about an hour) and the days ahead. The top bar's weather chip shows it in a drawer; a dashboard can put it in a page of its own. Narrow, then with `expanded` (readings tiles, a card for each hour).", children: _jsxs(Flex, { direction: "column", gap: 6, children: [_jsx(Flex, { direction: "column", width: 380, children: _jsx(WeatherForecast, { entity: "ha:weather.home", expanded: false }) }), _jsx(WeatherForecast, { entity: "ha:weather.home", expanded: true })] }) }), _jsx(ComponentDoc, { title: "Media Browser", components: ['MediaBrowser'], description: "A player's own library in the app's style: tap a folder to open it, a track or station to play it, or the play button on an album, playlist or artist for all of it. The search box appears when the library can be searched; with `search='icon'` (the second demo) it is an icon at the end of the row of tabs, after a thin line, and pressing it turns that row into the field, so it takes no room of its own. The `theater` layout (third demo) is one row of large cards that scrolls sideways, for a wide space; `list` is the compact default. While a shelf loads, placeholders take the room the cards will (fourth demo, a shelf that never arrives), so nothing moves.", children: _jsxs(Flex, { direction: "column", gap: 6, children: [_jsx(Flex, { direction: "column", maxHeight: 420, overflow: "auto", children: _jsx(MediaBrowser, { entity: "ha:media_player.living_room" }) }), _jsx(Flex, { direction: "column", maxHeight: 420, overflow: "auto", children: _jsx(MediaBrowser, { entity: "ha:media_player.living_room", search: "icon" }) }), _jsx(MediaBrowser, { entity: "ha:media_player.living_room", layout: "theater" }), _jsx(MediaBrowser, { entity: "ha:media_player.loading", layout: "theater" })] }) }), _jsx(ComponentDoc, { title: "Navigation", components: ['NavRail', 'NavDock', 'Page'], description: "Routes within one dashboard. A dashboard includes one itself, usually in its layout route: NavRail is fixed to the left and NavDock floats at the bottom, and both reserve the space they take in the Page around them, which pads so content never sits under them.", children: _jsxs(Flex, { direction: "column", gap: 5, children: [_jsx(SubPreview, { label: "NavRail, in a Page", height: 240, children: _jsxs(Page, { height: "100%", children: [_jsx(NavRail, { base: "/gallery", items: NAV_ITEMS }), _jsx(Typography, { as: "p", variant: "body", color: "textMuted", children: "Page content, padded clear of the rail." })] }) }), _jsx(SubPreview, { label: "NavDock", height: 140, children: _jsx(NavDock, { base: "/gallery", items: NAV_ITEMS }) })] }) }), _jsx(ComponentDoc, { title: "Animated Outlet", components: ['AnimatedOutlet'], description: "A dashboard layout's `Outlet` with a transition between its pages: the page that was showing fades out, then the new one fades in, sliding from the side it sits on in the nav (a later page from the right, an earlier one from the left) when you give it the nav's `items`. Without them the pages only fade. It does nothing for a visitor who prefers reduced motion. Try the links.", children: _jsx(AnimatedOutletDemo, {}) }), _jsx(ComponentDoc, { title: "Top Bar", components: ['TopBar'], description: "Page chrome above a dashboard's content: a title (a dropdown to switch dashboards, once there's more than one to switch to), scene shortcuts, weather (tap it for the forecast), presence, and a clock.", children: _jsx(TopBar, { title: "Living Room", dashboards: [
|
|
366
378
|
{ id: 'living-room', title: 'Living Room', icon: 'lu:sofa' },
|
|
367
379
|
{ id: 'bedroom', title: 'Bedroom', icon: 'lu:bed' },
|
|
368
380
|
{ id: 'bathroom', title: 'Bathroom', icon: 'tb:bath' },
|
|
@@ -18,8 +18,82 @@ export const COMPONENT_PROPS = {
|
|
|
18
18
|
},
|
|
19
19
|
],
|
|
20
20
|
},
|
|
21
|
+
AnimatedNumber: {
|
|
22
|
+
doc: 'A number that moves to its new value instead of jumping to it: a power reading that changes, a temperature. The first value is shown at once, and a new one is moved to from what is shown now, even if it has not arrived yet; the text is changed directly (no render per step), so many of them cost little, and none moves when the app is set to reduced motion.',
|
|
23
|
+
props: [
|
|
24
|
+
{
|
|
25
|
+
doc: 'The number to show. When it changes, what is shown moves to it instead of jumping.',
|
|
26
|
+
name: 'value',
|
|
27
|
+
optional: false,
|
|
28
|
+
type: 'number',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
doc: 'How a number is written, with its unit: `(n) => \\`${n.toFixed(1)} W\\``. Called for every step of the move, with a number between the old value and the new one, so it should round. Default: the number with as many decimals as `value` has.',
|
|
32
|
+
name: 'format',
|
|
33
|
+
optional: true,
|
|
34
|
+
type: '(n: number) => string',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
doc: 'Seconds the move takes. Default 0.6.',
|
|
38
|
+
name: 'duration',
|
|
39
|
+
optional: true,
|
|
40
|
+
type: 'number',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
Board: {
|
|
45
|
+
doc: 'A page laid out on a grid, for a dashboard made for one device. The page is `columns` equal columns (a gap between them) and rows as tall as what is in them, with twice that gap between rows. Nothing says where a cell goes: each `Cell` only says how big it is, and the board puts it in the first place it fits, in the order written. Every card is a whole number of grid modules tall and every gap is 3, so whatever the board makes stays on the grid. It takes the height that is left of the page. Opt in: a page of plain flex columns keeps working the same.',
|
|
46
|
+
props: [
|
|
47
|
+
{
|
|
48
|
+
doc: 'How many equal columns the page is divided into. Default 12.',
|
|
49
|
+
name: 'columns',
|
|
50
|
+
optional: true,
|
|
51
|
+
type: 'number',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
doc: '`Cell`s, each saying how big it is; the board places them.',
|
|
55
|
+
name: 'children',
|
|
56
|
+
optional: false,
|
|
57
|
+
type: 'ReactNode',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
Cell: {
|
|
62
|
+
doc: "Something on a `Board`, and how big it is: `cols` wide and `rows` tall. Where it goes is the board's business. A room is one cell (its header and its tiles), a player beside three of them is one that covers three rows, or fills.",
|
|
63
|
+
props: [
|
|
64
|
+
{
|
|
65
|
+
doc: 'How many columns wide. Default: all of them.',
|
|
66
|
+
name: 'cols',
|
|
67
|
+
optional: true,
|
|
68
|
+
type: 'number',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
doc: "How many rows of the board it covers, counting rows as tall as their content (a room is one): `3` ends where the third row does, and the cell is as tall as those rows, whatever is in it (a card in it that is too tall squeezes). `'fill'` starts where the cell is placed and goes down to the bottom of the page (or of the content, if that is longer), whatever rows are beside it; they keep their place. Default 1.",
|
|
72
|
+
name: 'rows',
|
|
73
|
+
optional: true,
|
|
74
|
+
type: "number | 'fill'",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
doc: "What is in it, one under the other with the gap between. In a cell of more than one row, or `'fill'`, the last card stretches to the cell's height.",
|
|
78
|
+
name: 'children',
|
|
79
|
+
optional: false,
|
|
80
|
+
type: 'ReactNode',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
TopRow: {
|
|
85
|
+
doc: 'The row along the top of a page you build yourself instead of with `TopBar`: its pieces (`DateChip`, `WeatherChip`, `Clock`, `SystemStatus`) in a line at the right, in the height the grid gives the top row, with no padding of its own.',
|
|
86
|
+
props: [
|
|
87
|
+
{
|
|
88
|
+
doc: 'What goes in the row: the date, the weather, the clock.',
|
|
89
|
+
name: 'children',
|
|
90
|
+
optional: false,
|
|
91
|
+
type: 'ReactNode',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
21
95
|
Page: {
|
|
22
|
-
doc: "The page every dashboard renders into: padded by the density's spacing, a column with gaps, exactly viewport height, and scrolling inside itself (the document never scrolls — the entity drawer is `position: fixed` and relies on that). It pads further for a `NavRail` or `NavDock` the dashboard includes. Render it once, in the app's root layout.",
|
|
96
|
+
doc: "The page every dashboard renders into: padded by the density's spacing, a column with gaps, exactly viewport height, and scrolling inside itself (the document never scrolls — the entity drawer is `position: fixed` and relies on that). It pads further for a `NavRail` or `NavDock` the dashboard includes. Render it once, in the app's root layout. The debug menu (`HASHSOME_DEBUG=1`) can draw the module grid over the page, spanning all of it (its padding is the grid's first three modules), with every card boxed green or red by whether it sits on the grid: for laying a dashboard out for one device. The height is rarely a whole number of grid modules; what is left over (under one module) is shared between the top and the bottom padding, so the content sits centered and the grid stays whole.",
|
|
23
97
|
props: [
|
|
24
98
|
{
|
|
25
99
|
doc: 'The dashboard.',
|
|
@@ -496,7 +570,7 @@ export const COMPONENT_PROPS = {
|
|
|
496
570
|
],
|
|
497
571
|
},
|
|
498
572
|
MediaPlayerColumn: {
|
|
499
|
-
doc: 'The player as an upright card for a narrow column beside a dashboard (a quarter to a third of the width): the artwork in a ring that shows (and seeks) the position, title, transport and a volume bar that is always visible. It is only as tall as it needs to be. Holding the card or pressing the artwork opens the drawer with the player and its library; the browse button opens that drawer expanded.',
|
|
573
|
+
doc: 'The player as an upright card for a narrow column beside a dashboard (a quarter to a third of the width): the artwork in a ring that shows (and seeks) the position, title, transport and a volume bar that is always visible. It is only as tall as it needs to be. Holding the card or pressing the artwork opens the drawer with the player and its library; the browse button opens that drawer expanded. With `overlays` there is no drawer: the library and the queue open full size, each on its own.',
|
|
500
574
|
props: [
|
|
501
575
|
{
|
|
502
576
|
doc: 'A media player, as a ref like `ma:kitchen` or `ha:media_player.kitchen`, or a handle (a custom source).',
|
|
@@ -516,6 +590,12 @@ export const COMPONENT_PROPS = {
|
|
|
516
590
|
optional: true,
|
|
517
591
|
type: 'ReactNode | false',
|
|
518
592
|
},
|
|
593
|
+
{
|
|
594
|
+
doc: "The library and the queue each open as a full-size overlay of their own, from a library button and a queue button beside the transport, instead of one half-size drawer with the whole player in it: for a small display, where the drawer's half state is no use. The library overlay is a `MediaBrowser` as a list (or your `browse` content), the queue overlay a `MediaQueue`; each button is left out when the player has none, or for `browse={false}`. Holding the card and pressing the artwork then do nothing. Shuffle moves up beside the title. Default `false`.",
|
|
595
|
+
name: 'overlays',
|
|
596
|
+
optional: true,
|
|
597
|
+
type: 'boolean',
|
|
598
|
+
},
|
|
519
599
|
],
|
|
520
600
|
},
|
|
521
601
|
MediaPlayerFull: {
|
|
@@ -551,6 +631,30 @@ export const COMPONENT_PROPS = {
|
|
|
551
631
|
optional: true,
|
|
552
632
|
type: 'boolean',
|
|
553
633
|
},
|
|
634
|
+
{
|
|
635
|
+
doc: 'In the narrow layout, where the queue has no room beside the player, a Library and a Queue tab above the list switch between them (shown when there is a `browser`, a `queue` and a player with a queue). `false` leaves the library alone, as before. In the wide layout the queue is beside the player and there are no tabs. Default `true`.',
|
|
636
|
+
name: 'tabs',
|
|
637
|
+
optional: true,
|
|
638
|
+
type: 'boolean',
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
doc: "The tab that is open first, when the tabs are on. Default `'library'`.",
|
|
642
|
+
name: 'defaultTab',
|
|
643
|
+
optional: true,
|
|
644
|
+
type: 'ListTab',
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
doc: 'The open tab, to keep it yourself (to remember it between visits, or open the queue from elsewhere); the tabs ask for a change through `onTabChange`. Without it, the component keeps it, until it is gone.',
|
|
648
|
+
name: 'tab',
|
|
649
|
+
optional: true,
|
|
650
|
+
type: 'ListTab',
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
doc: 'Called with the tab someone chose.',
|
|
654
|
+
name: 'onTabChange',
|
|
655
|
+
optional: true,
|
|
656
|
+
type: '(tab: ListTab) => void',
|
|
657
|
+
},
|
|
554
658
|
],
|
|
555
659
|
},
|
|
556
660
|
MediaBrowser: {
|
|
@@ -574,6 +678,12 @@ export const COMPONENT_PROPS = {
|
|
|
574
678
|
optional: true,
|
|
575
679
|
type: "'list' | 'theater' | 'auto'",
|
|
576
680
|
},
|
|
681
|
+
{
|
|
682
|
+
doc: 'How the search is offered, for a library that can be searched. `bar` is a field above the list. `icon` is a search icon at the right end of the row of tabs (or of the heading), after a thin line, which becomes the field when pressed, in that same row, so search takes no room of its own; its close button puts the tabs back. Default `bar`.',
|
|
683
|
+
name: 'search',
|
|
684
|
+
optional: true,
|
|
685
|
+
type: "'bar' | 'icon'",
|
|
686
|
+
},
|
|
577
687
|
],
|
|
578
688
|
},
|
|
579
689
|
MediaQueue: {
|
|
@@ -839,7 +949,7 @@ export const COMPONENT_PROPS = {
|
|
|
839
949
|
type: 'Density',
|
|
840
950
|
},
|
|
841
951
|
{
|
|
842
|
-
doc: "`'reduced'` turns animations and transitions off, for a slow display, `'full'` keeps them and `'auto'` (the default) leaves things as they are. A device can choose for itself with `?motion=reduced` (or `full`) on the address it opens
|
|
952
|
+
doc: "`'reduced'` turns animations and transitions off, for a slow display, `'full'` keeps them and `'auto'` (the default) leaves things as they are. A device can choose for itself with `?motion=reduced` (or `full`) on the address it opens, which wins over this prop. Nothing is kept: it holds while the app is open, moving between its pages, and a reload without the parameter goes back to this prop.",
|
|
843
953
|
name: 'motion',
|
|
844
954
|
optional: true,
|
|
845
955
|
type: 'MotionPreference',
|
|
@@ -850,6 +960,18 @@ export const COMPONENT_PROPS = {
|
|
|
850
960
|
optional: true,
|
|
851
961
|
type: 'ThemeOverrides',
|
|
852
962
|
},
|
|
963
|
+
{
|
|
964
|
+
doc: 'Shows the debug menu: a floating button at the bottom left whose popover shows the module grid, makes the page fullscreen and changes the theme, on the device, kept there. Default: on when `HASHSOME_DEBUG=1` (or `true`) was in the environment of `hashsome dev` or `build`.',
|
|
965
|
+
name: 'debug',
|
|
966
|
+
optional: true,
|
|
967
|
+
type: 'boolean',
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
doc: "The daylight sensor (`on` while the sun is up) the debug menu's Sun theme follows, when `theme` is not a sun schedule already (`theme={{ sun: … }}` names one). Without either, the menu has no Sun choice: Hashsome does not know which entity is the sun.",
|
|
971
|
+
name: 'sun',
|
|
972
|
+
optional: true,
|
|
973
|
+
type: 'EntityRef',
|
|
974
|
+
},
|
|
853
975
|
{
|
|
854
976
|
doc: 'The app.',
|
|
855
977
|
name: 'children',
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export * from './status.ts';
|
|
|
8
8
|
export type { IconName } from './icon-data.ts';
|
|
9
9
|
export * from './icon.tsx';
|
|
10
10
|
export * from './layout/grid.tsx';
|
|
11
|
+
export * from './layout/animated-number.tsx';
|
|
12
|
+
export * from './layout/board.tsx';
|
|
13
|
+
export * from './layout/top-row.tsx';
|
|
11
14
|
export * from './layout/page.tsx';
|
|
12
15
|
export * from './layout/animated-outlet.tsx';
|
|
13
16
|
export * from './layout/room-header.tsx';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,9 @@ export * from './hooks.js';
|
|
|
4
4
|
export * from './status.js';
|
|
5
5
|
export * from './icon.js';
|
|
6
6
|
export * from './layout/grid.js';
|
|
7
|
+
export * from './layout/animated-number.js';
|
|
8
|
+
export * from './layout/board.js';
|
|
9
|
+
export * from './layout/top-row.js';
|
|
7
10
|
export * from './layout/page.js';
|
|
8
11
|
export * from './layout/animated-outlet.js';
|
|
9
12
|
export * from './layout/room-header.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface AnimatedNumberProps {
|
|
2
|
+
/** The number to show. When it changes, what is shown moves to it instead of jumping. */
|
|
3
|
+
value: number;
|
|
4
|
+
/** How a number is written, with its unit: `(n) => \`${n.toFixed(1)} W\``. Called for every step of the move, with a number between the old value and the new one, so it should round. Default: the number with as many decimals as `value` has. */
|
|
5
|
+
format?: (n: number) => string;
|
|
6
|
+
/** Seconds the move takes. Default 0.6. */
|
|
7
|
+
duration?: number;
|
|
8
|
+
}
|
|
9
|
+
/** How many decimals a number is written with: `40.1` has one. */
|
|
10
|
+
export declare function decimalsOf(value: number): number;
|
|
11
|
+
/** A number that moves to its new value instead of jumping to it: a power reading that changes, a
|
|
12
|
+
* temperature. The first value is shown at once, and a new one is moved to from what is shown now, even
|
|
13
|
+
* if it has not arrived yet; the text is changed directly (no render per step), so many of them cost
|
|
14
|
+
* little, and none moves when the app is set to reduced motion. */
|
|
15
|
+
export declare function AnimatedNumber({ value, format, duration }: AnimatedNumberProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { animate, MotionGlobalConfig } from 'motion/react';
|
|
4
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
5
|
+
/** How many decimals a number is written with: `40.1` has one. */
|
|
6
|
+
export function decimalsOf(value) {
|
|
7
|
+
return Number.isFinite(value) ? (String(value).split('.')[1] ?? '').length : 0;
|
|
8
|
+
}
|
|
9
|
+
/** A number that moves to its new value instead of jumping to it: a power reading that changes, a
|
|
10
|
+
* temperature. The first value is shown at once, and a new one is moved to from what is shown now, even
|
|
11
|
+
* if it has not arrived yet; the text is changed directly (no render per step), so many of them cost
|
|
12
|
+
* little, and none moves when the app is set to reduced motion. */
|
|
13
|
+
export function AnimatedNumber({ value, format, duration = 0.6 }) {
|
|
14
|
+
const text = useRef(null);
|
|
15
|
+
const shown = useRef(value);
|
|
16
|
+
// What was asked for last, kept for the move, which must not start over because a caller's function is new.
|
|
17
|
+
const write = useRef((n) => String(n));
|
|
18
|
+
const decimals = decimalsOf(value);
|
|
19
|
+
const written = (n) => (format ? format(n) : n.toFixed(decimals));
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
write.current = written;
|
|
22
|
+
});
|
|
23
|
+
// Before the first paint of a new value, so the final value is never seen for a frame first.
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
const node = text.current;
|
|
26
|
+
const from = shown.current;
|
|
27
|
+
if (!node || from === value || !Number.isFinite(from) || !Number.isFinite(value)) {
|
|
28
|
+
shown.current = value;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Reduced motion: it is simply the new value.
|
|
32
|
+
if (MotionGlobalConfig.skipAnimations) {
|
|
33
|
+
shown.current = value;
|
|
34
|
+
node.textContent = write.current(value);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
node.textContent = write.current(from);
|
|
38
|
+
const move = animate(from, value, {
|
|
39
|
+
duration,
|
|
40
|
+
ease: 'easeOut',
|
|
41
|
+
onUpdate: (n) => {
|
|
42
|
+
shown.current = n;
|
|
43
|
+
node.textContent = write.current(n);
|
|
44
|
+
},
|
|
45
|
+
onComplete: () => {
|
|
46
|
+
shown.current = value;
|
|
47
|
+
node.textContent = write.current(value);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
return () => move.stop();
|
|
51
|
+
}, [value, duration]);
|
|
52
|
+
return (_jsx("span", { ref: text, css: { fontVariantNumeric: 'tabular-nums' }, children: written(value) }));
|
|
53
|
+
}
|