@sdxc/ui 2026.10.2 → 2026.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/components/highlight.d.ts +47 -0
- package/dist/components/highlight.js +43 -0
- package/dist/components/image-placeholder.js +6 -4
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +11 -2
- package/src/reset.css +13 -2
package/README.md
CHANGED
|
@@ -303,6 +303,8 @@ positioning, or a custom `--ui-*` command answered by a mixin.
|
|
|
303
303
|
- `Text`, `Header`, `Keyboard`, `Typeset` — muted body copy, an uppercase section label in a
|
|
304
304
|
`<header>`, a shortcut hint in a `<kbd>`, and a typography layer for already-rendered
|
|
305
305
|
markup with `docs`, `chat` and `reading` presets.
|
|
306
|
+
- `Highlight` — text split into `{ text, match }` segments, each match a tinted `<mark>`
|
|
307
|
+
that keeps the surrounding color and weight, for search results and filtered lists.
|
|
306
308
|
- `HeadingScope`, `Heading` — an ambient heading-depth scope and the heading that reads it.
|
|
307
309
|
- `SharedElement` — a host carrying a stable view-transition identity across page loads.
|
|
308
310
|
- `Calendar`, `RangeCalendar`, `DatePicker`, `DateRangePicker` — a month grid for one day or
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text with the stretches a search matched marked: a run of `{ text, match }` segments
|
|
3
|
+
* rendered as one inline `<span>`, each matched stretch a native `<mark>` tinted through a
|
|
4
|
+
* semantic color role. Segments stay text nodes, so the content is escaped by construction.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
import type { SemanticColor } from "../utils/semantic-color.js";
|
|
11
|
+
/**
|
|
12
|
+
* Prop types for {@link Highlight}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace Highlight {
|
|
15
|
+
/** Semantic color role the marks are tinted with. */
|
|
16
|
+
type Color = SemanticColor;
|
|
17
|
+
/** One stretch of the text, and whether the query matched it. */
|
|
18
|
+
interface Segment {
|
|
19
|
+
/** The stretch exactly as written. */
|
|
20
|
+
text: string;
|
|
21
|
+
/** Whether this stretch is drawn as a `<mark>`. */
|
|
22
|
+
match: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every native `<span>` attribute except `children`, which the segments replace, plus
|
|
26
|
+
* the `mix` passthrough.
|
|
27
|
+
*/
|
|
28
|
+
interface Props extends Omit<TagProps<"span">, "children"> {
|
|
29
|
+
/** The text in order, split where the matches start and end. */
|
|
30
|
+
segments: ReadonlyArray<Segment>;
|
|
31
|
+
/** Semantic color role of the marks. Defaults to {@link DEFAULT_COLOR}. */
|
|
32
|
+
color?: Color;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Renders the segments inline, each match as a `<mark>` with a quiet tint behind text
|
|
37
|
+
* that keeps the surrounding color and weight, so a match inside a link still reads as
|
|
38
|
+
* the link. A mark broken across lines keeps its rounded tint on every fragment.
|
|
39
|
+
*
|
|
40
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
41
|
+
* @returns The render function producing the highlighted text.
|
|
42
|
+
* @example
|
|
43
|
+
* <Highlight segments={[{ text: "Remix", match: true }, { text: " routing", match: false }]} />
|
|
44
|
+
* @example
|
|
45
|
+
* <Link href={post.href}><Highlight segments={post.title} color="warning" /></Link>
|
|
46
|
+
*/
|
|
47
|
+
export declare function Highlight(handle: Handle<Highlight.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
|
+
import { bg, fg } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { raw } from "@sdxc/u/general";
|
|
5
|
+
import { data, when } from "@sdxc/u/state";
|
|
6
|
+
/** Semantic color role {@link Highlight} falls back to when `color` is omitted. */
|
|
7
|
+
const DEFAULT_COLOR = "brand";
|
|
8
|
+
/**
|
|
9
|
+
* Renders the segments inline, each match as a `<mark>` with a quiet tint behind text
|
|
10
|
+
* that keeps the surrounding color and weight, so a match inside a link still reads as
|
|
11
|
+
* the link. A mark broken across lines keeps its rounded tint on every fragment.
|
|
12
|
+
*
|
|
13
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
14
|
+
* @returns The render function producing the highlighted text.
|
|
15
|
+
* @example
|
|
16
|
+
* <Highlight segments={[{ text: "Remix", match: true }, { text: " routing", match: false }]} />
|
|
17
|
+
* @example
|
|
18
|
+
* <Link href={post.href}><Highlight segments={post.title} color="warning" /></Link>
|
|
19
|
+
*/
|
|
20
|
+
export function Highlight(handle) {
|
|
21
|
+
return () => {
|
|
22
|
+
let { color, segments, mix, ...rest } = handle.props;
|
|
23
|
+
return (_jsx("span", { "data-color": color ?? DEFAULT_COLOR, ...rest, mix: [
|
|
24
|
+
when("& > mark", [
|
|
25
|
+
fg("inherit"),
|
|
26
|
+
rounded("sm"),
|
|
27
|
+
raw({
|
|
28
|
+
fontWeight: "inherit",
|
|
29
|
+
paddingInline: "0.1em",
|
|
30
|
+
marginInline: "-0.1em",
|
|
31
|
+
boxDecorationBreak: "clone",
|
|
32
|
+
WebkitBoxDecorationBreak: "clone",
|
|
33
|
+
}),
|
|
34
|
+
]),
|
|
35
|
+
data("color", "brand", when("& > mark", bg("brand.tint"))),
|
|
36
|
+
data("color", "neutral", when("& > mark", bg("neutral.tint"))),
|
|
37
|
+
data("color", "success", when("& > mark", bg("success.tint"))),
|
|
38
|
+
data("color", "warning", when("& > mark", bg("warning.tint"))),
|
|
39
|
+
data("color", "danger", when("& > mark", bg("danger.tint"))),
|
|
40
|
+
mix,
|
|
41
|
+
], children: segments.map((segment) => (segment.match ? _jsx("mark", { children: segment.text }) : segment.text)) }));
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
2
|
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
3
|
-
import { ringShadow, rounded } from "@sdxc/u/effects";
|
|
3
|
+
import { ringShadow, rounded, visibility } from "@sdxc/u/effects";
|
|
4
4
|
import { userSelect } from "@sdxc/u/general";
|
|
5
|
-
import { absolute, center, flex,
|
|
5
|
+
import { absolute, center, flex, inlineFlex, insBe, insIe, inset, items, justify, relative, shrink, } from "@sdxc/u/layout";
|
|
6
6
|
import { overflow } from "@sdxc/u/overflow";
|
|
7
7
|
import { bs, fit, is, mis } from "@sdxc/u/size";
|
|
8
8
|
import { data, precededBy, when } from "@sdxc/u/state";
|
|
@@ -115,9 +115,11 @@ ImagePlaceholder.Fallback = function ImagePlaceholderFallback(handle) {
|
|
|
115
115
|
/*
|
|
116
116
|
* Both layers fill the host, and this one is written after the image, so it
|
|
117
117
|
* would cover a picture that loaded. It stands down while an image is present
|
|
118
|
-
* and unbroken, and takes over once the image reports that it failed.
|
|
118
|
+
* and unbroken, and takes over once the image reports that it failed. It
|
|
119
|
+
* stands down through `visibility`, which no other rule here sets, so the
|
|
120
|
+
* order the page declared these rules in cannot bring it back.
|
|
119
121
|
*/
|
|
120
|
-
precededBy('img[data-slot="image"]:not([data-image-error])', hidden
|
|
122
|
+
precededBy('img[data-slot="image"]:not([data-image-error])', visibility("hidden")),
|
|
121
123
|
absolute(),
|
|
122
124
|
center(),
|
|
123
125
|
weight("medium"),
|
|
@@ -52,6 +52,7 @@ export * from "./group.js";
|
|
|
52
52
|
export * from "./header.js";
|
|
53
53
|
export * from "./heading.js";
|
|
54
54
|
export * from "./heading-scope.js";
|
|
55
|
+
export * from "./highlight.js";
|
|
55
56
|
export * from "./hover-card.js";
|
|
56
57
|
export * from "./image-placeholder.js";
|
|
57
58
|
export * from "./input.js";
|
package/dist/components/index.js
CHANGED
|
@@ -52,6 +52,7 @@ export * from "./group.js";
|
|
|
52
52
|
export * from "./header.js";
|
|
53
53
|
export * from "./heading.js";
|
|
54
54
|
export * from "./heading-scope.js";
|
|
55
|
+
export * from "./highlight.js";
|
|
55
56
|
export * from "./hover-card.js";
|
|
56
57
|
export * from "./image-placeholder.js";
|
|
57
58
|
export * from "./input.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/ui",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.8",
|
|
4
4
|
"description": "Styled, accessible remix/component components rendered as server HTML",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@sdxc/u": "2026.10.2",
|
|
22
22
|
"remix": "3.0.0"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "7641f481daf6aab5fecfd486c9478ec95aa532c5",
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
@@ -29,5 +29,14 @@
|
|
|
29
29
|
"type": "git",
|
|
30
30
|
"url": "git+https://github.com/sergiodxa/monorepo.git",
|
|
31
31
|
"directory": "packages/ui"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://sdxc.sergiodxa.com/api/ui",
|
|
34
|
+
"author": {
|
|
35
|
+
"name": "Sergio Xalambrí",
|
|
36
|
+
"url": "https://sergiodxa.com"
|
|
37
|
+
},
|
|
38
|
+
"funding": {
|
|
39
|
+
"type": "github",
|
|
40
|
+
"url": "https://github.com/sponsors/sergiodxa"
|
|
32
41
|
}
|
|
33
42
|
}
|
package/src/reset.css
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* borders reset to "0 solid" so bare border-widths work later, the theme's
|
|
4
4
|
* sans font stack applied once at the document root for every element to
|
|
5
5
|
* inherit, form controls that inherit font/color/line-height, transparent
|
|
6
|
-
* button/input backgrounds with a sensible cursor, block-level media,
|
|
7
|
-
* rest of the usual list/table/[hidden]
|
|
6
|
+
* button/input backgrounds with a sensible cursor, block-level media, the theme's
|
|
7
|
+
* focus ring for keyboard focus, and the rest of the usual list/table/[hidden]
|
|
8
|
+
* normalizations.
|
|
8
9
|
*
|
|
9
10
|
* Every selector is wrapped in :where(...) so the whole file carries zero
|
|
10
11
|
* specificity and can never beat a component's own css() rules.
|
|
@@ -102,6 +103,16 @@
|
|
|
102
103
|
outline: auto;
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
/*
|
|
107
|
+
* Keyboard focus draws the theme's ring on anything a component leaves unstyled, so a
|
|
108
|
+
* plain <summary>, link or control shows the same ring as the components do. It sits
|
|
109
|
+
* after the Firefox rule above so the ring wins there too.
|
|
110
|
+
*/
|
|
111
|
+
:where(:focus-visible) {
|
|
112
|
+
outline: 2px solid var(--ui-ring, Highlight);
|
|
113
|
+
outline-offset: 2px;
|
|
114
|
+
}
|
|
115
|
+
|
|
105
116
|
:where(progress) {
|
|
106
117
|
vertical-align: baseline;
|
|
107
118
|
}
|