@sdxc/kit 2026.11.27 → 2026.11.29
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/changelog.jsonl +189 -0
- package/dist/pkg/catalog.js +1 -0
- package/dist/scaffold/render.js +2 -2
- package/package.json +2 -2
- package/registry/ui/anchor-heading.json +19 -0
- package/registry/ui/autocomplete.json +3 -3
- package/registry/ui/banner.json +3 -3
- package/registry/ui/button.json +3 -3
- package/registry/ui/callout.json +16 -0
- package/registry/ui/checkbox.json +2 -2
- package/registry/ui/code-block.json +18 -0
- package/registry/ui/confirm.json +3 -3
- package/registry/ui/copy-button.json +14 -0
- package/registry/ui/date-field.json +4 -7
- package/registry/ui/date-picker.json +3 -5
- package/registry/ui/date-range-picker.json +2 -3
- package/registry/ui/dialog-dismiss.json +2 -2
- package/registry/ui/field-parts.json +30 -0
- package/registry/ui/filter-links.json +16 -0
- package/registry/ui/form.json +3 -3
- package/registry/ui/listbox.json +2 -2
- package/registry/ui/media-grid.json +3 -3
- package/registry/ui/pager.json +16 -0
- package/registry/ui/property-list.json +3 -3
- package/registry/ui/radio-group.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/range-months.json +3 -3
- package/registry/ui/rating-input.json +3 -3
- package/registry/ui/rating.json +3 -3
- package/registry/ui/review-card.json +3 -3
- package/registry/ui/search-field.json +6 -3
- package/registry/ui/section-bar.json +3 -3
- package/registry/ui/sidebar.json +2 -2
- package/registry/ui/table-of-contents.json +17 -0
- package/registry/ui/text-field.json +5 -9
- package/registry/ui/time-field.json +4 -7
- package/registry/ui/timeline.json +3 -3
- package/registry/ui/typeset.json +2 -2
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "time-field",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.29",
|
|
4
4
|
"dependencies": [
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"form",
|
|
8
|
-
"input",
|
|
9
|
-
"label"
|
|
5
|
+
"field-parts",
|
|
6
|
+
"input"
|
|
10
7
|
],
|
|
11
8
|
"exports": [
|
|
12
9
|
"TimeField"
|
|
13
10
|
],
|
|
14
11
|
"source": {
|
|
15
12
|
"path": "time-field.tsx",
|
|
16
|
-
"content": "/**\n * A
|
|
13
|
+
"content": "/**\n * A labeled, described and validated time field: the root renders a native\n * `<input type=\"time\">` from its native attributes, and the caller writes the caption,\n * description and error as parts. Every id and `aria-describedby` link between them\n * comes from this instance's own identifier, leaving no id bookkeeping to the caller.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { tabularNums } from \"@sdxc/u/typography\";\n\nimport {\n\tFieldDescription,\n\tFieldErrorMessage,\n\tFieldLabel,\n\tFieldScope,\n\twireField,\n} from \"@sdxc/ui/field-parts\";\nimport { Input } from \"@sdxc/ui/input\";\n\n/**\n * Prop types for {@link TimeField} and its parts.\n */\nexport namespace TimeField {\n\t/**\n\t * Semantic color role for the control's keyboard focus ring, each mapped\n\t * to its matching `--ui-*` variables.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Props accepted by {@link TimeField}. `mix` and the remaining native attributes\n\t * style the root element; the control's own native attributes are listed below,\n\t * and `children` holds the field's parts.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Semantic color role for the control's focus ring. Defaults to `\"neutral\"` when omitted. */\n\t\tcolor?: Color;\n\t\t/**\n\t\t * Native `autofocus`. Defaults to `true` for the first invalid field of an\n\t\t * enclosing {@link Form}'s `issues`, landing keyboard focus on the problem\n\t\t * after a server round-trip; pass it explicitly to override for this field.\n\t\t */\n\t\tautoFocus?: boolean;\n\t\t/** Native `name`; it also finds the enclosing {@link Form}'s issue for this field. */\n\t\tname?: string;\n\t\t/** Current value, in the platform's `\"HH:mm\"` (or `\"HH:mm:ss\"`) format, for a control a consumer tracks itself. */\n\t\tvalue?: string;\n\t\t/** Initial value, in that same format, for a control left to the platform's own uncontrolled state. */\n\t\tdefaultValue?: string;\n\t\t/** Earliest accepted time, in the same `\"HH:mm\"`/`\"HH:mm:ss\"` format. */\n\t\tmin?: string;\n\t\t/** Latest accepted time, in the same `\"HH:mm\"`/`\"HH:mm:ss\"` format. */\n\t\tmax?: string;\n\t\t/** Granularity of the accepted value, in seconds; `1` surfaces a seconds digit beside hours and minutes. */\n\t\tstep?: number;\n\t\trequired?: boolean;\n\t\tdisabled?: boolean;\n\t\treadOnly?: boolean;\n\t\t/** Native autofill hint. */\n\t\tautoComplete?: string;\n\t\t/**\n\t\t * The field's parts: `.Label`, `.Description` and `.Error`. The control follows\n\t\t * the caption, and the rest keep their order.\n\t\t */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/** Props accepted by {@link TimeField.Label}: a native `<label>` pointing at the control. */\n\texport interface LabelProps extends FieldScope.LabelProps {}\n\t/** Props accepted by {@link TimeField.Description}: a native `<p>` the control describes itself by. */\n\texport interface DescriptionProps extends FieldScope.DescriptionProps {}\n\t/** Props accepted by {@link TimeField.Error}: a native `<span>` holding the message. */\n\texport interface ErrorProps extends FieldScope.ErrorProps {}\n}\n\n/**\n * Renders a time field: the native time control, laid out with the parts the caller\n * writes. An error, from `.Error` or an enclosing {@link Form}'s issue for `name`, marks\n * the control invalid and recolors its border and ring to the danger tone.\n *\n * @param handle Runtime handle carrying the root element's props and this instance's stable identifier.\n * @returns The render function producing the field's markup.\n * @example\n * <TimeField name=\"reminderAt\">\n * \t<TimeField.Label>{t(\"form.reminder.label\")}</TimeField.Label>\n * </TimeField>\n * @example\n * <TimeField name=\"opensAt\" min=\"09:00\" max=\"17:00\">\n * \t<TimeField.Label>{t(\"form.opensAt.label\")}</TimeField.Label>\n * \t<TimeField.Description>{t(\"form.opensAt.hint\")}</TimeField.Description>\n * </TimeField>\n */\nexport function TimeField(handle: Handle<TimeField.Props>) {\n\treturn () => {\n\t\tlet {\n\t\t\tcolor,\n\t\t\tautoFocus,\n\t\t\tname,\n\t\t\tvalue,\n\t\t\tdefaultValue,\n\t\t\tmin,\n\t\t\tmax,\n\t\t\tstep,\n\t\t\trequired,\n\t\t\tdisabled,\n\t\t\treadOnly,\n\t\t\tautoComplete,\n\t\t\t\"aria-invalid\": ariaInvalid,\n\t\t\tchildren,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet field = wireField(handle, {\n\t\t\tslot: \"time-field\",\n\t\t\tchildren,\n\t\t\tname,\n\t\t\tcolor,\n\t\t\tautoFocus,\n\t\t\tariaInvalid,\n\t\t});\n\n\t\treturn (\n\t\t\t<FieldScope {...rest} context={field.context}>\n\t\t\t\t{field.arrange(\n\t\t\t\t\t<Input\n\t\t\t\t\t\t{...field.control}\n\t\t\t\t\t\ttype=\"time\"\n\t\t\t\t\t\tname={name}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\tdefaultValue={defaultValue}\n\t\t\t\t\t\tmin={min}\n\t\t\t\t\t\tmax={max}\n\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\tautoComplete={autoComplete}\n\t\t\t\t\t\tmix={tabularNums()}\n\t\t\t\t\t/>,\n\t\t\t\t)}\n\t\t\t</FieldScope>\n\t\t);\n\t};\n}\n\nTimeField.Label = FieldLabel;\nTimeField.Description = FieldDescription;\nTimeField.Error = FieldErrorMessage;\n"
|
|
17
14
|
},
|
|
18
15
|
"test": null
|
|
19
16
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timeline",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.29",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Timeline"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "timeline.tsx",
|
|
10
|
-
"content": "/**\n * A record's activity as an ordered list: a 2px rail threading 16px event icons toned by\n * what happened, one line per event, comment cards with an author header and reactions,\n * grouped commits, and a native `<details>` folding a run of quiet events into \"N more\".\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { EllipsisIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pseudoContent, raw, mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, grid, inlineFlex, items, justify, relative, vstack } from \"@sdxc/u/layout\";\nimport { bs, is, m, minIs, p, pi } from \"@sdxc/u/size\";\nimport { before, data, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { font, leading, text, truncate, weight } from \"@sdxc/u/typography\";\n\n/** The side of the square each event's icon sits centred in; the rail runs through its middle. */\nconst ICON_BOX = \"var(--ui-timeline-icon-box, 1.5rem)\";\n\n/** Tone an event's icon takes when `tone` is left unset. */\nconst DEFAULT_TONE: Timeline.Tone = \"neutral\";\n\n/**\n * Prop types for {@link Timeline} and its compound parts.\n */\nexport namespace Timeline {\n\t/** The semantic role an event's icon is drawn in. */\n\texport type Tone = \"neutral\" | \"brand\" | \"success\" | \"warning\" | \"danger\";\n\n\t/** Every native `<ol>` attribute. */\n\texport interface Props extends TagProps<\"ol\"> {}\n\n\t/** Every native `<li>` attribute, plus the event's parts. */\n\texport interface EventProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** A 16px glyph naming the kind of event, decorative beside the line's words. */\n\t\ticon: RemixNode;\n\t\t/** @default {@link DEFAULT_TONE} */\n\t\ttone?: Tone;\n\t\t/** A small avatar of the actor, shown before the name. */\n\t\tavatar?: RemixNode;\n\t\t/** Who did it, set in bold. */\n\t\tactor?: RemixNode;\n\t\t/** When it happened: a `RelativeTime` or plain text. */\n\t\ttime?: RemixNode;\n\t\t/** A comment or other body, set as a card under the line. */\n\t\tbody?: RemixNode;\n\t\t/** What happened, in muted text after the actor: \"resolved the incident\". */\n\t\tchildren?: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the comment's parts. */\n\texport interface CommentProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The author's avatar, set on the rail in place of an icon. */\n\t\tavatar: RemixNode;\n\t\t/** The author's name, set in bold at the start of the card's header. */\n\t\tauthor: RemixNode;\n\t\t/** The muted verb after the name: \"commented\", \"reviewed\". */\n\t\taction?: RemixNode;\n\t\t/** When it was written: a `RelativeTime` or plain text. */\n\t\ttime?: RemixNode;\n\t\t/** A `⋯` menu trigger, drawn at the end of the header. */\n\t\tmenu?: RemixNode;\n\t\t/** Reactions or other controls, drawn in a row under the body. */\n\t\treactions?: RemixNode;\n\t\t/** The rendered Markdown body. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the summary line and its commits. */\n\texport interface CommitsProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** A 16px glyph for the group, such as a commit icon. */\n\t\ticon: RemixNode;\n\t\t/** A small avatar of the pusher, shown before the name. */\n\t\tavatar?: RemixNode;\n\t\t/** Who pushed, set in bold. */\n\t\tactor?: RemixNode;\n\t\t/** What happened, muted: \"added 3 commits\". */\n\t\tsummary?: RemixNode;\n\t\t/** When the push happened. */\n\t\ttime?: RemixNode;\n\t\t/** The {@link Timeline.Commit} rows. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the commit's parts. */\n\texport interface CommitProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The commit's short sha, set in monospace at the end of the row. */\n\t\tsha: string;\n\t\t/** The commit's page; links the subject and the sha. */\n\t\thref?: string;\n\t\t/** A small avatar of the author. */\n\t\tavatar?: RemixNode;\n\t\t/** The commit's checks, such as a toned status icon with its accessible name. */\n\t\tcheck?: RemixNode;\n\t\t/** The commit's subject line. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/** Every native `<li>` attribute, plus the folded events. */\n\texport interface MoreProps extends Omit<TagProps<\"li\">, \"children\"> {\n\t\t/** The disclosure's label, such as \"4 more events\". */\n\t\tsummary: RemixNode;\n\t\t/** Starts unfolded. */\n\t\topen?: boolean;\n\t\t/** The folded {@link Timeline.Event} items. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * The two-column track every row shares: the icon box, then the line. Folded events use\n * it too, so their icons stay on the one rail the list draws.\n */\nfunction rowTrack() {\n\treturn [\n\t\tgrid(),\n\t\traw({ gridTemplateColumns: `${ICON_BOX} minmax(0, 1fr)` }),\n\t\tgap(3),\n\t\traw({ rowGap: \"0.5rem\" }),\n\t\titems(\"start\"),\n\t];\n}\n\n/**\n * Renders the `<ol>` and its rail, drawn once behind every icon so an opened fold keeps the line\n * whole; icons and {@link Timeline.Comment} cards sit on `--ui-timeline-surface`, masking the rail,\n * in a `--ui-timeline-icon-box` square. {@link Timeline.Commits} groups a push; all of it is HTML.\n *\n * @param handle Runtime handle carrying the `<ol>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Timeline>\n * \t<Timeline.Event icon={<CircleDotIcon />} tone=\"danger\" actor=\"Uptime\" time={<RelativeTime date={opened} />}>\n * \t\topened the incident\n * \t</Timeline.Event>\n * \t<Timeline.Event icon={<MessageSquareIcon />} avatar={<Avatar size=\"xs\" />} actor=\"Ana\" body={<p>Rolling back.</p>}>\n * \t\tcommented\n * \t</Timeline.Event>\n * </Timeline>\n * @example\n * <Timeline aria-label={t(\"pull.conversation\")}>\n * \t<Timeline.Comment id=\"comment-12\" avatar={<Avatar size=\"xs\" />} author=\"ana\" action={t(\"pull.commented\")} time={<RelativeTime date={at} />}>\n * \t\t<Markdown source={body} />\n * \t</Timeline.Comment>\n * \t<Timeline.Commits icon={<GitCommitHorizontalIcon />} actor=\"ana\" summary={t(\"pull.addedCommits\", { count: 1 })}>\n * \t\t<Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\">Fix the parser</Timeline.Commit>\n * \t</Timeline.Commits>\n * </Timeline>\n */\nexport function Timeline(handle: Handle<Timeline.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ol\n\t\t\t\tdata-slot=\"timeline\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\tvstack({ gap: 3 }),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tbefore([\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t\tinsetBlock: `calc(${ICON_BOX} / 2)`,\n\t\t\t\t\t\t\t\tinsetInlineStart: `calc(${ICON_BOX} / 2 - 1px)`,\n\t\t\t\t\t\t\t\tinlineSize: \"2px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * Renders one event: its toned icon on the rail, then a single wrapping line of avatar,\n * actor, description and time, then the body card when one is given.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the event's markup.\n * @example\n * <Timeline.Event icon={<RocketIcon />} tone=\"brand\" actor=\"deploy-bot\" time=\"2m ago\">\n * \tdeployed v4.2.1\n * </Timeline.Event>\n */\nTimeline.Event = function TimelineEvent(handle: Handle<Timeline.EventProps>) {\n\treturn () => {\n\t\tlet { icon, tone, avatar, actor, time, body, children, mix, ...rest } = handle.props;\n\t\tlet resolvedTone = tone ?? DEFAULT_TONE;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-event\"\n\t\t\t\tdata-tone={resolvedTone}\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(rowTrack(), mix)}\n\t\t\t>\n\t\t\t\t<TimelineIcon tone={resolvedTone}>{icon}</TimelineIcon>\n\t\t\t\t<div mix={[vstack({ gap: 2 }), minIs(0)]}>\n\t\t\t\t\t<p\n\t\t\t\t\t\tdata-slot=\"timeline-line\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", minBlockSize: ICON_BOX }),\n\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{avatar ? <span mix={[inlineFlex()]}>{avatar}</span> : null}\n\t\t\t\t\t\t{actor ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{actor}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{children ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\"), text(\"xs\")]}>\n\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</p>\n\t\t\t\t\t{body ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tdata-slot=\"timeline-body\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\t\t\"& > :first-child\": { marginBlockStart: 0 },\n\t\t\t\t\t\t\t\t\t\"& > :last-child\": { marginBlockEnd: 0 },\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{body}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a run of events folded behind a `<details>`: its summary sits on the rail with\n * an ellipsis glyph, and its events open in place, in the same list and on the same rail.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the folded run's markup.\n * @example\n * <Timeline.More summary=\"4 more events\">\n * \t{checks.map((check) => <Timeline.Event icon={<CheckIcon />} actor=\"Uptime\">{check.text}</Timeline.Event>)}\n * </Timeline.More>\n */\nTimeline.More = function TimelineMore(handle: Handle<Timeline.MoreProps>) {\n\treturn () => {\n\t\tlet { summary, open, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-more\" {...rest} mix={mergeMix([], mix)}>\n\t\t\t\t<details open={open} mix={[raw({ \"&[open] > summary\": { display: \"none\" } })]}>\n\t\t\t\t\t<summary\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t...rowTrack(),\n\t\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\t\traw({ \"&::-webkit-details-marker\": { display: \"none\" } }),\n\t\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: 2 })),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TimelineIcon tone=\"neutral\">\n\t\t\t\t\t\t\t<EllipsisIcon size={16} aria-hidden=\"true\" />\n\t\t\t\t\t\t</TimelineIcon>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t\t\t\thover(fg(\"neutral.emphasis\")),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{summary}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</summary>\n\t\t\t\t\t<ol mix={[m(0), p(0), listStyle(\"none\"), vstack({ gap: 3 })]}>{children}</ol>\n\t\t\t\t</details>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a comment as a card on the rail: the author's avatar sits where an event's icon\n * would, the header reads \"name action time\" with a `⋯` slot at its end, and the body and\n * reactions follow. A conversation reads as cards and housekeeping as single lines.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the comment's markup.\n * @example\n * <Timeline.Comment id=\"comment-12\" avatar={<Avatar size=\"xs\" />} author=\"ana\" action=\"commented\" time={<RelativeTime date={at} />} menu={<CommentMenu />} reactions={<Reactions />}>\n * \t<Markdown source={body} />\n * </Timeline.Comment>\n */\nTimeline.Comment = function TimelineComment(handle: Handle<Timeline.CommentProps>) {\n\treturn () => {\n\t\tlet { avatar, author, action, time, menu, reactions, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-comment\" {...rest} mix={mergeMix(rowTrack(), mix)}>\n\t\t\t\t<span\n\t\t\t\t\tdata-slot=\"timeline-avatar\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tis(ICON_BOX),\n\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{avatar}\n\t\t\t\t</span>\n\t\t\t\t<div\n\t\t\t\t\tdata-slot=\"timeline-card\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\t\traw({ overflow: \"clip\" }),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<header\n\t\t\t\t\t\tdata-slot=\"timeline-comment-header\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\t\traw({ minBlockSize: \"2.5rem\", paddingBlock: \"0.375rem\" }),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\traw({ borderBlockEnd: \"1px solid var(--ui-neutral-border)\" }),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", columnGap: \"0.375rem\", flex: \"1 1 auto\" }),\n\t\t\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{author}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{action ? (\n\t\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t\t{action}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{menu ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-comment-menu\" mix={[inlineFlex(), raw({ flexShrink: 0 })]}>\n\t\t\t\t\t\t\t\t{menu}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</header>\n\t\t\t\t\t<div\n\t\t\t\t\t\tdata-slot=\"timeline-comment-body\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\toverflowWrap: \"anywhere\",\n\t\t\t\t\t\t\t\t\"& > :first-child\": { marginBlockStart: 0 },\n\t\t\t\t\t\t\t\t\"& > :last-child\": { marginBlockEnd: 0 },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</div>\n\t\t\t\t\t{reactions ? (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tdata-slot=\"timeline-reactions\"\n\t\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\traw({ flexWrap: \"wrap\" }),\n\t\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\t\t\traw({ paddingBlockEnd: \"0.75rem\" }),\n\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{reactions}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders a push as one event on the rail with its commits listed under the line: each row\n * gives the subject, its checks and the short sha, so a run of commits costs one rail stop.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <Timeline.Commits icon={<GitCommitHorizontalIcon />} actor=\"ana\" summary=\"added 2 commits\" time=\"3h ago\">\n * \t<Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\" check={<CheckIcon aria-label=\"Checks passed\" />}>Fix the parser</Timeline.Commit>\n * </Timeline.Commits>\n */\nTimeline.Commits = function TimelineCommits(handle: Handle<Timeline.CommitsProps>) {\n\treturn () => {\n\t\tlet { icon, avatar, actor, summary, time, children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-commits\"\n\t\t\t\tdata-tone=\"neutral\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(rowTrack(), mix)}\n\t\t\t>\n\t\t\t\t<TimelineIcon tone=\"neutral\">{icon}</TimelineIcon>\n\t\t\t\t<div mix={[vstack({ gap: 1.5 }), minIs(0)]}>\n\t\t\t\t\t<p\n\t\t\t\t\t\tdata-slot=\"timeline-line\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", minBlockSize: ICON_BOX }),\n\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{avatar ? <span mix={[inlineFlex()]}>{avatar}</span> : null}\n\t\t\t\t\t\t{actor ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-actor\" mix={[weight(\"semibold\")]}>\n\t\t\t\t\t\t\t\t{actor}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{summary ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-description\" mix={[fg(\"neutral.muted\")]}>\n\t\t\t\t\t\t\t\t{summary}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{time ? (\n\t\t\t\t\t\t\t<span data-slot=\"timeline-time\" mix={[fg(\"neutral.muted\"), text(\"xs\")]}>\n\t\t\t\t\t\t\t\t{time}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</p>\n\t\t\t\t\t<ol\n\t\t\t\t\t\tdata-slot=\"timeline-commit-list\"\n\t\t\t\t\t\tmix={[m(0), p(0), listStyle(\"none\"), vstack({ gap: 0.5 })]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</ol>\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * Renders one commit of a {@link Timeline.Commits} group: avatar, the subject (truncated to\n * one line), the check-state slot, then the short sha in monospace at the row's end.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the commit's row.\n * @example <Timeline.Commit sha=\"a1b2c3d\" href=\"/commit/a1b2c3d\">Fix the parser</Timeline.Commit>\n */\nTimeline.Commit = function TimelineCommit(handle: Handle<Timeline.CommitProps>) {\n\treturn () => {\n\t\tlet { sha, href, avatar, check, children, mix, ...rest } = handle.props;\n\t\tlet linkMix = [\n\t\t\tfg(\"inherit\"),\n\t\t\traw({ textDecoration: \"none\" }),\n\t\t\thover(raw({ textDecoration: \"underline\" })),\n\t\t];\n\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-commit\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[flex(), items(\"center\"), gap(2), minIs(0), raw({ minBlockSize: \"1.75rem\" })],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{avatar ? <span mix={[inlineFlex(), raw({ flexShrink: 0 })]}>{avatar}</span> : null}\n\t\t\t\t<span data-slot=\"timeline-commit-subject\" mix={[truncate(), raw({ flex: \"0 1 auto\" })]}>\n\t\t\t\t\t{href ? (\n\t\t\t\t\t\t<a href={href} mix={linkMix}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tchildren\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t\t{check ? (\n\t\t\t\t\t<span data-slot=\"timeline-commit-check\" mix={[inlineFlex(), raw({ flexShrink: 0 })]}>\n\t\t\t\t\t\t{check}\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t\t<code\n\t\t\t\t\tdata-slot=\"timeline-commit-sha\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({ marginInlineStart: \"auto\", flexShrink: 0 }),\n\t\t\t\t\t\tfont(\"mono\"),\n\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{href ? (\n\t\t\t\t\t\t<a href={href} mix={linkMix}>\n\t\t\t\t\t\t\t{sha}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tsha\n\t\t\t\t\t)}\n\t\t\t\t</code>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/** Props {@link TimelineIcon} reads. */\ninterface TimelineIconProps {\n\ttone: Timeline.Tone;\n\tchildren: RemixNode;\n}\n\n/**\n * The icon box on the rail: the glyph in its tone, on the surface colour so the rail\n * reads as passing behind it.\n *\n * @param handle Runtime handle carrying the tone and glyph.\n * @returns The render function producing the icon box.\n */\nfunction TimelineIcon(handle: Handle<TimelineIconProps>) {\n\treturn () => {\n\t\tlet { tone, children } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-icon\"\n\t\t\t\tdata-tone={tone}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tis(ICON_BOX),\n\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tbg(\"var(--ui-timeline-surface, var(--ui-bg, Canvas))\"),\n\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\tdata(\"tone\", \"brand\", fg(\"brand\")),\n\t\t\t\t\tdata(\"tone\", \"success\", fg(\"success\")),\n\t\t\t\t\tdata(\"tone\", \"warning\", fg(\"warning\")),\n\t\t\t\t\tdata(\"tone\", \"danger\", fg(\"danger\")),\n\t\t\t\t\twhen(\"& > svg\", raw({ inlineSize: \"1rem\", blockSize: \"1rem\" })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t);\n\t};\n}\n"
|
|
10
|
+
"content": "/**\n * A record's activity as an ordered list: a 2px rail threading 16px event icons toned by\n * what happened, one line per event, comment cards with an author header and reactions,\n * grouped commits, and a native `<details>` folding a run of quiet events into \"N more\".\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { EllipsisIcon } from \"@sdxc/icons\";\nimport { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { cursor, listStyle, pseudoContent, raw, mergeMix } from \"@sdxc/u/general\";\nimport { flex, gap, grid, inlineFlex, items, justify, relative, vstack } from \"@sdxc/u/layout\";\nimport { bs, is, m, minIs, p, pi } from \"@sdxc/u/size\";\nimport { before, data, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { font, leading, text, truncate, weight } from \"@sdxc/u/typography\";\n\n/** The side of the square each event's icon sits centred in; the rail runs through its middle. */\nconst ICON_BOX = \"var(--ui-timeline-icon-box, 1.5rem)\";\n\n/** The surface icons and cards sit on, masking the rail behind them. */\nconst SURFACE = \"var(--ui-timeline-surface, var(--ui-bg, Canvas))\";\n\n/** Tone an event's icon takes when `tone` is left unset. */\nconst DEFAULT_TONE: Timeline.Tone = \"neutral\";\n\n/** The marker attribute a row's layout selects its rail parts by. */\nconst PART = \"data-timeline-part\";\n\n/**\n * Prop types for {@link Timeline} and its compound parts.\n */\nexport namespace Timeline {\n\t/** The semantic role an event's icon is drawn in. */\n\texport type Tone = \"neutral\" | \"brand\" | \"success\" | \"warning\" | \"danger\";\n\n\t/** What an event shares with its icon. */\n\texport interface EventContext {\n\t\ttone: Tone;\n\t}\n\n\t/** What a card shares with its body. */\n\texport interface CardContext {\n\t\tinCard: true;\n\t}\n\n\t/** What a comment header shares with its line and time. */\n\texport interface HeaderContext {\n\t\tinHeader: true;\n\t}\n\n\t/** What a commit row shares with its subject and sha. */\n\texport interface CommitContext {\n\t\thref?: string;\n\t}\n\n\t/** Every native `<ol>` attribute. */\n\texport interface Props extends TagProps<\"ol\"> {}\n\n\t/** Every native `<li>` attribute, plus the tone of the event's icon. */\n\texport interface EventProps extends TagProps<\"li\"> {\n\t\t/** @default {@link DEFAULT_TONE} */\n\t\ttone?: Tone;\n\t}\n\n\t/** Every native `<li>` attribute. */\n\texport interface ItemProps extends TagProps<\"li\"> {}\n\n\t/** Every native `<span>` attribute. */\n\texport interface SpanProps extends TagProps<\"span\"> {}\n\n\t/** Every native `<p>` attribute. */\n\texport interface LineProps extends TagProps<\"p\"> {}\n\n\t/** Every native `<div>` attribute. */\n\texport interface DivProps extends TagProps<\"div\"> {}\n\n\t/** Every native `<header>` attribute. */\n\texport interface HeaderProps extends TagProps<\"header\"> {}\n\n\t/** Every native `<ol>` attribute. */\n\texport interface ListProps extends TagProps<\"ol\"> {}\n\n\t/** Every native `<li>` attribute, plus the commit's page. */\n\texport interface CommitProps extends TagProps<\"li\"> {\n\t\t/** The commit's page; links {@link Timeline.Subject} and {@link Timeline.Sha}. */\n\t\thref?: string;\n\t}\n\n\t/** Every native `<code>` attribute. */\n\texport interface ShaProps extends TagProps<\"code\"> {}\n\n\t/** Every native `<li>` attribute, plus whether the fold starts open. */\n\texport interface MoreProps extends TagProps<\"li\"> {\n\t\t/** Starts unfolded. */\n\t\topen?: boolean;\n\t}\n\n\t/** Every native `<summary>` attribute. */\n\texport interface SummaryProps extends TagProps<\"summary\"> {}\n}\n\n/**\n * The two-column track every row shares: the rail part (an icon or an avatar) in the first\n * column's first row, every other part stacked in the second column, in the order written.\n */\nfunction rowTrack() {\n\treturn [\n\t\tgrid(),\n\t\traw({ gridTemplateColumns: `${ICON_BOX} minmax(0, 1fr)` }),\n\t\tgap(3),\n\t\traw({ rowGap: \"0.5rem\" }),\n\t\titems(\"start\"),\n\t\twhen(`& > :not([${PART}=icon], [${PART}=avatar])`, raw({ gridColumn: \"2\", minInlineSize: 0 })),\n\t\twhen(`& > [${PART}=icon], & > [${PART}=avatar]`, raw({ gridColumn: \"1\", gridRow: \"1\" })),\n\t\twhen(\n\t\t\t`& > [${PART}=avatar]`,\n\t\t\traw({\n\t\t\t\tposition: \"relative\",\n\t\t\t\tjustifyContent: \"center\",\n\t\t\t\tinlineSize: ICON_BOX,\n\t\t\t\tblockSize: ICON_BOX,\n\t\t\t\tborderRadius: \"9999px\",\n\t\t\t\tbackground: SURFACE,\n\t\t\t}),\n\t\t),\n\t];\n}\n\n/** The muted link a commit's subject and sha take when the commit has a page. */\nfunction commitLinkMix() {\n\treturn [\n\t\tfg(\"inherit\"),\n\t\traw({ textDecoration: \"none\" }),\n\t\thover(raw({ textDecoration: \"underline\" })),\n\t];\n}\n\n/**\n * Renders the `<ol>` and its rail, drawn once behind every icon so an opened fold keeps the line\n * whole; icons and {@link Timeline.Card}s sit on `--ui-timeline-surface`, masking the rail, in a\n * `--ui-timeline-icon-box` square. Every row is HTML, with no script.\n *\n * @param handle Runtime handle carrying the `<ol>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Timeline>\n * \t<Timeline.Event tone=\"danger\">\n * \t\t<Timeline.Icon><CircleDotIcon /></Timeline.Icon>\n * \t\t<Timeline.Line>\n * \t\t\t<Timeline.Actor>Uptime</Timeline.Actor>\n * \t\t\t<Timeline.Description>opened the incident</Timeline.Description>\n * \t\t\t<Timeline.Time><RelativeTime date={opened} /></Timeline.Time>\n * \t\t</Timeline.Line>\n * \t</Timeline.Event>\n * </Timeline>\n */\nexport function Timeline(handle: Handle<Timeline.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<ol\n\t\t\t\tdata-slot=\"timeline\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tm(0),\n\t\t\t\t\t\tp(0),\n\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\tvstack({ gap: 3 }),\n\t\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\t\tbefore([\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t\tinsetBlock: `calc(${ICON_BOX} / 2)`,\n\t\t\t\t\t\t\t\tinsetInlineStart: `calc(${ICON_BOX} / 2 - 1px)`,\n\t\t\t\t\t\t\t\tinlineSize: \"2px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n\n/**\n * One event: its {@link Timeline.Icon} on the rail, then a {@link Timeline.Line} and an\n * optional {@link Timeline.Body} card stacked beside it. The `tone` colours the icon.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the event's row.\n * @example\n * <Timeline.Event tone=\"brand\">\n * \t<Timeline.Icon><RocketIcon /></Timeline.Icon>\n * \t<Timeline.Line><Timeline.Actor>deploy-bot</Timeline.Actor><Timeline.Description>deployed v4.2.1</Timeline.Description></Timeline.Line>\n * </Timeline.Event>\n */\nTimeline.Event = function TimelineEvent(\n\thandle: Handle<Timeline.EventProps, Timeline.EventContext>,\n) {\n\treturn () => {\n\t\tlet { tone = DEFAULT_TONE, mix, ...rest } = handle.props;\n\t\thandle.context.set({ tone });\n\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-event\" data-tone={tone} {...rest} mix={mergeMix(rowTrack(), mix)} />\n\t\t);\n\t};\n};\n\n/**\n * A 16px glyph on the rail naming the kind of event, decorative beside the line's words and\n * drawn in its event's tone (neutral outside a {@link Timeline.Event}).\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the icon box.\n * @example <Timeline.Icon><CheckIcon /></Timeline.Icon>\n */\nTimeline.Icon = function TimelineIcon(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Timeline.Event) as Timeline.EventContext | undefined;\n\t\tlet tone = context?.tone ?? DEFAULT_TONE;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-icon\"\n\t\t\t\tdata-tone={tone}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-timeline-part=\"icon\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\trelative(),\n\t\t\t\t\t\tinlineFlex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t\tis(ICON_BOX),\n\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\tbg(SURFACE),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\tdata(\"tone\", \"brand\", fg(\"brand\")),\n\t\t\t\t\t\tdata(\"tone\", \"success\", fg(\"success\")),\n\t\t\t\t\t\tdata(\"tone\", \"warning\", fg(\"warning\")),\n\t\t\t\t\t\tdata(\"tone\", \"danger\", fg(\"danger\")),\n\t\t\t\t\t\twhen(\"& > svg\", raw({ inlineSize: \"1rem\", blockSize: \"1rem\" })),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A small avatar. Written directly in a {@link Timeline.Comment} it sits on the rail where an\n * event's icon would; inside a {@link Timeline.Line} or {@link Timeline.Commit} it sits inline.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the avatar's box.\n * @example <Timeline.Avatar><Avatar size=\"xs\"><Avatar.Fallback>AS</Avatar.Fallback></Avatar></Timeline.Avatar>\n */\nTimeline.Avatar = function TimelineAvatar(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-avatar\"\n\t\t\t\t{...rest}\n\t\t\t\tdata-timeline-part=\"avatar\"\n\t\t\t\tmix={mergeMix([inlineFlex(), items(\"center\"), raw({ flexShrink: 0 })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The event's single wrapping line of avatar, actor, description and time, at least as tall\n * as the icon so its words centre on it. Inside a {@link Timeline.Header} it fills the header.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the line.\n */\nTimeline.Line = function TimelineLine(handle: Handle<Timeline.LineProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet header = handle.context.get(Timeline.Header) as Timeline.HeaderContext | undefined;\n\n\t\treturn (\n\t\t\t<p\n\t\t\t\tdata-slot=\"timeline-line\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\theader\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"baseline\"),\n\t\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", columnGap: \"0.375rem\", flex: \"1 1 auto\" }),\n\t\t\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tm(0),\n\t\t\t\t\t\t\t\tflex(),\n\t\t\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\t\t\traw({ flexWrap: \"wrap\", minBlockSize: ICON_BOX }),\n\t\t\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\t\t\tleading(\"1.25rem\"),\n\t\t\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Who did it, set in bold.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the name.\n */\nTimeline.Actor = function TimelineActor(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn <span data-slot=\"timeline-actor\" {...rest} mix={mergeMix([weight(\"semibold\")], mix)} />;\n\t};\n};\n\n/**\n * What happened, in muted text after the actor: \"resolved the incident\", \"commented\".\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the description.\n */\nTimeline.Description = function TimelineDescription(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span data-slot=\"timeline-description\" {...rest} mix={mergeMix([fg(\"neutral.muted\")], mix)} />\n\t\t);\n\t};\n};\n\n/**\n * When it happened, such as a `RelativeTime`: muted and a size smaller on an event's line,\n * at the header's size inside a {@link Timeline.Header}.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the time.\n */\nTimeline.Time = function TimelineTime(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet header = handle.context.get(Timeline.Header) as Timeline.HeaderContext | undefined;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-time\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(header ? [fg(\"neutral.muted\")] : [fg(\"neutral.muted\"), text(\"xs\")], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A comment or other body under an event's line, set as a tinted bordered card; inside a\n * {@link Timeline.Card} it is the card's padded content, wrapping long words.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body.\n */\nTimeline.Body = function TimelineBody(handle: Handle<Timeline.DivProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet card = handle.context.get(Timeline.Card) as Timeline.CardContext | undefined;\n\t\tlet edges = raw({\n\t\t\t\"& > :first-child\": { marginBlockStart: 0 },\n\t\t\t\"& > :last-child\": { marginBlockEnd: 0 },\n\t\t});\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"timeline-body\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\tcard\n\t\t\t\t\t\t? [p(3), raw({ overflowWrap: \"anywhere\" }), edges]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tp(3),\n\t\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\t\tedges,\n\t\t\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A comment on the rail: its {@link Timeline.Avatar} sits where an event's icon would, and a\n * {@link Timeline.Card} beside it holds the header, body and reactions. A conversation reads\n * as cards and housekeeping as single lines.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the comment's row.\n * @example\n * <Timeline.Comment id=\"comment-12\">\n * \t<Timeline.Avatar><Avatar size=\"xs\" /></Timeline.Avatar>\n * \t<Timeline.Card>\n * \t\t<Timeline.Header>\n * \t\t\t<Timeline.Line><Timeline.Actor>ana</Timeline.Actor><Timeline.Description>commented</Timeline.Description></Timeline.Line>\n * \t\t\t<Timeline.Menu><CommentMenu /></Timeline.Menu>\n * \t\t</Timeline.Header>\n * \t\t<Timeline.Body><Markdown source={body} /></Timeline.Body>\n * \t</Timeline.Card>\n * </Timeline.Comment>\n */\nTimeline.Comment = function TimelineComment(handle: Handle<Timeline.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn <li data-slot=\"timeline-comment\" {...rest} mix={mergeMix(rowTrack(), mix)} />;\n\t};\n};\n\n/**\n * The bordered card a comment's header, body and reactions stack in, on the timeline surface.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the card.\n */\nTimeline.Card = function TimelineCard(handle: Handle<Timeline.DivProps, Timeline.CardContext>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\thandle.context.set({ inCard: true });\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"timeline-card\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tminIs(0),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\tbg(SURFACE),\n\t\t\t\t\t\traw({ overflow: \"clip\" }),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The card's tinted header row: a {@link Timeline.Line} reading \"name action time\", then a\n * {@link Timeline.Menu} at its end.\n *\n * @param handle Runtime handle carrying the host `<header>`'s props.\n * @returns The render function producing the header.\n */\nTimeline.Header = function TimelineHeader(\n\thandle: Handle<Timeline.HeaderProps, Timeline.HeaderContext>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\thandle.context.set({ inHeader: true });\n\t\treturn (\n\t\t\t<header\n\t\t\t\tdata-slot=\"timeline-comment-header\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tgap(2),\n\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\traw({ minBlockSize: \"2.5rem\", paddingBlock: \"0.375rem\" }),\n\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\traw({ borderBlockEnd: \"1px solid var(--ui-neutral-border)\" }),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A `⋯` menu trigger at the end of a comment's header, kept from shrinking.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the menu's box.\n */\nTimeline.Menu = function TimelineMenu(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-comment-menu\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([inlineFlex(), raw({ flexShrink: 0 })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Reactions or other controls in a wrapping row under a card's body.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the row.\n */\nTimeline.Reactions = function TimelineReactions(handle: Handle<Timeline.DivProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"timeline-reactions\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\traw({ flexWrap: \"wrap\" }),\n\t\t\t\t\t\tgap(1.5),\n\t\t\t\t\t\tpi(3),\n\t\t\t\t\t\traw({ paddingBlockEnd: \"0.75rem\" }),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * A push as one stop on the rail: a neutral {@link Timeline.Icon}, its {@link Timeline.Line},\n * and a {@link Timeline.CommitList} under it, so a run of commits costs one rail stop.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the group's row.\n * @example\n * <Timeline.Commits>\n * \t<Timeline.Icon><GitCommitHorizontalIcon /></Timeline.Icon>\n * \t<Timeline.Line><Timeline.Actor>ana</Timeline.Actor><Timeline.Description>added 2 commits</Timeline.Description></Timeline.Line>\n * \t<Timeline.CommitList>\n * \t\t<Timeline.Commit href=\"/commit/a1b2c3d\"><Timeline.Subject>Fix the parser</Timeline.Subject><Timeline.Sha>a1b2c3d</Timeline.Sha></Timeline.Commit>\n * \t</Timeline.CommitList>\n * </Timeline.Commits>\n */\nTimeline.Commits = function TimelineCommits(handle: Handle<Timeline.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-commits\"\n\t\t\t\tdata-tone=\"neutral\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([...rowTrack(), raw({ rowGap: \"0.375rem\" })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The list of a push's {@link Timeline.Commit} rows.\n *\n * @param handle Runtime handle carrying the host `<ol>`'s props.\n * @returns The render function producing the list.\n */\nTimeline.CommitList = function TimelineCommitList(handle: Handle<Timeline.ListProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<ol\n\t\t\t\tdata-slot=\"timeline-commit-list\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([m(0), p(0), listStyle(\"none\"), vstack({ gap: 0.5 })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * One commit row, laying out an inline {@link Timeline.Avatar}, the {@link Timeline.Subject},\n * a {@link Timeline.Check} and the {@link Timeline.Sha}; `href` links the subject and sha.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the commit's row.\n */\nTimeline.Commit = function TimelineCommit(\n\thandle: Handle<Timeline.CommitProps, Timeline.CommitContext>,\n) {\n\treturn () => {\n\t\tlet { href, mix, ...rest } = handle.props;\n\t\thandle.context.set({ href });\n\t\treturn (\n\t\t\t<li\n\t\t\t\tdata-slot=\"timeline-commit\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[flex(), items(\"center\"), gap(2), minIs(0), raw({ minBlockSize: \"1.75rem\" })],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The commit's subject line, truncated to one line and linked to the commit's page.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the subject.\n */\nTimeline.Subject = function TimelineSubject(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Timeline.Commit) as Timeline.CommitContext | undefined;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-commit-subject\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([truncate(), raw({ flex: \"0 1 auto\" })], mix)}\n\t\t\t>\n\t\t\t\t{context?.href ? (\n\t\t\t\t\t<a href={context.href} mix={commitLinkMix()}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\tchildren\n\t\t\t\t)}\n\t\t\t</span>\n\t\t);\n\t};\n};\n\n/**\n * The commit's checks, such as a toned status icon carrying its accessible name.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the check's box.\n */\nTimeline.Check = function TimelineCheck(handle: Handle<Timeline.SpanProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"timeline-commit-check\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([inlineFlex(), raw({ flexShrink: 0 })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * The commit's short sha, in monospace at the row's end and linked to the commit's page.\n *\n * @param handle Runtime handle carrying the host `<code>`'s props.\n * @returns The render function producing the sha.\n */\nTimeline.Sha = function TimelineSha(handle: Handle<Timeline.ShaProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\t\tlet context = handle.context.get(Timeline.Commit) as Timeline.CommitContext | undefined;\n\t\treturn (\n\t\t\t<code\n\t\t\t\tdata-slot=\"timeline-commit-sha\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({ marginInlineStart: \"auto\", flexShrink: 0 }),\n\t\t\t\t\t\tfont(\"mono\"),\n\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{context?.href ? (\n\t\t\t\t\t<a href={context.href} mix={commitLinkMix()}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\tchildren\n\t\t\t\t)}\n\t\t\t</code>\n\t\t);\n\t};\n};\n\n/**\n * A run of events folded behind a `<details>`: its {@link Timeline.Summary} sits on the rail,\n * and its {@link Timeline.MoreList} opens in place, on the same rail, hiding the summary.\n *\n * @param handle Runtime handle carrying the `<li>`'s props.\n * @returns The render function producing the folded run.\n * @example\n * <Timeline.More>\n * \t<Timeline.Summary>4 more events</Timeline.Summary>\n * \t<Timeline.MoreList>{checks.map((check) => <Timeline.Event>…</Timeline.Event>)}</Timeline.MoreList>\n * </Timeline.More>\n */\nTimeline.More = function TimelineMore(handle: Handle<Timeline.MoreProps>) {\n\treturn () => {\n\t\tlet { open, children, mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<li data-slot=\"timeline-more\" {...rest} mix={mergeMix([], mix)}>\n\t\t\t\t<details open={open} mix={[raw({ \"&[open] > summary\": { display: \"none\" } })]}>\n\t\t\t\t\t{children}\n\t\t\t\t</details>\n\t\t\t</li>\n\t\t);\n\t};\n};\n\n/**\n * The fold's label on the rail, such as \"4 more events\", after an ellipsis glyph in an icon box.\n *\n * @param handle Runtime handle carrying the host `<summary>`'s props.\n * @returns The render function producing the summary.\n */\nTimeline.Summary = function TimelineSummary(handle: Handle<Timeline.SummaryProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<summary\n\t\t\t\tdata-slot=\"timeline-summary\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\t...rowTrack(),\n\t\t\t\t\t\tlistStyle(\"none\"),\n\t\t\t\t\t\traw({ \"&::-webkit-details-marker\": { display: \"none\" } }),\n\t\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tfocusVisible(outline({ color: \"brand.ring\", width: 2, offset: 2 })),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<Timeline.Icon>\n\t\t\t\t\t<EllipsisIcon size={16} aria-hidden=\"true\" />\n\t\t\t\t</Timeline.Icon>\n\t\t\t\t<span\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tflex(),\n\t\t\t\t\t\titems(\"center\"),\n\t\t\t\t\t\tbs(ICON_BOX),\n\t\t\t\t\t\tfg(\"neutral.muted\"),\n\t\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t\thover(fg(\"neutral.emphasis\")),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</span>\n\t\t\t</summary>\n\t\t);\n\t};\n};\n\n/**\n * The folded events, listed on the same rail when the fold opens.\n *\n * @param handle Runtime handle carrying the host `<ol>`'s props.\n * @returns The render function producing the list.\n */\nTimeline.MoreList = function TimelineMoreList(handle: Handle<Timeline.ListProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\treturn (\n\t\t\t<ol\n\t\t\t\tdata-slot=\"timeline-more-list\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={mergeMix([m(0), p(0), listStyle(\"none\"), vstack({ gap: 3 })], mix)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "timeline.browser.test.tsx",
|
|
14
|
-
"content": "/**\n * Lays Timeline out in a real browser: an ordered list whose rail runs through the centre\n * of every icon, a line per event, a comment card in the text column, and a \"N more\"\n * disclosure whose folded events open on the same rail, comment cards with an author header and\n * reactions, and a push's commits listed under one rail stop.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { userEvent } from \"vitest/browser\";\n\nimport { Timeline } from \"@sdxc/ui/timeline\";\n\nimport \"@sdxc/ui/theme.css\";\n\n/** A 16px stand-in glyph. */\nfunction Glyph() {\n\treturn () => (\n\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\n/** An incident's activity: opened, a folded run of checks, a comment, resolved. */\nfunction Incident() {\n\treturn () => (\n\t\t<Timeline aria-label=\"Activity\">\n\t\t\t<Timeline.Event icon={<Glyph />} tone=\"danger\" actor=\"Uptime\" time=\"12m ago\">\n\t\t\t\topened the incident\n\t\t\t</Timeline.Event>\n\t\t\t<Timeline.More summary=\"2 more events\">\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"Uptime\" time=\"11m ago\">\n\t\t\t\t\tchecked from Frankfurt\n\t\t\t\t</Timeline.Event>\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"Uptime\" time=\"10m ago\">\n\t\t\t\t\tchecked from Singapore\n\t\t\t\t</Timeline.Event>\n\t\t\t</Timeline.More>\n\t\t\t<Timeline.Event\n\t\t\t\ticon={<Glyph />}\n\t\t\t\tactor=\"Ana Souza\"\n\t\t\t\ttime=\"8m ago\"\n\t\t\t\tbody={<p>Rolling back the 14:02 deploy.</p>}\n\t\t\t>\n\t\t\t\tcommented\n\t\t\t</Timeline.Event>\n\t\t\t<Timeline.Event icon={<Glyph />} tone=\"success\" actor=\"Ana Souza\" time=\"2m ago\">\n\t\t\t\tresolved the incident\n\t\t\t</Timeline.Event>\n\t\t</Timeline>\n\t);\n}\n\n/** Mounts the incident timeline in a 480px host. */\nfunction mount(): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\thost.style.width = \"480px\";\n\tdocument.body.appendChild(host);\n\trender(<Incident />, { container: host });\n\treturn host;\n}\n\n/** Horizontal centre of a box. */\nfunction centerX(element: Element): number {\n\tlet box = element.getBoundingClientRect();\n\treturn box.left + box.width / 2;\n}\n\nafterEach(() => {\n\tdocument.body.replaceChildren();\n});\n\ndescribe(\"Timeline\", () => {\n\ttest(\"is an ordered list of events\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\n\t\texpect(list.getAttribute(\"aria-label\")).toBe(\"Activity\");\n\t\texpect(list.querySelectorAll(\":scope > li\")).toHaveLength(4);\n\t});\n\n\ttest(\"runs a 2px rail through the centre of every 16px icon\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(rail.width).toBe(\"2px\");\n\t\tfor (let icon of host.querySelectorAll('[data-slot=\"timeline-icon\"]')) {\n\t\t\tif (icon.getClientRects().length === 0) continue;\n\t\t\texpect(centerX(icon)).toBeCloseTo(railCenter, 0);\n\t\t\texpect(icon.querySelector(\"svg\")!.getBoundingClientRect().width).toBe(16);\n\t\t}\n\t});\n\n\ttest(\"tones each icon by what happened\", () => {\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-danger-600\", \"rgb(220, 38, 38)\");\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-success-600\", \"rgb(22, 163, 74)\");\n\t\tlet host = mount();\n\t\tlet [opened] = host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]');\n\t\tlet resolved = [...host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]')].at(-1)!;\n\n\t\texpect(getComputedStyle(opened!).color).toBe(\"rgb(220, 38, 38)\");\n\t\texpect(getComputedStyle(resolved).color).toBe(\"rgb(22, 163, 74)\");\n\t});\n\n\ttest(\"keeps each event on one line with the actor in bold\", () => {\n\t\tlet host = mount();\n\t\tlet line = host.querySelector<HTMLElement>('[data-slot=\"timeline-line\"]')!;\n\t\tlet actor = line.querySelector('[data-slot=\"timeline-actor\"]')!;\n\n\t\texpect(line.getBoundingClientRect().height).toBeLessThanOrEqual(24);\n\t\texpect(Number(getComputedStyle(actor).fontWeight)).toBeGreaterThanOrEqual(600);\n\t});\n\n\ttest(\"sets a comment as a card in the text column\", () => {\n\t\tlet host = mount();\n\t\tlet body = host.querySelector<HTMLElement>('[data-slot=\"timeline-body\"]')!;\n\t\tlet line = body.parentElement!.querySelector('[data-slot=\"timeline-line\"]')!;\n\n\t\texpect(body.getBoundingClientRect().left).toBeCloseTo(line.getBoundingClientRect().left, 0);\n\t\texpect(getComputedStyle(body).borderTopWidth).toBe(\"1px\");\n\t});\n\n\ttest(\"folds quiet events behind a disclosure that opens them on the same rail\", async () => {\n\t\tlet host = mount();\n\t\tlet details = host.querySelector(\"details\")!;\n\t\tlet summary = details.querySelector(\"summary\")!;\n\t\tlet folded = details.querySelectorAll<HTMLElement>('[data-slot=\"timeline-event\"]');\n\t\tlet first = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\n\t\texpect(summary.textContent).toBe(\"2 more events\");\n\t\texpect(folded[0]!.checkVisibility()).toBe(false);\n\n\t\tawait userEvent.click(summary);\n\n\t\texpect(details.open).toBe(true);\n\t\texpect(folded[0]!.checkVisibility()).toBe(true);\n\t\tlet icon = folded[0]!.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\texpect(centerX(icon)).toBeCloseTo(centerX(first), 0);\n\t});\n\n\ttest(\"sets a comment as a card with the author's avatar on the rail\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline aria-label=\"Conversation\">\n\t\t\t\t<Timeline.Event icon={<Glyph />} actor=\"ana\" time=\"3h ago\">\n\t\t\t\t\topened this pull request\n\t\t\t\t</Timeline.Event>\n\t\t\t\t<Timeline.Comment\n\t\t\t\t\tid=\"comment-1\"\n\t\t\t\t\tavatar={\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-avatar\n\t\t\t\t\t\t\tstyle=\"display:block;width:20px;height:20px;border-radius:50%;background:gray\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tauthor=\"ana\"\n\t\t\t\t\taction=\"commented\"\n\t\t\t\t\ttime=\"2h ago\"\n\t\t\t\t\tmenu={\n\t\t\t\t\t\t<button type=\"button\" aria-label=\"Comment actions\">\n\t\t\t\t\t\t\t⋯\n\t\t\t\t\t\t</button>\n\t\t\t\t\t}\n\t\t\t\t\treactions={<button type=\"button\">👍 2</button>}\n\t\t\t\t>\n\t\t\t\t\t<p>Looks good to me.</p>\n\t\t\t\t</Timeline.Comment>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet comment = host.querySelector<HTMLElement>('[data-slot=\"timeline-comment\"]')!;\n\t\tlet header = comment.querySelector<HTMLElement>('[data-slot=\"timeline-comment-header\"]')!;\n\t\tlet card = comment.querySelector<HTMLElement>('[data-slot=\"timeline-card\"]')!;\n\t\tlet avatar = comment.querySelector<HTMLElement>('[data-slot=\"timeline-avatar\"]')!;\n\t\tlet icon = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\tlet menu = header.querySelector(\"button\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(comment.id).toBe(\"comment-1\");\n\t\texpect(centerX(avatar)).toBeCloseTo(railCenter, 0);\n\t\texpect(centerX(avatar)).toBeCloseTo(centerX(icon), 0);\n\t\texpect(getComputedStyle(card).borderTopWidth).toBe(\"1px\");\n\t\texpect(header.textContent).toContain(\"ana\");\n\t\texpect(header.textContent).toContain(\"commented\");\n\t\texpect(header.textContent).toContain(\"2h ago\");\n\t\texpect(menu.getBoundingClientRect().right).toBeCloseTo(\n\t\t\theader.getBoundingClientRect().right - 12,\n\t\t\t0,\n\t\t);\n\t\texpect(card.querySelector('[data-slot=\"timeline-comment-body\"] p')!.textContent).toBe(\n\t\t\t\"Looks good to me.\",\n\t\t);\n\t\tlet reactions = card.querySelector<HTMLElement>('[data-slot=\"timeline-reactions\"]')!;\n\t\texpect(reactions.getBoundingClientRect().top).toBeGreaterThan(\n\t\t\tcard.querySelector('[data-slot=\"timeline-comment-body\"]')!.getBoundingClientRect().top,\n\t\t);\n\t});\n\n\ttest(\"lists a push's commits under one rail stop, each with its check and short sha\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline aria-label=\"Conversation\">\n\t\t\t\t<Timeline.Commits icon={<Glyph />} actor=\"ana\" summary=\"added 2 commits\" time=\"1h ago\">\n\t\t\t\t\t<Timeline.Commit\n\t\t\t\t\t\tsha=\"a1b2c3d\"\n\t\t\t\t\t\thref=\"#a1b2c3d\"\n\t\t\t\t\t\tcheck={\n\t\t\t\t\t\t\t<span role=\"img\" aria-label=\"Checks passed\">\n\t\t\t\t\t\t\t\t✓\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\tParse ANSI colours in job logs and keep long subjects to a single truncated line\n\t\t\t\t\t</Timeline.Commit>\n\t\t\t\t\t<Timeline.Commit sha=\"e4f5a6b\">Fix the timestamp toggle</Timeline.Commit>\n\t\t\t\t</Timeline.Commits>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet group = host.querySelector<HTMLElement>('[data-slot=\"timeline-commits\"]')!;\n\t\tlet commits = group.querySelectorAll<HTMLElement>('[data-slot=\"timeline-commit\"]');\n\t\tlet first = commits[0]!;\n\t\tlet sha = first.querySelector<HTMLElement>('[data-slot=\"timeline-commit-sha\"]')!;\n\n\t\texpect(group.querySelectorAll('[data-slot=\"timeline-icon\"]')).toHaveLength(1);\n\t\texpect(commits).toHaveLength(2);\n\t\texpect(first.getBoundingClientRect().height).toBeLessThanOrEqual(32);\n\t\texpect(getComputedStyle(sha).fontFamily).toMatch(/mono/i);\n\t\texpect(sha.textContent).toBe(\"a1b2c3d\");\n\t\texpect(sha.getBoundingClientRect().right).toBeCloseTo(first.getBoundingClientRect().right, 0);\n\t\texpect(first.querySelector('[role=\"img\"]')!.getAttribute(\"aria-label\")).toBe(\"Checks passed\");\n\t\texpect(\n\t\t\tfirst\n\t\t\t\t.querySelector<HTMLAnchorElement>('[data-slot=\"timeline-commit-subject\"] a')!\n\t\t\t\t.getAttribute(\"href\"),\n\t\t).toBe(\"#a1b2c3d\");\n\t\texpect(commits[1]!.querySelector(\"a\")).toBeNull();\n\t});\n});\n"
|
|
14
|
+
"content": "/**\n * Lays Timeline out in a real browser: an ordered list whose rail runs through the centre\n * of every icon, a line per event, a comment card in the text column, and a \"N more\"\n * disclosure whose folded events open on the same rail, comment cards with an author header and\n * reactions, and a push's commits listed under one rail stop.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\nimport type { Handle } from \"remix/component\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { userEvent } from \"vitest/browser\";\n\nimport { Timeline } from \"@sdxc/ui/timeline\";\n\nimport \"@sdxc/ui/theme.css\";\n\n/** A 16px stand-in glyph. */\nfunction Glyph() {\n\treturn () => (\n\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\n/** Props {@link Event} reads. */\ninterface EventProps {\n\ttone?: Timeline.Tone;\n\tactor: string;\n\ttime: string;\n\tchildren: string;\n}\n\n/** A one-line event with a glyph on the rail, the shape most rows take. */\nfunction Event(handle: Handle<EventProps>) {\n\treturn () => (\n\t\t<Timeline.Event tone={handle.props.tone}>\n\t\t\t<Timeline.Icon>\n\t\t\t\t<Glyph />\n\t\t\t</Timeline.Icon>\n\t\t\t<Timeline.Line>\n\t\t\t\t<Timeline.Actor>{handle.props.actor}</Timeline.Actor>\n\t\t\t\t<Timeline.Description>{handle.props.children}</Timeline.Description>\n\t\t\t\t<Timeline.Time>{handle.props.time}</Timeline.Time>\n\t\t\t</Timeline.Line>\n\t\t</Timeline.Event>\n\t);\n}\n\n/** An incident's activity: opened, a folded run of checks, a comment, resolved. */\nfunction Incident() {\n\treturn () => (\n\t\t<Timeline aria-label=\"Activity\">\n\t\t\t<Event tone=\"danger\" actor=\"Uptime\" time=\"12m ago\">\n\t\t\t\topened the incident\n\t\t\t</Event>\n\t\t\t<Timeline.More>\n\t\t\t\t<Timeline.Summary>2 more events</Timeline.Summary>\n\t\t\t\t<Timeline.MoreList>\n\t\t\t\t\t<Event actor=\"Uptime\" time=\"11m ago\">\n\t\t\t\t\t\tchecked from Frankfurt\n\t\t\t\t\t</Event>\n\t\t\t\t\t<Event actor=\"Uptime\" time=\"10m ago\">\n\t\t\t\t\t\tchecked from Singapore\n\t\t\t\t\t</Event>\n\t\t\t\t</Timeline.MoreList>\n\t\t\t</Timeline.More>\n\t\t\t<Timeline.Event>\n\t\t\t\t<Timeline.Line>\n\t\t\t\t\t<Timeline.Actor>Ana Souza</Timeline.Actor>\n\t\t\t\t\t<Timeline.Description>commented</Timeline.Description>\n\t\t\t\t\t<Timeline.Time>8m ago</Timeline.Time>\n\t\t\t\t</Timeline.Line>\n\t\t\t\t<Timeline.Body>\n\t\t\t\t\t<p>Rolling back the 14:02 deploy.</p>\n\t\t\t\t</Timeline.Body>\n\t\t\t\t<Timeline.Icon>\n\t\t\t\t\t<Glyph />\n\t\t\t\t</Timeline.Icon>\n\t\t\t</Timeline.Event>\n\t\t\t<Event tone=\"success\" actor=\"Ana Souza\" time=\"2m ago\">\n\t\t\t\tresolved the incident\n\t\t\t</Event>\n\t\t</Timeline>\n\t);\n}\n\n/** Mounts the incident timeline in a 480px host. */\nfunction mount(): HTMLElement {\n\tlet host = document.createElement(\"div\");\n\thost.style.width = \"480px\";\n\tdocument.body.appendChild(host);\n\trender(<Incident />, { container: host });\n\treturn host;\n}\n\n/** Horizontal centre of a box. */\nfunction centerX(element: Element): number {\n\tlet box = element.getBoundingClientRect();\n\treturn box.left + box.width / 2;\n}\n\nafterEach(() => {\n\tdocument.body.replaceChildren();\n});\n\ndescribe(\"Timeline\", () => {\n\ttest(\"is an ordered list of events\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\n\t\texpect(list.getAttribute(\"aria-label\")).toBe(\"Activity\");\n\t\texpect(list.querySelectorAll(\":scope > li\")).toHaveLength(4);\n\t});\n\n\ttest(\"runs a 2px rail through the centre of every 16px icon\", () => {\n\t\tlet host = mount();\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(rail.width).toBe(\"2px\");\n\t\tfor (let icon of host.querySelectorAll('[data-slot=\"timeline-icon\"]')) {\n\t\t\tif (icon.getClientRects().length === 0) continue;\n\t\t\texpect(centerX(icon)).toBeCloseTo(railCenter, 0);\n\t\t\texpect(icon.querySelector(\"svg\")!.getBoundingClientRect().width).toBe(16);\n\t\t}\n\t});\n\n\ttest(\"tones each icon by what happened\", () => {\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-danger-600\", \"rgb(220, 38, 38)\");\n\t\tdocument.documentElement.style.setProperty(\"--ui-color-success-600\", \"rgb(22, 163, 74)\");\n\t\tlet host = mount();\n\t\tlet [opened] = host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]');\n\t\tlet resolved = [...host.querySelectorAll<HTMLElement>('[data-slot=\"timeline-icon\"]')].at(-1)!;\n\n\t\texpect(getComputedStyle(opened!).color).toBe(\"rgb(220, 38, 38)\");\n\t\texpect(getComputedStyle(resolved).color).toBe(\"rgb(22, 163, 74)\");\n\t});\n\n\ttest(\"keeps each event on one line with the actor in bold\", () => {\n\t\tlet host = mount();\n\t\tlet line = host.querySelector<HTMLElement>('[data-slot=\"timeline-line\"]')!;\n\t\tlet actor = line.querySelector('[data-slot=\"timeline-actor\"]')!;\n\n\t\texpect(line.getBoundingClientRect().height).toBeLessThanOrEqual(24);\n\t\texpect(Number(getComputedStyle(actor).fontWeight)).toBeGreaterThanOrEqual(600);\n\t});\n\n\ttest(\"sets a comment as a card in the text column\", () => {\n\t\tlet host = mount();\n\t\tlet body = host.querySelector<HTMLElement>('[data-slot=\"timeline-body\"]')!;\n\t\tlet line = body.parentElement!.querySelector('[data-slot=\"timeline-line\"]')!;\n\n\t\texpect(body.getBoundingClientRect().left).toBeCloseTo(line.getBoundingClientRect().left, 0);\n\t\texpect(getComputedStyle(body).borderTopWidth).toBe(\"1px\");\n\t});\n\n\ttest(\"folds quiet events behind a disclosure that opens them on the same rail\", async () => {\n\t\tlet host = mount();\n\t\tlet details = host.querySelector(\"details\")!;\n\t\tlet summary = details.querySelector(\"summary\")!;\n\t\tlet folded = details.querySelectorAll<HTMLElement>('[data-slot=\"timeline-event\"]');\n\t\tlet first = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\n\t\texpect(summary.textContent).toBe(\"2 more events\");\n\t\texpect(folded[0]!.checkVisibility()).toBe(false);\n\n\t\tawait userEvent.click(summary);\n\n\t\texpect(details.open).toBe(true);\n\t\texpect(folded[0]!.checkVisibility()).toBe(true);\n\t\tlet icon = folded[0]!.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\texpect(centerX(icon)).toBeCloseTo(centerX(first), 0);\n\t});\n\n\ttest(\"sets a comment as a card with the author's avatar on the rail\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline aria-label=\"Conversation\">\n\t\t\t\t<Event actor=\"ana\" time=\"3h ago\">\n\t\t\t\t\topened this pull request\n\t\t\t\t</Event>\n\t\t\t\t<Timeline.Comment id=\"comment-1\">\n\t\t\t\t\t<Timeline.Avatar>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-avatar\n\t\t\t\t\t\t\tstyle=\"display:block;width:20px;height:20px;border-radius:50%;background:gray\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Timeline.Avatar>\n\t\t\t\t\t<Timeline.Card>\n\t\t\t\t\t\t<Timeline.Header>\n\t\t\t\t\t\t\t<Timeline.Line>\n\t\t\t\t\t\t\t\t<Timeline.Actor>ana</Timeline.Actor>\n\t\t\t\t\t\t\t\t<Timeline.Description>commented</Timeline.Description>\n\t\t\t\t\t\t\t\t<Timeline.Time>2h ago</Timeline.Time>\n\t\t\t\t\t\t\t</Timeline.Line>\n\t\t\t\t\t\t\t<Timeline.Menu>\n\t\t\t\t\t\t\t\t<button type=\"button\" aria-label=\"Comment actions\">\n\t\t\t\t\t\t\t\t\t⋯\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</Timeline.Menu>\n\t\t\t\t\t\t</Timeline.Header>\n\t\t\t\t\t\t<Timeline.Body>\n\t\t\t\t\t\t\t<p>Looks good to me.</p>\n\t\t\t\t\t\t</Timeline.Body>\n\t\t\t\t\t\t<Timeline.Reactions>\n\t\t\t\t\t\t\t<button type=\"button\">👍 2</button>\n\t\t\t\t\t\t</Timeline.Reactions>\n\t\t\t\t\t</Timeline.Card>\n\t\t\t\t</Timeline.Comment>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet list = host.querySelector(\"ol\")!;\n\t\tlet comment = host.querySelector<HTMLElement>('[data-slot=\"timeline-comment\"]')!;\n\t\tlet header = comment.querySelector<HTMLElement>('[data-slot=\"timeline-comment-header\"]')!;\n\t\tlet card = comment.querySelector<HTMLElement>('[data-slot=\"timeline-card\"]')!;\n\t\tlet avatar = comment.querySelector<HTMLElement>('[data-slot=\"timeline-avatar\"]')!;\n\t\tlet icon = host.querySelector('[data-slot=\"timeline-icon\"]')!;\n\t\tlet menu = header.querySelector(\"button\")!;\n\t\tlet rail = getComputedStyle(list, \"::before\");\n\t\tlet railCenter = list.getBoundingClientRect().left + parseFloat(rail.left) + 1;\n\n\t\texpect(comment.id).toBe(\"comment-1\");\n\t\texpect(centerX(avatar)).toBeCloseTo(railCenter, 0);\n\t\texpect(centerX(avatar)).toBeCloseTo(centerX(icon), 0);\n\t\texpect(getComputedStyle(card).borderTopWidth).toBe(\"1px\");\n\t\texpect(header.textContent).toContain(\"ana\");\n\t\texpect(header.textContent).toContain(\"commented\");\n\t\texpect(header.textContent).toContain(\"2h ago\");\n\t\texpect(menu.getBoundingClientRect().right).toBeCloseTo(\n\t\t\theader.getBoundingClientRect().right - 12,\n\t\t\t0,\n\t\t);\n\t\texpect(card.querySelector('[data-slot=\"timeline-body\"] p')!.textContent).toBe(\n\t\t\t\"Looks good to me.\",\n\t\t);\n\t\tlet reactions = card.querySelector<HTMLElement>('[data-slot=\"timeline-reactions\"]')!;\n\t\texpect(reactions.getBoundingClientRect().top).toBeGreaterThan(\n\t\t\tcard.querySelector('[data-slot=\"timeline-body\"]')!.getBoundingClientRect().top,\n\t\t);\n\t});\n\n\ttest(\"lists a push's commits under one rail stop, each with its check and short sha\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline aria-label=\"Conversation\">\n\t\t\t\t<Timeline.Commits>\n\t\t\t\t\t<Timeline.Icon>\n\t\t\t\t\t\t<Glyph />\n\t\t\t\t\t</Timeline.Icon>\n\t\t\t\t\t<Timeline.Line>\n\t\t\t\t\t\t<Timeline.Actor>ana</Timeline.Actor>\n\t\t\t\t\t\t<Timeline.Description>added 2 commits</Timeline.Description>\n\t\t\t\t\t\t<Timeline.Time>1h ago</Timeline.Time>\n\t\t\t\t\t</Timeline.Line>\n\t\t\t\t\t<Timeline.CommitList>\n\t\t\t\t\t\t<Timeline.Commit href=\"#a1b2c3d\">\n\t\t\t\t\t\t\t<Timeline.Subject>\n\t\t\t\t\t\t\t\tParse ANSI colours in job logs and keep long subjects to a single truncated line\n\t\t\t\t\t\t\t</Timeline.Subject>\n\t\t\t\t\t\t\t<Timeline.Check>\n\t\t\t\t\t\t\t\t<span role=\"img\" aria-label=\"Checks passed\">\n\t\t\t\t\t\t\t\t\t✓\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</Timeline.Check>\n\t\t\t\t\t\t\t<Timeline.Sha>a1b2c3d</Timeline.Sha>\n\t\t\t\t\t\t</Timeline.Commit>\n\t\t\t\t\t\t<Timeline.Commit>\n\t\t\t\t\t\t\t<Timeline.Subject>Fix the timestamp toggle</Timeline.Subject>\n\t\t\t\t\t\t\t<Timeline.Sha>e4f5a6b</Timeline.Sha>\n\t\t\t\t\t\t</Timeline.Commit>\n\t\t\t\t\t</Timeline.CommitList>\n\t\t\t\t</Timeline.Commits>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet group = host.querySelector<HTMLElement>('[data-slot=\"timeline-commits\"]')!;\n\t\tlet commits = group.querySelectorAll<HTMLElement>('[data-slot=\"timeline-commit\"]');\n\t\tlet first = commits[0]!;\n\t\tlet sha = first.querySelector<HTMLElement>('[data-slot=\"timeline-commit-sha\"]')!;\n\n\t\texpect(group.querySelectorAll('[data-slot=\"timeline-icon\"]')).toHaveLength(1);\n\t\texpect(commits).toHaveLength(2);\n\t\texpect(first.getBoundingClientRect().height).toBeLessThanOrEqual(32);\n\t\texpect(getComputedStyle(sha).fontFamily).toMatch(/mono/i);\n\t\texpect(sha.textContent).toBe(\"a1b2c3d\");\n\t\texpect(sha.getBoundingClientRect().right).toBeCloseTo(first.getBoundingClientRect().right, 0);\n\t\texpect(first.querySelector('[role=\"img\"]')!.getAttribute(\"aria-label\")).toBe(\"Checks passed\");\n\t\texpect(\n\t\t\tfirst\n\t\t\t\t.querySelector<HTMLAnchorElement>('[data-slot=\"timeline-commit-subject\"] a')!\n\t\t\t\t.getAttribute(\"href\"),\n\t\t).toBe(\"#a1b2c3d\");\n\t\texpect(commits[1]!.querySelector(\"a\")).toBeNull();\n\t});\n\n\ttest(\"draws parts alone with their defaults and leaves no gap for a missing part\", () => {\n\t\tlet host = document.createElement(\"div\");\n\t\thost.style.width = \"480px\";\n\t\tdocument.body.appendChild(host);\n\t\trender(\n\t\t\t<Timeline>\n\t\t\t\t<Timeline.Event>\n\t\t\t\t\t<Timeline.Line>\n\t\t\t\t\t\t<Timeline.Actor>ana</Timeline.Actor>\n\t\t\t\t\t</Timeline.Line>\n\t\t\t\t</Timeline.Event>\n\t\t\t\t<li>\n\t\t\t\t\t<Timeline.Icon>\n\t\t\t\t\t\t<Glyph />\n\t\t\t\t\t</Timeline.Icon>\n\t\t\t\t\t<Timeline.Body>\n\t\t\t\t\t\t<p>Alone</p>\n\t\t\t\t\t</Timeline.Body>\n\t\t\t\t</li>\n\t\t\t</Timeline>,\n\t\t\t{ container: host },\n\t\t);\n\t\tlet event = host.querySelector<HTMLElement>('[data-slot=\"timeline-event\"]')!;\n\t\tlet icon = host.querySelector<HTMLElement>('[data-slot=\"timeline-icon\"]')!;\n\t\tlet body = host.querySelector<HTMLElement>('[data-slot=\"timeline-body\"]')!;\n\n\t\texpect(event.children).toHaveLength(1);\n\t\texpect(event.querySelector('[data-slot=\"timeline-description\"]')).toBeNull();\n\t\texpect(icon.dataset.tone).toBe(\"neutral\");\n\t\texpect(getComputedStyle(body).borderTopWidth).toBe(\"1px\");\n\t});\n});\n"
|
|
15
15
|
}
|
|
16
16
|
}
|
package/registry/ui/typeset.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typeset",
|
|
3
|
-
"changedIn": "2026.11.
|
|
3
|
+
"changedIn": "2026.11.29",
|
|
4
4
|
"dependencies": [],
|
|
5
5
|
"exports": [
|
|
6
6
|
"Typeset"
|
|
7
7
|
],
|
|
8
8
|
"source": {
|
|
9
9
|
"path": "typeset.tsx",
|
|
10
|
-
"content": "/**\n * A typography layer wrapping already-rendered markdown or HTML content and\n * supplying every size, weight, spacing, and color decision through three\n * custom properties: `--ui-typeset-size`, `--ui-typeset-leading`, and\n * `--ui-typeset-flow`. `data-preset` swaps all three for a different rhythm\n * context; `data-not-typeset` opts a subtree out of the whole layer. Flow spacing reaches\n * through a `HeadingScope` wrapper and leaves a component's `data-slot` list items to it.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { keyframes } from \"@sdxc/u/animation\";\nimport { bg, border, borderEdge, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw, mergeMix } from \"@sdxc/u/general\";\nimport { block, container } from \"@sdxc/u/layout\";\nimport { overflow, overflowBlock, overflowInline } from \"@sdxc/u/overflow\";\nimport { at } from \"@sdxc/u/responsive\";\nimport { is, maxIs, pb, pi, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport {\n\tbalance,\n\tleading,\n\tpretty,\n\ttabularNums,\n\ttextAlign,\n\ttextDecoration,\n\ttracking,\n\tweight,\n} from \"@sdxc/u/typography\";\nimport { css } from \"remix/component\";\n\nimport { easings } from \"@sdxc/ui/animations\";\n\n/**\n * Named container {@link Typeset} declares on its own host, so its wide-table\n * handling can grant roomier cell and code-block padding once there's enough\n * space, instead of reading the viewport.\n */\nconst CONTAINER_NAME = \"ui-typeset\";\n\n/** Matches an element that is neither a `data-not-typeset` subtree's root nor inside one. */\nconst OUTSIDE_OPT_OUT = \":not(:where([data-not-typeset], [data-not-typeset] *))\";\n\n/** Rhythm context {@link Typeset} falls back to when `preset` is omitted. */\nconst DEFAULT_PRESET: Typeset.Preset = \"docs\";\n\n/**\n * Body size each preset writes to `--ui-typeset-size`. On a 16px root, `docs`\n * is 18px and `reading` is 20px, so long-form copy is large enough to read;\n * `chat` is 15px for a turn taken in a denser column.\n */\nconst PRESET_BODY_SIZE: Record<Typeset.Preset, string> = {\n\tdocs: \"1.125rem\",\n\tchat: \"0.9375rem\",\n\treading: \"1.25rem\",\n};\n\n/**\n * Size body copy and headings compute from. Clearing `--ui-typeset-size`\n * still leaves the docs body, which is the preset a host uses by default.\n */\nconst TYPESET_SIZE = `var(--ui-typeset-size, ${PRESET_BODY_SIZE.docs})`;\n\n/** CSS length each edge of a wide table's own fade tapers over. */\nconst TABLE_FADE_SIZE = \"2.5rem\";\n\n/**\n * Custom property carrying the gradient direction a wide table's edge fade\n * paints along, mirrored under `:dir(rtl)` so the same mask string works in\n * both writing directions without a second, mirrored gradient.\n */\nconst TABLE_FADE_DIRECTION_PROPERTY = \"--ui-typeset-table-fade-direction\";\n\n/**\n * `@keyframes` name backing a wide table's scroll-linked edge fade; the\n * `keyframes()` call using it must stay a top-level mixin rather than nested\n * under the table selector, since the serializer only recognizes stops there.\n */\nconst TABLE_FADE_KEYFRAMES_NAME = \"ui-typeset-table-fade\";\n\n/** Proportion of a wide table's own scroll range its edge fade ramps across. */\nconst TABLE_FADE_RAMP_PERCENT = 10;\n\n/** The style shape {@link css} accepts, reused so a keyframes block can be built ahead of the call. */\ntype Styles = Parameters<typeof css>[0];\n\n/**\n * Builds the four-stop mask-image gradient a wide table's edge fade paints:\n * a leading stop, two middle stops marking where the faded band meets the\n * fully opaque middle, and a trailing stop; only the middle stops move.\n */\nfunction tableFadeMask(startStop: string, endStop: string): string {\n\treturn `linear-gradient(to var(${TABLE_FADE_DIRECTION_PROPERTY}, right), transparent 0%, black ${startStop}, black ${endStop}, transparent 100%)`;\n}\n\nconst TABLE_FADE_SETTLED_STOP = `calc(100% - ${TABLE_FADE_SIZE})`;\nconst TABLE_FADE_SETTLED_MASK = tableFadeMask(TABLE_FADE_SIZE, TABLE_FADE_SETTLED_STOP);\n\n/**\n * Stops the wide-table edge fade animates through: fully faded on the leading\n * edge at rest, settled on both edges across the long middle of the scroll\n * range, and fully faded on the trailing edge at the end.\n */\nconst TABLE_FADE_KEYFRAMES: Record<string, Styles> = {\n\t\"0%\": { maskImage: tableFadeMask(\"0%\", TABLE_FADE_SETTLED_STOP) },\n\t[`${TABLE_FADE_RAMP_PERCENT}%, ${100 - TABLE_FADE_RAMP_PERCENT}%`]: {\n\t\tmaskImage: TABLE_FADE_SETTLED_MASK,\n\t},\n\t\"100%\": { maskImage: tableFadeMask(TABLE_FADE_SIZE, \"100%\") },\n};\n\n/**\n * Prop types for {@link Typeset}.\n */\nexport namespace Typeset {\n\t/**\n\t * Rhythm context. `\"docs\"` sets the body at 18px, the size for a page meant\n\t * to be read. `\"reading\"` sets it at 20px for a long-form article. `\"chat\"`\n\t * sets it at 15px for a turn in a denser column.\n\t */\n\texport type Preset = \"docs\" | \"chat\" | \"reading\";\n\n\t/**\n\t * Every native `<div>` attribute plus `mix`. `preset` defaults to\n\t * {@link DEFAULT_PRESET}; setting a `--ui-typeset-*` property directly\n\t * overrides it, and `data-not-typeset` opts a subtree out entirely.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Rhythm context. Defaults to {@link DEFAULT_PRESET}. */\n\t\tpreset?: Preset;\n\t}\n}\n\n/**\n * Narrows a descendant rule to elements outside every `data-not-typeset` subtree. Each rule\n * the layer writes lands in a cascade layer of its own, so an opt-out has to be part of the\n * rule's selector; the exclusion adds no specificity, and it sits ahead of a pseudo-element.\n */\nfunction prose(selector: `&${string}`): `&${string}` {\n\tlet pseudoElement = selector.indexOf(\"::\");\n\tif (pseudoElement === -1) return `${selector}${OUTSIDE_OPT_OUT}`;\n\treturn `&${selector.slice(1, pseudoElement)}${OUTSIDE_OPT_OUT}${selector.slice(pseudoElement)}`;\n}\n\n/**\n * Renders a `<div>` that sizes and colors already-rendered markdown or HTML\n * content through `--ui-typeset-size`, `--ui-typeset-leading`, and\n * `--ui-typeset-flow`, computing heading sizes via `calc()` off one shared value.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the typeset layer's markup.\n * @example\n * <Typeset preset=\"reading\">{renderedArticleHtml}</Typeset>\n * @example\n * <Typeset preset=\"chat\">\n * \t<p>{t(\"assistant.reply\")}</p>\n * </Typeset>\n * @example\n * <Typeset>\n * \t<p>{t(\"docs.intro\")}</p>\n * \t<div data-not-typeset>\n * \t\t<EmbeddedWidget />\n * \t</div>\n * </Typeset>\n */\nexport function Typeset(handle: Handle<Typeset.Props>) {\n\treturn () => {\n\t\tlet { preset, mix, ...rest } = handle.props;\n\t\tlet resolvedPreset = preset ?? DEFAULT_PRESET;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-preset={resolvedPreset}\n\t\t\t\tdata-slot=\"typeset\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\t\tkeyframes(TABLE_FADE_KEYFRAMES_NAME, TABLE_FADE_KEYFRAMES),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tfontSize: TYPESET_SIZE,\n\t\t\t\t\t\t\tlineHeight: \"var(--ui-typeset-leading, 1.75)\",\n\n\t\t\t\t\t\t\t'&[data-preset=\"docs\"]': {\n\t\t\t\t\t\t\t\t\"--ui-typeset-size\": PRESET_BODY_SIZE.docs,\n\t\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.75\",\n\t\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"1.25em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'&[data-preset=\"chat\"]': {\n\t\t\t\t\t\t\t\t\"--ui-typeset-size\": PRESET_BODY_SIZE.chat,\n\t\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.5\",\n\t\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"0.75em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'&[data-preset=\"reading\"]': {\n\t\t\t\t\t\t\t\t\"--ui-typeset-size\": PRESET_BODY_SIZE.reading,\n\t\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.8\",\n\t\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"1.5em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& > * + *\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& > * + div[data-heading-level] > :first-child\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(blockquote, li:not([data-slot])) > * + *\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h1)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 2)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h2)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 1.5)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h3)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 1.25)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h4)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 1.125)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h5)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: TYPESET_SIZE,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h6)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 0.875)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(ul)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tlistStyleType: \"disc\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(ol)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tlistStyleType: \"decimal\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(ul, ol) :where(ul)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tlistStyleType: \"circle\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(blockquote)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontStyle: \"italic\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(a)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttextUnderlineOffset: \"0.15em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(a):hover\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttextDecorationThickness: \"2px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(em, i)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontStyle: \"italic\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(code)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(pre)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(pre code)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tpadding: \"0\",\n\t\t\t\t\t\t\t\tfontSize: \"1em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(table)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tborderCollapse: \"collapse\",\n\t\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\t\tscrollbarWidth: \"thin\",\n\t\t\t\t\t\t\t\tscrollbarGutter: \"stable\",\n\n\t\t\t\t\t\t\t\t[TABLE_FADE_DIRECTION_PROPERTY]: \"right\",\n\t\t\t\t\t\t\t\tmaskImage: \"none\",\n\t\t\t\t\t\t\t\t\"-webkit-mask-image\": \"none\",\n\n\t\t\t\t\t\t\t\t\"&:dir(rtl)\": {\n\t\t\t\t\t\t\t\t\t[TABLE_FADE_DIRECTION_PROPERTY]: \"left\",\n\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar\": {\n\t\t\t\t\t\t\t\t\twidth: \"0.75rem\",\n\t\t\t\t\t\t\t\t\theight: \"0.75rem\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar-track\": {\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar-thumb\": {\n\t\t\t\t\t\t\t\t\tborderRadius: \"var(--ui-radius-full, 9999px)\",\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-border)\",\n\t\t\t\t\t\t\t\t\tborderWidth: \"3px\",\n\t\t\t\t\t\t\t\t\tborderStyle: \"solid\",\n\t\t\t\t\t\t\t\t\tborderColor: \"transparent\",\n\t\t\t\t\t\t\t\t\tbackgroundClip: \"content-box\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar-thumb:hover\": {\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-border-strong)\",\n\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\"@supports (animation-timeline: scroll())\": {\n\t\t\t\t\t\t\t\t\tanimationName: TABLE_FADE_KEYFRAMES_NAME,\n\t\t\t\t\t\t\t\t\tanimationDuration: \"auto\",\n\t\t\t\t\t\t\t\t\tanimationTimingFunction: easings.linear,\n\t\t\t\t\t\t\t\t\tanimationFillMode: \"both\",\n\t\t\t\t\t\t\t\t\tanimationTimeline: \"scroll(self inline)\",\n\t\t\t\t\t\t\t\t\t\"@media (prefers-reduced-motion: reduce)\": {\n\t\t\t\t\t\t\t\t\t\tanimationName: \"none\",\n\t\t\t\t\t\t\t\t\t\tmaskImage: TABLE_FADE_SETTLED_MASK,\n\t\t\t\t\t\t\t\t\t\t\"-webkit-mask-image\": TABLE_FADE_SETTLED_MASK,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\n\t\t\t\t\t\tat(\"30rem\", CONTAINER_NAME, [\n\t\t\t\t\t\t\twhen(prose(\"& :where(th, td)\"), raw({ paddingInline: \"1em\" })),\n\t\t\t\t\t\t\twhen(prose(\"& :where(pre)\"), raw({ paddingInline: \"1.25em\" })),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(pre)\"), leading(1.6)),\n\n\t\t\t\t\t\twhen(prose(\"& :where(h1, h2, h3, h4, h5, h6)\"), [\n\t\t\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\t\t\tleading(1.25),\n\t\t\t\t\t\t\ttracking(\"tight\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\tbalance(),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(prose(\"& :where(h6)\"), fg(\"neutral\")),\n\n\t\t\t\t\t\twhen(prose(\"& :where(p, li, blockquote, dd)\"), pretty()),\n\n\t\t\t\t\t\twhen(prose(\"& :where(ul, ol)\"), pis(\"1.5em\")),\n\t\t\t\t\t\twhen(prose(\"& :where(li)::marker\"), fg(\"neutral.muted\")),\n\n\t\t\t\t\t\twhen(prose(\"& :where(blockquote)\"), [\n\t\t\t\t\t\t\tpis(\"1em\"),\n\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\tborderEdge(\"inline-start\", { color: \"neutral\", width: \"0.25em\" }),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(hr)\"),\n\t\t\t\t\t\t\tborderEdge(\"block-start\", { color: \"neutral\", width: \"1px\" }),\n\t\t\t\t\t\t),\n\n\t\t\t\t\t\twhen(prose(\"& :where(a)\"), [fg(\"brand\"), textDecoration(\"underline\")]),\n\t\t\t\t\t\twhen(prose(\"& :where(a):focus-visible\"), [\n\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\t\trounded(\"xs\"),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(strong, b)\"), [weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(code)\"), [\n\t\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\tpi(\"0.3em\"),\n\t\t\t\t\t\t\tpb(\"0.15em\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(prose(\"& :where(pre)\"), [\n\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\tpi(\"1em\"),\n\t\t\t\t\t\t\tpb(\"0.875em\"),\n\t\t\t\t\t\t\toverflowInline(\"auto\"),\n\t\t\t\t\t\t\toverflowBlock(\"hidden\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\toverscrollBehaviorInline: \"contain\",\n\t\t\t\t\t\t\t\toverscrollBehaviorX: \"contain\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A fenced block's `code` is an inline box, so the chip padding above would\n\t\t\t\t\t\t * apply at the start of the box alone and indent the block's first line\n\t\t\t\t\t\t * past every line under it. The block's own padding is the `pre`'s.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(prose(\"& :where(pre code)\"), [\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\tfg(\"inherit\"),\n\t\t\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\t\t\tpi(0),\n\t\t\t\t\t\t\tpb(0),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(table)\"), [\n\t\t\t\t\t\t\tblock(),\n\t\t\t\t\t\t\tis(\"max(100%, max-content)\"),\n\t\t\t\t\t\t\tmaxIs(\"full\"),\n\t\t\t\t\t\t\toverflow(\"auto\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(prose(\"& :where(th, td):not([align])\"), textAlign(\"start\")),\n\t\t\t\t\t\twhen(prose(\"& :where(th)\"), [weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\twhen(prose(\"& :where(th, td)\"), [\n\t\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\t\tpi(\"0.75em\"),\n\t\t\t\t\t\t\tpb(\"0.5em\"),\n\t\t\t\t\t\t\tborderEdge(\"block-end\", { color: \"neutral\", width: \"1px\" }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
10
|
+
"content": "/**\n * A typography layer wrapping already-rendered markdown or HTML content and\n * supplying every size, weight, spacing, and color decision through three\n * custom properties: `--ui-typeset-size`, `--ui-typeset-leading`, and\n * `--ui-typeset-flow`. `data-preset` swaps all three for a different rhythm\n * context; `data-not-typeset` opts a subtree out of the whole layer. Flow spacing reaches\n * through a `HeadingScope` wrapper and leaves a component's `data-slot` list items to it.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { keyframes } from \"@sdxc/u/animation\";\nimport { bg, border, borderEdge, fg, outline } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw, mergeMix } from \"@sdxc/u/general\";\nimport { block, container } from \"@sdxc/u/layout\";\nimport { overflow, overflowBlock, overflowInline } from \"@sdxc/u/overflow\";\nimport { at } from \"@sdxc/u/responsive\";\nimport { is, maxIs, pb, pi, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport {\n\tbalance,\n\tleading,\n\tpretty,\n\ttabularNums,\n\ttextAlign,\n\ttextDecoration,\n\ttracking,\n\tweight,\n} from \"@sdxc/u/typography\";\nimport { css } from \"remix/component\";\n\nimport { easings } from \"@sdxc/ui/animations\";\nimport { mergeStyle } from \"@sdxc/ui/utils\";\n\n/**\n * Named container {@link Typeset} declares on its own host, so its wide-table\n * handling can grant roomier cell and code-block padding once there's enough\n * space, instead of reading the viewport.\n */\nconst CONTAINER_NAME = \"ui-typeset\";\n\n/** Matches an element that is neither a `data-not-typeset` subtree's root nor inside one. */\nconst OUTSIDE_OPT_OUT = \":not(:where([data-not-typeset], [data-not-typeset] *))\";\n\n/** Rhythm context {@link Typeset} falls back to when `preset` is omitted. */\nconst DEFAULT_PRESET: Typeset.Preset = \"docs\";\n\n/**\n * Body size each preset writes to `--ui-typeset-size`. On a 16px root, `docs`\n * is 18px and `reading` is 20px, so long-form copy is large enough to read;\n * `chat` is 15px for a turn taken in a denser column.\n */\nconst PRESET_BODY_SIZE: Record<Typeset.Preset, string> = {\n\tdocs: \"1.125rem\",\n\tchat: \"0.9375rem\",\n\treading: \"1.25rem\",\n};\n\n/**\n * Size body copy and headings compute from. Clearing `--ui-typeset-size`\n * still leaves the docs body, which is the preset a host uses by default.\n */\nconst TYPESET_SIZE = `var(--ui-typeset-size, ${PRESET_BODY_SIZE.docs})`;\n\n/**\n * Space above and below a figure or callout set straight in the prose, wider than the flow\n * between paragraphs so a code block or an aside reads as set apart from the text around it.\n */\nconst BLOCK_GAP = `calc(${TYPESET_SIZE} * 1.75)`;\n\n/** CSS length each edge of a wide table's own fade tapers over. */\nconst TABLE_FADE_SIZE = \"2.5rem\";\n\n/**\n * Custom property carrying the gradient direction a wide table's edge fade\n * paints along, mirrored under `:dir(rtl)` so the same mask string works in\n * both writing directions without a second, mirrored gradient.\n */\nconst TABLE_FADE_DIRECTION_PROPERTY = \"--ui-typeset-table-fade-direction\";\n\n/**\n * `@keyframes` name backing a wide table's scroll-linked edge fade; the\n * `keyframes()` call using it must stay a top-level mixin rather than nested\n * under the table selector, since the serializer only recognizes stops there.\n */\nconst TABLE_FADE_KEYFRAMES_NAME = \"ui-typeset-table-fade\";\n\n/** Proportion of a wide table's own scroll range its edge fade ramps across. */\nconst TABLE_FADE_RAMP_PERCENT = 10;\n\n/** The style shape {@link css} accepts, reused so a keyframes block can be built ahead of the call. */\ntype Styles = Parameters<typeof css>[0];\n\n/**\n * Builds the four-stop mask-image gradient a wide table's edge fade paints:\n * a leading stop, two middle stops marking where the faded band meets the\n * fully opaque middle, and a trailing stop; only the middle stops move.\n */\nfunction tableFadeMask(startStop: string, endStop: string): string {\n\treturn `linear-gradient(to var(${TABLE_FADE_DIRECTION_PROPERTY}, right), transparent 0%, black ${startStop}, black ${endStop}, transparent 100%)`;\n}\n\nconst TABLE_FADE_SETTLED_STOP = `calc(100% - ${TABLE_FADE_SIZE})`;\nconst TABLE_FADE_SETTLED_MASK = tableFadeMask(TABLE_FADE_SIZE, TABLE_FADE_SETTLED_STOP);\n\n/**\n * Stops the wide-table edge fade animates through: fully faded on the leading\n * edge at rest, settled on both edges across the long middle of the scroll\n * range, and fully faded on the trailing edge at the end.\n */\nconst TABLE_FADE_KEYFRAMES: Record<string, Styles> = {\n\t\"0%\": { maskImage: tableFadeMask(\"0%\", TABLE_FADE_SETTLED_STOP) },\n\t[`${TABLE_FADE_RAMP_PERCENT}%, ${100 - TABLE_FADE_RAMP_PERCENT}%`]: {\n\t\tmaskImage: TABLE_FADE_SETTLED_MASK,\n\t},\n\t\"100%\": { maskImage: tableFadeMask(TABLE_FADE_SIZE, \"100%\") },\n};\n\n/**\n * Prop types for {@link Typeset}.\n */\nexport namespace Typeset {\n\t/**\n\t * Rhythm context. `\"docs\"` sets the body at 18px, the size for a page meant\n\t * to be read. `\"reading\"` sets it at 20px for a long-form article. `\"chat\"`\n\t * sets it at 15px for a turn in a denser column.\n\t */\n\texport type Preset = \"docs\" | \"chat\" | \"reading\";\n\n\t/**\n\t * Every native `<div>` attribute plus `mix`. `preset` defaults to\n\t * {@link DEFAULT_PRESET}; setting a `--ui-typeset-*` property directly\n\t * overrides it, and `data-not-typeset` opts a subtree out entirely.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Rhythm context. Defaults to {@link DEFAULT_PRESET}. */\n\t\tpreset?: Preset;\n\t\t/**\n\t\t * Body size as a CSS length, written to `--ui-typeset-size` in place of the preset's;\n\t\t * headings and every em-based space scale from it.\n\t\t */\n\t\tsize?: string;\n\t}\n}\n\n/**\n * Narrows a descendant rule to elements outside every `data-not-typeset` subtree. Each rule\n * the layer writes lands in a cascade layer of its own, so an opt-out has to be part of the\n * rule's selector; the exclusion adds no specificity, and it sits ahead of a pseudo-element.\n */\nfunction prose(selector: `&${string}`): `&${string}` {\n\tlet pseudoElement = selector.indexOf(\"::\");\n\tif (pseudoElement === -1) return `${selector}${OUTSIDE_OPT_OUT}`;\n\treturn `&${selector.slice(1, pseudoElement)}${OUTSIDE_OPT_OUT}${selector.slice(pseudoElement)}`;\n}\n\n/**\n * Renders a `<div>` that sizes and colors already-rendered markdown or HTML\n * content through `--ui-typeset-size`, `--ui-typeset-leading`, and\n * `--ui-typeset-flow`, computing heading sizes via `calc()` off one shared value.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the typeset layer's markup.\n * @example\n * <Typeset preset=\"reading\">{renderedArticleHtml}</Typeset>\n * @example\n * <Typeset preset=\"chat\">\n * \t<p>{t(\"assistant.reply\")}</p>\n * </Typeset>\n * @example\n * <Typeset>\n * \t<p>{t(\"docs.intro\")}</p>\n * \t<div data-not-typeset>\n * \t\t<EmbeddedWidget />\n * \t</div>\n * </Typeset>\n */\nexport function Typeset(handle: Handle<Typeset.Props>) {\n\treturn () => {\n\t\tlet { preset, size, style, mix, ...rest } = handle.props;\n\t\tlet resolvedPreset = preset ?? DEFAULT_PRESET;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tstyle={size === undefined ? style : mergeStyle(style, { \"--ui-typeset-size\": size })}\n\t\t\t\tdata-preset={resolvedPreset}\n\t\t\t\tdata-slot=\"typeset\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\t\tkeyframes(TABLE_FADE_KEYFRAMES_NAME, TABLE_FADE_KEYFRAMES),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tfontSize: TYPESET_SIZE,\n\t\t\t\t\t\t\tlineHeight: \"var(--ui-typeset-leading, 1.75)\",\n\n\t\t\t\t\t\t\t'&[data-preset=\"docs\"]': {\n\t\t\t\t\t\t\t\t\"--ui-typeset-size\": PRESET_BODY_SIZE.docs,\n\t\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.75\",\n\t\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"1.25em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'&[data-preset=\"chat\"]': {\n\t\t\t\t\t\t\t\t\"--ui-typeset-size\": PRESET_BODY_SIZE.chat,\n\t\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.5\",\n\t\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"0.75em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'&[data-preset=\"reading\"]': {\n\t\t\t\t\t\t\t\t\"--ui-typeset-size\": PRESET_BODY_SIZE.reading,\n\t\t\t\t\t\t\t\t\"--ui-typeset-leading\": \"1.8\",\n\t\t\t\t\t\t\t\t\"--ui-typeset-flow\": \"1.5em\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& > * + *\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& > * + div[data-heading-level] > :first-child\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose('& > :where(figure, [data-slot=\"callout\"])'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlock: BLOCK_GAP,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose('& > :where(figure, [data-slot=\"callout\"]):first-child'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"0\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose('& > :where(figure, [data-slot=\"callout\"]):last-child'),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockEnd: \"0\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(blockquote, li:not([data-slot])) > * + *\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tmarginBlockStart: \"var(--ui-typeset-flow, 1.25em)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h1)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 2)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h2)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 1.5)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h3)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 1.25)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h4)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 1.125)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h5)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: TYPESET_SIZE,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(h6)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: `calc(${TYPESET_SIZE} * 0.875)`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(ul)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tlistStyleType: \"disc\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(ol)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tlistStyleType: \"decimal\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(ul, ol) :where(ul)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tlistStyleType: \"circle\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(blockquote)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontStyle: \"italic\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(a)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttextUnderlineOffset: \"0.15em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(a):hover\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttextDecorationThickness: \"2px\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(em, i)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontStyle: \"italic\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(code)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(pre)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(pre code)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tpadding: \"0\",\n\t\t\t\t\t\t\t\tfontSize: \"1em\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(table)\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tborderCollapse: \"collapse\",\n\t\t\t\t\t\t\t\tfontSize: \"0.875em\",\n\t\t\t\t\t\t\t\tscrollbarWidth: \"thin\",\n\t\t\t\t\t\t\t\tscrollbarGutter: \"stable\",\n\n\t\t\t\t\t\t\t\t[TABLE_FADE_DIRECTION_PROPERTY]: \"right\",\n\t\t\t\t\t\t\t\tmaskImage: \"none\",\n\t\t\t\t\t\t\t\t\"-webkit-mask-image\": \"none\",\n\n\t\t\t\t\t\t\t\t\"&:dir(rtl)\": {\n\t\t\t\t\t\t\t\t\t[TABLE_FADE_DIRECTION_PROPERTY]: \"left\",\n\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar\": {\n\t\t\t\t\t\t\t\t\twidth: \"0.75rem\",\n\t\t\t\t\t\t\t\t\theight: \"0.75rem\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar-track\": {\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar-thumb\": {\n\t\t\t\t\t\t\t\t\tborderRadius: \"var(--ui-radius-full, 9999px)\",\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-border)\",\n\t\t\t\t\t\t\t\t\tborderWidth: \"3px\",\n\t\t\t\t\t\t\t\t\tborderStyle: \"solid\",\n\t\t\t\t\t\t\t\t\tborderColor: \"transparent\",\n\t\t\t\t\t\t\t\t\tbackgroundClip: \"content-box\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"&::-webkit-scrollbar-thumb:hover\": {\n\t\t\t\t\t\t\t\t\tbackgroundColor: \"var(--ui-neutral-border-strong)\",\n\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\"@supports (animation-timeline: scroll())\": {\n\t\t\t\t\t\t\t\t\tanimationName: TABLE_FADE_KEYFRAMES_NAME,\n\t\t\t\t\t\t\t\t\tanimationDuration: \"auto\",\n\t\t\t\t\t\t\t\t\tanimationTimingFunction: easings.linear,\n\t\t\t\t\t\t\t\t\tanimationFillMode: \"both\",\n\t\t\t\t\t\t\t\t\tanimationTimeline: \"scroll(self inline)\",\n\t\t\t\t\t\t\t\t\t\"@media (prefers-reduced-motion: reduce)\": {\n\t\t\t\t\t\t\t\t\t\tanimationName: \"none\",\n\t\t\t\t\t\t\t\t\t\tmaskImage: TABLE_FADE_SETTLED_MASK,\n\t\t\t\t\t\t\t\t\t\t\"-webkit-mask-image\": TABLE_FADE_SETTLED_MASK,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\n\t\t\t\t\t\tat(\"30rem\", CONTAINER_NAME, [\n\t\t\t\t\t\t\twhen(prose(\"& :where(th, td)\"), raw({ paddingInline: \"1em\" })),\n\t\t\t\t\t\t\twhen(prose(\"& :where(pre)\"), raw({ paddingInline: \"1.25em\" })),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(pre)\"), leading(1.6)),\n\n\t\t\t\t\t\twhen(prose(\"& :where(h1, h2, h3, h4, h5, h6)\"), [\n\t\t\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\t\t\tleading(1.25),\n\t\t\t\t\t\t\ttracking(\"tight\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\tbalance(),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(prose(\"& :where(h6)\"), fg(\"neutral\")),\n\n\t\t\t\t\t\twhen(prose(\"& :where(p, li, blockquote, dd)\"), pretty()),\n\n\t\t\t\t\t\twhen(prose(\"& :where(ul, ol)\"), pis(\"1.5em\")),\n\t\t\t\t\t\twhen(prose(\"& :where(li)::marker\"), fg(\"neutral.muted\")),\n\n\t\t\t\t\t\twhen(prose(\"& :where(blockquote)\"), [\n\t\t\t\t\t\t\tpis(\"1em\"),\n\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\tborderEdge(\"inline-start\", { color: \"neutral\", width: \"0.25em\" }),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(\n\t\t\t\t\t\t\tprose(\"& :where(hr)\"),\n\t\t\t\t\t\t\tborderEdge(\"block-start\", { color: \"neutral\", width: \"1px\" }),\n\t\t\t\t\t\t),\n\n\t\t\t\t\t\twhen(prose(\"& :where(a)\"), [fg(\"brand\"), textDecoration(\"underline\")]),\n\t\t\t\t\t\twhen(prose(\"& :where(a):focus-visible\"), [\n\t\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\t\trounded(\"xs\"),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(strong, b)\"), [weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(code)\"), [\n\t\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\tpi(\"0.3em\"),\n\t\t\t\t\t\t\tpb(\"0.15em\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(prose(\"& :where(pre)\"), [\n\t\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\t\tborder({ color: \"neutral.border\", width: 1 }),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t\tpi(\"1em\"),\n\t\t\t\t\t\t\tpb(\"0.875em\"),\n\t\t\t\t\t\t\toverflowInline(\"auto\"),\n\t\t\t\t\t\t\toverflowBlock(\"hidden\"),\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\toverscrollBehaviorInline: \"contain\",\n\t\t\t\t\t\t\t\toverscrollBehaviorX: \"contain\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * A fenced block's `code` is an inline box, so the chip padding above would\n\t\t\t\t\t\t * apply at the start of the box alone and indent the block's first line\n\t\t\t\t\t\t * past every line under it. The block's own padding is the `pre`'s.\n\t\t\t\t\t\t */\n\t\t\t\t\t\twhen(prose(\"& :where(pre code)\"), [\n\t\t\t\t\t\t\tbg(\"transparent\"),\n\t\t\t\t\t\t\tfg(\"inherit\"),\n\t\t\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\t\t\tpi(0),\n\t\t\t\t\t\t\tpb(0),\n\t\t\t\t\t\t]),\n\n\t\t\t\t\t\twhen(prose(\"& :where(table)\"), [\n\t\t\t\t\t\t\tblock(),\n\t\t\t\t\t\t\tis(\"max(100%, max-content)\"),\n\t\t\t\t\t\t\tmaxIs(\"full\"),\n\t\t\t\t\t\t\toverflow(\"auto\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\twhen(prose(\"& :where(th, td):not([align])\"), textAlign(\"start\")),\n\t\t\t\t\t\twhen(prose(\"& :where(th)\"), [weight(\"semibold\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\t\twhen(prose(\"& :where(th, td)\"), [\n\t\t\t\t\t\t\ttabularNums(),\n\t\t\t\t\t\t\tpi(\"0.75em\"),\n\t\t\t\t\t\t\tpb(\"0.5em\"),\n\t\t\t\t\t\t\tborderEdge(\"block-end\", { color: \"neutral\", width: \"1px\" }),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
|
|
11
11
|
},
|
|
12
12
|
"test": {
|
|
13
13
|
"path": "typeset.test.tsx",
|