@sdxc/ui 2026.11.18 → 2026.11.22
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/README.md +133 -1
- package/dist/app/index.d.ts +1 -0
- package/dist/app/index.js +1 -0
- package/dist/app/mixins/command-palette.js +10 -2
- package/dist/app/mixins/log-viewer.js +17 -14
- package/dist/app/mixins/route-dialog.d.ts +17 -0
- package/dist/app/mixins/route-dialog.js +53 -0
- package/dist/app/optimistic-toggle.js +6 -0
- package/dist/app/route-dialog.d.ts +38 -0
- package/dist/app/route-dialog.js +49 -0
- package/dist/audio/equalizer.d.ts +24 -0
- package/dist/audio/equalizer.js +57 -0
- package/dist/audio/index.d.ts +16 -0
- package/dist/audio/index.js +16 -0
- package/dist/audio/media-tile.d.ts +38 -0
- package/dist/audio/media-tile.js +98 -0
- package/dist/audio/player-bar.d.ts +108 -0
- package/dist/audio/player-bar.js +338 -0
- package/dist/audio/queue-list.d.ts +56 -0
- package/dist/audio/queue-list.js +102 -0
- package/dist/audio/track-list.d.ts +91 -0
- package/dist/audio/track-list.js +226 -0
- package/dist/audio/utils/media-session.d.ts +44 -0
- package/dist/audio/utils/media-session.js +87 -0
- package/dist/audio/utils/play-queue.d.ts +98 -0
- package/dist/audio/utils/play-queue.js +149 -0
- package/dist/audio/utils/track-time.d.ts +28 -0
- package/dist/audio/utils/track-time.js +36 -0
- package/dist/chat/composer-format.d.ts +35 -0
- package/dist/chat/composer-format.js +84 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mention-menu.d.ts +43 -0
- package/dist/chat/mention-menu.js +70 -0
- package/dist/chat/message-group.d.ts +92 -0
- package/dist/chat/message-group.js +222 -0
- package/dist/chat/mixins/composer-format.d.ts +28 -0
- package/dist/chat/mixins/composer-format.js +80 -0
- package/dist/chat/mixins/composer-send.d.ts +2 -2
- package/dist/chat/mixins/composer-send.js +4 -2
- package/dist/chat/mixins/mention-menu.d.ts +41 -0
- package/dist/chat/mixins/mention-menu.js +213 -0
- package/dist/chat/mixins/reaction-sync.d.ts +47 -0
- package/dist/chat/mixins/reaction-sync.js +172 -0
- package/dist/chat/reaction-bar.d.ts +70 -0
- package/dist/chat/reaction-bar.js +108 -0
- package/dist/chat/typing-indicator.d.ts +42 -0
- package/dist/chat/typing-indicator.js +68 -0
- package/dist/chat/utils/composer-text.d.ts +38 -0
- package/dist/chat/utils/composer-text.js +86 -0
- package/dist/chat/utils/markdown-format.d.ts +30 -0
- package/dist/chat/utils/markdown-format.js +158 -0
- package/dist/chat/utils/mention-query.d.ts +55 -0
- package/dist/chat/utils/mention-query.js +60 -0
- package/dist/commerce/cart-drawer.d.ts +69 -0
- package/dist/commerce/cart-drawer.js +163 -0
- package/dist/commerce/cart-line.d.ts +32 -0
- package/dist/commerce/cart-line.js +43 -0
- package/dist/commerce/checkout-layout.d.ts +32 -0
- package/dist/commerce/checkout-layout.js +51 -0
- package/dist/commerce/facet-filters.d.ts +121 -0
- package/dist/commerce/facet-filters.js +318 -0
- package/dist/commerce/fulfilment-note.d.ts +28 -0
- package/dist/commerce/fulfilment-note.js +26 -0
- package/dist/commerce/index.d.ts +27 -0
- package/dist/commerce/index.js +27 -0
- package/dist/commerce/item-options-dialog.d.ts +67 -0
- package/dist/commerce/item-options-dialog.js +150 -0
- package/dist/commerce/menu-item-card.d.ts +37 -0
- package/dist/commerce/menu-item-card.js +96 -0
- package/dist/commerce/option-group.d.ts +62 -0
- package/dist/commerce/option-group.js +121 -0
- package/dist/commerce/order-summary.d.ts +42 -0
- package/dist/commerce/order-summary.js +76 -0
- package/dist/commerce/order-tracker.d.ts +80 -0
- package/dist/commerce/order-tracker.js +178 -0
- package/dist/commerce/price.d.ts +52 -0
- package/dist/commerce/price.js +108 -0
- package/dist/commerce/product-card.d.ts +53 -0
- package/dist/commerce/product-card.js +127 -0
- package/dist/commerce/product-gallery.d.ts +70 -0
- package/dist/commerce/product-gallery.js +186 -0
- package/dist/commerce/promo-code.d.ts +56 -0
- package/dist/commerce/promo-code.js +101 -0
- package/dist/commerce/quantity-stepper.d.ts +42 -0
- package/dist/commerce/quantity-stepper.js +53 -0
- package/dist/commerce/question-list.d.ts +53 -0
- package/dist/commerce/question-list.js +92 -0
- package/dist/commerce/shipping-estimate.d.ts +53 -0
- package/dist/commerce/shipping-estimate.js +39 -0
- package/dist/commerce/sort-select.d.ts +38 -0
- package/dist/commerce/sort-select.js +38 -0
- package/dist/commerce/variant-picker.d.ts +75 -0
- package/dist/commerce/variant-picker.js +135 -0
- package/dist/components/amount.d.ts +46 -0
- package/dist/components/amount.js +34 -0
- package/dist/components/autocomplete.d.ts +82 -0
- package/dist/components/autocomplete.js +114 -0
- package/dist/components/carousel.d.ts +31 -1
- package/dist/components/carousel.js +66 -3
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +11 -0
- package/dist/components/letterbox.d.ts +47 -0
- package/dist/components/letterbox.js +56 -0
- package/dist/components/lightbox.d.ts +88 -0
- package/dist/components/lightbox.js +224 -0
- package/dist/components/media-grid.d.ts +53 -0
- package/dist/components/media-grid.js +89 -0
- package/dist/components/range-months.d.ts +100 -0
- package/dist/components/range-months.js +274 -0
- package/dist/components/rating-input.d.ts +33 -0
- package/dist/components/rating-input.js +63 -0
- package/dist/components/rating.d.ts +38 -0
- package/dist/components/rating.js +66 -0
- package/dist/components/review-card.d.ts +39 -0
- package/dist/components/review-card.js +59 -0
- package/dist/components/section-bar.d.ts +57 -0
- package/dist/components/section-bar.js +140 -0
- package/dist/components/step-indicator.d.ts +46 -0
- package/dist/components/step-indicator.js +96 -0
- package/dist/finance/index.d.ts +10 -0
- package/dist/finance/index.js +10 -0
- package/dist/finance/ledger.d.ts +60 -0
- package/dist/finance/ledger.js +93 -0
- package/dist/finance/payment-card.d.ts +49 -0
- package/dist/finance/payment-card.js +115 -0
- package/dist/map/engine.d.ts +49 -0
- package/dist/map/engine.js +591 -0
- package/dist/map/index.d.ts +12 -0
- package/dist/map/index.js +12 -0
- package/dist/map/map-canvas.d.ts +101 -0
- package/dist/map/map-canvas.js +275 -0
- package/dist/map/map.d.ts +217 -0
- package/dist/map/map.js +598 -0
- package/dist/map/mixins/map-link.d.ts +30 -0
- package/dist/map/mixins/map-link.js +116 -0
- package/dist/map/utils/basemap.d.ts +88 -0
- package/dist/map/utils/basemap.js +84 -0
- package/dist/map/utils/cluster.d.ts +43 -0
- package/dist/map/utils/cluster.js +80 -0
- package/dist/map/utils/mercator.d.ts +66 -0
- package/dist/map/utils/mercator.js +92 -0
- package/dist/map/utils/stage.d.ts +24 -0
- package/dist/map/utils/stage.js +49 -0
- package/dist/mixins/autocomplete.d.ts +28 -0
- package/dist/mixins/autocomplete.js +283 -0
- package/dist/mixins/carousel-controls.d.ts +14 -3
- package/dist/mixins/carousel-controls.js +89 -30
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/lightbox-controls.d.ts +34 -0
- package/dist/mixins/lightbox-controls.js +176 -0
- package/dist/schedule/agenda.d.ts +63 -0
- package/dist/schedule/agenda.js +221 -0
- package/dist/schedule/day-strip.d.ts +50 -0
- package/dist/schedule/day-strip.js +136 -0
- package/dist/schedule/free-busy.d.ts +96 -0
- package/dist/schedule/free-busy.js +285 -0
- package/dist/schedule/index.d.ts +15 -0
- package/dist/schedule/index.js +15 -0
- package/dist/schedule/mixins/day-strip-scroll.d.ts +16 -0
- package/dist/schedule/mixins/day-strip-scroll.js +40 -0
- package/dist/schedule/mixins/time-grid-drag.d.ts +24 -0
- package/dist/schedule/mixins/time-grid-drag.js +532 -0
- package/dist/schedule/month-view.d.ts +68 -0
- package/dist/schedule/month-view.js +301 -0
- package/dist/schedule/time-grid.d.ts +168 -0
- package/dist/schedule/time-grid.js +417 -0
- package/dist/schedule/utils/time-grid-layout.d.ts +50 -0
- package/dist/schedule/utils/time-grid-layout.js +93 -0
- package/dist/schedule/year-view.d.ts +46 -0
- package/dist/schedule/year-view.js +142 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/typewriter-text.d.ts +20 -0
- package/dist/styles/typewriter-text.js +23 -0
- package/dist/test/map.d.ts +18 -0
- package/dist/test/map.js +96 -0
- package/dist/test/reels.d.ts +30 -0
- package/dist/test/reels.js +41 -0
- package/dist/test/stories.d.ts +31 -0
- package/dist/test/stories.js +66 -0
- package/dist/travel/boarding-pass.d.ts +107 -0
- package/dist/travel/boarding-pass.js +293 -0
- package/dist/travel/car-offer.d.ts +70 -0
- package/dist/travel/car-offer.js +127 -0
- package/dist/travel/fare-calendar.d.ts +85 -0
- package/dist/travel/fare-calendar.js +233 -0
- package/dist/travel/fare-options.d.ts +84 -0
- package/dist/travel/fare-options.js +142 -0
- package/dist/travel/flight-itinerary.d.ts +84 -0
- package/dist/travel/flight-itinerary.js +112 -0
- package/dist/travel/flight-option.d.ts +58 -0
- package/dist/travel/flight-option.js +111 -0
- package/dist/travel/flight-segment.d.ts +105 -0
- package/dist/travel/flight-segment.js +174 -0
- package/dist/travel/index.d.ts +20 -0
- package/dist/travel/index.js +20 -0
- package/dist/travel/package-savings.d.ts +74 -0
- package/dist/travel/package-savings.js +128 -0
- package/dist/travel/price-breakdown.d.ts +66 -0
- package/dist/travel/price-breakdown.js +102 -0
- package/dist/travel/rating-breakdown.d.ts +81 -0
- package/dist/travel/rating-breakdown.js +132 -0
- package/dist/travel/seat-map.d.ts +108 -0
- package/dist/travel/seat-map.js +371 -0
- package/dist/travel/trip-timeline.d.ts +84 -0
- package/dist/travel/trip-timeline.js +212 -0
- package/dist/utils/gamepad-presses.d.ts +21 -0
- package/dist/utils/gamepad-presses.js +28 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/move-focus.d.ts +20 -0
- package/dist/utils/move-focus.js +28 -0
- package/dist/utils/range-months.d.ts +54 -0
- package/dist/utils/range-months.js +98 -0
- package/dist/utils/swipe-direction.d.ts +23 -0
- package/dist/utils/swipe-direction.js +27 -0
- package/dist/utils/typewriter.d.ts +49 -0
- package/dist/utils/typewriter.js +171 -0
- package/dist/video/index.d.ts +6 -2
- package/dist/video/index.js +6 -2
- package/dist/video/mixins/reel-feed-sync.d.ts +41 -0
- package/dist/video/mixins/reel-feed-sync.js +430 -0
- package/dist/video/mixins/story-viewer-sync.d.ts +31 -0
- package/dist/video/mixins/story-viewer-sync.js +391 -0
- package/dist/video/reel-feed.d.ts +95 -0
- package/dist/video/reel-feed.js +124 -0
- package/dist/video/story-ring.d.ts +32 -0
- package/dist/video/story-ring.js +42 -0
- package/dist/video/story-viewer.d.ts +85 -0
- package/dist/video/story-viewer.js +250 -0
- package/package.json +21 -2
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "@sdxc/icons";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { borderSpacing } from "@sdxc/u/layout";
|
|
5
|
+
import { CALENDAR_DAY_DATE_ATTRIBUTE } from "../mixins/calendar-keys.js";
|
|
6
|
+
import { dayTime, firstUnavailableAfter, monthWeeks, nextSelection, rangePosition, shiftMonth, weekdayTime, } from "../utils/range-months.js";
|
|
7
|
+
import { Calendar } from "./calendar.js";
|
|
8
|
+
import { Heading } from "./heading.js";
|
|
9
|
+
/** How many months show when `months` is unset: a stay's two ends usually fit across two. */
|
|
10
|
+
const DEFAULT_MONTHS = 2;
|
|
11
|
+
/** The first weekday column when `weekStartsOn` is unset: Sunday. */
|
|
12
|
+
const DEFAULT_WEEK_STARTS_ON = 0;
|
|
13
|
+
/** The custom property every day cell sizes from: 40px, or the 44px touch target on a coarse pointer. */
|
|
14
|
+
const CELL = "var(--ui-range-months-cell)";
|
|
15
|
+
/** The previous and next links' size: 32px, or the touch target on a coarse pointer. */
|
|
16
|
+
const NAV = "max(2rem, var(--ui-target-size, 0px))";
|
|
17
|
+
/** The band colour for the days between the two ends of a chosen or previewed range. */
|
|
18
|
+
const BAND = "var(--ui-brand-bg-tint-hover)";
|
|
19
|
+
/** The lighter band a pending range previews toward the hovered or focused day. */
|
|
20
|
+
const PREVIEW = "var(--ui-brand-bg-tint)";
|
|
21
|
+
/** Matches a day cell the pointer or keyboard focus is on. */
|
|
22
|
+
const ACTIVE = ":is(:hover, :focus-within)";
|
|
23
|
+
/**
|
|
24
|
+
* Renders `months` month grids from `month`, each day a link to `href`'s URL for the selection
|
|
25
|
+
* a click makes: with no start, or both ends set, the day becomes a new start; with only a start,
|
|
26
|
+
* a later day becomes the end and an earlier or equal one the new start. Single mode links each day
|
|
27
|
+
* as `{ start: day }`. Unavailable days, days outside `min`–`max`, and, while a start waits for its
|
|
28
|
+
* end, days past the first unavailable day after it render as plain text.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <RangeMonths
|
|
32
|
+
* label={t("stay.dates")}
|
|
33
|
+
* labels={{ previous: t("calendar.previous"), next: t("calendar.next"), start: t("stay.checkIn"), end: t("stay.checkOut") }}
|
|
34
|
+
* locale={locale}
|
|
35
|
+
* month="2026-03"
|
|
36
|
+
* start={query.checkIn}
|
|
37
|
+
* end={query.checkOut}
|
|
38
|
+
* today="2026-03-02"
|
|
39
|
+
* min="2026-03-02"
|
|
40
|
+
* isUnavailable={(date) => booked.has(date)}
|
|
41
|
+
* dayNote={(date) => `$${prices[date]}`}
|
|
42
|
+
* href={(next) => `?${new URLSearchParams({ ...next })}`}
|
|
43
|
+
* />
|
|
44
|
+
* @example
|
|
45
|
+
* <RangeMonths single months={1} label={t("jump")} labels={labels} month="2026-03" start={day} today={today} href={({ start, month }) => `/day/${start ?? month}`} />
|
|
46
|
+
*/
|
|
47
|
+
export function RangeMonths(handle) {
|
|
48
|
+
return () => {
|
|
49
|
+
let { month, months, start, end, single = false, today, min, max, isUnavailable, nights = false, href, dayNote, weekStartsOn, locale, label, headingLevel, labels, mix, ...rest } = handle.props;
|
|
50
|
+
let firstWeekday = weekStartsOn ?? DEFAULT_WEEK_STARTS_ON;
|
|
51
|
+
let shown = Array.from({ length: Math.max(1, months ?? DEFAULT_MONTHS) }, (_, index) => shiftMonth(month, index));
|
|
52
|
+
let lastShown = shown[shown.length - 1] ?? month;
|
|
53
|
+
let selection = { start, end: single ? undefined : end, single };
|
|
54
|
+
let block = !single && start !== undefined && end === undefined
|
|
55
|
+
? firstUnavailableAfter(start, `${lastShown}-31`, isUnavailable)
|
|
56
|
+
: undefined;
|
|
57
|
+
let previousMonth = shiftMonth(month, -1);
|
|
58
|
+
let showPrevious = min === undefined || previousMonth >= min.slice(0, 7);
|
|
59
|
+
let showNext = max === undefined || lastShown < max.slice(0, 7);
|
|
60
|
+
let monthName = new Intl.DateTimeFormat(locale, {
|
|
61
|
+
month: "long",
|
|
62
|
+
year: "numeric",
|
|
63
|
+
timeZone: "UTC",
|
|
64
|
+
});
|
|
65
|
+
let dayName = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone: "UTC" });
|
|
66
|
+
let weekdayName = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" });
|
|
67
|
+
let weekdays = Array.from({ length: 7 }, (_, index) => weekdayName.format(weekdayTime(firstWeekday, index)));
|
|
68
|
+
/** The URL a day link points at, following the click rules in {@link RangeMonths}. */
|
|
69
|
+
function dayHref(date) {
|
|
70
|
+
return href(withMonth(nextSelection(date, selection), month));
|
|
71
|
+
}
|
|
72
|
+
/** Whether a click on `date` may produce a selection at all. */
|
|
73
|
+
function isSelectable(date) {
|
|
74
|
+
if (min !== undefined && date < min)
|
|
75
|
+
return false;
|
|
76
|
+
if (max !== undefined && date > max)
|
|
77
|
+
return false;
|
|
78
|
+
if (nights && date === block)
|
|
79
|
+
return true;
|
|
80
|
+
if (isUnavailable?.(date))
|
|
81
|
+
return false;
|
|
82
|
+
return block === undefined || date < block;
|
|
83
|
+
}
|
|
84
|
+
return (_jsxs("div", { role: "group", "aria-label": label, ...rest, "data-slot": "range-months", mix: mergeMix([
|
|
85
|
+
raw({
|
|
86
|
+
"--ui-range-months-cell": "max(2.5rem, var(--ui-target-size, 0px))",
|
|
87
|
+
position: "relative",
|
|
88
|
+
fontVariantNumeric: "tabular-nums",
|
|
89
|
+
[`& [data-pending]${ACTIVE}, & td[data-pending]:has(~ td[data-pending]${ACTIVE}), & tr:has(~ tr td[data-pending]${ACTIVE}) td[data-pending], & [data-slot=range-months-month]:has(~ [data-slot=range-months-month] td[data-pending]${ACTIVE}) td[data-pending]`]: { backgroundColor: PREVIEW },
|
|
90
|
+
[`&:has(td[data-pending]${ACTIVE}) td[data-range=only]:not(:last-child)`]: {
|
|
91
|
+
background: `linear-gradient(to right, transparent 50%, ${PREVIEW} 50%)`,
|
|
92
|
+
},
|
|
93
|
+
[`&:has(td[data-pending]${ACTIVE}) td[data-range=only]:not(:last-child):dir(rtl)`]: {
|
|
94
|
+
background: `linear-gradient(to left, transparent 50%, ${PREVIEW} 50%)`,
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
], mix), children: [showPrevious ? (_jsx("a", { href: href(withMonth({ start, end: selection.end }, previousMonth)), "aria-label": labels.previous, "data-slot": "range-months-previous", mix: [navLinkStyle("start")], children: _jsx(ChevronLeftIcon, { "aria-hidden": "true" }) })) : null, showNext ? (_jsx("a", { href: href(withMonth({ start, end: selection.end }, shiftMonth(month, 1))), "aria-label": labels.next, "data-slot": "range-months-next", mix: [navLinkStyle("end")], children: _jsx(ChevronRightIcon, { "aria-hidden": "true" }) })) : null, _jsx("div", { "data-slot": "range-months-months", mix: [
|
|
98
|
+
raw({
|
|
99
|
+
display: "grid",
|
|
100
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, calc(7 * ${CELL})), calc(7 * ${CELL})))`,
|
|
101
|
+
justifyContent: "start",
|
|
102
|
+
columnGap: "2rem",
|
|
103
|
+
rowGap: "1.5rem",
|
|
104
|
+
}),
|
|
105
|
+
], children: shown.map((key) => {
|
|
106
|
+
let monthLabel = monthName.format(dayTime(key));
|
|
107
|
+
return (_jsxs("section", { "data-slot": "range-months-month", "data-month": key, children: [_jsx(Calendar.Header, { mix: [raw({ minBlockSize: NAV, marginBlockEnd: "0.5rem", paddingInline: NAV })], children: _jsx(Calendar.Heading, { level: headingLevel, children: monthLabel }) }), _jsxs(Calendar.Grid, { "aria-label": monthLabel, mix: [borderSpacing("0"), raw({ inlineSize: "100%", tableLayout: "fixed" })], children: [_jsx(Calendar.GridHeader, { children: _jsx(Calendar.Row, { children: weekdays.map((weekday) => (_jsx(Calendar.HeaderCell, { children: weekday }, weekday))) }) }), _jsx(Calendar.GridBody, { children: monthWeeks(key, firstWeekday).map((week, row) => (_jsx(Calendar.Row, { children: week.map((date, column) => {
|
|
108
|
+
if (date === null) {
|
|
109
|
+
return (_jsx("td", { "data-slot": "range-months-blank" }, `${key}-${row}-${column}`));
|
|
110
|
+
}
|
|
111
|
+
let position = rangePosition(date, selection);
|
|
112
|
+
let unavailable = isUnavailable?.(date) ?? false;
|
|
113
|
+
let selectable = isSelectable(date);
|
|
114
|
+
let pending = selectable &&
|
|
115
|
+
!single &&
|
|
116
|
+
start !== undefined &&
|
|
117
|
+
end === undefined &&
|
|
118
|
+
date > start;
|
|
119
|
+
let note = dayNote === undefined ? undefined : dayNote(date);
|
|
120
|
+
let stateLabel = dayStateLabel(position, single, labels);
|
|
121
|
+
return (_jsx("td", { "data-slot": "range-months-day", "data-range": position, "data-pending": pending ? "" : undefined, "data-unavailable": unavailable ? "" : undefined, "aria-disabled": selectable ? undefined : "true", mix: [dayCellStyle()], children: _jsx(RangeMonthsDay, { date: date, href: selectable ? dayHref(date) : undefined, label: stateLabel === undefined
|
|
122
|
+
? dayName.format(dayTime(date))
|
|
123
|
+
: `${dayName.format(dayTime(date))}, ${stateLabel}`, today: date === today, note: note, hasNotes: dayNote !== undefined }) }, date));
|
|
124
|
+
}) }, `${key}-${row}`))) })] })] }, key));
|
|
125
|
+
}) })] }));
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* One day's content: a link when it can be picked, otherwise plain text, each holding the day
|
|
130
|
+
* number and, when the calendar carries notes, the note line under it.
|
|
131
|
+
*/
|
|
132
|
+
function RangeMonthsDay(handle) {
|
|
133
|
+
return () => {
|
|
134
|
+
let { date, href, label, today, note, hasNotes } = handle.props;
|
|
135
|
+
let content = (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "range-months-number", children: Number(date.slice(8, 10)) }), hasNotes ? (_jsx("span", { "data-slot": "range-months-note", mix: [
|
|
136
|
+
raw({
|
|
137
|
+
minBlockSize: "1em",
|
|
138
|
+
fontSize: "0.625rem",
|
|
139
|
+
lineHeight: "1",
|
|
140
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
141
|
+
"[data-range=start] &, [data-range=end] &, [data-range=only] &": {
|
|
142
|
+
color: "inherit",
|
|
143
|
+
opacity: "0.85",
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
], children: note })) : null] }));
|
|
147
|
+
let attributes = {
|
|
148
|
+
[CALENDAR_DAY_DATE_ATTRIBUTE]: date,
|
|
149
|
+
"aria-current": today ? "date" : undefined,
|
|
150
|
+
"data-today": today ? "" : undefined,
|
|
151
|
+
};
|
|
152
|
+
if (href === undefined) {
|
|
153
|
+
return (_jsx("span", { ...attributes, "data-slot": "range-months-day-text", mix: [dayContentStyle()], children: content }));
|
|
154
|
+
}
|
|
155
|
+
return (_jsx("a", { ...attributes, href: href, "aria-label": label, mix: [dayContentStyle()], children: content }));
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Adds the first month on view to a selection, leaving out the ends that are unset. */
|
|
159
|
+
function withMonth(selection, month) {
|
|
160
|
+
let next = { month };
|
|
161
|
+
if (selection.start !== undefined)
|
|
162
|
+
next.start = selection.start;
|
|
163
|
+
if (selection.end !== undefined)
|
|
164
|
+
next.end = selection.end;
|
|
165
|
+
return next;
|
|
166
|
+
}
|
|
167
|
+
/** The selection state appended to a day's spoken name, when the caller supplied its word. */
|
|
168
|
+
function dayStateLabel(position, single, words) {
|
|
169
|
+
if (position === "only")
|
|
170
|
+
return single ? words.selected : words.start;
|
|
171
|
+
if (position === "start")
|
|
172
|
+
return words.start;
|
|
173
|
+
if (position === "end")
|
|
174
|
+
return words.end;
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A day's `<td>`: the band behind a chosen range, squared where it runs on and rounded where it
|
|
179
|
+
* meets a week's edge, with the two ends' cells half-filled toward the days between.
|
|
180
|
+
*/
|
|
181
|
+
function dayCellStyle() {
|
|
182
|
+
return raw({
|
|
183
|
+
padding: "0",
|
|
184
|
+
textAlign: "center",
|
|
185
|
+
verticalAlign: "middle",
|
|
186
|
+
"&[data-range=middle]": { backgroundColor: BAND },
|
|
187
|
+
"&[data-range=middle]:first-child": {
|
|
188
|
+
borderStartStartRadius: "9999px",
|
|
189
|
+
borderEndStartRadius: "9999px",
|
|
190
|
+
},
|
|
191
|
+
"&[data-range=middle]:last-child": {
|
|
192
|
+
borderStartEndRadius: "9999px",
|
|
193
|
+
borderEndEndRadius: "9999px",
|
|
194
|
+
},
|
|
195
|
+
"&[data-range=start]:not(:last-child)": {
|
|
196
|
+
background: `linear-gradient(to right, transparent 50%, ${BAND} 50%)`,
|
|
197
|
+
},
|
|
198
|
+
"&[data-range=end]:not(:first-child)": {
|
|
199
|
+
background: `linear-gradient(to left, transparent 50%, ${BAND} 50%)`,
|
|
200
|
+
},
|
|
201
|
+
"&[data-range=start]:not(:last-child):dir(rtl)": {
|
|
202
|
+
background: `linear-gradient(to left, transparent 50%, ${BAND} 50%)`,
|
|
203
|
+
},
|
|
204
|
+
"&[data-range=end]:not(:first-child):dir(rtl)": {
|
|
205
|
+
background: `linear-gradient(to right, transparent 50%, ${BAND} 50%)`,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A day's link or text: a round target at least {@link CELL} tall, solid at either end of the
|
|
211
|
+
* range, muted and struck through when taken, faded when outside `min`–`max`, underlined for today.
|
|
212
|
+
*/
|
|
213
|
+
function dayContentStyle() {
|
|
214
|
+
return raw({
|
|
215
|
+
display: "grid",
|
|
216
|
+
placeContent: "center",
|
|
217
|
+
justifyItems: "center",
|
|
218
|
+
gap: "0.125rem",
|
|
219
|
+
inlineSize: "100%",
|
|
220
|
+
minBlockSize: CELL,
|
|
221
|
+
paddingBlock: "0.25rem",
|
|
222
|
+
borderRadius: "9999px",
|
|
223
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
224
|
+
fontSize: "0.875rem",
|
|
225
|
+
lineHeight: "1.1",
|
|
226
|
+
textDecoration: "none",
|
|
227
|
+
outlineOffset: "-2px",
|
|
228
|
+
"&:is(a):hover": { backgroundColor: "var(--ui-neutral-bg-tint-hover)" },
|
|
229
|
+
"&:is(a):focus-visible": { outline: "2px solid var(--ui-brand-ring)" },
|
|
230
|
+
"[data-range=middle] &": { color: "var(--ui-brand-fg-emphasis)" },
|
|
231
|
+
"[data-range=middle] &:is(a):hover, [data-pending] &:is(a):hover": {
|
|
232
|
+
backgroundColor: "var(--ui-brand-bg-tint-pressed)",
|
|
233
|
+
},
|
|
234
|
+
"[data-range=start] &:is(a), [data-range=end] &:is(a), [data-range=only] &:is(a), [data-range=only] &": {
|
|
235
|
+
backgroundColor: "var(--ui-brand-bg-solid)",
|
|
236
|
+
color: "var(--ui-brand-fg-on-solid)",
|
|
237
|
+
},
|
|
238
|
+
"[aria-disabled=true] &": { color: "var(--ui-neutral-fg-muted)", opacity: "0.45" },
|
|
239
|
+
"[data-unavailable] &": { opacity: "1" },
|
|
240
|
+
"[data-unavailable] & [data-slot=range-months-number]": { textDecoration: "line-through" },
|
|
241
|
+
"&[data-today] [data-slot=range-months-number]": {
|
|
242
|
+
fontWeight: "700",
|
|
243
|
+
textDecorationLine: "underline",
|
|
244
|
+
textDecorationThickness: "2px",
|
|
245
|
+
textUnderlineOffset: "3px",
|
|
246
|
+
},
|
|
247
|
+
"[data-unavailable] &[data-today] [data-slot=range-months-number]": {
|
|
248
|
+
textDecorationLine: "underline line-through",
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* A previous or next link: a round chevron button pinned to the heading row's `side`, so the
|
|
254
|
+
* pair flanks the first month's heading however the months wrap.
|
|
255
|
+
*/
|
|
256
|
+
function navLinkStyle(side) {
|
|
257
|
+
return raw({
|
|
258
|
+
position: "absolute",
|
|
259
|
+
insetBlockStart: "0",
|
|
260
|
+
insetInlineStart: side === "start" ? "0" : "auto",
|
|
261
|
+
insetInlineEnd: side === "end" ? "0" : "auto",
|
|
262
|
+
zIndex: "1",
|
|
263
|
+
display: "grid",
|
|
264
|
+
placeItems: "center",
|
|
265
|
+
inlineSize: NAV,
|
|
266
|
+
blockSize: NAV,
|
|
267
|
+
borderRadius: "9999px",
|
|
268
|
+
color: "var(--ui-neutral-fg)",
|
|
269
|
+
"&:hover": { backgroundColor: "var(--ui-neutral-bg-tint-hover)" },
|
|
270
|
+
"&:focus-visible": { outline: "2px solid var(--ui-brand-ring)", outlineOffset: "2px" },
|
|
271
|
+
"& svg": { inlineSize: "1rem", blockSize: "1rem" },
|
|
272
|
+
"&:dir(rtl) svg": { scale: "-1 1" },
|
|
273
|
+
});
|
|
274
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A star picker for a review form: a fieldset of native radios drawn as stars, where the
|
|
3
|
+
* picked star and every one before it fill, and hovering previews a score. It posts a plain
|
|
4
|
+
* number, the arrow keys move between stars, and it works with no script at all.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link RatingInput}. */
|
|
11
|
+
export declare namespace RatingInput {
|
|
12
|
+
/** Props accepted by {@link RatingInput}; the host is a `<fieldset>`. */
|
|
13
|
+
interface Props extends Omit<TagProps<"fieldset">, "children" | "name"> {
|
|
14
|
+
/** The field the score posts as. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** The score picked now, from 1 to the number of labels. */
|
|
17
|
+
value?: number;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
/** The question the stars answer, such as "Your rating". */
|
|
20
|
+
legend: RemixNode;
|
|
21
|
+
/** One name per star, lowest first, such as "1 star — Poor"; their count sets the scale. */
|
|
22
|
+
labels: string[];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Renders one radio and its star label per entry of `labels`, in score order so the native
|
|
27
|
+
* arrow keys step up and down the scale. A star fills when its own radio or any later one is
|
|
28
|
+
* checked, and hovering a star fills it and every earlier one in place of the checked score.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <RatingInput name="rating" legend="Your rating" required labels={["1 star — Poor", "2 stars — Fair", "3 stars — Good", "4 stars — Great", "5 stars — Excellent"]} />
|
|
32
|
+
*/
|
|
33
|
+
export declare function RatingInput(handle: Handle<RatingInput.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { STAR_PATH } from "./rating.js";
|
|
5
|
+
/** Painted on a filled star. */
|
|
6
|
+
const FILLED = "var(--ui-rating-color, var(--ui-warning-bg-solid))";
|
|
7
|
+
/** Painted on a star past the score. */
|
|
8
|
+
const EMPTY = "var(--ui-neutral-border-strong, var(--ui-neutral-border))";
|
|
9
|
+
/**
|
|
10
|
+
* Renders one radio and its star label per entry of `labels`, in score order so the native
|
|
11
|
+
* arrow keys step up and down the scale. A star fills when its own radio or any later one is
|
|
12
|
+
* checked, and hovering a star fills it and every earlier one in place of the checked score.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <RatingInput name="rating" legend="Your rating" required labels={["1 star — Poor", "2 stars — Fair", "3 stars — Good", "4 stars — Great", "5 stars — Excellent"]} />
|
|
16
|
+
*/
|
|
17
|
+
export function RatingInput(handle) {
|
|
18
|
+
return () => {
|
|
19
|
+
let { id, labels, legend, mix, name, required, value, ...rest } = handle.props;
|
|
20
|
+
let base = id ?? handle.id;
|
|
21
|
+
return (_jsxs("fieldset", { ...rest, id: id, "data-slot": "rating-input", mix: mergeMix([raw({ margin: "0", padding: "0", border: "0", minInlineSize: "0" })], mix), children: [_jsx("legend", { mix: [
|
|
22
|
+
raw({
|
|
23
|
+
padding: "0",
|
|
24
|
+
marginBlockEnd: "0.5rem",
|
|
25
|
+
fontSize: "0.875rem",
|
|
26
|
+
fontWeight: "600",
|
|
27
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
28
|
+
}),
|
|
29
|
+
], children: legend }), _jsx("div", { "data-slot": "rating-input-stars", mix: [
|
|
30
|
+
raw({
|
|
31
|
+
position: "relative",
|
|
32
|
+
display: "inline-flex",
|
|
33
|
+
gap: "0.125rem",
|
|
34
|
+
"& label": {
|
|
35
|
+
display: "grid",
|
|
36
|
+
placeItems: "center",
|
|
37
|
+
inlineSize: "2.75rem",
|
|
38
|
+
blockSize: "2.75rem",
|
|
39
|
+
borderRadius: "0.5rem",
|
|
40
|
+
color: EMPTY,
|
|
41
|
+
cursor: "pointer",
|
|
42
|
+
transition: "color 120ms ease, transform 120ms ease",
|
|
43
|
+
},
|
|
44
|
+
"& svg": { inlineSize: "1.75rem", blockSize: "1.75rem" },
|
|
45
|
+
"& input:checked + label, & label:has(~ input:checked)": { color: FILLED },
|
|
46
|
+
"&:has(label:hover) label": { color: EMPTY },
|
|
47
|
+
"&:has(label:hover) label:hover, &:has(label:hover) label:has(~ label:hover)": {
|
|
48
|
+
color: FILLED,
|
|
49
|
+
},
|
|
50
|
+
"& input:focus-visible + label": {
|
|
51
|
+
outline: "2px solid var(--ui-brand-ring)",
|
|
52
|
+
outlineOffset: "-2px",
|
|
53
|
+
},
|
|
54
|
+
"& input:disabled + label": { cursor: "not-allowed", opacity: "0.5" },
|
|
55
|
+
"@media (prefers-reduced-motion: reduce)": { "& label": { transition: "none" } },
|
|
56
|
+
}),
|
|
57
|
+
], children: labels.map((label, index) => {
|
|
58
|
+
let score = index + 1;
|
|
59
|
+
let inputId = `${base}-${score}`;
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { type: "radio", id: inputId, name: name, value: String(score), defaultChecked: value === score, required: required, mix: [visuallyHidden()] }), _jsxs("label", { htmlFor: inputId, title: label, "data-score": String(score), children: [_jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: STAR_PATH, fill: "currentColor" }) }), _jsx("span", { mix: [visuallyHidden()], children: label })] })] }));
|
|
61
|
+
}) })] }));
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A score out of a few stars, read at a glance: a muted row of stars with a filled row laid
|
|
3
|
+
* over it and clipped to the score's share, so 4.3 shows the fourth star whole and a third of
|
|
4
|
+
* the fifth. Assistive tech reads one sentence instead of five pictures.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** The outline of a five-pointed star in a 24 × 24 box. */
|
|
11
|
+
export declare const STAR_PATH = "M12 2.5l2.94 5.96 6.56.95-4.75 4.63 1.12 6.54L12 17.5l-5.87 3.08 1.12-6.54L2.5 9.41l6.56-.95L12 2.5z";
|
|
12
|
+
/** Prop types for {@link Rating}. */
|
|
13
|
+
export declare namespace Rating {
|
|
14
|
+
/** Props accepted by {@link Rating}; the host is a `<span>`. */
|
|
15
|
+
interface Props extends Omit<TagProps<"span">, "children"> {
|
|
16
|
+
/** The score, fractional, between 0 and `max`; a value outside is held to the scale. */
|
|
17
|
+
value: number;
|
|
18
|
+
/** How many ratings the score averages, shown after the stars as "(128)". */
|
|
19
|
+
count?: number;
|
|
20
|
+
/** @default 5 */
|
|
21
|
+
max?: number;
|
|
22
|
+
/** @default "md" */
|
|
23
|
+
size?: "sm" | "md";
|
|
24
|
+
/** What assistive tech reads; `{value}` and `{max}` fill in. @default "{value} out of {max} stars" */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** Replaces the "(128)" text, such as "128 reviews" or a link to them. */
|
|
27
|
+
countLabel?: RemixNode;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Renders the stars as one `role="img"` whose name states the score, followed by the count.
|
|
32
|
+
* Stars take `--ui-rating-color` (the warning tone by default) and empty ones the border tone,
|
|
33
|
+
* so a theme recolours every rating at once.
|
|
34
|
+
*
|
|
35
|
+
* @example <Rating value={4.3} count={128} />
|
|
36
|
+
* @example <Rating value={5} size="sm" label="Rated {value} of {max}" />
|
|
37
|
+
*/
|
|
38
|
+
export declare function Rating(handle: Handle<Rating.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
3
|
+
/** The outline of a five-pointed star in a 24 × 24 box. */
|
|
4
|
+
export const STAR_PATH = "M12 2.5l2.94 5.96 6.56.95-4.75 4.63 1.12 6.54L12 17.5l-5.87 3.08 1.12-6.54L2.5 9.41l6.56-.95L12 2.5z";
|
|
5
|
+
/** Top of the scale when `max` is left out. */
|
|
6
|
+
const DEFAULT_MAX = 5;
|
|
7
|
+
/** Edge of one star, by size. */
|
|
8
|
+
const STAR_SIZE = { sm: "0.875rem", md: "1.125rem" };
|
|
9
|
+
/** A row of `count` stars painted in the current colour. */
|
|
10
|
+
function Stars(handle) {
|
|
11
|
+
return () => (_jsx(_Fragment, { children: Array.from({ length: handle.props.count }, () => (_jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: STAR_PATH, fill: "currentColor" }) }))) }));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Renders the stars as one `role="img"` whose name states the score, followed by the count.
|
|
15
|
+
* Stars take `--ui-rating-color` (the warning tone by default) and empty ones the border tone,
|
|
16
|
+
* so a theme recolours every rating at once.
|
|
17
|
+
*
|
|
18
|
+
* @example <Rating value={4.3} count={128} />
|
|
19
|
+
* @example <Rating value={5} size="sm" label="Rated {value} of {max}" />
|
|
20
|
+
*/
|
|
21
|
+
export function Rating(handle) {
|
|
22
|
+
return () => {
|
|
23
|
+
let { count, countLabel, label = "{value} out of {max} stars", max = DEFAULT_MAX, mix, size = "md", value, ...rest } = handle.props;
|
|
24
|
+
let score = Math.min(Math.max(value, 0), max);
|
|
25
|
+
let share = max > 0 ? (score / max) * 100 : 0;
|
|
26
|
+
let spoken = label
|
|
27
|
+
.replace("{value}", String(Math.round(score * 10) / 10))
|
|
28
|
+
.replace("{max}", String(max));
|
|
29
|
+
let star = STAR_SIZE[size];
|
|
30
|
+
let tail = countLabel ?? (count === undefined ? undefined : `(${count})`);
|
|
31
|
+
return (_jsxs("span", { ...rest, "data-slot": "rating", "data-size": size, mix: mergeMix([
|
|
32
|
+
raw({
|
|
33
|
+
display: "inline-flex",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
gap: "0.375rem",
|
|
36
|
+
fontSize: size === "sm" ? "0.8125rem" : "0.875rem",
|
|
37
|
+
lineHeight: "1",
|
|
38
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
39
|
+
verticalAlign: "middle",
|
|
40
|
+
}),
|
|
41
|
+
], mix), children: [_jsxs("span", { role: "img", "aria-label": spoken, "data-slot": "rating-stars", mix: [
|
|
42
|
+
raw({
|
|
43
|
+
position: "relative",
|
|
44
|
+
display: "inline-flex",
|
|
45
|
+
flex: "none",
|
|
46
|
+
color: "var(--ui-neutral-border-strong, var(--ui-neutral-border))",
|
|
47
|
+
"& svg": {
|
|
48
|
+
display: "block",
|
|
49
|
+
flex: "none",
|
|
50
|
+
inlineSize: star,
|
|
51
|
+
blockSize: star,
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
], children: [_jsx(Stars, { count: max }), _jsx("span", { "data-slot": "rating-fill", style: { inlineSize: `${Math.round(share * 100) / 100}%` }, mix: [
|
|
55
|
+
raw({
|
|
56
|
+
position: "absolute",
|
|
57
|
+
insetBlock: "0",
|
|
58
|
+
insetInlineStart: "0",
|
|
59
|
+
display: "flex",
|
|
60
|
+
overflow: "clip",
|
|
61
|
+
whiteSpace: "nowrap",
|
|
62
|
+
color: "var(--ui-rating-color, var(--ui-warning-bg-solid))",
|
|
63
|
+
}),
|
|
64
|
+
], children: _jsx(Stars, { count: max }) })] }), tail === undefined ? null : (_jsx("span", { "data-slot": "rating-count", mix: [raw({ fontVariantNumeric: "tabular-nums" })], children: tail }))] }));
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One customer review: the stars, a title and the words, then who wrote it and when, a
|
|
3
|
+
* verified mark, what they bought, any photos, and room for a "Was this helpful?" form. Reviews
|
|
4
|
+
* stack in a list separated by hairlines.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link ReviewCard}. */
|
|
11
|
+
export declare namespace ReviewCard {
|
|
12
|
+
/** Props accepted by {@link ReviewCard}; the host is an `<article>`. */
|
|
13
|
+
interface Props extends Omit<TagProps<"article">, "children" | "title"> {
|
|
14
|
+
author: RemixNode;
|
|
15
|
+
/** The stars the reviewer gave, out of five. */
|
|
16
|
+
rating: number;
|
|
17
|
+
title?: RemixNode;
|
|
18
|
+
body: RemixNode;
|
|
19
|
+
/** When it was written, such as a `<time>` or a relative date. */
|
|
20
|
+
date: RemixNode;
|
|
21
|
+
/** The mark of a confirmed purchase, such as "Verified buyer"; shown with a check. */
|
|
22
|
+
verified?: RemixNode;
|
|
23
|
+
/** What the reviewer bought, such as "Size: 50×70 · Oak frame". */
|
|
24
|
+
meta?: RemixNode;
|
|
25
|
+
/** Photos the reviewer added, laid out by the caller. */
|
|
26
|
+
media?: RemixNode;
|
|
27
|
+
/** A slot at the end of the footer, such as a POST form voting the review helpful. */
|
|
28
|
+
helpful?: RemixNode;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Renders the review as an `<article>`: small stars and the title on top, the body in reading
|
|
33
|
+
* size, photos beneath, and a wrapping footer row of author, date, verified mark and purchase
|
|
34
|
+
* with the helpful slot pushed to the end.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* <ReviewCard author="Maya R." rating={5} title="Better in person" body="The paper is heavy and the colours are rich." date="2 weeks ago" verified="Verified buyer" meta="50×70 · Oak frame" />
|
|
38
|
+
*/
|
|
39
|
+
export declare function ReviewCard(handle: Handle<ReviewCard.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { CircleCheckIcon } from "@sdxc/icons";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { Rating } from "./rating.js";
|
|
5
|
+
/**
|
|
6
|
+
* Renders the review as an `<article>`: small stars and the title on top, the body in reading
|
|
7
|
+
* size, photos beneath, and a wrapping footer row of author, date, verified mark and purchase
|
|
8
|
+
* with the helpful slot pushed to the end.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <ReviewCard author="Maya R." rating={5} title="Better in person" body="The paper is heavy and the colours are rich." date="2 weeks ago" verified="Verified buyer" meta="50×70 · Oak frame" />
|
|
12
|
+
*/
|
|
13
|
+
export function ReviewCard(handle) {
|
|
14
|
+
return () => {
|
|
15
|
+
let { author, body, date, helpful, media, meta, mix, rating, title, verified, ...rest } = handle.props;
|
|
16
|
+
return (_jsxs("article", { ...rest, "data-slot": "review-card", mix: mergeMix([
|
|
17
|
+
raw({
|
|
18
|
+
display: "grid",
|
|
19
|
+
gap: "0.625rem",
|
|
20
|
+
paddingBlock: "1.25rem",
|
|
21
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
22
|
+
color: "var(--ui-neutral-fg)",
|
|
23
|
+
}),
|
|
24
|
+
], mix), children: [_jsxs("div", { mix: [raw({ display: "grid", gap: "0.375rem" })], children: [_jsx(Rating, { value: rating, size: "sm" }), title === undefined ? null : (_jsx("p", { "data-slot": "review-card-title", mix: [
|
|
25
|
+
raw({
|
|
26
|
+
margin: "0",
|
|
27
|
+
fontSize: "1rem",
|
|
28
|
+
fontWeight: "650",
|
|
29
|
+
lineHeight: "1.35",
|
|
30
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
31
|
+
}),
|
|
32
|
+
], children: title }))] }), _jsx("div", { "data-slot": "review-card-body", mix: [
|
|
33
|
+
raw({
|
|
34
|
+
fontSize: "0.9375rem",
|
|
35
|
+
lineHeight: "1.6",
|
|
36
|
+
"& > p": { margin: "0" },
|
|
37
|
+
"& > p + p": { marginBlockStart: "0.75em" },
|
|
38
|
+
}),
|
|
39
|
+
], children: body }), media === undefined ? null : _jsx("div", { "data-slot": "review-card-media", children: media }), _jsxs("footer", { "data-slot": "review-card-footer", mix: [
|
|
40
|
+
raw({
|
|
41
|
+
display: "flex",
|
|
42
|
+
flexWrap: "wrap",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
columnGap: "0.75rem",
|
|
45
|
+
rowGap: "0.375rem",
|
|
46
|
+
fontSize: "0.8125rem",
|
|
47
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
48
|
+
}),
|
|
49
|
+
], children: [_jsx("span", { mix: [raw({ fontWeight: "600", color: "var(--ui-neutral-fg-emphasis)" })], children: author }), _jsx("span", { children: date }), verified === undefined ? null : (_jsxs("span", { "data-slot": "review-card-verified", mix: [
|
|
50
|
+
raw({
|
|
51
|
+
display: "inline-flex",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
gap: "0.25rem",
|
|
54
|
+
color: "var(--ui-success-fg)",
|
|
55
|
+
"& > svg": { inlineSize: "0.875rem", blockSize: "0.875rem" },
|
|
56
|
+
}),
|
|
57
|
+
], children: [_jsx(CircleCheckIcon, { "aria-hidden": "true" }), verified] })), meta === undefined ? null : _jsx("span", { "data-slot": "review-card-meta", children: meta }), helpful === undefined ? null : (_jsx("span", { "data-slot": "review-card-helpful", mix: [raw({ marginInlineStart: "auto" })], children: helpful }))] })] }));
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sticky row of chips linking to the sections of one long page, such as a menu's
|
|
3
|
+
* categories or a product's specs. The links work as plain anchors; once its island loads,
|
|
4
|
+
* the chip of the section being read is marked and slides into view inside the row.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/** Prop types for {@link SectionBar}. */
|
|
11
|
+
export declare namespace SectionBar {
|
|
12
|
+
/** One section the bar links to. */
|
|
13
|
+
interface Item {
|
|
14
|
+
/** The section element's `id`, which the chip links to as `#id`. */
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** A count after the label, such as how many dishes the category holds. */
|
|
18
|
+
count?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Props accepted by {@link SectionBar}; the host is a `<nav>`. */
|
|
21
|
+
interface Props extends Omit<TagProps<"nav">, "children"> {
|
|
22
|
+
/** The bar's `id`, unique on the page; its island finds the bar by it. */
|
|
23
|
+
id: string;
|
|
24
|
+
/** The landmark's name, such as "Menu categories". */
|
|
25
|
+
label: string;
|
|
26
|
+
items: Item[];
|
|
27
|
+
/**
|
|
28
|
+
* Where the bar sticks, as a CSS length from the top of the viewport, such as the
|
|
29
|
+
* height of a sticky top bar above it. Each section gives itself a `scroll-margin-top`
|
|
30
|
+
* of at least this plus the bar's own height, so a jump lands below the bar.
|
|
31
|
+
*
|
|
32
|
+
* @default "0px"
|
|
33
|
+
*/
|
|
34
|
+
top?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Props {@link SectionBarSpy} serializes for hydration. */
|
|
37
|
+
type SpyProps = {
|
|
38
|
+
/** The bar's `id`. */
|
|
39
|
+
bar: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** The bar's own height, which a section's `scroll-margin-top` adds to the sticky offset. */
|
|
43
|
+
export declare const SECTION_BAR_BLOCK_SIZE = "3.25rem";
|
|
44
|
+
/**
|
|
45
|
+
* Renders the bar: a `<nav>` holding a sideways-scrolling row of chip links, the first one
|
|
46
|
+
* marked current until the island reads the scroll.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* <SectionBar id="menu-bar" label="Menu categories" top="4rem" items={[{ id: "tacos", label: "Tacos", count: 3 }]} />
|
|
50
|
+
*/
|
|
51
|
+
export declare function SectionBar(handle: Handle<SectionBar.Props>): () => import("remix/component").RemixElement;
|
|
52
|
+
/**
|
|
53
|
+
* The island that follows the scroll: on each frame the page scrolls, the current section is
|
|
54
|
+
* the last one whose top has passed under the bar, and its chip is marked and scrolled into
|
|
55
|
+
* the row's view. A page scrolled to its end marks the last section, however short it is.
|
|
56
|
+
*/
|
|
57
|
+
export declare const SectionBarSpy: EntryComponent<SectionBar.SpyProps>;
|