@sdxc/ui 2026.11.14 → 2026.11.17

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.
@@ -0,0 +1,155 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { ChevronLeftIcon, ChevronRightIcon } from "@sdxc/icons";
3
+ import { mergeMix, raw } from "@sdxc/u/general";
4
+ import { hidden } from "@sdxc/u/layout";
5
+ import { motionReduce } from "@sdxc/u/responsive";
6
+ import { when } from "@sdxc/u/state";
7
+ import { clientEntry } from "remix/component";
8
+ import { READY_ATTRIBUTE, STEP_ATTRIBUTE, videoShelfSteps } from "./mixins/video-shelf-steps.js";
9
+ /** Each item's inline size per shape, wider on wider screens and never a sliver on a phone. */
10
+ const ITEM_SIZES = {
11
+ landscape: "clamp(13.5rem, 21cqi, 19rem)",
12
+ poster: "clamp(8.25rem, 13cqi, 11.5rem)",
13
+ };
14
+ /** Container the shelf declares, which its item sizes read their width from. */
15
+ const CONTAINER = "ui-video-shelf";
16
+ /**
17
+ * Space before the first card and after the last, so the shelf runs edge to edge while its
18
+ * cards line up with the page's own gutter; a page sets it to that gutter.
19
+ */
20
+ const INSET = "var(--ui-video-shelf-inset, 1rem)";
21
+ /** Gap between two cards. */
22
+ const GAP = "var(--ui-video-shelf-gap, 0.75rem)";
23
+ /**
24
+ * Renders the shelf: the heading row, then the scroller holding a list of items, between two
25
+ * paging buttons kept hidden until the shelf's island reveals them. The scroller is a labelled
26
+ * region, so a keyboard reaches it and scrolls it with the arrow keys.
27
+ *
28
+ * @example
29
+ * <VideoShelf id="trending" title="Trending now" labels={{ previous: "Previous", next: "Next" }}>
30
+ * {titles.map((title) => <VideoShelf.Item><VideoCard {...title} /></VideoShelf.Item>)}
31
+ * </VideoShelf>
32
+ */
33
+ export function VideoShelf(handle) {
34
+ return () => {
35
+ let { action, children, id, labels, level = 2, mix, size = "landscape", title, ...rest } = handle.props;
36
+ let headingId = `${id}-title`;
37
+ return (_jsxs("section", { ...rest, id: id, "aria-labelledby": headingId, "data-slot": "video-shelf", "data-size": size, mix: mergeMix([
38
+ raw({
39
+ "--ui-video-shelf-item-size": ITEM_SIZES[size],
40
+ containerName: CONTAINER,
41
+ containerType: "inline-size",
42
+ position: "relative",
43
+ display: "grid",
44
+ gap: "0.625rem",
45
+ minInlineSize: "0",
46
+ }),
47
+ when("&:hover [data-video-shelf-step]:not([disabled])", raw({ opacity: "1" })),
48
+ when("&:focus-within [data-video-shelf-step]:not([disabled])", raw({ opacity: "1" })),
49
+ ], mix), children: [_jsxs("div", { mix: [
50
+ raw({
51
+ display: "flex",
52
+ alignItems: "baseline",
53
+ justifyContent: "space-between",
54
+ gap: "1rem",
55
+ paddingInline: INSET,
56
+ }),
57
+ ], children: [_jsx(ShelfHeading, { id: headingId, level: level, children: title }), action === undefined ? null : (_jsx("div", { mix: [raw({ fontSize: "0.875rem", flexShrink: "0" })], children: action }))] }), _jsxs("div", { mix: [raw({ position: "relative", minInlineSize: "0" })], children: [_jsx(ShelfStep, { direction: -1, label: labels.previous }), _jsx("div", { id: `${id}-scroller`, role: "region", "aria-labelledby": headingId, "data-slot": "video-shelf-scroller", mix: [
58
+ raw({
59
+ overflowX: "auto",
60
+ overflowY: "hidden",
61
+ overscrollBehaviorX: "contain",
62
+ scrollSnapType: "x mandatory",
63
+ scrollPaddingInline: INSET,
64
+ scrollBehavior: "smooth",
65
+ scrollbarWidth: "thin",
66
+ outline: "none",
67
+ }),
68
+ when(`&[${READY_ATTRIBUTE}]`, raw({ scrollbarWidth: "none" })),
69
+ when("&:focus-visible", raw({ boxShadow: "inset 0 0 0 2px var(--ui-brand-ring)" })),
70
+ motionReduce(raw({ scrollBehavior: "auto" })),
71
+ ], children: _jsx("ul", { mix: [
72
+ raw({
73
+ display: "grid",
74
+ gridAutoFlow: "column",
75
+ gridAutoColumns: "var(--ui-video-shelf-item-size)",
76
+ gap: GAP,
77
+ margin: "0",
78
+ paddingBlock: "0.25rem 0.5rem",
79
+ paddingInline: INSET,
80
+ listStyle: "none",
81
+ inlineSize: "max-content",
82
+ }),
83
+ ], children: children }) }), _jsx(ShelfStep, { direction: 1, label: labels.next })] }), _jsx(VideoShelfSync, {})] }));
84
+ };
85
+ }
86
+ /** The shelf's heading at the level its page outline needs. */
87
+ function ShelfHeading(handle) {
88
+ return () => {
89
+ let { children, id, level } = handle.props;
90
+ let mix = [
91
+ raw({
92
+ margin: "0",
93
+ fontSize: "var(--ui-video-shelf-title-size, 1.125rem)",
94
+ lineHeight: "1.5rem",
95
+ fontWeight: "700",
96
+ letterSpacing: "-0.01em",
97
+ color: "var(--ui-neutral-fg-emphasis)",
98
+ }),
99
+ ];
100
+ return level === 3 ? (_jsx("h3", { id: id, mix: mix, children: children })) : (_jsx("h2", { id: id, mix: mix, children: children }));
101
+ };
102
+ }
103
+ /**
104
+ * One card's place in the shelf, snapping to the scroller's start so a step lands on a card's
105
+ * edge rather than through one.
106
+ */
107
+ VideoShelf.Item = function VideoShelfItem(handle) {
108
+ return () => {
109
+ let { mix, ...rest } = handle.props;
110
+ return (_jsx("li", { ...rest, "data-slot": "video-shelf-item", mix: mergeMix([raw({ scrollSnapAlign: "start", minInlineSize: "0" })], mix) }));
111
+ };
112
+ };
113
+ /**
114
+ * A paging button over one edge of the shelf, tall enough to cover the art and shaded toward
115
+ * the edge. It renders hidden: the island reveals it where a pointer can hover, and keeps it
116
+ * disabled at the end it points to.
117
+ */
118
+ function ShelfStep(handle) {
119
+ return () => {
120
+ let { direction, label } = handle.props;
121
+ let start = direction === -1;
122
+ return (_jsx("button", { type: "button", hidden: true, "aria-label": label, [STEP_ATTRIBUTE]: String(direction), mix: [
123
+ raw({
124
+ position: "absolute",
125
+ zIndex: "1",
126
+ insetBlock: "0.25rem 0.5rem",
127
+ insetInlineStart: start ? "0" : "auto",
128
+ insetInlineEnd: start ? "auto" : "0",
129
+ inlineSize: `max(2.75rem, calc(${INSET} + 0.25rem))`,
130
+ display: "grid",
131
+ placeItems: "center",
132
+ padding: "0",
133
+ border: "0",
134
+ cursor: "pointer",
135
+ color: "oklch(0.98 0 0)",
136
+ background: `linear-gradient(${start ? "to right" : "to left"}, rgb(0 0 0 / 0.7), rgb(0 0 0 / 0))`,
137
+ opacity: "0",
138
+ transition: "opacity 160ms ease",
139
+ "& > svg": { inlineSize: "1.75rem", blockSize: "1.75rem" },
140
+ "@media (hover: none)": { display: "none" },
141
+ }),
142
+ when("&[hidden]", hidden()),
143
+ when("&[disabled]", raw({ opacity: "0", pointerEvents: "none" })),
144
+ when("&:focus-visible", raw({ opacity: "1", outline: "2px solid var(--ui-brand-ring)", outlineOffset: "-2px" })),
145
+ motionReduce(raw({ transition: "none" })),
146
+ ], children: start ? _jsx(ChevronLeftIcon, { "aria-hidden": "true" }) : _jsx(ChevronRightIcon, { "aria-hidden": "true" }) }));
147
+ };
148
+ }
149
+ /**
150
+ * The island inside every {@link VideoShelf}: a hidden marker that reveals and runs the paging
151
+ * buttons. It loads from `@sdxc/ui/video/video-shelf`, which the browser entry maps to an import.
152
+ */
153
+ export const VideoShelfSync = clientEntry("@sdxc/ui/video/video-shelf#VideoShelfSync", function VideoShelfSync() {
154
+ return () => _jsx("span", { hidden: true, mix: [videoShelfSteps()] });
155
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/ui",
3
- "version": "2026.11.14",
3
+ "version": "2026.11.17",
4
4
  "description": "Styled, accessible remix/component components rendered as server HTML",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "peerDependencies": {
41
41
  "remix": "3.2.0"
42
42
  },
43
- "gitHead": "5d069a9e855202a3a5e79141319e4e2d2ce7c084",
43
+ "gitHead": "d0a98d9f22d429ae5da7d5e75b4c0f55d311e758",
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },