@hashsome/ui 0.4.0 → 0.6.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 +79 -51
- package/dist/entities/light-tile.d.ts +3 -1
- package/dist/entities/light-tile.js +29 -20
- package/dist/entities/media-browser.d.ts +3 -1
- package/dist/entities/media-browser.js +41 -15
- package/dist/entities/media-player-bar.d.ts +9 -1
- package/dist/entities/media-player-bar.js +122 -12
- 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/media-seek.d.ts +4 -1
- package/dist/entities/media-seek.js +22 -3
- package/dist/entities/nav-dock.js +3 -3
- package/dist/entities/now-playing.d.ts +3 -1
- package/dist/entities/now-playing.js +8 -3
- package/dist/entities/seek-line.js +12 -0
- package/dist/entities/top-bar.d.ts +21 -0
- package/dist/entities/top-bar.js +19 -10
- package/dist/gallery/gallery.js +18 -3
- package/dist/gallery/props-data.js +187 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/layout/animated-outlet.d.ts +14 -0
- package/dist/layout/animated-outlet.js +44 -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/detail-provider.d.ts +4 -2
- package/dist/layout/detail-provider.js +2 -2
- package/dist/layout/drawer-controls.js +36 -8
- package/dist/layout/entity-drawer.js +1 -1
- package/dist/layout/grid-overlay.d.ts +6 -0
- package/dist/layout/grid-overlay.js +143 -0
- package/dist/layout/hold-progress.d.ts +8 -2
- package/dist/layout/hold-progress.js +20 -4
- 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 +14 -10
- package/dist/layout/top-row.d.ts +9 -0
- package/dist/layout/top-row.js +10 -0
- package/dist/layout/use-drawer.d.ts +3 -2
- package/dist/layout/use-drawer.js +5 -3
- package/dist/provider.d.ts +15 -4
- package/dist/provider.js +144 -13
- package/dist/theme/global-styles.js +3 -0
- package/dist/theme/grid.d.ts +30 -0
- package/dist/theme/grid.js +38 -0
- package/dist/theme/index.js +2 -1
- package/dist/theme/schedule.d.ts +33 -0
- package/dist/theme/schedule.js +44 -0
- package/dist/theme/tokens.d.ts +2 -0
- package/package.json +2 -2
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] })] }));
|
|
@@ -138,10 +142,12 @@ function StatusChip({ children }) {
|
|
|
138
142
|
return (_jsx(Flex, { align: "center", gap: 2, background: "surface", border: true, radius: "full", px: 3.5, py: 2.5, children: children }));
|
|
139
143
|
}
|
|
140
144
|
/** Current weather, as a pill: an icon for the sky and a rounded whole-degree reading. A `weather`
|
|
141
|
-
* entity gives the real condition
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
* entity gives the real condition, today's high and low once its forecast has loaded, and opens the
|
|
146
|
+
* forecast when tapped (if its source has one); a plain `sensor.*` (an outdoor temperature) gets a
|
|
147
|
+
* fixed sun and no forecast, since a sensor says nothing about the sky. The top bar's weather pill,
|
|
148
|
+
* for a dashboard that builds its own header instead of using `TopBar`. */
|
|
149
|
+
export function WeatherChip({ entity, drawer = true }) {
|
|
150
|
+
return useEntity(entity)?.kind === 'weather' ? (_jsx(WeatherPill, { entity: entity, drawer: drawer })) : (_jsx(SensorWeather, { entity: entity }));
|
|
145
151
|
}
|
|
146
152
|
/** Text boxes cut to the height of the digits, so the reading and the range, in different sizes, are
|
|
147
153
|
* both centred on their digits and not on the font's line box (which sits a little low or high).
|
|
@@ -149,7 +155,7 @@ function WeatherChip({ entity }) {
|
|
|
149
155
|
/** The height of one line of the 12px label text. */
|
|
150
156
|
const LABEL_LINE = 15;
|
|
151
157
|
const TRIM_TO_DIGITS = { textBox: 'trim-both cap alphabetic' };
|
|
152
|
-
function WeatherPill({ entity }) {
|
|
158
|
+
function WeatherPill({ entity, drawer }) {
|
|
153
159
|
const handle = useEntityHandle('weather', entity);
|
|
154
160
|
const { status } = handle;
|
|
155
161
|
const weather = handle.entity;
|
|
@@ -166,7 +172,7 @@ function WeatherPill({ entity }) {
|
|
|
166
172
|
const chip = (_jsxs(StatusChip, { children: [_jsx(Flex, { as: "span", css: { minHeight: LABEL_LINE }, children: _jsx(WeatherIcon, { condition: condition, size: 14 }) }), _jsx(Typography, { as: "span", variant: "label", css: TRIM_TO_DIGITS, children: ready
|
|
167
173
|
? `${Math.round(weather.temperature ?? 0)}°`
|
|
168
174
|
: statusLabels[status] }), ready && range ? (_jsx(Typography, { as: "span", variant: "secondary", color: "textMuted", css: TRIM_TO_DIGITS, children: range })) : null] }));
|
|
169
|
-
if (!forecastable) {
|
|
175
|
+
if (!forecastable || !drawer) {
|
|
170
176
|
return chip;
|
|
171
177
|
}
|
|
172
178
|
return (_jsx(DrawerTrigger, { icon: look.icon, label: weather?.name ?? 'Weather', kind: "Weather", body: _jsx(WeatherForecast, { entity: entity }), children: (open) => (_jsx(PlainButton, { "aria-label": `${weather?.name ?? 'Weather'}: forecast`, onClick: open, children: chip })) }));
|
|
@@ -244,14 +250,17 @@ function useNow(intervalMs) {
|
|
|
244
250
|
}, [intervalMs]);
|
|
245
251
|
return now;
|
|
246
252
|
}
|
|
247
|
-
|
|
253
|
+
/** A short date pill (`Tue · Oct 6`), the top bar's, for a dashboard that builds its own header. */
|
|
254
|
+
export function DateChip() {
|
|
248
255
|
const now = useNow(60_000);
|
|
249
256
|
const weekday = now.toLocaleDateString(undefined, { weekday: 'short' });
|
|
250
257
|
const day = now.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
|
|
251
258
|
return (_jsx(StatusChip, { children: _jsxs(Typography, { as: "span", variant: "label", children: [weekday, " \u00B7 ", day] }) }));
|
|
252
259
|
}
|
|
253
|
-
|
|
260
|
+
/** The top bar's clock: the time in the large clock type, with AM/PM beside it in a 12h format. For
|
|
261
|
+
* a dashboard that builds its own header instead of using `TopBar`. */
|
|
262
|
+
export function Clock({ format = 'auto' }) {
|
|
254
263
|
const now = useNow(30_000);
|
|
255
264
|
const { time, dayPeriod } = formatClock(now, format);
|
|
256
|
-
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] }));
|
|
257
266
|
}
|
package/dist/gallery/gallery.js
CHANGED
|
@@ -3,11 +3,13 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@emotion/reac
|
|
|
3
3
|
import { Flex, Typography } from 'e-prim';
|
|
4
4
|
import { LocalClient } from '@hashsome/core';
|
|
5
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { NavLink, Route, Routes } from 'react-router';
|
|
6
7
|
import { ActionButton } from '../entities/action-button.js';
|
|
7
8
|
import { ClimateTile } from '../entities/climate-tile.js';
|
|
8
9
|
import { LightTile } from '../entities/light-tile.js';
|
|
9
10
|
import { MediaBrowser } from '../entities/media-browser.js';
|
|
10
11
|
import { MediaPlayerBar } from '../entities/media-player-bar.js';
|
|
12
|
+
import { AnimatedOutlet } from '../layout/animated-outlet.js';
|
|
11
13
|
import { MediaPlayerColumn } from '../entities/media-player-column.js';
|
|
12
14
|
import { MediaPlayerFull } from '../entities/media-player-full.js';
|
|
13
15
|
import { MediaQueue } from '../entities/media-queue.js';
|
|
@@ -17,13 +19,15 @@ import { NavRail } from '../entities/nav-rail.js';
|
|
|
17
19
|
import { Page } from '../layout/page.js';
|
|
18
20
|
import { SceneButton } from '../entities/scene-button.js';
|
|
19
21
|
import { SensorReadout } from '../entities/sensor-readout.js';
|
|
20
|
-
import { PresenceStack, SystemStatus, TopBar } from '../entities/top-bar.js';
|
|
22
|
+
import { Clock, DateChip, PresenceStack, SystemStatus, TopBar, WeatherChip, } from '../entities/top-bar.js';
|
|
21
23
|
import { Icon } from '../icon.js';
|
|
22
24
|
import { EnergyChart, } from '../layout/energy-chart.js';
|
|
25
|
+
import { Board, Cell } from '../layout/board.js';
|
|
23
26
|
import { Grid } from '../layout/grid.js';
|
|
24
27
|
import { HistorySection } from '../layout/history-section.js';
|
|
25
28
|
import { RoomHeader } from '../layout/room-header.js';
|
|
26
29
|
import { Tile } from '../layout/tile.js';
|
|
30
|
+
import { TopRow } from '../layout/top-row.js';
|
|
27
31
|
import { HashsomeProvider } from '../provider.js';
|
|
28
32
|
import { createGalleryIntegration } from './fixtures.js';
|
|
29
33
|
import { COMPONENT_PROPS } from './props-data.js';
|
|
@@ -79,6 +83,17 @@ function TileFillDemo() {
|
|
|
79
83
|
* chrome). `NavDock` is `position: fixed`, which a plain wrapper can't contain — `transform` on
|
|
80
84
|
* an ancestor makes it establish a containing block for fixed-position descendants instead (a
|
|
81
85
|
* standard CSS escape hatch), confining it to this box instead of the real viewport. */
|
|
86
|
+
const DEMO_PAGES = [
|
|
87
|
+
{ to: '', label: 'Lights', icon: 'lu:lightbulb' },
|
|
88
|
+
{ to: 'climate', label: 'Climate', icon: 'lu:thermometer' },
|
|
89
|
+
{ to: 'music', label: 'Music', icon: 'lu:music' },
|
|
90
|
+
];
|
|
91
|
+
const DEMO_BASE = '/gallery/transition';
|
|
92
|
+
/** Three pages under a route of the gallery's own router, with links to go between them: later ones
|
|
93
|
+
* slide in from the right. Until the address is under the demo's route there is a link to start it. */
|
|
94
|
+
function AnimatedOutletDemo() {
|
|
95
|
+
return (_jsx(Flex, { direction: "column", gap: 3, height: 140, p: 3, children: _jsxs(Routes, { children: [_jsx(Route, { path: DEMO_BASE, element: _jsxs(_Fragment, { children: [_jsx(Flex, { gap: 2, children: DEMO_PAGES.map((page) => (_jsx(NavLink, { to: page.to ? `${DEMO_BASE}/${page.to}` : DEMO_BASE, end: true, children: ({ isActive }) => (_jsx(Flex, { as: "span", align: "center", px: 3, height: 32, radius: "full", background: isActive ? 'accent' : 'surfaceRaised', color: isActive ? 'accentText' : 'text', children: _jsx(Typography, { as: "span", variant: "label", children: page.label }) })) }, page.to))) }), _jsx(AnimatedOutlet, { items: [...DEMO_PAGES], base: DEMO_BASE })] }), children: DEMO_PAGES.map((page) => (_jsx(Route, { ...(page.to ? { path: page.to } : { index: true }), element: _jsx(Flex, { center: true, grow: 1, background: "surfaceRaised", radius: "row", children: _jsx(Typography, { as: "span", variant: "heading", children: page.label }) }) }, page.to))) }), _jsx(Route, { path: "*", element: _jsx(Flex, { center: true, grow: 1, children: _jsx(NavLink, { to: DEMO_BASE, children: "Try the transition" }) }) })] }) }));
|
|
96
|
+
}
|
|
82
97
|
function SubPreview({ label, height, children, }) {
|
|
83
98
|
return (_jsxs(Flex, { direction: "column", gap: 2, children: [_jsx(Typography, { as: "span", variant: "eyebrow", uppercase: true, color: "textMuted", children: label }), _jsx(Flex, { position: "relative", overflow: "hidden", radius: "row", border: true, height: height, css: { transform: 'translateZ(0)' }, children: children })] }));
|
|
84
99
|
}
|
|
@@ -349,9 +364,9 @@ export function Gallery({ density = 'comfortable' }) {
|
|
|
349
364
|
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.25)',
|
|
350
365
|
transform: mode === 'dark' ? 'translate(28px, -50%)' : 'translateY(-50%)',
|
|
351
366
|
transition: 'transform 0.2s ease',
|
|
352
|
-
}) }), _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.", children: _jsxs(Flex, { direction: "column", gap: 3, children: [_jsx(MediaPlayerBar, { entity: "ha:media_player.living_room" }), _jsx(MediaPlayerBar, { entity: "ha:media_player.off" })] }) }), _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: "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: [
|
|
367
|
+
}) }), _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: "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: [
|
|
353
368
|
{ id: 'living-room', title: 'Living Room', icon: 'lu:sofa' },
|
|
354
369
|
{ id: 'bedroom', title: 'Bedroom', icon: 'lu:bed' },
|
|
355
370
|
{ id: 'bathroom', title: 'Bathroom', icon: 'tb:bath' },
|
|
356
|
-
], scenes: [{ entity: 'ha:scene.tv_time', icon: 'lu:tv' }], weather: "ha:weather.home", people: ['ha:person.dan', 'ha:person.alex'] }) }), _jsx(ComponentDoc, { title: "Presence Stack", components: ['PresenceStack'], description: "Overlapping avatar circles for a handful of person entities (the Top Bar's presence), each with a picture or a colored initial.", children: _jsx(PresenceStack, { entities: ['ha:person.dan', 'ha:person.alex'] }) }), _jsx(ComponentDoc, { title: "System Status", components: ['SystemStatus'], description: "The dot at the top bar's right edge. Green when the runtime and every integration are up, amber while something is connecting, red when something is down; click it for per-system detail. Shown here open, in each state.", children: _jsxs(Flex, { gap: 6, px: 6, align: "flex-start", justify: "space-around", minHeight: 32, children: [_jsx(SystemStatus, { defaultOpen: true, link: "open", statuses: { ha: 'connected', ma: 'connected' } }), _jsx(SystemStatus, { defaultOpen: true, link: "open", statuses: { ha: 'connected', ma: 'connecting' } }), _jsx(SystemStatus, { defaultOpen: true, link: "open", statuses: { ha: 'error', ma: 'disconnected' } })] }) }), _jsx(ComponentDoc, { title: "Hashsome Provider", description: "The app provider: connects to the runtime, installs the theme, font and density globally, and renders the shared detail drawer. Everything on this page runs inside one \u2014 use the toggle above to flip its theme.", components: ['HashsomeProvider'], children: _jsx(Typography, { as: "span", variant: "body", color: "textMuted", children: `theme="${mode}" · density="${density}"` }) })] }) }) }));
|
|
371
|
+
], scenes: [{ entity: 'ha:scene.tv_time', icon: 'lu:tv' }], weather: "ha:weather.home", people: ['ha:person.dan', 'ha:person.alex'] }) }), _jsx(ComponentDoc, { title: "Header pieces", components: ['DateChip', 'WeatherChip', 'Clock'], description: "The top bar's date, weather and clock, on their own: for a dashboard that builds its own header (a small room display, say) without the title, switcher and scenes of a whole TopBar. Put them in a row with SystemStatus, PresenceStack or anything else.", children: _jsxs(Flex, { align: "center", gap: 3, px: 4, children: [_jsx(DateChip, {}), _jsx(WeatherChip, { entity: "ha:weather.home" }), _jsx(Clock, { format: "24h" })] }) }), _jsx(ComponentDoc, { title: "Presence Stack", components: ['PresenceStack'], description: "Overlapping avatar circles for a handful of person entities (the Top Bar's presence), each with a picture or a colored initial.", children: _jsx(PresenceStack, { entities: ['ha:person.dan', 'ha:person.alex'] }) }), _jsx(ComponentDoc, { title: "System Status", components: ['SystemStatus'], description: "The dot at the top bar's right edge. Green when the runtime and every integration are up, amber while something is connecting, red when something is down; click it for per-system detail. Shown here open, in each state.", children: _jsxs(Flex, { gap: 6, px: 6, align: "flex-start", justify: "space-around", minHeight: 32, children: [_jsx(SystemStatus, { defaultOpen: true, link: "open", statuses: { ha: 'connected', ma: 'connected' } }), _jsx(SystemStatus, { defaultOpen: true, link: "open", statuses: { ha: 'connected', ma: 'connecting' } }), _jsx(SystemStatus, { defaultOpen: true, link: "open", statuses: { ha: 'error', ma: 'disconnected' } })] }) }), _jsx(ComponentDoc, { title: "Hashsome Provider", description: "The app provider: connects to the runtime, installs the theme, font and density globally, and renders the shared detail drawer. Everything on this page runs inside one \u2014 use the toggle above to flip its theme.", components: ['HashsomeProvider'], children: _jsx(Typography, { as: "span", variant: "body", color: "textMuted", children: `theme="${mode}" · density="${density}"` }) })] }) }) }));
|
|
357
372
|
}
|
|
@@ -18,8 +18,59 @@ export const COMPONENT_PROPS = {
|
|
|
18
18
|
},
|
|
19
19
|
],
|
|
20
20
|
},
|
|
21
|
+
Board: {
|
|
22
|
+
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.',
|
|
23
|
+
props: [
|
|
24
|
+
{
|
|
25
|
+
doc: 'How many equal columns the page is divided into. Default 12.',
|
|
26
|
+
name: 'columns',
|
|
27
|
+
optional: true,
|
|
28
|
+
type: 'number',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
doc: '`Cell`s, each saying how big it is; the board places them.',
|
|
32
|
+
name: 'children',
|
|
33
|
+
optional: false,
|
|
34
|
+
type: 'ReactNode',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
Cell: {
|
|
39
|
+
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.",
|
|
40
|
+
props: [
|
|
41
|
+
{
|
|
42
|
+
doc: 'How many columns wide. Default: all of them.',
|
|
43
|
+
name: 'cols',
|
|
44
|
+
optional: true,
|
|
45
|
+
type: 'number',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
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.",
|
|
49
|
+
name: 'rows',
|
|
50
|
+
optional: true,
|
|
51
|
+
type: "number | 'fill'",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
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.",
|
|
55
|
+
name: 'children',
|
|
56
|
+
optional: false,
|
|
57
|
+
type: 'ReactNode',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
TopRow: {
|
|
62
|
+
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.',
|
|
63
|
+
props: [
|
|
64
|
+
{
|
|
65
|
+
doc: 'What goes in the row: the date, the weather, the clock.',
|
|
66
|
+
name: 'children',
|
|
67
|
+
optional: false,
|
|
68
|
+
type: 'ReactNode',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
21
72
|
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.",
|
|
73
|
+
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
74
|
props: [
|
|
24
75
|
{
|
|
25
76
|
doc: 'The dashboard.',
|
|
@@ -35,6 +86,23 @@ export const COMPONENT_PROPS = {
|
|
|
35
86
|
},
|
|
36
87
|
],
|
|
37
88
|
},
|
|
89
|
+
AnimatedOutlet: {
|
|
90
|
+
doc: "A dashboard layout's `<Outlet />` with a transition between its pages: the page that was showing fades out (sliding a little toward the side it was on), then the new one fades in from the side it is on. It is a drop-in for `Outlet` in a layout route, and does nothing the first time a page shows or for a visitor who prefers reduced motion.",
|
|
91
|
+
props: [
|
|
92
|
+
{
|
|
93
|
+
doc: "The dashboard's pages in the order its nav lists them (the same `items` as `NavRail` or `NavDock`). A page then slides in from the side it sits on: a later page from the right, an earlier one from the left. Left out, pages only fade.",
|
|
94
|
+
name: 'items',
|
|
95
|
+
optional: true,
|
|
96
|
+
type: 'NavItem[]',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
doc: 'The path `items` are relative to, e.g. `/bathroom`. Needed with `items`.',
|
|
100
|
+
name: 'base',
|
|
101
|
+
optional: true,
|
|
102
|
+
type: 'string',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
38
106
|
RoomHeader: {
|
|
39
107
|
doc: 'The header that starts a room: muted icon and title, a hairline, and readouts on the right. Put it above a `Grid` (or any tiles); it adds its own space above, so consecutive rooms read as groups.',
|
|
40
108
|
props: [
|
|
@@ -283,6 +351,12 @@ export const COMPONENT_PROPS = {
|
|
|
283
351
|
optional: true,
|
|
284
352
|
type: 'LightColorPreset[]',
|
|
285
353
|
},
|
|
354
|
+
{
|
|
355
|
+
doc: 'Holding the tile opens a drawer with the full controls, the color bars, the energy chart and the recent activity. `false` leaves the tile as it is without it: a toggle that dims by dragging, with the color swatches if the light has color, and no drawer built, which is lighter on a small display. Default `true`.',
|
|
356
|
+
name: 'drawer',
|
|
357
|
+
optional: true,
|
|
358
|
+
type: 'boolean',
|
|
359
|
+
},
|
|
286
360
|
],
|
|
287
361
|
},
|
|
288
362
|
ClimateTile: {
|
|
@@ -446,10 +520,34 @@ export const COMPONENT_PROPS = {
|
|
|
446
520
|
optional: true,
|
|
447
521
|
type: 'ReactNode | false',
|
|
448
522
|
},
|
|
523
|
+
{
|
|
524
|
+
doc: '`false` builds no drawer: holding the card, pressing the artwork and the browse button then do nothing, which is lighter on a small display. Default `true`. See `onOpen` to send them somewhere else instead.',
|
|
525
|
+
name: 'drawer',
|
|
526
|
+
optional: true,
|
|
527
|
+
type: 'boolean',
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
doc: "Called instead of opening the drawer when the card is held, the artwork pressed or the browse button pressed: for a dashboard with a page of its own for the player (a `MediaPlayerFull`), `onOpen={() => navigate('/bathroom/music')}`. Given, no drawer is built. The browse button stays unless `browse` is `false`.",
|
|
531
|
+
name: 'onOpen',
|
|
532
|
+
optional: true,
|
|
533
|
+
type: '() => void',
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
doc: 'The library and the queue each open as a full-size overlay of their own, from the browse button and a new queue button, instead of one drawer with the whole player in it: for a small display, where the card itself is the player. 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, unless `onOpen` is given. Default `false`.',
|
|
537
|
+
name: 'overlays',
|
|
538
|
+
optional: true,
|
|
539
|
+
type: 'boolean',
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
doc: "`1` puts the controls beside the track, in one pill; `2` puts them on a second row under it, for a narrow space (a small wall display). Default `'auto'`: one row, and two once the bar is narrower than 560 px wide.",
|
|
543
|
+
name: 'rows',
|
|
544
|
+
optional: true,
|
|
545
|
+
type: "1 | 2 | 'auto'",
|
|
546
|
+
},
|
|
449
547
|
],
|
|
450
548
|
},
|
|
451
549
|
MediaPlayerColumn: {
|
|
452
|
-
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.',
|
|
550
|
+
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.',
|
|
453
551
|
props: [
|
|
454
552
|
{
|
|
455
553
|
doc: 'A media player, as a ref like `ma:kitchen` or `ha:media_player.kitchen`, or a handle (a custom source).',
|
|
@@ -469,6 +567,12 @@ export const COMPONENT_PROPS = {
|
|
|
469
567
|
optional: true,
|
|
470
568
|
type: 'ReactNode | false',
|
|
471
569
|
},
|
|
570
|
+
{
|
|
571
|
+
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`.",
|
|
572
|
+
name: 'overlays',
|
|
573
|
+
optional: true,
|
|
574
|
+
type: 'boolean',
|
|
575
|
+
},
|
|
472
576
|
],
|
|
473
577
|
},
|
|
474
578
|
MediaPlayerFull: {
|
|
@@ -504,6 +608,30 @@ export const COMPONENT_PROPS = {
|
|
|
504
608
|
optional: true,
|
|
505
609
|
type: 'boolean',
|
|
506
610
|
},
|
|
611
|
+
{
|
|
612
|
+
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`.',
|
|
613
|
+
name: 'tabs',
|
|
614
|
+
optional: true,
|
|
615
|
+
type: 'boolean',
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
doc: "The tab that is open first, when the tabs are on. Default `'library'`.",
|
|
619
|
+
name: 'defaultTab',
|
|
620
|
+
optional: true,
|
|
621
|
+
type: 'ListTab',
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
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.',
|
|
625
|
+
name: 'tab',
|
|
626
|
+
optional: true,
|
|
627
|
+
type: 'ListTab',
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
doc: 'Called with the tab someone chose.',
|
|
631
|
+
name: 'onTabChange',
|
|
632
|
+
optional: true,
|
|
633
|
+
type: '(tab: ListTab) => void',
|
|
634
|
+
},
|
|
507
635
|
],
|
|
508
636
|
},
|
|
509
637
|
MediaBrowser: {
|
|
@@ -527,6 +655,12 @@ export const COMPONENT_PROPS = {
|
|
|
527
655
|
optional: true,
|
|
528
656
|
type: "'list' | 'theater' | 'auto'",
|
|
529
657
|
},
|
|
658
|
+
{
|
|
659
|
+
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`.',
|
|
660
|
+
name: 'search',
|
|
661
|
+
optional: true,
|
|
662
|
+
type: "'bar' | 'icon'",
|
|
663
|
+
},
|
|
530
664
|
],
|
|
531
665
|
},
|
|
532
666
|
MediaQueue: {
|
|
@@ -686,6 +820,23 @@ export const COMPONENT_PROPS = {
|
|
|
686
820
|
},
|
|
687
821
|
],
|
|
688
822
|
},
|
|
823
|
+
WeatherChip: {
|
|
824
|
+
doc: "Current weather, as a pill: an icon for the sky and a rounded whole-degree reading. A `weather` entity gives the real condition, today's high and low once its forecast has loaded, and opens the forecast when tapped (if its source has one); a plain `sensor.*` (an outdoor temperature) gets a fixed sun and no forecast, since a sensor says nothing about the sky. The top bar's weather pill, for a dashboard that builds its own header instead of using `TopBar`.",
|
|
825
|
+
props: [
|
|
826
|
+
{
|
|
827
|
+
doc: 'A weather entity, like `ha:weather.forecast_home`, or a plain temperature sensor.',
|
|
828
|
+
name: 'entity',
|
|
829
|
+
optional: false,
|
|
830
|
+
type: 'EntityRef',
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
doc: "Tapping a weather entity's pill opens its forecast in a drawer. `false` builds none and the pill is only what it shows, which is lighter on a small display. Default `true`.",
|
|
834
|
+
name: 'drawer',
|
|
835
|
+
optional: true,
|
|
836
|
+
type: 'boolean',
|
|
837
|
+
},
|
|
838
|
+
],
|
|
839
|
+
},
|
|
689
840
|
PresenceStack: {
|
|
690
841
|
doc: 'Overlapping avatar circles for a handful of `person.*` entities.',
|
|
691
842
|
props: [
|
|
@@ -703,6 +854,21 @@ export const COMPONENT_PROPS = {
|
|
|
703
854
|
},
|
|
704
855
|
],
|
|
705
856
|
},
|
|
857
|
+
DateChip: {
|
|
858
|
+
doc: "A short date pill (`Tue · Oct 6`), the top bar's, for a dashboard that builds its own header.",
|
|
859
|
+
props: [],
|
|
860
|
+
},
|
|
861
|
+
Clock: {
|
|
862
|
+
doc: "The top bar's clock: the time in the large clock type, with AM/PM beside it in a 12h format. For a dashboard that builds its own header instead of using `TopBar`.",
|
|
863
|
+
props: [
|
|
864
|
+
{
|
|
865
|
+
doc: "`'auto'` follows the browser's locale (browsers don't read the OS 12/24h setting, so an `en-US` browser shows AM/PM); `'12h'`/`'24h'` force it. Default `'auto'`.",
|
|
866
|
+
name: 'format',
|
|
867
|
+
optional: true,
|
|
868
|
+
type: "'auto' | '12h' | '24h'",
|
|
869
|
+
},
|
|
870
|
+
],
|
|
871
|
+
},
|
|
706
872
|
WeatherForecast: {
|
|
707
873
|
doc: "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, with `expanded` for the full-size layout. Wide, it adds the current readings and a card for each hour. A source with no forecast shows only the weather now.",
|
|
708
874
|
props: [
|
|
@@ -742,7 +908,7 @@ export const COMPONENT_PROPS = {
|
|
|
742
908
|
type: "Omit<RemoteClientOptions, 'url'>",
|
|
743
909
|
},
|
|
744
910
|
{
|
|
745
|
-
doc: "`'system'` follows the browser/OS preference and updates live. Default `'dark'`. A `useThemeToggle()` caller (e.g. `NavRail`'s dev toggle) can still override this at runtime.",
|
|
911
|
+
doc: "`'light'`, `'dark'`, `'system'` (follows the browser/OS preference and updates live), or a schedule: `{ dark: { from: '19:00', to: '07:00' } }` is dark between those times on the display's clock, `{ sun: 'ha:sun.sun' }` is dark while that entity, a `daylight` sensor (`on` while the sun is up; the Home Assistant integration makes one of `sun.sun`), is `off`. Default `'dark'`. A schedule and the document shell's first paint use `'system'` until the time or the entity is known. A `useThemeToggle()` caller (e.g. `NavRail`'s dev toggle) can still override this at runtime. Pass a constant defined outside the component.",
|
|
746
912
|
name: 'theme',
|
|
747
913
|
optional: true,
|
|
748
914
|
type: 'ThemeMode',
|
|
@@ -759,12 +925,30 @@ export const COMPONENT_PROPS = {
|
|
|
759
925
|
optional: true,
|
|
760
926
|
type: 'Density',
|
|
761
927
|
},
|
|
928
|
+
{
|
|
929
|
+
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.",
|
|
930
|
+
name: 'motion',
|
|
931
|
+
optional: true,
|
|
932
|
+
type: 'MotionPreference',
|
|
933
|
+
},
|
|
762
934
|
{
|
|
763
935
|
doc: 'Partial changes to the built-in theme — colors per light/dark, radii, typography, spacing, density sizes. Pass a constant defined outside the component: a new object each render rebuilds the theme each render.',
|
|
764
936
|
name: 'overrides',
|
|
765
937
|
optional: true,
|
|
766
938
|
type: 'ThemeOverrides',
|
|
767
939
|
},
|
|
940
|
+
{
|
|
941
|
+
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`.',
|
|
942
|
+
name: 'debug',
|
|
943
|
+
optional: true,
|
|
944
|
+
type: 'boolean',
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
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.",
|
|
948
|
+
name: 'sun',
|
|
949
|
+
optional: true,
|
|
950
|
+
type: 'EntityRef',
|
|
951
|
+
},
|
|
768
952
|
{
|
|
769
953
|
doc: 'The app.',
|
|
770
954
|
name: 'children',
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ 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/board.tsx';
|
|
12
|
+
export * from './layout/top-row.tsx';
|
|
11
13
|
export * from './layout/page.tsx';
|
|
14
|
+
export * from './layout/animated-outlet.tsx';
|
|
12
15
|
export * from './layout/room-header.tsx';
|
|
13
16
|
export { Tile, type TileProps } from './layout/tile.tsx';
|
|
14
17
|
export * from './layout/energy-chart.tsx';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,10 @@ 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/board.js';
|
|
8
|
+
export * from './layout/top-row.js';
|
|
7
9
|
export * from './layout/page.js';
|
|
10
|
+
export * from './layout/animated-outlet.js';
|
|
8
11
|
export * from './layout/room-header.js';
|
|
9
12
|
export { Tile } from './layout/tile.js';
|
|
10
13
|
export * from './layout/energy-chart.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NavItem } from '../entities/nav-rail.tsx';
|
|
2
|
+
export interface AnimatedOutletProps {
|
|
3
|
+
/** The dashboard's pages in the order its nav lists them (the same `items` as `NavRail` or `NavDock`). A page then slides in from the side it sits on: a later page from the right, an earlier one from the left. Left out, pages only fade. */
|
|
4
|
+
items?: NavItem[];
|
|
5
|
+
/** The path `items` are relative to, e.g. `/bathroom`. Needed with `items`. */
|
|
6
|
+
base?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A dashboard layout's `<Outlet />` with a transition between its pages: the page that was showing
|
|
10
|
+
* fades out (sliding a little toward the side it was on), then the new one fades in from the side
|
|
11
|
+
* it is on. It is a drop-in for `Outlet` in a layout route, and does nothing the first time a page
|
|
12
|
+
* shows or for a visitor who prefers reduced motion.
|
|
13
|
+
*/
|
|
14
|
+
export declare function AnimatedOutlet({ items, base }: AnimatedOutletProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { AnimatePresence, motion, useReducedMotion } from 'motion/react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useLocation, useOutlet } from 'react-router';
|
|
6
|
+
/** How far a page slides, in px, as it comes and goes. */
|
|
7
|
+
const SLIDE = 24;
|
|
8
|
+
/** The index of the item whose page `pathname` is, or -1. */
|
|
9
|
+
function indexAt(pathname, items, base) {
|
|
10
|
+
if (!items || base === undefined) {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
const here = pathname.replace(/\/$/, '') || '/';
|
|
14
|
+
return items.findIndex((item) => (item.to ? `${base}/${item.to}` : base) === here);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A dashboard layout's `<Outlet />` with a transition between its pages: the page that was showing
|
|
18
|
+
* fades out (sliding a little toward the side it was on), then the new one fades in from the side
|
|
19
|
+
* it is on. It is a drop-in for `Outlet` in a layout route, and does nothing the first time a page
|
|
20
|
+
* shows or for a visitor who prefers reduced motion.
|
|
21
|
+
*/
|
|
22
|
+
export function AnimatedOutlet({ items, base }) {
|
|
23
|
+
const outlet = useOutlet();
|
|
24
|
+
const { pathname } = useLocation();
|
|
25
|
+
const still = useReducedMotion();
|
|
26
|
+
const index = indexAt(pathname, items, base);
|
|
27
|
+
// Moving to a later page is +1, to an earlier one -1; with no order to go by, 0 is just a fade.
|
|
28
|
+
const [seen, setSeen] = useState({ index, direction: 0 });
|
|
29
|
+
if (seen.index !== index) {
|
|
30
|
+
setSeen({
|
|
31
|
+
index,
|
|
32
|
+
direction: index === -1 || seen.index === -1 ? 0 : Math.sign(index - seen.index),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const seconds = still ? 0 : 0.14;
|
|
36
|
+
const slide = still ? 0 : SLIDE;
|
|
37
|
+
return (_jsx(AnimatePresence, { mode: "wait", initial: false, custom: seen.direction, children: _jsx(motion.div, { custom: seen.direction, variants: {
|
|
38
|
+
enter: (side) => ({ opacity: 0, x: side * slide }),
|
|
39
|
+
show: { opacity: 1, x: 0 },
|
|
40
|
+
exit: (side) => ({ opacity: 0, x: -side * slide }),
|
|
41
|
+
}, initial: "enter", animate: "show", exit: "exit", transition: { duration: seconds, ease: 'easeOut' },
|
|
42
|
+
// A page fills the space it is given, as it does without the wrapper.
|
|
43
|
+
css: { display: 'flex', flexDirection: 'column', flex: '1 1 auto', minHeight: 0 }, children: outlet }, pathname) }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface BoardProps {
|
|
3
|
+
/** How many equal columns the page is divided into. Default 12. */
|
|
4
|
+
columns?: number;
|
|
5
|
+
/** `Cell`s, each saying how big it is; the board places them. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/** A page laid out on a grid, for a dashboard made for one device. The page is `columns` equal columns
|
|
9
|
+
* (a gap between them) and rows as tall as what is in them, with twice that gap between rows. Nothing
|
|
10
|
+
* says where a cell goes: each `Cell` only says how big it is, and the board puts it in the first
|
|
11
|
+
* place it fits, in the order written. Every card is a whole number of grid modules tall and every gap
|
|
12
|
+
* is 3, so whatever the board makes stays on the grid. It takes the height that is left of the page.
|
|
13
|
+
* Opt in: a page of plain flex columns keeps working the same. */
|
|
14
|
+
export declare function Board({ columns, children }: BoardProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
+
export interface CellProps {
|
|
16
|
+
/** How many columns wide. Default: all of them. */
|
|
17
|
+
cols?: number;
|
|
18
|
+
/** 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. */
|
|
19
|
+
rows?: number | 'fill';
|
|
20
|
+
/** 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. */
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/** Something on a `Board`, and how big it is: `cols` wide and `rows` tall. Where it goes is the board's
|
|
24
|
+
* business. A room is one cell (its header and its tiles), a player beside three of them is one that
|
|
25
|
+
* covers three rows, or fills. */
|
|
26
|
+
export declare function Cell({ cols, rows, children }: CellProps): import("@emotion/react/jsx-runtime").JSX.Element;
|