@newtone-dev/ui-react-web 0.18.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.
@@ -50,3 +50,46 @@
50
50
  circle and every face in a row is a different shape. */
51
51
  object-fit: cover;
52
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
+ }
@@ -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;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,+BAoBhF"}
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"}
@@ -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":";AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAe;IAC7E,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;QAChB,mFAAmF;QACnF,0EAA0E;QAC1E,KAAK,EACD,IAAI,KAAK,SAAS;YACd,CAAC,CAAC,KAAK;YACP,CAAC,CAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE,GAAG,KAAK,EAAoB,KAEpE,IAAI,GACV,CACL,CAAA;AACL,CAAC"}
1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;QACjF,OAAO,EAAC,MAAM,EACd,QAAQ,EAAC,OAAO,EAChB,KAAK,EAAE,KAAK,KACR,IAAI,GACV,CACL,CAAA;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtone-dev/ui-react-web",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",