@slotform/react-ui 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/density.d.ts +4 -0
- package/dist/density.d.ts.map +1 -0
- package/dist/density.js +8 -0
- package/dist/density.js.map +1 -0
- package/dist/index.d.ts +400 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/node/canvas.d.ts +3 -0
- package/dist/node/canvas.d.ts.map +1 -0
- package/dist/node/canvas.js +13 -0
- package/dist/node/canvas.js.map +1 -0
- package/dist/node/codegen.d.ts +6 -0
- package/dist/node/codegen.d.ts.map +1 -0
- package/dist/node/codegen.js +70 -0
- package/dist/node/codegen.js.map +1 -0
- package/dist/node/css-escape.d.ts +8 -0
- package/dist/node/css-escape.d.ts.map +1 -0
- package/dist/node/css-escape.js +12 -0
- package/dist/node/css-escape.js.map +1 -0
- package/dist/node/fonts.d.ts +6 -0
- package/dist/node/fonts.d.ts.map +1 -0
- package/dist/node/fonts.js +219 -0
- package/dist/node/fonts.js.map +1 -0
- package/dist/node/lint.d.ts +3 -0
- package/dist/node/lint.d.ts.map +1 -0
- package/dist/node/lint.js +23 -0
- package/dist/node/lint.js.map +1 -0
- package/dist/node/mode.d.ts +9 -0
- package/dist/node/mode.d.ts.map +1 -0
- package/dist/node/mode.js +38 -0
- package/dist/node/mode.js.map +1 -0
- package/dist/node/theme.d.ts +13 -0
- package/dist/node/theme.d.ts.map +1 -0
- package/dist/node/theme.js +160 -0
- package/dist/node/theme.js.map +1 -0
- package/dist/types.d.ts +250 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +80 -0
- package/dist/types.js.map +1 -0
- package/guide/acts.md +61 -0
- package/guide/audio.md +77 -0
- package/guide/blocks.md +82 -0
- package/guide/canvas-choosing.md +34 -0
- package/guide/canvas-editing.md +36 -0
- package/guide/canvas-layout.md +46 -0
- package/guide/canvas-opening.md +47 -0
- package/guide/canvas-overview.md +24 -0
- package/guide/canvas-states.md +37 -0
- package/guide/canvas-view.md +46 -0
- package/guide/canvas.md +94 -0
- package/guide/containers.md +60 -0
- package/guide/content.md +40 -0
- package/guide/controls.md +89 -0
- package/guide/density.md +48 -0
- package/guide/dock.md +42 -0
- package/guide/drag.md +38 -0
- package/guide/figures.md +25 -0
- package/guide/forms.md +82 -0
- package/guide/pane-bar.md +11 -0
- package/guide/pane.md +50 -0
- package/guide/reference.md +74 -0
- package/guide/rules.md +109 -0
- package/guide/section.md +29 -0
- package/guide/shell.md +26 -0
- package/guide/shots.md +37 -0
- package/guide/sidebar.md +30 -0
- package/guide/table.md +119 -0
- package/lint/no-arbitrary-value.grit +9 -0
- package/lint/no-class-on-component.grit +12 -0
- package/lint/no-density.grit +8 -0
- package/lint/no-host-look.grit +38 -0
- package/lint/no-img.grit +10 -0
- package/lint/no-navigate-act.grit +22 -0
- package/lint/no-raw-style.grit +8 -0
- package/package.json +150 -3
- package/src/density.ts +9 -0
- package/src/index.ts +503 -0
- package/src/node/canvas.ts +14 -0
- package/src/node/codegen.ts +100 -0
- package/src/node/css-escape.ts +27 -0
- package/src/node/fonts.ts +260 -0
- package/src/node/lint.ts +25 -0
- package/src/node/mode.ts +64 -0
- package/src/node/theme.ts +232 -0
- package/src/types.ts +120 -0
- package/src/ui/atoms/avatar/base.tsx +42 -0
- package/src/ui/atoms/button/glyph.tsx +244 -0
- package/src/ui/atoms/button/link.tsx +81 -0
- package/src/ui/atoms/button/look.ts +32 -0
- package/src/ui/atoms/button/reason.tsx +69 -0
- package/src/ui/atoms/chip/base.tsx +85 -0
- package/src/ui/atoms/count/base.tsx +27 -0
- package/src/ui/atoms/icon/index.tsx +51 -0
- package/src/ui/atoms/message/waiting.tsx +19 -0
- package/src/ui/atoms/prose/painted.tsx +35 -0
- package/src/ui/atoms/row/badges.tsx +226 -0
- package/src/ui/atoms/row/leading.tsx +166 -0
- package/src/ui/atoms/row/lock.tsx +17 -0
- package/src/ui/atoms/row/marks.tsx +79 -0
- package/src/ui/atoms/section/card.tsx +27 -0
- package/src/ui/atoms/spinner/index.tsx +42 -0
- package/src/ui/atoms/status/base.tsx +51 -0
- package/src/ui/atoms/status/change.tsx +29 -0
- package/src/ui/atoms/status/dot.tsx +45 -0
- package/src/ui/atoms/switch/checkbox.tsx +121 -0
- package/src/ui/atoms/turn.tsx +28 -0
- package/src/ui/components/action-bar/base.tsx +276 -0
- package/src/ui/components/action-bar/index.tsx +20 -0
- package/src/ui/components/avatar/index.tsx +21 -0
- package/src/ui/components/banner/index.tsx +207 -0
- package/src/ui/components/banner/pending.tsx +109 -0
- package/src/ui/components/bar-chart/index.tsx +701 -0
- package/src/ui/components/button/base.tsx +214 -0
- package/src/ui/components/button/face.tsx +84 -0
- package/src/ui/components/button/index.tsx +206 -0
- package/src/ui/components/canvas/connection.tsx +26 -0
- package/src/ui/components/canvas/edges.tsx +116 -0
- package/src/ui/components/canvas/elk.ts +260 -0
- package/src/ui/components/canvas/floor.ts +173 -0
- package/src/ui/components/canvas/geometry.ts +772 -0
- package/src/ui/components/canvas/ground.tsx +97 -0
- package/src/ui/components/canvas/group.tsx +156 -0
- package/src/ui/components/canvas/hit.ts +40 -0
- package/src/ui/components/canvas/index.tsx +497 -0
- package/src/ui/components/canvas/label.tsx +53 -0
- package/src/ui/components/canvas/layout.ts +543 -0
- package/src/ui/components/canvas/lift.ts +272 -0
- package/src/ui/components/canvas/look.ts +129 -0
- package/src/ui/components/canvas/node.tsx +689 -0
- package/src/ui/components/canvas/open.ts +243 -0
- package/src/ui/components/canvas/opening.ts +240 -0
- package/src/ui/components/canvas/view.ts +621 -0
- package/src/ui/components/canvas/viewport.ts +417 -0
- package/src/ui/components/canvas/zoom.tsx +113 -0
- package/src/ui/components/card/index.tsx +20 -0
- package/src/ui/components/chip/index.tsx +24 -0
- package/src/ui/components/code/frame.ts +2 -0
- package/src/ui/components/code/index.tsx +234 -0
- package/src/ui/components/columns/index.tsx +51 -0
- package/src/ui/components/count/index.tsx +17 -0
- package/src/ui/components/diff/index.tsx +249 -0
- package/src/ui/components/diff/word.tsx +104 -0
- package/src/ui/components/dock/index.tsx +262 -0
- package/src/ui/components/file-row/index.tsx +213 -0
- package/src/ui/components/form/base.tsx +280 -0
- package/src/ui/components/form/derive.tsx +269 -0
- package/src/ui/components/form/index.tsx +49 -0
- package/src/ui/components/form/saved.tsx +39 -0
- package/src/ui/components/form-field/index.tsx +658 -0
- package/src/ui/components/gallery/index.tsx +83 -0
- package/src/ui/components/gate/index.tsx +183 -0
- package/src/ui/components/image/base.tsx +245 -0
- package/src/ui/components/image/index.tsx +58 -0
- package/src/ui/components/input/base.tsx +246 -0
- package/src/ui/components/input/code.tsx +108 -0
- package/src/ui/components/input/drop.ts +37 -0
- package/src/ui/components/input/file.tsx +154 -0
- package/src/ui/components/input/index.tsx +132 -0
- package/src/ui/components/input/prose.tsx +107 -0
- package/src/ui/components/input/refusal.tsx +30 -0
- package/src/ui/components/item-header/base.tsx +410 -0
- package/src/ui/components/menu/base.tsx +319 -0
- package/src/ui/components/message/attachments.tsx +101 -0
- package/src/ui/components/message/base.tsx +266 -0
- package/src/ui/components/message-input/index.tsx +377 -0
- package/src/ui/components/missing/base.tsx +45 -0
- package/src/ui/components/pane/head.tsx +399 -0
- package/src/ui/components/pane/index.tsx +325 -0
- package/src/ui/components/picker/base.tsx +1551 -0
- package/src/ui/components/picker/index.tsx +224 -0
- package/src/ui/components/picker/list.tsx +423 -0
- package/src/ui/components/picker/segments.tsx +183 -0
- package/src/ui/components/prose/index.tsx +259 -0
- package/src/ui/components/qr-code/index.tsx +65 -0
- package/src/ui/components/row/acts.tsx +126 -0
- package/src/ui/components/row/fact.tsx +54 -0
- package/src/ui/components/row/index.tsx +1370 -0
- package/src/ui/components/row/progress.tsx +38 -0
- package/src/ui/components/row/status.tsx +54 -0
- package/src/ui/components/row/title.ts +7 -0
- package/src/ui/components/rules/index.tsx +290 -0
- package/src/ui/components/section/band.tsx +39 -0
- package/src/ui/components/section/head.tsx +267 -0
- package/src/ui/components/section/index.tsx +409 -0
- package/src/ui/components/section/rows.tsx +356 -0
- package/src/ui/components/sheet/base.tsx +272 -0
- package/src/ui/components/sheet/confirm.tsx +79 -0
- package/src/ui/components/sheet/docked.tsx +218 -0
- package/src/ui/components/sheet/form.tsx +76 -0
- package/src/ui/components/sheet/head.tsx +120 -0
- package/src/ui/components/sheet/index.tsx +45 -0
- package/src/ui/components/sheet/layer.tsx +168 -0
- package/src/ui/components/sheet/outlet.tsx +58 -0
- package/src/ui/components/sheet/task.tsx +41 -0
- package/src/ui/components/shell/cut.tsx +116 -0
- package/src/ui/components/shell/drag.tsx +45 -0
- package/src/ui/components/shell/host.tsx +71 -0
- package/src/ui/components/shell/index.tsx +737 -0
- package/src/ui/components/shell/panes.tsx +76 -0
- package/src/ui/components/shell/preview.ts +230 -0
- package/src/ui/components/shell/rail.tsx +163 -0
- package/src/ui/components/shell/row.ts +11 -0
- package/src/ui/components/shell/switcher.tsx +143 -0
- package/src/ui/components/shell/tree.tsx +252 -0
- package/src/ui/components/slider/base.tsx +139 -0
- package/src/ui/components/slider/index.tsx +57 -0
- package/src/ui/components/stages/index.tsx +198 -0
- package/src/ui/components/stats/count-links.tsx +47 -0
- package/src/ui/components/stats/index.tsx +203 -0
- package/src/ui/components/stats/meter.tsx +213 -0
- package/src/ui/components/stats/parts.ts +10 -0
- package/src/ui/components/step-count/index.tsx +45 -0
- package/src/ui/components/switch/base.tsx +86 -0
- package/src/ui/components/switch/index.tsx +38 -0
- package/src/ui/components/table/columns.tsx +131 -0
- package/src/ui/components/table/index.tsx +2215 -0
- package/src/ui/components/text/index.tsx +37 -0
- package/src/ui/components/thread/index.tsx +503 -0
- package/src/ui/components/thread/latest.tsx +59 -0
- package/src/ui/components/toast/index.tsx +113 -0
- package/src/ui/components/toast/layer.tsx +26 -0
- package/src/ui/components/toolbar/filters.tsx +161 -0
- package/src/ui/components/toolbar/index.tsx +125 -0
- package/src/ui/components/waveform/index.tsx +205 -0
- package/src/ui/globals.css +427 -0
- package/src/ui/lib/act.ts +60 -0
- package/src/ui/lib/age.ts +49 -0
- package/src/ui/lib/bound.ts +16 -0
- package/src/ui/lib/canvas-layout.ts +11 -0
- package/src/ui/lib/caret.ts +9 -0
- package/src/ui/lib/chip-lines.ts +3 -0
- package/src/ui/lib/closed.ts +8 -0
- package/src/ui/lib/code.tsx +184 -0
- package/src/ui/lib/columns.ts +39 -0
- package/src/ui/lib/commit.ts +24 -0
- package/src/ui/lib/container.ts +112 -0
- package/src/ui/lib/copy.ts +29 -0
- package/src/ui/lib/drag.ts +575 -0
- package/src/ui/lib/empty.tsx +85 -0
- package/src/ui/lib/field.ts +39 -0
- package/src/ui/lib/focus.ts +175 -0
- package/src/ui/lib/folds.ts +67 -0
- package/src/ui/lib/follow.ts +220 -0
- package/src/ui/lib/form.ts +19 -0
- package/src/ui/lib/guards.ts +38 -0
- package/src/ui/lib/heading.ts +14 -0
- package/src/ui/lib/ink.ts +26 -0
- package/src/ui/lib/lang.ts +7 -0
- package/src/ui/lib/leave.ts +14 -0
- package/src/ui/lib/lockup.tsx +145 -0
- package/src/ui/lib/measure.ts +22 -0
- package/src/ui/lib/media.ts +63 -0
- package/src/ui/lib/modality.ts +69 -0
- package/src/ui/lib/moment.ts +13 -0
- package/src/ui/lib/more.tsx +76 -0
- package/src/ui/lib/navigate.ts +210 -0
- package/src/ui/lib/noop.ts +3 -0
- package/src/ui/lib/not-found.tsx +40 -0
- package/src/ui/lib/paint.tsx +55 -0
- package/src/ui/lib/parts-line.tsx +54 -0
- package/src/ui/lib/picked.ts +18 -0
- package/src/ui/lib/player-store.ts +38 -0
- package/src/ui/lib/player.ts +139 -0
- package/src/ui/lib/portal.ts +12 -0
- package/src/ui/lib/read.tsx +269 -0
- package/src/ui/lib/region.tsx +49 -0
- package/src/ui/lib/reorder.ts +154 -0
- package/src/ui/lib/rest.ts +16 -0
- package/src/ui/lib/saved.ts +29 -0
- package/src/ui/lib/scramble.tsx +147 -0
- package/src/ui/lib/scrolls.ts +70 -0
- package/src/ui/lib/style.ts +6 -0
- package/src/ui/lib/swap.tsx +107 -0
- package/src/ui/lib/toast.ts +39 -0
- package/src/ui/lib/walk-classes.ts +16 -0
- package/src/ui/lib/window.tsx +376 -0
- package/src/ui/worker.d.ts +4 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { Datum } from "@slotform/ui-core/read";
|
|
3
|
+
import {
|
|
4
|
+
GALLERY,
|
|
5
|
+
GALLERY_TILE,
|
|
6
|
+
imageAspect,
|
|
7
|
+
text,
|
|
8
|
+
} from "@slotform/ui-core/variants";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import type { Closed } from "../../lib/closed.ts";
|
|
11
|
+
import { PictureTile, PictureView } from "../image/base.tsx";
|
|
12
|
+
|
|
13
|
+
// A caption is cut to its tile's width with an ellipsis and names itself
|
|
14
|
+
// through the frame's cut tooltip. Its own width is none, so the picture alone
|
|
15
|
+
// sizes the tile and the caption takes the tile's width.
|
|
16
|
+
const CAPTION = "w-0 min-w-full truncate";
|
|
17
|
+
|
|
18
|
+
/** One picture of a gallery. */
|
|
19
|
+
export interface GalleryItem {
|
|
20
|
+
/** What tells the picture apart from the others, kept while the list changes. */
|
|
21
|
+
key: string;
|
|
22
|
+
/** The picture's address. A selection paints the tile, inert, until its read lands. */
|
|
23
|
+
src: Datum<string>;
|
|
24
|
+
/** What the picture shows: the tile's accessible name and the full view's name (a sentence). */
|
|
25
|
+
alt: string;
|
|
26
|
+
/** The picture's width over its height (`16 / 10`): the tile stands at it, held no narrower than three to four. */
|
|
27
|
+
aspect: number;
|
|
28
|
+
/** A line under the tile, cut to its width (a file's name, a page's address). */
|
|
29
|
+
caption?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface GalleryProps extends Closed {
|
|
33
|
+
/** The pictures, in the order the full view steps through them. */
|
|
34
|
+
items: readonly GalleryItem[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Pictures side by side: each a tile a fixed height at its aspect (no narrower than three to four, cropped from its top; no wider than the container), its caption cut under it, the tiles wrapping a gap apart. A tile paints, waits and fails as an Image does. Pressed, the full view opens on that picture over the scrim, contain-fit inside the page inset, with Previous and Next beside it (and the arrow keys) stepping through the others, a lifted Close act, Escape and a press outside. */
|
|
38
|
+
export function Gallery({ items }: GalleryProps) {
|
|
39
|
+
// The picture open, by its key: a list that changes under the view keeps it
|
|
40
|
+
// on its picture, and a picture that leaves the list closes it.
|
|
41
|
+
const [open, setOpen] = useState<string>();
|
|
42
|
+
const at = items.findIndex((item) => item.key === open);
|
|
43
|
+
const shown = items[at];
|
|
44
|
+
const previous = items[at - 1];
|
|
45
|
+
const next = items[at + 1];
|
|
46
|
+
return (
|
|
47
|
+
<div data-wide="" className={GALLERY}>
|
|
48
|
+
{items.map((item) => {
|
|
49
|
+
const ratio = imageAspect("tile", item.aspect);
|
|
50
|
+
return (
|
|
51
|
+
<div key={item.key} className={GALLERY_TILE}>
|
|
52
|
+
<PictureTile
|
|
53
|
+
src={item.src}
|
|
54
|
+
alt={item.alt}
|
|
55
|
+
fit="tile"
|
|
56
|
+
box={{ aspectRatio: ratio }}
|
|
57
|
+
onOpen={() => setOpen(item.key)}
|
|
58
|
+
/>
|
|
59
|
+
{item.caption ? (
|
|
60
|
+
<span className={cn(text({ role: "meta" }), CAPTION)}>
|
|
61
|
+
{item.caption}
|
|
62
|
+
</span>
|
|
63
|
+
) : null}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
})}
|
|
67
|
+
<PictureView
|
|
68
|
+
open={shown !== undefined}
|
|
69
|
+
onClose={() => setOpen(undefined)}
|
|
70
|
+
src={shown?.src ?? ""}
|
|
71
|
+
alt={shown?.alt ?? ""}
|
|
72
|
+
steps={
|
|
73
|
+
shown === undefined
|
|
74
|
+
? undefined
|
|
75
|
+
: {
|
|
76
|
+
onPrevious: previous && (() => setOpen(previous.key)),
|
|
77
|
+
onNext: next && (() => setOpen(next.key)),
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { LinkAct, Run, Runs } from "@slotform/ui-core/descriptors";
|
|
3
|
+
import type { ProcedureCall } from "@slotform/ui-core/form";
|
|
4
|
+
import { runsOf } from "@slotform/ui-core/runs";
|
|
5
|
+
import {
|
|
6
|
+
BLOCK_IN,
|
|
7
|
+
CARD,
|
|
8
|
+
GATE,
|
|
9
|
+
GATE_COLUMN,
|
|
10
|
+
GATE_LOCKUP_ROW,
|
|
11
|
+
GATE_STEP,
|
|
12
|
+
ROWS,
|
|
13
|
+
text,
|
|
14
|
+
} from "@slotform/ui-core/variants";
|
|
15
|
+
import { Children, type ReactNode, use, useId, useState } from "react";
|
|
16
|
+
import type { Act } from "../../lib/act.ts";
|
|
17
|
+
import type { Closed } from "../../lib/closed.ts";
|
|
18
|
+
import { RunText } from "../../lib/code.tsx";
|
|
19
|
+
import { PageTitle } from "../../lib/container.ts";
|
|
20
|
+
import { focusFirst } from "../../lib/focus.ts";
|
|
21
|
+
import { HeadingContext } from "../../lib/heading.ts";
|
|
22
|
+
import { Lockup, useLockup } from "../../lib/lockup.tsx";
|
|
23
|
+
import { DistanceContext } from "../../lib/media.ts";
|
|
24
|
+
import { useScrolls } from "../../lib/scrolls.ts";
|
|
25
|
+
import { GATE_CENTRED } from "../../lib/walk-classes.ts";
|
|
26
|
+
import { Scroller, useScroller } from "../../lib/window.tsx";
|
|
27
|
+
import { ActionBarBase } from "../action-bar/base.tsx";
|
|
28
|
+
import { FormRows, FormShell } from "../form/base.tsx";
|
|
29
|
+
import { useStandingForm } from "../form/derive.tsx";
|
|
30
|
+
import type { FormProps } from "../form/index.tsx";
|
|
31
|
+
import { ContainerHost, ContainerMain } from "../shell/host.tsx";
|
|
32
|
+
import { StepCount } from "../step-count/index.tsx";
|
|
33
|
+
|
|
34
|
+
// The frame fills the viewport and the page inside scrolls itself, as the
|
|
35
|
+
// Shell's does, so the toasts stand at the viewport's foot. Inside a `Panes`
|
|
36
|
+
// (a room's, whose set it then draws at) it grows across the place's row,
|
|
37
|
+
// which would otherwise hold it at its content's width.
|
|
38
|
+
const BOX = "flex flex-col grow min-w-0 h-dvh overflow-hidden";
|
|
39
|
+
// The column stands in the page's middle while it fits: an auto margin, never
|
|
40
|
+
// `justify-center`, which clips the top of a column taller than the page, so
|
|
41
|
+
// it scrolls from its top instead, with a tab stop of its own while it scrolls
|
|
42
|
+
// and holds nothing a keyboard reaches (`useScrolls`). On touch the step
|
|
43
|
+
// stands at the top, for the keyboard; in a room Panes there is no keyboard,
|
|
44
|
+
// and the step stands in the middle of the screen, as a lock screen's does.
|
|
45
|
+
const PAGE =
|
|
46
|
+
"flex flex-col items-center grow min-h-0 overflow-y-auto focus-visible:-outline-offset-2";
|
|
47
|
+
const COLUMN = GATE_CENTRED;
|
|
48
|
+
const COLUMN_TOUCH = "touch:my-0";
|
|
49
|
+
const STEP = "flex flex-col";
|
|
50
|
+
// A Gate's form stands its card and its bar in the step's column, a step's
|
|
51
|
+
// gap apart, as the step's parts stand.
|
|
52
|
+
const FORM = "flex flex-col";
|
|
53
|
+
|
|
54
|
+
// biome-ignore lint/suspicious/noExplicitAny: any procedure
|
|
55
|
+
type AnyCall = any;
|
|
56
|
+
|
|
57
|
+
/** A page outside the shell: what the product is, where the flow stands, what this step is. */
|
|
58
|
+
export interface GateProps<P extends ProcedureCall = AnyCall> extends Closed {
|
|
59
|
+
/** A `Banner` standing in the step under the title and description, before the body, at the column's width: a verdict stands with the content it is about. */
|
|
60
|
+
banner?: ReactNode;
|
|
61
|
+
/** The page's one `h1` (a short phrase; wraps). */
|
|
62
|
+
title: string;
|
|
63
|
+
/** A meta line under the title, a sentence or runs: `{ strong }` runs draw at weight 500 (the address the step names) (a sentence; wraps). */
|
|
64
|
+
description?: Run | Runs;
|
|
65
|
+
/** Where an onboarding flow stands, a `StepCount` between the mark and the title. */
|
|
66
|
+
step?: { at: number; of: number };
|
|
67
|
+
/** The step's body, ahead of the `form`: a `Picker` in `fit: list`, `Section`s of rows, a first run's `Button`s, or the step's controls drawn directly when it holds only local state. */
|
|
68
|
+
children?: ReactNode;
|
|
69
|
+
/** The step's acts in reading order, the filled act last (a first run's "Connect", a consent's Decline then Allow, a Back then a Continue, a way home as a `LinkAct`), drawn as an `ActionBar` under the body, as a form's bar stands: across the column, the filled act on top, a blocked act's reason under them. A step with a `form` gives its alternatives (a Back, a passkey) as the form's `acts`, so the step holds one bar. The body stays for prose and controls. */
|
|
70
|
+
acts?: (Act | LinkAct)[];
|
|
71
|
+
/** The step's form, a `Form`'s props (its procedure, its fields), drawn after the body in the column: its fields a card, its bar after the card. */
|
|
72
|
+
form?: FormProps<P>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// A step that opens hands focus to its first field; a step with none leaves
|
|
76
|
+
// focus where it is.
|
|
77
|
+
const opens = (step: HTMLDivElement | null) => {
|
|
78
|
+
if (step) focusFirst(step, "input, textarea");
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// One step of the flow: a block of its own per `title`, so a step the viewer's
|
|
82
|
+
// act replaces fades in on `base` and takes focus as it mounts; a step the
|
|
83
|
+
// page opens with does not fade.
|
|
84
|
+
function GateStep(props: { fresh: boolean; children: ReactNode }) {
|
|
85
|
+
return (
|
|
86
|
+
<div ref={opens} className={cn(GATE_STEP, STEP, props.fresh && BLOCK_IN)}>
|
|
87
|
+
{props.children}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// The step's form over its procedure, its bar after its card. It stands in
|
|
93
|
+
// the step, so a new step starts it afresh.
|
|
94
|
+
function GateForm<P extends ProcedureCall>(props: { form: FormProps<P> }) {
|
|
95
|
+
const { form, frame, touch, bar } = useStandingForm(props.form);
|
|
96
|
+
// A Gate's form over a procedure that asks nothing (an invitation's Accept)
|
|
97
|
+
// is its bar alone: it holds no field, read or part to draw a card around.
|
|
98
|
+
const fieldless =
|
|
99
|
+
form.groups === undefined &&
|
|
100
|
+
Children.count(form.children) === 0 &&
|
|
101
|
+
form.after === undefined &&
|
|
102
|
+
form.read === undefined;
|
|
103
|
+
return (
|
|
104
|
+
<FormShell
|
|
105
|
+
frame={frame}
|
|
106
|
+
touch={touch}
|
|
107
|
+
guards={form.commit !== "field"}
|
|
108
|
+
edited={form.edited}
|
|
109
|
+
className={cn(GATE_STEP, FORM)}
|
|
110
|
+
>
|
|
111
|
+
{fieldless ? null : (
|
|
112
|
+
<div className={cn(CARD, ROWS)}>
|
|
113
|
+
<FormRows
|
|
114
|
+
frame={frame}
|
|
115
|
+
groups={form.groups}
|
|
116
|
+
empty={form.empty}
|
|
117
|
+
after={form.after}
|
|
118
|
+
>
|
|
119
|
+
{form.children}
|
|
120
|
+
</FormRows>
|
|
121
|
+
</div>
|
|
122
|
+
)}
|
|
123
|
+
{bar}
|
|
124
|
+
</FormShell>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** A root container for a page outside the shell (sign-in, a consent step): one centred column at the `auth` width on the surface. The step is one stack, one fields gap between each part: the app's lockup when the app has an icon (its icon at the avatar's size beside its name; a drawn `react({ logo })` lockup stands 40 px tall at every density), the `StepCount`, the title, the description, the `banner` (a verdict stands with the content it is about, so an act's result lands beside the act, not above the page), the body, the `form` (its fields a card, its bar after it) and the `acts`, each bar laid out by the column's width as every `ActionBar` is, so at the auth width its acts stand across the column, the filled act on top. On touch it spans the viewport inside the page inset and the step stands at the top. The first field of a step takes focus as the page opens and as `title` changes. A step that submits something is a derived `form` over the step's procedure; a step with local state only draws its controls in its body. It hosts `toast()` and `confirm()` as the `Shell` does, and its body's `Section`s title a level under the `h1`. Inside a room `Panes` (`<Panes distance="room"><Gate … /></Panes>`, a TV's signed-out or failed page) it fills the place and draws at the room set. A first run is a titled Gate whose `acts` are its acts. It draws no word of its own. */
|
|
129
|
+
export function Gate<P extends ProcedureCall = AnyCall>({
|
|
130
|
+
title,
|
|
131
|
+
description,
|
|
132
|
+
step,
|
|
133
|
+
banner,
|
|
134
|
+
acts,
|
|
135
|
+
form,
|
|
136
|
+
children,
|
|
137
|
+
}: GateProps<P>) {
|
|
138
|
+
const lockup = useLockup();
|
|
139
|
+
const far = use(DistanceContext);
|
|
140
|
+
const titleId = useId();
|
|
141
|
+
// The step the page opened with arrives with the page.
|
|
142
|
+
const [opened] = useState(title);
|
|
143
|
+
const scroll = useScroller();
|
|
144
|
+
useScrolls(scroll.node);
|
|
145
|
+
return (
|
|
146
|
+
<ContainerHost>
|
|
147
|
+
<PageTitle value={titleId}>
|
|
148
|
+
<HeadingContext value={2}>
|
|
149
|
+
<div className={BOX}>
|
|
150
|
+
<ContainerMain>
|
|
151
|
+
<div ref={scroll.ref} className={cn(GATE, PAGE)}>
|
|
152
|
+
<Scroller value={scroll}>
|
|
153
|
+
<div
|
|
154
|
+
className={cn(GATE_COLUMN, COLUMN, !far && COLUMN_TOUCH)}
|
|
155
|
+
>
|
|
156
|
+
<GateStep key={title} fresh={title !== opened}>
|
|
157
|
+
{lockup ? (
|
|
158
|
+
<Lockup lockup={lockup} className={GATE_LOCKUP_ROW} />
|
|
159
|
+
) : null}
|
|
160
|
+
{step ? <StepCount at={step.at} of={step.of} /> : null}
|
|
161
|
+
<h1 id={titleId} className={text({ role: "title" })}>
|
|
162
|
+
{title}
|
|
163
|
+
</h1>
|
|
164
|
+
{description ? (
|
|
165
|
+
<p className={text({ role: "meta" })}>
|
|
166
|
+
<RunText runs={runsOf(description)} />
|
|
167
|
+
</p>
|
|
168
|
+
) : null}
|
|
169
|
+
{banner}
|
|
170
|
+
{children}
|
|
171
|
+
{form ? <GateForm form={form} /> : null}
|
|
172
|
+
{acts ? <ActionBarBase acts={acts} /> : null}
|
|
173
|
+
</GateStep>
|
|
174
|
+
</div>
|
|
175
|
+
</Scroller>
|
|
176
|
+
</div>
|
|
177
|
+
</ContainerMain>
|
|
178
|
+
</div>
|
|
179
|
+
</HeadingContext>
|
|
180
|
+
</PageTitle>
|
|
181
|
+
</ContainerHost>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
2
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
3
|
+
import { useSelections } from "@slotform/ui-core/react/read";
|
|
4
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
5
|
+
import { type Datum, paints } from "@slotform/ui-core/read";
|
|
6
|
+
import {
|
|
7
|
+
IMAGE_CLOSE,
|
|
8
|
+
IMAGE_FAILED_INK,
|
|
9
|
+
IMAGE_FULL,
|
|
10
|
+
type ImageFit,
|
|
11
|
+
image,
|
|
12
|
+
imagePicture,
|
|
13
|
+
text,
|
|
14
|
+
} from "@slotform/ui-core/variants";
|
|
15
|
+
import { type CSSProperties, useState } from "react";
|
|
16
|
+
import { IconButtonBase } from "../../atoms/button/glyph.tsx";
|
|
17
|
+
import { Icon } from "../../atoms/icon/index.tsx";
|
|
18
|
+
import { PAINT_BOX } from "../../lib/paint.tsx";
|
|
19
|
+
import { IMAGE_BOX } from "../../lib/walk-classes.ts";
|
|
20
|
+
import { SheetLayer } from "../sheet/layer.tsx";
|
|
21
|
+
|
|
22
|
+
// The picture and its full view, which an Image draws once and a Gallery once
|
|
23
|
+
// per tile, with one full view that steps through its pictures.
|
|
24
|
+
|
|
25
|
+
// A press moves the frame's hairline, the pointer's step lighter than the
|
|
26
|
+
// press's; the ring is the base layer's.
|
|
27
|
+
const PRESS = "hover:border-edge-hover active:border-ink-body";
|
|
28
|
+
const PICTURE = "block object-cover";
|
|
29
|
+
// A waiting picture is mounted to fetch, and drawn when its bytes are here.
|
|
30
|
+
const FETCHING = "absolute inset-0 opacity-0";
|
|
31
|
+
// A picture in a box of its aspect fills the box, cover-cropped.
|
|
32
|
+
const BOXED = "absolute inset-0 h-full";
|
|
33
|
+
// A tile crops a picture taller than it from the top, where a page's head is.
|
|
34
|
+
const TOP = "object-top";
|
|
35
|
+
const FAILED = "flex flex-col items-center justify-center";
|
|
36
|
+
// The words of a failed tile: a thumbnail or a gallery's tile has no room for
|
|
37
|
+
// a sentence, so its alt shows in a tooltip, the glyph alone drawn; a content
|
|
38
|
+
// tile wraps its alt whole inside its box, centred under the glyph.
|
|
39
|
+
const ALT = "min-w-0 max-w-full text-center";
|
|
40
|
+
// The full view fills the sheet's layer, which takes no press: the picture
|
|
41
|
+
// and the acts take theirs, and a press anywhere else is on the scrim. The
|
|
42
|
+
// picture is contained inside the page inset.
|
|
43
|
+
const VIEW = "relative flex size-full items-center justify-center";
|
|
44
|
+
const FULL_PICTURE =
|
|
45
|
+
"block max-h-full max-w-full object-contain pointer-events-auto";
|
|
46
|
+
// The acts' layers cover the picture, so Close stands at its corner and
|
|
47
|
+
// Previous and Next at its sides, each centred on its height.
|
|
48
|
+
const CLOSE_LAYER =
|
|
49
|
+
"absolute inset-0 flex items-start justify-end pointer-events-none";
|
|
50
|
+
const STEP_LAYER =
|
|
51
|
+
"absolute inset-0 flex items-center justify-between pointer-events-none";
|
|
52
|
+
const HIT = "flex pointer-events-auto";
|
|
53
|
+
const KEYS = "contents";
|
|
54
|
+
|
|
55
|
+
type Status = "pending" | "loaded" | "failed";
|
|
56
|
+
|
|
57
|
+
/** The picture's address and its box: the frame paints, waits, fails and opens as an Image's does. */
|
|
58
|
+
interface PictureTileProps {
|
|
59
|
+
src: Datum<string>;
|
|
60
|
+
alt: string;
|
|
61
|
+
fit: ImageFit;
|
|
62
|
+
/** The box's aspect, or none for a thumbnail's square. */
|
|
63
|
+
box: CSSProperties | undefined;
|
|
64
|
+
/** A press on the loaded or waiting picture, with its address; absent, the tile is a picture to look at, with nothing to press. */
|
|
65
|
+
onOpen?: (src: string) => void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The picture in a hairline frame at its fit: painted while its address is a selection still to land, a skeleton while the bytes come, failed an `ImageOff` glyph in the meta ink (over the alt on the content fit, the alt its tooltip otherwise; an empty address is a failed one), and a button that opens it once its address is here, given `onOpen`. */
|
|
69
|
+
export function PictureTile({
|
|
70
|
+
src: given,
|
|
71
|
+
alt,
|
|
72
|
+
fit,
|
|
73
|
+
box,
|
|
74
|
+
onOpen,
|
|
75
|
+
}: PictureTileProps) {
|
|
76
|
+
const [named] = useSelections([given]);
|
|
77
|
+
const src = named.painted ? "" : named.value;
|
|
78
|
+
const [seen, setSeen] = useState<{ src: string; status: Status }>();
|
|
79
|
+
// Keyed by the address, so a new `src` is fetched again.
|
|
80
|
+
const status =
|
|
81
|
+
src === "" ? "failed" : seen?.src === src ? seen.status : "pending";
|
|
82
|
+
const settle = (settled: Status) => setSeen({ src, status: settled });
|
|
83
|
+
// A picture the browser already holds is complete before its handlers
|
|
84
|
+
// attach.
|
|
85
|
+
const fetched = (node: HTMLImageElement | null) => {
|
|
86
|
+
if (node?.complete && status === "pending")
|
|
87
|
+
settle(node.naturalWidth > 0 ? "loaded" : "failed");
|
|
88
|
+
};
|
|
89
|
+
if (named.painted && !paints(named)) return null;
|
|
90
|
+
if (named.painted)
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
aria-hidden
|
|
94
|
+
inert
|
|
95
|
+
style={box}
|
|
96
|
+
className={cn(image({ fit }), IMAGE_BOX, PAINT_BOX)}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
if (status === "failed")
|
|
100
|
+
return (
|
|
101
|
+
<div
|
|
102
|
+
style={box}
|
|
103
|
+
title={fit === "content" ? undefined : alt}
|
|
104
|
+
className={cn(image({ fit, state: "error" }), FAILED, IMAGE_FAILED_INK)}
|
|
105
|
+
>
|
|
106
|
+
{/* A mini tile (a dock's cover) holds the glyph at the meta size. */}
|
|
107
|
+
<Icon name="ImageOff" fit={fit === "mini" ? "meta" : undefined} />
|
|
108
|
+
{fit === "content" ? (
|
|
109
|
+
<span className={cn(text({ role: "meta" }), ALT)}>{alt}</span>
|
|
110
|
+
) : null}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
const framed = cn(
|
|
114
|
+
image({ fit, state: status === "pending" ? "loading" : "rest" }),
|
|
115
|
+
IMAGE_BOX,
|
|
116
|
+
);
|
|
117
|
+
const picture = (
|
|
118
|
+
<img
|
|
119
|
+
ref={fetched}
|
|
120
|
+
src={src}
|
|
121
|
+
alt={alt}
|
|
122
|
+
onLoad={() => settle("loaded")}
|
|
123
|
+
onError={() => settle("failed")}
|
|
124
|
+
className={cn(
|
|
125
|
+
imagePicture({ fit }),
|
|
126
|
+
status === "pending" ? FETCHING : PICTURE,
|
|
127
|
+
status === "loaded" && box && BOXED,
|
|
128
|
+
fit === "tile" && TOP,
|
|
129
|
+
)}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
if (!onOpen)
|
|
133
|
+
return (
|
|
134
|
+
<div
|
|
135
|
+
aria-busy={status === "pending" || undefined}
|
|
136
|
+
style={box}
|
|
137
|
+
className={framed}
|
|
138
|
+
>
|
|
139
|
+
{picture}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
return (
|
|
143
|
+
<button
|
|
144
|
+
type="button"
|
|
145
|
+
aria-busy={status === "pending" || undefined}
|
|
146
|
+
onClick={() => onOpen(src)}
|
|
147
|
+
style={box}
|
|
148
|
+
className={cn(framed, PRESS)}
|
|
149
|
+
>
|
|
150
|
+
{picture}
|
|
151
|
+
</button>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Previous and Next in a full view: each moves to the neighbouring picture, none past the ends. */
|
|
156
|
+
interface PictureSteps {
|
|
157
|
+
onPrevious: (() => void) | undefined;
|
|
158
|
+
onNext: (() => void) | undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The full picture over the scrim, contain-fit inside the page inset, with a lifted Close act, Escape and a press outside; given steps, a lifted Previous and Next beside it and the arrow keys. */
|
|
162
|
+
export function PictureView(props: {
|
|
163
|
+
open: boolean;
|
|
164
|
+
onClose: () => void;
|
|
165
|
+
/** The picture's address; a selection still to land draws no picture yet. */
|
|
166
|
+
src: Datum<string>;
|
|
167
|
+
alt: string;
|
|
168
|
+
steps?: PictureSteps;
|
|
169
|
+
}) {
|
|
170
|
+
const words = useWords();
|
|
171
|
+
const { steps } = props;
|
|
172
|
+
const [named] = useSelections([props.src]);
|
|
173
|
+
const src = named.painted ? undefined : named.value;
|
|
174
|
+
const step = (event: React.KeyboardEvent) => {
|
|
175
|
+
if (!steps) return;
|
|
176
|
+
const to =
|
|
177
|
+
event.key === "ArrowLeft"
|
|
178
|
+
? steps.onPrevious
|
|
179
|
+
: event.key === "ArrowRight"
|
|
180
|
+
? steps.onNext
|
|
181
|
+
: undefined;
|
|
182
|
+
if (!to) return;
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
to();
|
|
185
|
+
};
|
|
186
|
+
return (
|
|
187
|
+
<SheetLayer
|
|
188
|
+
open={props.open}
|
|
189
|
+
onClose={props.onClose}
|
|
190
|
+
label={props.alt}
|
|
191
|
+
place="view"
|
|
192
|
+
>
|
|
193
|
+
{/* The keys the view takes reach it from whichever act holds focus; the
|
|
194
|
+
wrapper draws no box, so each layer stands over the sheet's layer. */}
|
|
195
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: the arrow keys step the view; Previous and Next are its buttons. */}
|
|
196
|
+
<div className={KEYS} onKeyDown={step}>
|
|
197
|
+
<div className={cn(IMAGE_FULL, VIEW)}>
|
|
198
|
+
{src ? (
|
|
199
|
+
<img src={src} alt={props.alt} className={FULL_PICTURE} />
|
|
200
|
+
) : null}
|
|
201
|
+
</div>
|
|
202
|
+
{steps ? (
|
|
203
|
+
<div className={cn(IMAGE_FULL, STEP_LAYER)}>
|
|
204
|
+
<StepAct
|
|
205
|
+
icon="ChevronLeft"
|
|
206
|
+
label={words.previous}
|
|
207
|
+
onAct={steps.onPrevious}
|
|
208
|
+
/>
|
|
209
|
+
<StepAct
|
|
210
|
+
icon="ChevronRight"
|
|
211
|
+
label={words.next}
|
|
212
|
+
onAct={steps.onNext}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
) : null}
|
|
216
|
+
<div className={cn(IMAGE_FULL, CLOSE_LAYER)}>
|
|
217
|
+
<span className={cn(IMAGE_CLOSE, HIT)}>
|
|
218
|
+
<Dialog.Close
|
|
219
|
+
render={<IconButtonBase icon="X" label={words.close} />}
|
|
220
|
+
/>
|
|
221
|
+
</span>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</SheetLayer>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// A step's act, lifted like Close; at an end the place holds nothing, so the
|
|
229
|
+
// other stays at its side.
|
|
230
|
+
function StepAct(props: {
|
|
231
|
+
icon: "ChevronLeft" | "ChevronRight";
|
|
232
|
+
label: string;
|
|
233
|
+
onAct: (() => void) | undefined;
|
|
234
|
+
}) {
|
|
235
|
+
if (!props.onAct) return <span />;
|
|
236
|
+
return (
|
|
237
|
+
<span className={cn(IMAGE_CLOSE, HIT)}>
|
|
238
|
+
<IconButtonBase
|
|
239
|
+
icon={props.icon}
|
|
240
|
+
label={props.label}
|
|
241
|
+
onClick={props.onAct}
|
|
242
|
+
/>
|
|
243
|
+
</span>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Datum } from "@slotform/ui-core/read";
|
|
2
|
+
import { IMAGE_CAP_LINES, imageAspect } from "@slotform/ui-core/variants";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import type { Closed } from "../../lib/closed.ts";
|
|
5
|
+
import { PictureTile, PictureView } from "./base.tsx";
|
|
6
|
+
|
|
7
|
+
interface ImageBase extends Closed {
|
|
8
|
+
/** The picture's address. A selection paints the tile, inert, until its read lands. */
|
|
9
|
+
src: Datum<string>;
|
|
10
|
+
/** What the picture shows: the button's accessible name, the failed shape's words and the full view's name (a sentence; wraps in the failed shape). */
|
|
11
|
+
alt: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** A thumbnail is a square and takes no aspect; a content picture's box is its width over its height, which only its consumer knows before the bytes are here. */
|
|
15
|
+
type ImageSize =
|
|
16
|
+
| {
|
|
17
|
+
/** A square tile at the thumbnail size, cover-cropped; it fills the tile whatever the picture's shape, so it takes no `aspect`. */
|
|
18
|
+
fit: "thumb";
|
|
19
|
+
/** A thumbnail is a square: it takes no aspect. */
|
|
20
|
+
aspect?: never;
|
|
21
|
+
}
|
|
22
|
+
| {
|
|
23
|
+
/** The container's width at the picture's `aspect`, capped in height (the default); a content picture, not a tile: a box the cap holds narrows to its aspect and stands centred. */
|
|
24
|
+
fit?: "content";
|
|
25
|
+
/** The picture's width over its height (`16 / 9`), which the screen gives as it knows it before the bytes land: its box stands at it in every state (painted, loading, failed, loaded), the picture cover-cropped to it. */
|
|
26
|
+
aspect: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** A picture that opens full size. */
|
|
30
|
+
export type ImageProps = ImageBase & ImageSize;
|
|
31
|
+
|
|
32
|
+
/** The picture in a hairline frame, cover-cropped to its tile or its cap. While its address is a selection still to land the frame is painted at the loaded height (a thumbnail's square, a content picture's `aspect`), and while the bytes are on their way it is a skeleton there; failed, an `ImageOff` glyph in the meta ink over the alt text (a thumbnail draws the glyph alone, the alt its name) and nothing to open. Pressed, the full picture opens over the scrim, contain-fit inside the page inset, with a Close act, Escape and a press outside. */
|
|
33
|
+
export function Image({ src, alt, fit, aspect }: ImageProps) {
|
|
34
|
+
const place = fit ?? "content";
|
|
35
|
+
const [open, setOpen] = useState<string>();
|
|
36
|
+
// The box's aspect is the consumer's data, the same in every state. A box
|
|
37
|
+
// the height cap holds narrows to its aspect, so a tall or square picture
|
|
38
|
+
// stands smaller rather than cropped, centred in its container.
|
|
39
|
+
const ratio = imageAspect(place, aspect);
|
|
40
|
+
const box =
|
|
41
|
+
ratio === undefined
|
|
42
|
+
? undefined
|
|
43
|
+
: {
|
|
44
|
+
aspectRatio: ratio,
|
|
45
|
+
maxWidth: `calc(${IMAGE_CAP_LINES} * var(--spacing-line-body) * ${ratio})`,
|
|
46
|
+
};
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<PictureTile src={src} alt={alt} fit={place} box={box} onOpen={setOpen} />
|
|
50
|
+
<PictureView
|
|
51
|
+
open={open !== undefined}
|
|
52
|
+
onClose={() => setOpen(undefined)}
|
|
53
|
+
src={open ?? ""}
|
|
54
|
+
alt={alt}
|
|
55
|
+
/>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
}
|