@cloudgrid-io/ui 0.59.1 → 0.59.2

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.
@@ -39,14 +39,27 @@
39
39
  * block does not know what a grid is; a caller who needs two families passes two
40
40
  * different `seed` prefixes and gets two stable, different looks.
41
41
  *
42
- * ## A broken image falls back with no JavaScript
43
- *
44
- * The initials are always rendered. An image, when there is one, is painted OVER
45
- * them. So a 404, a dead signed URL or a blocked third-party host paints nothing
46
- * and the tile underneath simply shows through — the same arrangement
47
- * `EntityCard` uses for `previewUrl`, and for the same reason: an `onError`
48
- * swap would make this a client component to solve a problem the layering
49
- * already solves.
42
+ * ## A loaded picture draws no letter and no ground (ui#511)
43
+ *
44
+ * Until ui#511 the initials were always rendered and the picture painted over
45
+ * them, with no JavaScript. A picture with transparent areas showed the letter
46
+ * and the ground through them: a 3:1 logo the Console pads to a transparent
47
+ * square showed the letter's feet under the bar. So the mark watches its
48
+ * picture now (`AvatarFrame`, the one client part, so this module and its
49
+ * constants stay usable from a server component), and says what it knows in
50
+ * `data-picture` once it knows it:
51
+ *
52
+ * - No `src`, or a picture still loading (the first frame, and the server's):
53
+ * no attribute, and the ground and the letter, with the picture painted over
54
+ * them the moment it arrives. The markup of before, byte for byte.
55
+ * - `loaded`: the picture alone. No letter, and the ground is
56
+ * `pictureGround`'s: transparent (Asaf, 2026-11-17), so a transparent logo
57
+ * sits on whatever is behind it. The shape and the radius stay.
58
+ * - `error`: a 404, a dead signed URL, a blocked host. The ground and the
59
+ * letter, and the broken image is hidden, so a spoken `alt` is not drawn as
60
+ * text over the letter.
61
+ *
62
+ * Without JavaScript it stays the first frame, which is what it was before.
50
63
  *
51
64
  * ## `alt` is what makes an avatar speak
52
65
  *
@@ -155,7 +168,10 @@ declare function Avatar({ name, seed, src, alt, size, monogram, shape, look: loo
155
168
  * id rather than a title.
156
169
  */
157
170
  seed?: string;
158
- /** A real picture, painted over the initials. A miss falls back to them. */
171
+ /**
172
+ * A real picture. Once it has loaded it is drawn alone, with no initials and
173
+ * no ground under it (ui#511); while it loads, and if it fails, the initials.
174
+ */
159
175
  src?: string;
160
176
  /**
161
177
  * The accessible name. Omitted — the default — the mark is `aria-hidden`,
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../src/blocks/avatar.tsx"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,gBAAgB,uCAAwC,CAAA;AAErE,2CAA2C;AAC3C,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY;;;;CAIf,CAAA;AAEV,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,YAAY,CAAA;AAsBlD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,mFAIjB,CAAA;AAEV,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAC1D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAC7C,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE9C,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAEvD;AAyBD,iBAAS,MAAM,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,GAAG,EACH,IAAS,EACT,QAAQ,EACR,KAAgB,EAChB,IAAI,EAAE,QAAqB,EAC3B,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,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GAAG,QAAQ,CAAA;AAE9C,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAEvD;AAmCD,iBAAS,MAAM,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,GAAG,EACH,IAAS,EACT,QAAQ,EACR,KAAgB,EAChB,IAAI,EAAE,QAAqB,EAC3B,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IAClD,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,cAAc,GAAG,UAAU,CAAA;IAClC,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mFAAmF;IACnF,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,mGAAmG;IACnG,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,+BA+DA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -1,5 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from "../lib/cloudgrid-cn.js";
3
+ import { AvatarFrame } from "../lib/avatar-frame.js";
3
4
  import { entityIdentityLook, entityIdentitySeed, entityMonogram, } from "./entity-identity.js";
4
5
  /**
5
6
  * A person, as a mark: their picture if there is one, their initials on a
@@ -42,14 +43,27 @@ import { entityIdentityLook, entityIdentitySeed, entityMonogram, } from "./entit
42
43
  * block does not know what a grid is; a caller who needs two families passes two
43
44
  * different `seed` prefixes and gets two stable, different looks.
44
45
  *
45
- * ## A broken image falls back with no JavaScript
46
+ * ## A loaded picture draws no letter and no ground (ui#511)
46
47
  *
47
- * The initials are always rendered. An image, when there is one, is painted OVER
48
- * them. So a 404, a dead signed URL or a blocked third-party host paints nothing
49
- * and the tile underneath simply shows through — the same arrangement
50
- * `EntityCard` uses for `previewUrl`, and for the same reason: an `onError`
51
- * swap would make this a client component to solve a problem the layering
52
- * already solves.
48
+ * Until ui#511 the initials were always rendered and the picture painted over
49
+ * them, with no JavaScript. A picture with transparent areas showed the letter
50
+ * and the ground through them: a 3:1 logo the Console pads to a transparent
51
+ * square showed the letter's feet under the bar. So the mark watches its
52
+ * picture now (`AvatarFrame`, the one client part, so this module and its
53
+ * constants stay usable from a server component), and says what it knows in
54
+ * `data-picture` once it knows it:
55
+ *
56
+ * - No `src`, or a picture still loading (the first frame, and the server's):
57
+ * no attribute, and the ground and the letter, with the picture painted over
58
+ * them the moment it arrives. The markup of before, byte for byte.
59
+ * - `loaded`: the picture alone. No letter, and the ground is
60
+ * `pictureGround`'s: transparent (Asaf, 2026-11-17), so a transparent logo
61
+ * sits on whatever is behind it. The shape and the radius stay.
62
+ * - `error`: a 404, a dead signed URL, a blocked host. The ground and the
63
+ * letter, and the broken image is hidden, so a spoken `alt` is not drawn as
64
+ * text over the letter.
65
+ *
66
+ * Without JavaScript it stays the first frame, which is what it was before.
53
67
  *
54
68
  * ## `alt` is what makes an avatar speak
55
69
  *
@@ -180,6 +194,15 @@ const SQUARE_RADIUS = {
180
194
  };
181
195
  /** 15/32 of the box, `--cg-avatar-letter-ratio` (#482): 15px at 32, as the frame. */
182
196
  const PASTEL_RATIO = "--cg-avatar-letter-ratio";
197
+ /**
198
+ * The ground behind a LOADED picture (ui#511). Asaf's call, 2026-11-17:
199
+ * transparent, on every surface, so a transparent logo sits on the page and an
200
+ * opaque one fills the shape. No border: a hairline is possible if Asaf wants a
201
+ * transparent logo's square to read. This is the one place that decides it.
202
+ */
203
+ function pictureGround(_ground) {
204
+ return "transparent";
205
+ }
183
206
  const firstLetter = (name) => {
184
207
  // Array.from walks code points, so an emoji first is drawn whole, never half a pair.
185
208
  const ch = Array.from(name.trim())[0] ?? "";
@@ -197,29 +220,27 @@ function Avatar({ name, seed, src, alt, size = 24, monogram, shape = "circle", l
197
220
  // One rule, resolved once, so the three elements below cannot disagree about
198
221
  // whether this mark is announced. See the docblock: silent by default.
199
222
  const spoken = alt !== undefined;
200
- return (_jsxs("span", { "data-slot": "avatar", "data-size": box, "data-look": pastelToken ? `pastel-${AVATAR_PASTELS.indexOf(pastelToken) + 1}` : look.name, "data-shape": shape, ...(spoken ? { role: "img", "aria-label": alt } : { "aria-hidden": true }), className: cn("relative isolate inline-flex shrink-0 select-none items-center justify-center overflow-hidden", squareRadius ? null : "rounded-pill", pastel ? "font-normal" : "font-medium", className), style: {
223
+ // The identity tile's measured shade, and mixed toward --cg-ink the same
224
+ // way. Not mixed against --cg-surface-card: that token is `transparent`
225
+ // inside a purple panel, and mixing a hue into transparent gives a
226
+ // half-transparent hue rather than a shade.
227
+ // ui#496: one colour per person, space and grid, as in 0.53.1. 0.54.0
228
+ // painted every person lavender (Primary 20 under Primary press); that
229
+ // was a mistake in the design, and the identity look is back.
230
+ const ground = pastelToken
231
+ ? `var(${pastelToken})`
232
+ : `color-mix(in srgb, var(${look.hue}) ${look.tile}, var(--cg-ink))`;
233
+ return (_jsx(AvatarFrame, { src: src, imageAlt: spoken ? alt : "", letters: letters, pictureGround: pictureGround(ground), "data-slot": "avatar", "data-size": box, "data-look": pastelToken ? `pastel-${AVATAR_PASTELS.indexOf(pastelToken) + 1}` : look.name, "data-shape": shape, ...(spoken ? { role: "img", "aria-label": alt } : { "aria-hidden": true }), className: cn("relative isolate inline-flex shrink-0 select-none items-center justify-center overflow-hidden", squareRadius ? null : "rounded-pill", pastel ? "font-normal" : "font-medium", className), style: {
201
234
  width: box,
202
235
  height: box,
203
236
  // The diameter times a named ratio (#482), so the size is a token's.
204
237
  fontSize: `calc(${box}px * var(${pastel ? PASTEL_RATIO : MONOGRAM_RATIO}))`,
205
238
  ...(squareRadius ? { borderRadius: `var(${squareRadius})` } : null),
206
239
  lineHeight: 1,
207
- // The identity tile's measured shade, and mixed toward --cg-ink the same
208
- // way. Not mixed against --cg-surface-card: that token is `transparent`
209
- // inside a purple panel, and mixing a hue into transparent gives a
210
- // half-transparent hue rather than a shade.
211
- // ui#496: one colour per person, space and grid, as in 0.53.1. 0.54.0
212
- // painted every person lavender (Primary 20 under Primary press); that
213
- // was a mistake in the design, and the identity look is back.
214
- background: pastelToken
215
- ? `var(${pastelToken})`
216
- : `color-mix(in srgb, var(${look.hue}) ${look.tile}, var(--cg-ink))`,
240
+ background: ground,
217
241
  color: pastel ? "var(--cg-ink)" : "var(--cg-text-on-primary)",
218
242
  ...style,
219
- }, ...props, children: [_jsx("span", { "data-slot": "avatar-initials", "aria-hidden": "true", children: letters }), src ? (
220
- // Over the initials, never instead of them. `alt=""` when the mark is
221
- // silent, so a decorative avatar does not announce a filename.
222
- _jsx("img", { "data-slot": "avatar-image", src: src, alt: spoken ? alt : "", className: "absolute inset-0 size-full object-cover" })) : null] }));
243
+ }, ...props }));
223
244
  }
224
245
  export { Avatar };
225
246
  //# sourceMappingURL=avatar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../src/blocks/avatar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GACf,MAAM,+BAA+B,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EA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,IAAI,CAAC;YACnE,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,MAAM;YAClB,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,2BAA2B;YAC7D,GAAG,KAAK;SACT,KACG,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ declare function AvatarFrame({ src, imageAlt, letters, pictureGround, ...props }: Omit<React.ComponentProps<"span">, "children"> & {
3
+ src?: string;
4
+ /** The image's own `alt`: `""` when the mark is silent. */
5
+ imageAlt: string;
6
+ letters: string;
7
+ /** The ground under a loaded picture; `style.background` is the letter's. */
8
+ pictureGround: string;
9
+ }): React.JSX.Element;
10
+ export { AvatarFrame };
11
+ //# sourceMappingURL=avatar-frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-frame.d.ts","sourceRoot":"","sources":["../../src/lib/avatar-frame.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA6D9B,iBAAS,WAAW,CAAC,EACnB,GAAG,EACH,QAAQ,EACR,OAAO,EACP,aAAa,EACb,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IAClD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAA;CACtB,qBAkCA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ /**
5
+ * Keyed by `src`, so a new picture starts at `loading` again rather than
6
+ * inheriting the last one's answer.
7
+ *
8
+ * The load and error events are the main path. An image the browser finished
9
+ * before React hydrated fired its event before React listened, so the effect
10
+ * reads `complete` once: loaded if it has pixels. A finished image with no
11
+ * pixels is a failure, or an SVG with no size of its own; a fresh `Image` on
12
+ * the same URL, served from the cache, fires the event that tells them apart.
13
+ * Until then it is `loading`, which draws what the mark drew before ui#511.
14
+ */
15
+ function usePictureStatus(src) {
16
+ const image = React.useRef(null);
17
+ const [settled, setSettled] = React.useState(null);
18
+ React.useEffect(() => {
19
+ const el = image.current;
20
+ if (!src || !el?.complete)
21
+ return;
22
+ if (el.naturalWidth > 0) {
23
+ setSettled({ src, status: "loaded" });
24
+ return;
25
+ }
26
+ let live = true;
27
+ const probe = new window.Image();
28
+ probe.onload = () => live && setSettled({ src, status: "loaded" });
29
+ probe.onerror = () => live && setSettled({ src, status: "error" });
30
+ probe.src = el.currentSrc || src;
31
+ return () => {
32
+ live = false;
33
+ probe.onload = probe.onerror = null;
34
+ };
35
+ }, [src]);
36
+ const status = !src ? undefined : settled?.src === src ? settled.status : "loading";
37
+ const onLoad = () => {
38
+ if (src)
39
+ setSettled({ src, status: "loaded" });
40
+ };
41
+ const onError = () => {
42
+ if (src)
43
+ setSettled({ src, status: "error" });
44
+ };
45
+ return { image, status, onLoad, onError };
46
+ }
47
+ function AvatarFrame({ src, imageAlt, letters, pictureGround, ...props }) {
48
+ const picture = usePictureStatus(src);
49
+ const loaded = picture.status === "loaded";
50
+ return (
51
+ // `data-picture` only once the load is known, and `style` kept in its own
52
+ // place among the props, so the server's markup is what it was before
53
+ // ui#511, byte for byte (test/avatar-colours-496.test.mjs).
54
+ _jsxs("span", { ...props, style: loaded ? { ...props.style, background: pictureGround } : props.style, "data-picture": picture.status === "loading" ? undefined : picture.status, children: [loaded ? null : (_jsx("span", { "data-slot": "avatar-initials", "aria-hidden": "true", children: letters })), src ? (
55
+ // Over the initials while it loads, alone once it has. Not drawn when it
56
+ // fails, but kept: the element is where a test or devtools reads why.
57
+ _jsx("img", { ref: picture.image, "data-slot": "avatar-image", src: src, alt: imageAlt, style: picture.status === "error" ? { display: "none" } : undefined, onLoad: picture.onLoad, onError: picture.onError, className: "absolute inset-0 size-full object-cover" })) : null] }));
58
+ }
59
+ export { AvatarFrame };
60
+ //# sourceMappingURL=avatar-frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-frame.js","sourceRoot":"","sources":["../../src/lib/avatar-frame.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAkB9B;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CAAC,GAAuB;IAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAA;IAClD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqD,IAAI,CAAC,CAAA;IAEtG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAA;QACxB,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,QAAQ;YAAE,OAAM;QACjC,IAAI,EAAE,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YACxB,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;YACrC,OAAM;QACR,CAAC;QACD,IAAI,IAAI,GAAG,IAAI,CAAA;QACf,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAA;QAChC,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QAClE,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;QAClE,KAAK,CAAC,GAAG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AAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,aAEtE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACf,4BAAgB,iBAAiB,iBAAa,MAAM,YACjD,OAAO,GACH,CACR,EACA,GAAG,CAAC,CAAC,CAAC;YACL,yEAAyE;YACzE,sEAAsE;YACtE,cACE,GAAG,EAAE,OAAO,CAAC,KAAK,eACR,cAAc,EACxB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,EACnE,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,OAAO,EAAE,OAAO,CAAC,OAAO,EACxB,SAAS,EAAC,yCAAyC,GACnD,CACH,CAAC,CAAC,CAAC,IAAI,IACH,CACR,CAAA;AACH,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudgrid-io/ui",
3
- "version": "0.59.1",
3
+ "version": "0.59.2",
4
4
  "description": "CloudGrid design system: React components, brand design tokens, Tailwind theme, self-hosted fonts.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",