@newtone-dev/ui-react-web 0.17.0 → 0.19.0
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/dist/avatar/avatar.css +52 -1
- package/dist/avatar/avatar.d.ts +8 -1
- package/dist/avatar/avatar.d.ts.map +1 -1
- package/dist/avatar/avatar.js +16 -8
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/page/page.d.ts.map +1 -1
- package/dist/page/page.js +2 -1
- package/dist/page/page.js.map +1 -1
- package/dist/text/selection-paint.d.ts +18 -0
- package/dist/text/selection-paint.d.ts.map +1 -0
- package/dist/text/selection-paint.js +178 -0
- package/dist/text/selection-paint.js.map +1 -0
- package/dist/text/text.css +16 -0
- package/package.json +1 -1
package/dist/avatar/avatar.css
CHANGED
|
@@ -36,9 +36,60 @@
|
|
|
36
36
|
block-size: auto;
|
|
37
37
|
aspect-ratio: 1;
|
|
38
38
|
border-radius: 50%;
|
|
39
|
-
|
|
39
|
+
/* TWO TOKENS AND THE GRADIENT IS DRAWN HERE, from 2026-10-01. A themed colour is one step, so a
|
|
40
|
+
gradient cannot be one token: the ends are `avatar.gradient-{start,end}.fill`. Top to bottom
|
|
41
|
+
is 180deg; Joshua asked for it turned 30 degrees counterclockwise, and CSS counts clockwise,
|
|
42
|
+
so 150deg. components/avatar.md. */
|
|
43
|
+
background: linear-gradient(
|
|
44
|
+
150deg,
|
|
45
|
+
var(--newtone-avatar-gradient-start-fill),
|
|
46
|
+
var(--newtone-avatar-gradient-end-fill)
|
|
47
|
+
);
|
|
40
48
|
|
|
41
49
|
/* A photograph is almost never square. Without this, a 4:3 original is squeezed into the
|
|
42
50
|
circle and every face in a row is a different shape. */
|
|
43
51
|
object-fit: cover;
|
|
44
52
|
}
|
|
53
|
+
|
|
54
|
+
/* TWO PICTURES, FROM 2026-10-01 (`hoverSrc`). Joshua: *"andrea's avatar should show her smiling on
|
|
55
|
+
* rest, and laughing on hover. Of course, as long as it is clickable."*
|
|
56
|
+
*
|
|
57
|
+
* The span is the circle and the plate, from the rule above; the images fill one grid cell on top of
|
|
58
|
+
* it. `overflow: hidden` because the radius is on the span and a radius does not round children.
|
|
59
|
+
*
|
|
60
|
+
* BOTH PICTURES FADE, NOT ONLY THE TOP ONE: they are transparent cut-outs, so a hover picture laid
|
|
61
|
+
* over a rest picture that stayed visible shows both faces at once.
|
|
62
|
+
*
|
|
63
|
+
* CLICKABLE IS READ FROM THE ANCESTOR. The avatar is never the control -- it sits in a card that is a
|
|
64
|
+
* link -- so the swap waits for an `a` or `button` around it to be hovered or keyboard-focused. In
|
|
65
|
+
* nothing clickable the hover picture is never shown. components/avatar.md. */
|
|
66
|
+
.newtone-avatar--swap {
|
|
67
|
+
display: grid;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.newtone-avatar--swap > img {
|
|
72
|
+
grid-area: 1 / 1;
|
|
73
|
+
inline-size: 100%;
|
|
74
|
+
block-size: 100%;
|
|
75
|
+
object-fit: cover;
|
|
76
|
+
transition: opacity 200ms ease;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.newtone-avatar--swap > .newtone-avatar__hover {
|
|
80
|
+
opacity: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:is(a, button):is(:hover, :focus-visible) .newtone-avatar--swap > .newtone-avatar__rest {
|
|
84
|
+
opacity: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:is(a, button):is(:hover, :focus-visible) .newtone-avatar--swap > .newtone-avatar__hover {
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (prefers-reduced-motion: reduce) {
|
|
92
|
+
.newtone-avatar--swap > img {
|
|
93
|
+
transition: none;
|
|
94
|
+
}
|
|
95
|
+
}
|
package/dist/avatar/avatar.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export interface AvatarProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, '
|
|
|
14
14
|
* avatar.md.
|
|
15
15
|
*/
|
|
16
16
|
size?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A second picture, shown while a link or button around the avatar is hovered or focused, and
|
|
19
|
+
* never otherwise -- *as long as it is clickable* is read from the ancestor, in avatar.css, so
|
|
20
|
+
* there is nothing to pass that could disagree with it. Since 2026-10-01, react-web 0.19.0;
|
|
21
|
+
* avatar.md.
|
|
22
|
+
*/
|
|
23
|
+
hoverSrc?: string;
|
|
17
24
|
}
|
|
18
25
|
/**
|
|
19
26
|
* A person, in a circle, on a plate.
|
|
@@ -45,5 +52,5 @@ export interface AvatarProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, '
|
|
|
45
52
|
* Nothing here has a slot for one. The day a second site wants a marker, what crosses is the slot,
|
|
46
53
|
* not the flag.
|
|
47
54
|
*/
|
|
48
|
-
export declare function Avatar({ src, alt, size, className, style, ...rest }: AvatarProps): import("react").JSX.Element;
|
|
55
|
+
export declare function Avatar({ src, alt, size, hoverSrc, className, style, ...rest }: AvatarProps): import("react").JSX.Element;
|
|
49
56
|
//# sourceMappingURL=avatar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../src/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE7D,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IACjF,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../src/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE7D,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IACjF,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,+BAmD1F"}
|
package/dist/avatar/avatar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* A person, in a circle, on a plate.
|
|
4
4
|
*
|
|
@@ -29,15 +29,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
29
29
|
* Nothing here has a slot for one. The day a second site wants a marker, what crosses is the slot,
|
|
30
30
|
* not the flag.
|
|
31
31
|
*/
|
|
32
|
-
export function Avatar({ src, alt, size, className, style, ...rest }) {
|
|
32
|
+
export function Avatar({ src, alt, size, hoverSrc, className, style, ...rest }) {
|
|
33
|
+
// The diameter, written here since 2026-09-26 rather than declared by the caller's sheet: a
|
|
34
|
+
// consuming site declares no `--newtone-*` property (issue 201).
|
|
35
|
+
const sized = size === undefined ? style : { '--newtone-avatar-size': size, ...style };
|
|
36
|
+
// TWO PICTURES ARE A SPAN, AND ONE IS STILL THE `<img>`, so every call site without `hoverSrc`
|
|
37
|
+
// renders exactly what it did. The plate moves to the span so it sits behind both; the caller's
|
|
38
|
+
// attributes stay on the rest picture, which is the one that carries the name. The hover picture
|
|
39
|
+
// is `alt=""` (the same person, named once) and is NOT lazy: it is invisible, so lazy loading
|
|
40
|
+
// would fetch it on the first hover and show an empty circle there. avatar.md.
|
|
41
|
+
if (hoverSrc !== undefined) {
|
|
42
|
+
return (_jsxs("span", { className: ['newtone-avatar', 'newtone-avatar--swap', className]
|
|
43
|
+
.filter(Boolean)
|
|
44
|
+
.join(' '), style: sized, children: [_jsx("img", { src: src, alt: alt, decoding: "async", className: "newtone-avatar__rest", ...rest }), _jsx("img", { src: hoverSrc, alt: "", decoding: "async", className: "newtone-avatar__hover", width: rest.width, height: rest.height })] }));
|
|
45
|
+
}
|
|
33
46
|
return (_jsx("img", { src: src, alt: alt, className: ['newtone-avatar', className].filter(Boolean).join(' '),
|
|
34
47
|
// Both default here rather than at each call site, because a portrait is never the
|
|
35
48
|
// thing a reader is waiting for and every existing call site wrote both by hand.
|
|
36
|
-
loading: "lazy", decoding: "async",
|
|
37
|
-
// The diameter, written here since 2026-09-26 rather than declared by the caller's
|
|
38
|
-
// sheet: a consuming site declares no `--newtone-*` property (issue 201).
|
|
39
|
-
style: size === undefined
|
|
40
|
-
? style
|
|
41
|
-
: { '--newtone-avatar-size': size, ...style }, ...rest }));
|
|
49
|
+
loading: "lazy", decoding: "async", style: sized, ...rest }));
|
|
42
50
|
}
|
|
43
51
|
//# sourceMappingURL=avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../src/avatar/avatar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../src/avatar/avatar.tsx"],"names":[],"mappings":";AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAe;IACvF,4FAA4F;IAC5F,iEAAiE;IACjE,MAAM,KAAK,GACP,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE,GAAG,KAAK,EAAoB,CAAA;IAE/F,+FAA+F;IAC/F,gGAAgG;IAChG,iGAAiG;IACjG,8FAA8F;IAC9F,+EAA+E;IAC/E,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,CACH,gBACI,SAAS,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,SAAS,CAAC;iBAC3D,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,GAAG,CAAC,EACd,KAAK,EAAE,KAAK,aAEZ,cACI,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAC,OAAO,EAChB,SAAS,EAAC,sBAAsB,KAC5B,IAAI,GACV,EACF,cACI,GAAG,EAAE,QAAQ,EACb,GAAG,EAAC,EAAE,EACN,QAAQ,EAAC,OAAO,EAChB,SAAS,EAAC,uBAAuB,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,MAAM,GACrB,IACC,CACV,CAAA;IACL,CAAC;IAED,OAAO,CACH,cACI,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAClE,mFAAmF;QACnF,iFAAiF;QACjF,OAAO,EAAC,MAAM,EACd,QAAQ,EAAC,OAAO,EAChB,KAAK,EAAE,KAAK,KACR,IAAI,GACV,CACL,CAAA;AACL,CAAC"}
|
package/dist/page/page.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/page/page.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/page/page.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,KAAK,EAAiB,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AACH,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC1D;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,0DAA0D;IAC1D,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,kFAAkF;IAClF,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;CACvB;AAED,wBAAgB,IAAI,CAAC,EACjB,MAAM,EACN,MAAM,EACN,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,eAAe,EACf,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,SAAS,+BAmDX;yBA9De,IAAI;aAwER,QAAQ"}
|
package/dist/page/page.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// and this renders inside server components -- see the repo blueprint, section 4.3.
|
|
4
4
|
import { Surface } from '../surface/index.js';
|
|
5
5
|
import { PageBand } from './band.js';
|
|
6
|
+
import { SelectionPaint } from '../text/selection-paint.js';
|
|
6
7
|
export function Page({ navbar, footer, maxInlineSize, theme, mode, elevation, footerElevation, className, children, ...rest }) {
|
|
7
8
|
// THE CAP IS A CUSTOM PROPERTY ON THE ROOT FROM 2026-09-21 LATE, where it was an inline
|
|
8
9
|
// `max-inline-size` on the one track this component rendered. It had to move because a band's
|
|
@@ -15,7 +16,7 @@ export function Page({ navbar, footer, maxInlineSize, theme, mode, elevation, fo
|
|
|
15
16
|
const root = maxInlineSize
|
|
16
17
|
? { '--newtone-page-max-inline-size': maxInlineSize }
|
|
17
18
|
: undefined;
|
|
18
|
-
return (_jsxs(Surface, { theme: theme, mode: mode, elevation: elevation, className: ['newtone-page', className].filter(Boolean).join(' '), style: root, ...rest, children: [navbar, _jsxs("div", { className: "newtone-page-body", children: [_jsx("main", { className: "newtone-page-main", children: children }), footer ? (_jsx(Surface, { as: "footer", elevation: footerElevation, className: "newtone-page-footer", children: _jsx("div", { className: "newtone-page-track", children: footer }) })) : null] })] }));
|
|
19
|
+
return (_jsxs(Surface, { theme: theme, mode: mode, elevation: elevation, className: ['newtone-page', className].filter(Boolean).join(' '), style: root, ...rest, children: [navbar, _jsx(SelectionPaint, {}), _jsxs("div", { className: "newtone-page-body", children: [_jsx("main", { className: "newtone-page-main", children: children }), footer ? (_jsx(Surface, { as: "footer", elevation: footerElevation, className: "newtone-page-footer", children: _jsx("div", { className: "newtone-page-track", children: footer }) })) : null] })] }));
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* The band hangs off `Page` and is exported nowhere else.
|
package/dist/page/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/page/page.tsx"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,o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qB,YAM/B,cAAK,SAAS,EAAC,oBAAoB,YAAE,MAAM,GAAO,GAC5C,CACb,CAAC,CAAC,CAAC,IAAI,IACN,IACA,CACb,CAAA;AACL,CAAC;AAED;;;;;;;GAOG;AACH,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paints the selection fill UNDER the text, as the selected blocks' own backgrounds. From 2026-09-30.
|
|
3
|
+
* Blueprint components/text.md, *The fill is painted under the text, not by the browser*.
|
|
4
|
+
*
|
|
5
|
+
* **Chrome paints a selection line by line -- a line's fill, then its text -- so the next line's fill
|
|
6
|
+
* covers the descenders of the line above** wherever a scale's line-height is shorter than its face's
|
|
7
|
+
* ascent plus descent. Joshua, on Andrea's home heading: *"the selection background obstructs the
|
|
8
|
+
* hanging letter from the line before, like the g's"*. Measured: 792 covered glyph pixels at 390 in
|
|
9
|
+
* Chrome, 0 in WebKit, 0 in both with this mounted. No property `::selection` takes reaches the order.
|
|
10
|
+
*
|
|
11
|
+
* **An element's backgrounds paint under all of its own text.** So while this is mounted `text.css`
|
|
12
|
+
* makes the highlight's background transparent, and this writes one gradient layer per selected line
|
|
13
|
+
* into the inline background of the block whose text it is. The ink is still the browser's.
|
|
14
|
+
*
|
|
15
|
+
* Renders nothing. `Page` mounts it; two mounts share one listener.
|
|
16
|
+
*/
|
|
17
|
+
export declare function SelectionPaint(): null;
|
|
18
|
+
//# sourceMappingURL=selection-paint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-paint.d.ts","sourceRoot":"","sources":["../../src/text/selection-paint.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,SAG7B"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Paints the selection fill UNDER the text, as the selected blocks' own backgrounds. From 2026-09-30.
|
|
5
|
+
* Blueprint components/text.md, *The fill is painted under the text, not by the browser*.
|
|
6
|
+
*
|
|
7
|
+
* **Chrome paints a selection line by line -- a line's fill, then its text -- so the next line's fill
|
|
8
|
+
* covers the descenders of the line above** wherever a scale's line-height is shorter than its face's
|
|
9
|
+
* ascent plus descent. Joshua, on Andrea's home heading: *"the selection background obstructs the
|
|
10
|
+
* hanging letter from the line before, like the g's"*. Measured: 792 covered glyph pixels at 390 in
|
|
11
|
+
* Chrome, 0 in WebKit, 0 in both with this mounted. No property `::selection` takes reaches the order.
|
|
12
|
+
*
|
|
13
|
+
* **An element's backgrounds paint under all of its own text.** So while this is mounted `text.css`
|
|
14
|
+
* makes the highlight's background transparent, and this writes one gradient layer per selected line
|
|
15
|
+
* into the inline background of the block whose text it is. The ink is still the browser's.
|
|
16
|
+
*
|
|
17
|
+
* Renders nothing. `Page` mounts it; two mounts share one listener.
|
|
18
|
+
*/
|
|
19
|
+
export function SelectionPaint() {
|
|
20
|
+
useEffect(install, []);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const ATTR = 'data-newtone-selection';
|
|
24
|
+
const NATIVE = 'data-newtone-selection-native';
|
|
25
|
+
const PROPS = [
|
|
26
|
+
'background-image',
|
|
27
|
+
'background-position',
|
|
28
|
+
'background-size',
|
|
29
|
+
'background-repeat',
|
|
30
|
+
'background-origin',
|
|
31
|
+
];
|
|
32
|
+
const FILL = 'linear-gradient(var(--newtone-selection-fill), var(--newtone-selection-fill))';
|
|
33
|
+
let mounts = 0;
|
|
34
|
+
/** Each painted block, and the inline values it had before, which go back on the next change. `null`
|
|
35
|
+
* is a block that had no `style` attribute at all, so it gets none back rather than an empty one. */
|
|
36
|
+
const painted = new Map();
|
|
37
|
+
function install() {
|
|
38
|
+
if (mounts++ === 0) {
|
|
39
|
+
document.documentElement.setAttribute(ATTR, '');
|
|
40
|
+
document.addEventListener('selectionchange', paint);
|
|
41
|
+
document.addEventListener('scroll', onScroll, true);
|
|
42
|
+
window.addEventListener('resize', paint);
|
|
43
|
+
paint();
|
|
44
|
+
}
|
|
45
|
+
return () => {
|
|
46
|
+
if (--mounts > 0)
|
|
47
|
+
return;
|
|
48
|
+
document.removeEventListener('selectionchange', paint);
|
|
49
|
+
document.removeEventListener('scroll', onScroll, true);
|
|
50
|
+
window.removeEventListener('resize', paint);
|
|
51
|
+
restore();
|
|
52
|
+
document.documentElement.removeAttribute(ATTR);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** The page scrolling moves every block together; only a nested scroller moves text inside one. */
|
|
56
|
+
function onScroll(event) {
|
|
57
|
+
if (painted.size && event.target !== document)
|
|
58
|
+
paint();
|
|
59
|
+
}
|
|
60
|
+
function restore() {
|
|
61
|
+
for (const [block, saved] of painted) {
|
|
62
|
+
if (saved)
|
|
63
|
+
PROPS.forEach((prop, i) => block.style.setProperty(prop, saved[i]));
|
|
64
|
+
else
|
|
65
|
+
block.removeAttribute('style');
|
|
66
|
+
block.removeAttribute(NATIVE);
|
|
67
|
+
}
|
|
68
|
+
painted.clear();
|
|
69
|
+
}
|
|
70
|
+
/** The nearest ancestor that lays its own lines out: what an inline's text is painted by. */
|
|
71
|
+
function blockOf(node, display) {
|
|
72
|
+
let el = node.parentElement;
|
|
73
|
+
while (el) {
|
|
74
|
+
let d = display.get(el);
|
|
75
|
+
if (d === undefined)
|
|
76
|
+
display.set(el, (d = getComputedStyle(el).display));
|
|
77
|
+
if (d !== 'inline' && d !== 'contents')
|
|
78
|
+
return el;
|
|
79
|
+
el = el.parentElement;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
function paint() {
|
|
84
|
+
restore();
|
|
85
|
+
const selection = document.getSelection();
|
|
86
|
+
if (!selection || selection.isCollapsed)
|
|
87
|
+
return;
|
|
88
|
+
// ---- every selected text node's rects, grouped by the block that paints them ----------------
|
|
89
|
+
const lines = new Map();
|
|
90
|
+
const display = new Map();
|
|
91
|
+
for (let r = 0; r < selection.rangeCount; r++) {
|
|
92
|
+
const range = selection.getRangeAt(r);
|
|
93
|
+
const root = range.commonAncestorContainer;
|
|
94
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
95
|
+
let node = root.nodeType === Node.TEXT_NODE ? root : walker.nextNode();
|
|
96
|
+
for (; node; node = root.nodeType === Node.TEXT_NODE ? null : walker.nextNode()) {
|
|
97
|
+
if (!range.intersectsNode(node))
|
|
98
|
+
continue;
|
|
99
|
+
const block = blockOf(node, display);
|
|
100
|
+
if (!(block instanceof HTMLElement))
|
|
101
|
+
continue;
|
|
102
|
+
const part = document.createRange();
|
|
103
|
+
part.selectNodeContents(node);
|
|
104
|
+
if (node === range.startContainer)
|
|
105
|
+
part.setStart(node, range.startOffset);
|
|
106
|
+
if (node === range.endContainer)
|
|
107
|
+
part.setEnd(node, range.endOffset);
|
|
108
|
+
// THE GLYPH BOX GROWS TO THE LINE BOX: centred, `line-height` tall. At `normal` the
|
|
109
|
+
// content area is the line.
|
|
110
|
+
const lh = parseFloat(getComputedStyle(block).lineHeight);
|
|
111
|
+
let list = lines.get(block);
|
|
112
|
+
if (!list)
|
|
113
|
+
lines.set(block, (list = []));
|
|
114
|
+
for (const rect of part.getClientRects()) {
|
|
115
|
+
if (!rect.width)
|
|
116
|
+
continue;
|
|
117
|
+
const h = Number.isFinite(lh) ? lh : rect.height;
|
|
118
|
+
const y = rect.top + rect.height / 2 - h / 2;
|
|
119
|
+
list.push({ x: rect.left, y, w: rect.width, h, key: Math.round(y) });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const px = 1 / (window.devicePixelRatio || 1);
|
|
124
|
+
const snap = (v) => Math.round(v / px) * px;
|
|
125
|
+
for (const [block, list] of lines) {
|
|
126
|
+
if (!list.length)
|
|
127
|
+
continue;
|
|
128
|
+
painted.set(block, block.hasAttribute('style')
|
|
129
|
+
? PROPS.map((prop) => block.style.getPropertyValue(prop))
|
|
130
|
+
: null);
|
|
131
|
+
// A BLOCK THAT ALREADY PAINTS A PICTURE KEEPS THE BROWSER'S FILL. Writing ours would replace
|
|
132
|
+
// its image; text.css gives this attribute the fill back.
|
|
133
|
+
const style = getComputedStyle(block);
|
|
134
|
+
if (style.backgroundImage !== 'none' || style.backgroundClip === 'text') {
|
|
135
|
+
block.setAttribute(NATIVE, '');
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// ---- lines that stack meet at one shared edge --------------------------------------------
|
|
139
|
+
// The upper one runs one device pixel under the lower: Chrome snaps each background layer on
|
|
140
|
+
// its own, and two edges that met exactly left a 1px seam. They are the same colour.
|
|
141
|
+
const keys = [...new Set(list.map((line) => line.key))].sort((a, b) => a - b);
|
|
142
|
+
for (let i = 1; i < keys.length; i++) {
|
|
143
|
+
const above = list.filter((line) => line.key === keys[i - 1]);
|
|
144
|
+
const below = list.filter((line) => line.key === keys[i]);
|
|
145
|
+
const bottom = Math.max(...above.map((line) => line.y + line.h));
|
|
146
|
+
const top = Math.min(...below.map((line) => line.y));
|
|
147
|
+
if (Math.abs(top - bottom) > below[0].h / 2)
|
|
148
|
+
continue;
|
|
149
|
+
const edge = (top + bottom) / 2;
|
|
150
|
+
for (const line of above)
|
|
151
|
+
line.h = edge - line.y + px;
|
|
152
|
+
for (const line of below) {
|
|
153
|
+
line.h += line.y - edge;
|
|
154
|
+
line.y = edge;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// ---- into the block's own coordinates, divided by its scale ------------------------------
|
|
158
|
+
// A slide laid out at 1440 and scaled to the window reports its rects scaled; its
|
|
159
|
+
// backgrounds are positioned before the transform.
|
|
160
|
+
const box = block.getBoundingClientRect();
|
|
161
|
+
const sx = block.offsetWidth ? box.width / block.offsetWidth : 1;
|
|
162
|
+
const sy = block.offsetHeight ? box.height / block.offsetHeight : 1;
|
|
163
|
+
const at = list.map((line) => {
|
|
164
|
+
const y = snap((line.y - box.top) / sy);
|
|
165
|
+
const bottom = snap((line.y + line.h - box.top) / sy);
|
|
166
|
+
return {
|
|
167
|
+
pos: `${(line.x - box.left) / sx}px ${y}px`,
|
|
168
|
+
size: `${line.w / sx}px ${bottom - y}px`,
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
block.style.setProperty('background-image', at.map(() => FILL).join(', '));
|
|
172
|
+
block.style.setProperty('background-position', at.map((layer) => layer.pos).join(', '));
|
|
173
|
+
block.style.setProperty('background-size', at.map((layer) => layer.size).join(', '));
|
|
174
|
+
block.style.setProperty('background-repeat', 'no-repeat');
|
|
175
|
+
block.style.setProperty('background-origin', 'border-box');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=selection-paint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-paint.js","sourceRoot":"","sources":["../../src/text/selection-paint.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc;IAC1B,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACtB,OAAO,IAAI,CAAA;AACf,CAAC;AAED,MAAM,IAAI,GAAG,wBAAwB,CAAA;AACrC,MAAM,MAAM,GAAG,+BAA+B,CAAA;AAC9C,MAAM,KAAK,GAAG;IACV,kBAAkB;IAClB,qBAAqB;IACrB,iBAAiB;IACjB,mBAAmB;IACnB,mBAAmB;CACb,CAAA;AACV,MAAM,IAAI,GAAG,+EAA+E,CAAA;AAE5F,IAAI,MAAM,GAAG,CAAC,CAAA;AACd;qGACqG;AACrG,MAAM,OAAO,GAAG,IAAI,GAAG,EAAgC,CAAA;AAEvD,SAAS,OAAO;IACZ,IAAI,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;QACjB,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAC/C,QAA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C,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAC1E,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACvF,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,iBAAiB,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACpF,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAA;QACzD,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;IAC9D,CAAC;AACL,CAAC"}
|
package/dist/text/text.css
CHANGED
|
@@ -405,3 +405,19 @@
|
|
|
405
405
|
background-color: var(--newtone-selection-fill);
|
|
406
406
|
color: var(--newtone-selection-text);
|
|
407
407
|
}
|
|
408
|
+
|
|
409
|
+
/* THE FILL IS PAINTED UNDER THE TEXT WHILE A PAGE IS MOUNTED, 2026-09-30 -- Joshua: "the selection
|
|
410
|
+
background obstructs the hanging letter from the line before, like the g's". Chrome paints each
|
|
411
|
+
line's fill and then its text, so the next line's fill covers the descenders above it. SelectionPaint
|
|
412
|
+
(selection-paint.tsx) marks <html> and writes the fill into each selected block's own background,
|
|
413
|
+
which paints under all of that block's text; the highlight's own goes transparent. A field's text
|
|
414
|
+
has no rects to paint, and a block that already paints an image is left to the browser.
|
|
415
|
+
components/text.md, *The fill is painted under the text, not by the browser*. */
|
|
416
|
+
html[data-newtone-selection] :not(input, textarea)::selection {
|
|
417
|
+
background-color: transparent;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
html[data-newtone-selection] [data-newtone-selection-native]::selection,
|
|
421
|
+
html[data-newtone-selection] [data-newtone-selection-native] :not(input, textarea)::selection {
|
|
422
|
+
background-color: var(--newtone-selection-fill);
|
|
423
|
+
}
|