@jcsoftdev/ui 0.4.0 → 0.5.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.
Files changed (131) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +1 -1
  3. package/dist/atoms/button/button.d.ts +8 -1
  4. package/dist/atoms/button/button.js +10 -3
  5. package/dist/atoms/divider/divider.d.ts +15 -0
  6. package/dist/atoms/divider/divider.js +27 -0
  7. package/dist/atoms/divider/index.d.ts +1 -0
  8. package/dist/atoms/divider/index.js +1 -0
  9. package/dist/atoms/icon-button/icon-button.d.ts +1 -1
  10. package/dist/atoms/index.d.ts +1 -0
  11. package/dist/atoms/index.js +1 -0
  12. package/dist/auth/auth-illustration/auth-illustration.d.ts +35 -0
  13. package/dist/auth/auth-illustration/auth-illustration.js +72 -0
  14. package/dist/auth/auth-illustration/index.d.ts +3 -0
  15. package/dist/auth/auth-illustration/index.js +11 -0
  16. package/dist/auth/auth-illustration/look.d.ts +30 -0
  17. package/dist/auth/auth-illustration/look.js +0 -0
  18. package/dist/auth/auth-illustration/model.d.ts +133 -0
  19. package/dist/auth/auth-illustration/model.js +202 -0
  20. package/dist/auth/auth-illustration/use-art-pointer.d.ts +9 -0
  21. package/dist/auth/auth-illustration/use-art-pointer.js +69 -0
  22. package/dist/auth/auth-layout/auth-layout.d.ts +80 -0
  23. package/dist/auth/auth-layout/auth-layout.js +190 -0
  24. package/dist/auth/auth-layout/index.d.ts +1 -0
  25. package/dist/auth/auth-layout/index.js +1 -0
  26. package/dist/auth/character/character.d.ts +12 -0
  27. package/dist/auth/character/character.js +333 -0
  28. package/dist/auth/character/index.d.ts +1 -0
  29. package/dist/auth/character/index.js +1 -0
  30. package/dist/auth/index.d.ts +4 -0
  31. package/dist/auth/index.js +4 -0
  32. package/dist/auth/internal/auth-context.d.ts +17 -0
  33. package/dist/auth/internal/auth-context.js +10 -0
  34. package/dist/auth/internal/auth-styles.d.ts +1 -0
  35. package/dist/auth/internal/auth-styles.js +29 -0
  36. package/dist/auth/internal/portal-glyphs.d.ts +6 -0
  37. package/dist/auth/internal/portal-glyphs.js +39 -0
  38. package/dist/auth/login-form/context.d.ts +51 -0
  39. package/dist/auth/login-form/context.js +12 -0
  40. package/dist/auth/login-form/index.d.ts +2 -0
  41. package/dist/auth/login-form/index.js +23 -0
  42. package/dist/auth/login-form/login-form.d.ts +66 -0
  43. package/dist/auth/login-form/login-form.js +233 -0
  44. package/dist/auth/login-form/parts.d.ts +71 -0
  45. package/dist/auth/login-form/parts.js +371 -0
  46. package/dist/auth/looks/auth-illustration-any.d.ts +16 -0
  47. package/dist/auth/looks/auth-illustration-any.js +24 -0
  48. package/dist/auth/looks/index.d.ts +1 -0
  49. package/dist/auth/looks/index.js +1 -0
  50. package/dist/auth/mosaic/index.d.ts +1 -0
  51. package/dist/auth/mosaic/index.js +1 -0
  52. package/dist/auth/mosaic/mosaic.d.ts +11 -0
  53. package/dist/auth/mosaic/mosaic.js +195 -0
  54. package/dist/auth/slabs/index.d.ts +1 -0
  55. package/dist/auth/slabs/index.js +1 -0
  56. package/dist/auth/slabs/slabs.d.ts +13 -0
  57. package/dist/auth/slabs/slabs.js +136 -0
  58. package/dist/auth/stack/index.d.ts +1 -0
  59. package/dist/auth/stack/index.js +1 -0
  60. package/dist/auth/stack/stack.d.ts +6 -0
  61. package/dist/auth/stack/stack.js +222 -0
  62. package/dist/auth/statement/index.d.ts +1 -0
  63. package/dist/auth/statement/index.js +1 -0
  64. package/dist/auth/statement/statement.d.ts +13 -0
  65. package/dist/auth/statement/statement.js +99 -0
  66. package/dist/forms/index.d.ts +1 -0
  67. package/dist/forms/index.js +1 -0
  68. package/dist/forms/input/input.js +2 -1
  69. package/dist/forms/password-input/index.d.ts +1 -0
  70. package/dist/forms/password-input/index.js +1 -0
  71. package/dist/forms/password-input/password-input.d.ts +16 -0
  72. package/dist/forms/password-input/password-input.js +45 -0
  73. package/dist/i18n/strings.d.ts +64 -0
  74. package/dist/i18n/strings.js +34 -2
  75. package/dist/icons/eye.d.ts +2 -0
  76. package/dist/icons/eye.js +11 -0
  77. package/dist/icons/graduation-cap.d.ts +2 -0
  78. package/dist/icons/graduation-cap.js +12 -0
  79. package/dist/icons/house.d.ts +2 -0
  80. package/dist/icons/house.js +11 -0
  81. package/dist/icons/index.d.ts +4 -0
  82. package/dist/icons/index.js +8 -0
  83. package/dist/icons/mail.d.ts +2 -0
  84. package/dist/icons/mail.js +11 -0
  85. package/icons/svg/eye.svg +4 -0
  86. package/icons/svg/graduation-cap.svg +5 -0
  87. package/icons/svg/house.svg +4 -0
  88. package/icons/svg/mail.svg +4 -0
  89. package/package.json +2 -2
  90. package/src/atoms/button/button.tsx +25 -3
  91. package/src/atoms/divider/divider.tsx +40 -0
  92. package/src/atoms/divider/index.ts +1 -0
  93. package/src/atoms/icon-button/icon-button.tsx +1 -1
  94. package/src/atoms/index.ts +1 -0
  95. package/src/auth/auth-illustration/auth-illustration.tsx +100 -0
  96. package/src/auth/auth-illustration/index.ts +8 -0
  97. package/src/auth/auth-illustration/look.ts +32 -0
  98. package/src/auth/auth-illustration/model.ts +330 -0
  99. package/src/auth/auth-illustration/use-art-pointer.ts +78 -0
  100. package/src/auth/auth-layout/auth-layout.tsx +282 -0
  101. package/src/auth/auth-layout/index.ts +1 -0
  102. package/src/auth/character/character.tsx +346 -0
  103. package/src/auth/character/index.ts +1 -0
  104. package/src/auth/index.ts +4 -0
  105. package/src/auth/internal/auth-context.ts +26 -0
  106. package/src/auth/internal/auth-styles.tsx +39 -0
  107. package/src/auth/internal/portal-glyphs.tsx +32 -0
  108. package/src/auth/login-form/context.ts +78 -0
  109. package/src/auth/login-form/index.ts +21 -0
  110. package/src/auth/login-form/login-form.tsx +330 -0
  111. package/src/auth/login-form/parts.tsx +457 -0
  112. package/src/auth/looks/auth-illustration-any.tsx +38 -0
  113. package/src/auth/looks/index.ts +1 -0
  114. package/src/auth/mosaic/index.ts +1 -0
  115. package/src/auth/mosaic/mosaic.tsx +255 -0
  116. package/src/auth/slabs/index.ts +1 -0
  117. package/src/auth/slabs/slabs.tsx +181 -0
  118. package/src/auth/stack/index.ts +1 -0
  119. package/src/auth/stack/stack.tsx +267 -0
  120. package/src/auth/statement/index.ts +1 -0
  121. package/src/auth/statement/statement.tsx +122 -0
  122. package/src/forms/index.ts +1 -0
  123. package/src/forms/input/input.tsx +2 -0
  124. package/src/forms/password-input/index.ts +1 -0
  125. package/src/forms/password-input/password-input.tsx +57 -0
  126. package/src/i18n/strings.ts +64 -0
  127. package/src/icons/eye.tsx +12 -0
  128. package/src/icons/graduation-cap.tsx +13 -0
  129. package/src/icons/house.tsx +12 -0
  130. package/src/icons/index.ts +4 -0
  131. package/src/icons/mail.tsx +12 -0
@@ -0,0 +1,255 @@
1
+ "use client";
2
+
3
+ import type { CSSProperties } from "react";
4
+ import type { AuthVariantProps } from "../auth-illustration/look.js";
5
+ import {
6
+ isoBox,
7
+ isoPoint,
8
+ keystroke,
9
+ MOSAIC_GLYPH_TILES,
10
+ MOSAIC_SIZES,
11
+ mosaicFilled,
12
+ mosaicGlint,
13
+ mosaicTiles,
14
+ } from "../auth-illustration/model.js";
15
+ import { PORTAL_GLYPHS } from "../internal/portal-glyphs.js";
16
+
17
+ /** Side of the tiled floor, the platform's margin and thickness, and the tiles' depth, in iso units. */
18
+ const FLOOR = 260;
19
+ const MARGIN = 12;
20
+ const BASE_H = 26;
21
+ const TILE_H = 14;
22
+ const GAP = 3;
23
+ const VIEW = { x: -270, y: -215, w: 540, h: 400 } as const;
24
+ const CENTER_Y = VIEW.y + VIEW.h / 2;
25
+
26
+ const PLATFORM = isoBox(FLOOR + MARGIN * 2, FLOOR + MARGIN * 2, BASE_H);
27
+ const SHADOW = isoBox(FLOOR + MARGIN * 2 + 30, FLOOR + MARGIN * 2 + 30, 0).top;
28
+
29
+ /** Everything above the platform's two front edges: tile sides below the floor stay hidden. */
30
+ const CLIP = (() => {
31
+ const half = FLOOR / 2 + MARGIN;
32
+ const left = isoPoint(-half, half, BASE_H);
33
+ const front = isoPoint(half, half, BASE_H);
34
+ const right = isoPoint(half, -half, BASE_H);
35
+ return `M${left.x} ${left.y}L${front.x} ${front.y}L${right.x} ${right.y}L${right.x} ${VIEW.y}L${left.x} ${VIEW.y}Z`;
36
+ })();
37
+
38
+ /** The tiled floor seen from above, raised a little so lifted tiles stay inside it. */
39
+ const FLOOR_TOP = isoBox(FLOOR + MARGIN * 2, FLOOR + MARGIN * 2, BASE_H + 10).top;
40
+ /**
41
+ * A soft horizontal band, parked just above the floor: on this floor a diagonal of tiles is a
42
+ * screen row, so moving it 375px down sweeps the tiles in order.
43
+ */
44
+ const BAND = { x: -280, y: -251, w: 560, h: 72 } as const;
45
+ /** The idle sheen and the error sweep. */
46
+ const BANDS = ["sheen", "alarm"] as const;
47
+
48
+ const GRIDS = MOSAIC_SIZES.map((n) => {
49
+ const size = FLOOR / n;
50
+ const face = size - GAP;
51
+ const shape = isoBox(face, face, TILE_H);
52
+ const inset = face * 0.07;
53
+ const corner = isoPoint(-face / 2 + inset, -face / 2 + inset, TILE_H);
54
+ const k = (face - inset * 2) / 100;
55
+ const glyphTransform = `translate(${corner.x} ${corner.y}) matrix(${0.866 * k} ${0.5 * k} ${-0.866 * k} ${0.5 * k} 0 0)`;
56
+ const glyphs = MOSAIC_GLYPH_TILES[n];
57
+ const tiles = mosaicTiles(n).map((tile) => {
58
+ const at = isoPoint(
59
+ -FLOOR / 2 + (tile.col + 0.5) * size,
60
+ -FLOOR / 2 + (tile.row + 0.5) * size,
61
+ BASE_H - TILE_H,
62
+ );
63
+ const glyph = glyphs.findIndex(([row, col]) => row === tile.row && col === tile.col);
64
+ const top = isoPoint(0, 0, TILE_H);
65
+ return {
66
+ ...tile,
67
+ at,
68
+ glyph,
69
+ tx: Math.round(((at.x + top.x) / (VIEW.w / 2)) * 1000) / 1000,
70
+ ty: Math.round(((at.y + top.y - CENTER_Y) / (VIEW.h / 2)) * 1000) / 1000,
71
+ };
72
+ });
73
+ return { n, shape, glyphTransform, tiles };
74
+ });
75
+
76
+ /**
77
+ * Only the floor on screen animates. The other two sizes stay in the markup for the container
78
+ * queries, and Chrome still runs animations inside a hidden SVG group, so a hidden grid names no
79
+ * animation: the visible one sets the names through custom properties (an unset one leaves the
80
+ * `animation` declaration invalid, which means none).
81
+ */
82
+ const ON = '.ui-msc-grid[data-n="';
83
+ const SHOW =
84
+ "display:inline;--b:ui-msc-bob;--r:ui-msc-ripple;--g0:ui-msc-glint-0;--g1:ui-msc-glint-1";
85
+
86
+ const CSS = `
87
+ @keyframes ui-msc-glint-0{35%{transform:translateY(-9px)}}
88
+ @keyframes ui-msc-glint-1{35%{transform:translateY(-9px)}}
89
+ @keyframes ui-msc-sheen{58%{transform:none}86%,to{transform:translateY(375px)}}
90
+ @keyframes ui-msc-sweep{to{transform:translateY(375px)}}
91
+ @keyframes ui-msc-ripple{40%{transform:translateY(-12px)}75%{transform:translateY(2px)}}
92
+ @keyframes ui-msc-bob{50%{transform:translateY(-5px)}}
93
+ @keyframes ui-msc-rise{from{opacity:0;transform:translateY(40px)}}
94
+ .ui-msc{scale:1.12;transform-origin:50% 60%;--msc-base:color-mix(in srgb,var(--ink) 12%,var(--surface));--msc-tile:var(--surface);--msc-lit:var(--accent);--msc-active:color-mix(in srgb,var(--ink) 86%,var(--surface));--msc-glow:color-mix(in srgb,var(--accent-2) 70%,white);--msc-grout:color-mix(in srgb,var(--ink) 22%,transparent);--glyph-line:var(--accent)}
95
+ .ui-auth-art[data-panel=solid] .ui-msc{--msc-base:var(--ua-tint);--msc-tile:color-mix(in srgb,white 55%,var(--auth-art-bg));--msc-lit:var(--ua-mid);--msc-active:var(--auth-art-ink);--msc-glow:white;--msc-grout:color-mix(in srgb,var(--auth-art-ink) 28%,transparent);--glyph-line:var(--auth-art-ink)}
96
+ .ui-msc-grid{display:none}
97
+ @container art (width<24rem){${ON}4"]{${SHOW}}}
98
+ @container art (24rem<=width<34rem){.ui-msc{scale:.88}${ON}5"]{${SHOW}}}
99
+ @container art (width>=34rem){.ui-msc{scale:.9}${ON}6"]{${SHOW}}}
100
+ .ui-msc-stage{animation:ui-msc-rise .9s var(--ua-land) backwards .1s}
101
+ .ui-msc-shadow{fill:var(--ua-shadow)}
102
+ .ui-msc-base-top{fill:var(--msc-base)}
103
+ .ui-msc-base-left{fill:color-mix(in srgb,var(--msc-base) 82%,black)}
104
+ .ui-msc-base-right{fill:color-mix(in srgb,var(--msc-base) 66%,black)}
105
+ .ui-msc-dots{fill:color-mix(in srgb,black 28%,transparent)}
106
+ .ui-msc-edge{stroke:var(--msc-edge,var(--ua-edge));stroke-width:2.2;stroke-linejoin:round}
107
+ .ui-auth-art[data-state=error] .ui-msc{--msc-edge:color-mix(in srgb,var(--danger) 70%,var(--ua-edge))}
108
+ .ui-msc-tile{--top:var(--msc-tile);--glow:max(0,1 - (max(var(--px,9) - var(--tx),var(--tx) - var(--px,9)) + max(var(--py,9) - var(--ty),var(--ty) - var(--py,9))) * 2.6)}
109
+ .ui-msc-tile[data-lit]{--top:var(--msc-lit)}
110
+ .ui-msc-tile[data-active]{--top:var(--msc-active)}
111
+ .ui-msc-lift{transform:translateY(calc((var(--lit) * -8 - var(--glow) * 5 - var(--act) * 14) * 1px));transition:transform .55s var(--ua-bounce);transition-delay:calc(var(--d) * 28ms)}
112
+ .ui-msc-tile-top{fill:var(--msc-tile);stroke:var(--msc-grout);stroke-width:1.2;stroke-linejoin:round}
113
+ .ui-msc-tile[data-active] .ui-msc-tile-top{fill:var(--msc-active)}
114
+ .ui-msc-litface{fill:var(--msc-lit);opacity:var(--lit);transition:opacity .35s linear;transition-delay:calc(var(--d) * 28ms)}
115
+ .ui-msc-tile[data-active] .ui-msc-litface{opacity:0}
116
+ .ui-msc-tile-left{fill:color-mix(in srgb,var(--top) 78%,black)}
117
+ .ui-msc-side{opacity:max(var(--lit),var(--act));transition:opacity .2s linear;transition-delay:calc(var(--d) * 28ms)}
118
+ .ui-msc-tile-right{fill:color-mix(in srgb,var(--top) 62%,black)}
119
+ .ui-msc-tile[data-lit] .ui-msc-litface,.ui-msc-tile[data-active] .ui-msc-tile-top,.ui-msc-tile:is([data-lit],[data-active]) .ui-msc-side{stroke:var(--ua-edge);stroke-width:1.6;stroke-linejoin:round}
120
+ .ui-msc-glow{fill:var(--msc-glow);opacity:calc(var(--glow) * .7);transition:opacity .25s linear}
121
+ .ui-msc-sheen-stop{stop-color:white}
122
+ .ui-msc-alarm-stop{stop-color:var(--danger)}
123
+ .ui-msc-sheen{opacity:.5;animation:ui-msc-sheen 5s ease-in-out infinite}
124
+ .ui-auth-art[data-state=success] .ui-msc-sheen{opacity:.9;animation:ui-msc-sweep 1.1s .25s var(--ua-glide) backwards}
125
+ .ui-msc-alarm{opacity:.85}
126
+ .ui-auth-art[data-state=error] .ui-msc-alarm{animation:ui-msc-sweep .8s var(--ua-glide) both}
127
+ .ui-msc-bob{animation:var(--b) 3.2s ease-in-out infinite}
128
+ .ui-msc-glint-0{animation:var(--g0) .4s var(--ua-glide)}
129
+ .ui-msc-glint-1{animation:var(--g1) .4s var(--ua-glide)}
130
+ .ui-auth-art[data-state=success] .ui-msc-pop{animation:var(--r) .6s var(--ua-glide) backwards;animation-delay:calc(.25s + var(--ring) * 75ms)}
131
+ .ui-msc-glyph{--glyph-a:color-mix(in srgb,var(--ua-edge) 30%,var(--msc-tile));--glyph-b:color-mix(in srgb,var(--ua-edge) 30%,var(--msc-tile));--glyph-c:var(--msc-tile);--glyph-line:var(--msc-tile)}
132
+ .ui-msc-tile[data-lit] .ui-msc-glyph{--glyph-a:color-mix(in srgb,var(--msc-lit) 55%,black);--glyph-b:color-mix(in srgb,var(--msc-lit) 55%,black);--glyph-c:var(--msc-lit);--glyph-line:var(--msc-lit)}
133
+ .ui-msc-tile[data-active] .ui-msc-glyph{--glyph-a:var(--msc-lit);--glyph-b:var(--msc-tile);--glyph-c:var(--msc-active);--glyph-line:var(--msc-tile)}
134
+ .ui-auth-art[data-panel=solid] .ui-msc-tile[data-active] .ui-msc-glyph{--glyph-a:var(--ua-tint);--glyph-b:var(--ua-tint);--glyph-c:var(--auth-art-ink)}
135
+ @media (prefers-reduced-motion:reduce){
136
+ .ui-msc *{animation:none!important}
137
+ .ui-auth-art[data-state=error] .ui-msc-alarm{opacity:.5;transform:translateY(916px) scaleY(4.4)}
138
+ .ui-msc-lift,.ui-msc-litface,.ui-msc-side{transition:none}
139
+ }
140
+ `;
141
+
142
+ /**
143
+ * A living floor of isometric tiles on a platform. The tiles light diagonally as the form fills,
144
+ * glint on each keystroke and glow under the pointer, and a soft sheen crosses the floor now and
145
+ * then; an error sweeps a red band across it and success ripples out from the centre. Three tiles carry the portal glyphs and the active one
146
+ * stands raised. Its container picks a 4, 5 or 6 tile wide floor.
147
+ */
148
+ export function Mosaic({ state, progress, activeIndex, uid }: AuthVariantProps) {
149
+ const dots = `url(#${uid}-mosaic-dots)`;
150
+ // The glint class of the last keystroke stays on through every state, so leaving an error does
151
+ // not replay it (a CSS animation restarts only when its class changes).
152
+ const tick = keystroke(progress);
153
+ return (
154
+ <>
155
+ <style href="jcsoftdev-ui-auth-mosaic" precedence="default">
156
+ {CSS}
157
+ </style>
158
+ {/* biome-ignore lint/a11y/noSvgWithoutTitle: the wrapper names the illustration or hides it */}
159
+ <svg viewBox={`${VIEW.x} ${VIEW.y} ${VIEW.w} ${VIEW.h}`} focusable="false" className="ui-msc">
160
+ <defs>
161
+ <pattern id={`${uid}-mosaic-dots`} width="5" height="5" patternUnits="userSpaceOnUse">
162
+ <circle className="ui-msc-dots" cx="2.5" cy="2.5" r="1" />
163
+ </pattern>
164
+ <clipPath id={`${uid}-mosaic-clip`}>
165
+ <path d={CLIP} />
166
+ </clipPath>
167
+ <clipPath id={`${uid}-mosaic-floor`}>
168
+ <path d={FLOOR_TOP} />
169
+ </clipPath>
170
+ {BANDS.map((band) => (
171
+ <linearGradient key={band} id={`${uid}-mosaic-${band}`} x1="0" y1="0" x2="0" y2="1">
172
+ <stop className={`ui-msc-${band}-stop`} offset="0" stopOpacity="0" />
173
+ <stop className={`ui-msc-${band}-stop`} offset=".5" stopOpacity="1" />
174
+ <stop className={`ui-msc-${band}-stop`} offset="1" stopOpacity="0" />
175
+ </linearGradient>
176
+ ))}
177
+ </defs>
178
+ <g className="ui-msc-stage">
179
+ <path className="ui-msc-shadow" d={SHADOW} transform="translate(16 18)" />
180
+ <path className="ui-msc-base-left ui-msc-edge" d={PLATFORM.left} />
181
+ <path className="ui-msc-base-right ui-msc-edge" d={PLATFORM.right} />
182
+ <path d={PLATFORM.left} fill={dots} />
183
+ <path d={PLATFORM.right} fill={dots} />
184
+ <path className="ui-msc-base-top ui-msc-edge" d={PLATFORM.top} />
185
+ <g clipPath={`url(#${uid}-mosaic-clip)`}>
186
+ {GRIDS.map(({ n, shape, glyphTransform, tiles }) => {
187
+ const lit = mosaicFilled(state, progress, n);
188
+ const glint = mosaicGlint(tick.count, n);
189
+ return (
190
+ <g key={n} className="ui-msc-grid" data-n={n}>
191
+ {tiles.map((tile, k) => {
192
+ const on = tile.diagonal < lit;
193
+ const active = tile.glyph >= 0 && tile.glyph === activeIndex;
194
+ const vars = {
195
+ "--d": tile.diagonal,
196
+ "--ring": tile.ring,
197
+ "--lit": on ? 1 : 0,
198
+ "--act": active ? 1 : 0,
199
+ "--tx": tile.tx,
200
+ "--ty": tile.ty,
201
+ } as CSSProperties;
202
+ const pop =
203
+ k === glint ? `ui-msc-pop ui-msc-glint-${tick.phase}` : "ui-msc-pop";
204
+ return (
205
+ <g
206
+ key={`${tile.row}:${tile.col}`}
207
+ className="ui-msc-tile"
208
+ data-lit={on || undefined}
209
+ data-active={active || undefined}
210
+ style={vars}
211
+ transform={`translate(${tile.at.x} ${tile.at.y})`}
212
+ >
213
+ <g className="ui-msc-lift">
214
+ <g className={pop}>
215
+ <g className={active ? "ui-msc-bob" : undefined}>
216
+ <path className="ui-msc-side ui-msc-tile-left" d={shape.left} />
217
+ <path className="ui-msc-side ui-msc-tile-right" d={shape.right} />
218
+ <path className="ui-msc-tile-top" d={shape.top} />
219
+ <path className="ui-msc-litface" d={shape.top} />
220
+ <path className="ui-msc-glow" d={shape.top} />
221
+ {tile.glyph >= 0 ? (
222
+ <g className="ui-msc-glyph" transform={glyphTransform}>
223
+ {PORTAL_GLYPHS[tile.glyph]}
224
+ </g>
225
+ ) : null}
226
+ </g>
227
+ </g>
228
+ </g>
229
+ </g>
230
+ );
231
+ })}
232
+ </g>
233
+ );
234
+ })}
235
+ </g>
236
+ <g clipPath={`url(#${uid}-mosaic-floor)`}>
237
+ {BANDS.map((band) => (
238
+ <rect
239
+ key={band}
240
+ className={`ui-msc-band ui-msc-${band}`}
241
+ fill={`url(#${uid}-mosaic-${band})`}
242
+ x={BAND.x}
243
+ y={BAND.y}
244
+ width={BAND.w}
245
+ height={BAND.h}
246
+ />
247
+ ))}
248
+ </g>
249
+ </g>
250
+ </svg>
251
+ </>
252
+ );
253
+ }
254
+
255
+ Mosaic.variant = "mosaic";
@@ -0,0 +1 @@
1
+ export * from "./slabs.js";
@@ -0,0 +1,181 @@
1
+ "use client";
2
+
3
+ import type { CSSProperties } from "react";
4
+ import {
5
+ type AuthState,
6
+ keystroke,
7
+ SLAB_COUNT,
8
+ slabPlacement,
9
+ slabSpread,
10
+ sparkVectors,
11
+ } from "../auth-illustration/model.js";
12
+ import { PORTAL_GLYPHS } from "../internal/portal-glyphs.js";
13
+
14
+ /** Rules of the slabs look: colours per slab, depth faces, entrance, parallax, hop and cheer. */
15
+ const CSS = `
16
+ @keyframes ui-auth-drop{0%{opacity:0;transform:translateY(-180px)}45%{opacity:1}}
17
+ @keyframes ui-auth-shadow-in{from{opacity:0;transform:scale(.35)}}
18
+ @keyframes ui-auth-bob{50%{transform:translateY(-7px)}}
19
+ @keyframes ui-auth-hop-0{40%{transform:translateY(-11px)}}
20
+ @keyframes ui-auth-hop-1{40%{transform:translateY(-11px)}}
21
+ @keyframes ui-auth-cheer{35%{transform:translateY(-18px)}70%{transform:translateY(3px)}}
22
+ .ui-auth-slab-tone-0{--top:var(--accent);--glyph-a:var(--surface);--glyph-b:var(--ink);--glyph-c:var(--accent);--dots:color-mix(in srgb,black 30%,transparent)}
23
+ .ui-auth-slab-tone-1{--top:var(--surface);--glyph-a:var(--accent);--glyph-b:var(--ink);--glyph-c:var(--surface);--dots:color-mix(in srgb,black 30%,transparent)}
24
+ .ui-auth-slab-tone-2{--top:color-mix(in srgb,var(--ink) 86%,var(--surface));--glyph-a:var(--accent);--glyph-b:var(--surface);--glyph-c:var(--surface);--dots:color-mix(in srgb,white 20%,transparent)}
25
+ .ui-auth-art[data-panel=solid] .ui-auth-slab-tone-0{--top:var(--auth-art-ink);--glyph-a:var(--auth-art-bg);--glyph-b:var(--auth-art-ink);--glyph-c:var(--ua-tint);--dots:color-mix(in srgb,var(--auth-art-bg) 30%,transparent)}
26
+ .ui-auth-art[data-panel=solid] .ui-auth-slab-tone-1{--top:var(--ua-tint);--glyph-a:var(--auth-art-ink);--glyph-b:var(--auth-art-ink);--glyph-c:var(--ua-tint);--dots:color-mix(in srgb,var(--auth-art-ink) 35%,transparent)}
27
+ .ui-auth-art[data-panel=solid] .ui-auth-slab-tone-2{--top:var(--ua-mid);--glyph-a:var(--ua-tint);--glyph-b:var(--auth-art-ink);--glyph-c:var(--ua-mid);--dots:color-mix(in srgb,var(--auth-art-ink) 35%,transparent)}
28
+ .ui-auth-art[data-panel=solid] .ui-auth-inlay{stroke:color-mix(in srgb,var(--auth-art-ink) 22%,transparent)}
29
+ .ui-auth-slab{--glyph-line:var(--accent);--left:color-mix(in srgb,var(--top) 82%,black);--right:color-mix(in srgb,var(--top) 66%,black)}
30
+ .ui-auth-art[data-panel=solid] .ui-auth-slab-tone-0{--glyph-line:var(--auth-art-ink)}
31
+ .ui-auth-art[data-panel=solid] .ui-auth-slab-tone-2{--glyph-line:var(--ua-tint)}
32
+ .ui-auth-art[data-state=error] .ui-auth-slab{--edge:color-mix(in srgb,var(--danger) 70%,var(--ua-edge))}
33
+ .ui-auth-pos{transform:translate(calc(var(--x) * 1px),calc(var(--y) * 1px));transition:transform .85s var(--ua-bounce)}
34
+ .ui-auth-par{transform:translate(calc(var(--px,0) * (5px + var(--i) * 3px)),calc(var(--py,0) * (4px + var(--i) * 2px)));transition:transform .6s var(--ua-glide)}
35
+ .ui-auth-lift{transform:translateY(calc(var(--lift) * -1px));transition:transform .85s var(--ua-bounce)}
36
+ .ui-auth-enter{animation:ui-auth-drop .9s var(--ua-land) backwards;animation-delay:calc(.15s + var(--i) * .14s)}
37
+ .ui-auth-hop-0{animation:ui-auth-hop-0 .32s var(--ua-glide)}
38
+ .ui-auth-hop-1{animation:ui-auth-hop-1 .32s var(--ua-glide)}
39
+ .ui-auth-art[data-state=success] .ui-auth-hop{animation:ui-auth-cheer .5s var(--ua-glide) backwards;animation-delay:calc(.75s + var(--i) * .07s)}
40
+ .ui-auth-bob{animation:ui-auth-bob 4.6s ease-in-out infinite;animation-delay:calc(var(--i) * -1.4s)}
41
+ .ui-auth-face-top{fill:var(--top)}
42
+ .ui-auth-face-left{fill:var(--left)}
43
+ .ui-auth-face-right{fill:var(--right)}
44
+ .ui-auth-edge{stroke:var(--edge,var(--ua-edge));stroke-width:2.2;stroke-linejoin:round}
45
+ .ui-auth-dots{fill:var(--dots)}
46
+ .ui-auth-shadow{fill:var(--ua-shadow);transform-box:fill-box;transform-origin:center;opacity:calc(1 - var(--lift) / 150);transition:opacity .85s var(--ua-glide);animation:ui-auth-shadow-in .9s var(--ua-land) backwards;animation-delay:calc(.15s + var(--i) * .14s)}
47
+ .ui-auth-inlay{fill:none;stroke:color-mix(in srgb,var(--ink) 14%,transparent);stroke-width:2}
48
+ @media (prefers-reduced-motion:reduce){
49
+ .ui-auth-enter,.ui-auth-bob,.ui-auth-art[data-state] .ui-auth-hop,.ui-auth-hop-0,.ui-auth-hop-1,.ui-auth-shadow{animation:none}
50
+ .ui-auth-pos,.ui-auth-lift,.ui-auth-shadow{transition:none}
51
+ .ui-auth-par{transform:none;transition:none}
52
+ }
53
+ `;
54
+
55
+ const THICKNESS = 22;
56
+ const TOP = "M0 0 L86.6 50 L0 100 L-86.6 50Z";
57
+ const LEFT = `M-86.6 50 L0 100 L0 ${100 + THICKNESS} L-86.6 ${50 + THICKNESS}Z`;
58
+ const RIGHT = `M0 100 L86.6 50 L86.6 ${50 + THICKNESS} L0 ${100 + THICKNESS}Z`;
59
+ const SPARK = "M0-11 L3-3 L11 0 L3 3 L0 11 L-3 3 L-11 0 L-3-3Z";
60
+ const SPARKS = sparkVectors();
61
+
62
+ function Slab({
63
+ index,
64
+ spread,
65
+ activeIndex,
66
+ dotsId,
67
+ hop,
68
+ }: {
69
+ index: number;
70
+ spread: number;
71
+ activeIndex: number;
72
+ dotsId: string;
73
+ hop: 0 | 1 | null;
74
+ }) {
75
+ const live = slabPlacement(index, spread, activeIndex);
76
+ const vars = {
77
+ "--i": index,
78
+ "--x": live.x,
79
+ "--y": live.y,
80
+ "--lift": live.lift,
81
+ } as CSSProperties;
82
+ const dots = `url(#${dotsId})`;
83
+ return (
84
+ <g className={`ui-auth-pos ui-auth-slab ui-auth-slab-tone-${index}`} style={vars}>
85
+ <g transform={`translate(24 ${THICKNESS + 22})`}>
86
+ <path className="ui-auth-shadow" d={TOP} />
87
+ </g>
88
+ <g className="ui-auth-par">
89
+ <g className="ui-auth-lift">
90
+ <g className="ui-auth-enter">
91
+ <g className={hop === null ? "ui-auth-hop" : `ui-auth-hop ui-auth-hop-${hop}`}>
92
+ <g className="ui-auth-bob">
93
+ <path className="ui-auth-face-left ui-auth-edge" d={LEFT} />
94
+ <path className="ui-auth-face-right ui-auth-edge" d={RIGHT} />
95
+ <path d={LEFT} fill={dots} />
96
+ <path d={RIGHT} fill={dots} />
97
+ <path className="ui-auth-face-top ui-auth-edge" d={TOP} />
98
+ <g transform="matrix(0.866 0.5 -0.866 0.5 0 0)">
99
+ <rect className="ui-auth-inlay" x="9" y="9" width="82" height="82" rx="8" />
100
+ {PORTAL_GLYPHS[index]}
101
+ </g>
102
+ </g>
103
+ </g>
104
+ </g>
105
+ </g>
106
+ </g>
107
+ </g>
108
+ );
109
+ }
110
+
111
+ export interface SlabsProps {
112
+ state: AuthState;
113
+ progress: number;
114
+ activeIndex: number;
115
+ /** Unique within the page; names the halftone pattern. */
116
+ uid: string;
117
+ }
118
+
119
+ /** Three isometric portal slabs that float apart at rest and assemble as the form fills. */
120
+ export function Slabs({ state, progress, activeIndex, uid }: SlabsProps) {
121
+ const spread = slabSpread(state, progress);
122
+ const dotsId = `${uid}-dots`;
123
+ // The last keystroke's hop class stays on through every state: a CSS animation restarts only
124
+ // when its class changes, so an error settling back to password, or a refocus, never hops.
125
+ const tick = keystroke(progress, SLAB_COUNT);
126
+ return (
127
+ <>
128
+ <style href="jcsoftdev-ui-auth-slabs" precedence="default">
129
+ {CSS}
130
+ </style>
131
+ {/* biome-ignore lint/a11y/noSvgWithoutTitle: the wrapper names the illustration or hides it */}
132
+ <svg
133
+ viewBox="40 60 560 440"
134
+ focusable="false"
135
+ style={{ "--spread": spread } as CSSProperties}
136
+ >
137
+ <defs>
138
+ <pattern id={dotsId} width="5" height="5" patternUnits="userSpaceOnUse">
139
+ <circle className="ui-auth-dots" cx="2.5" cy="2.5" r="1" />
140
+ </pattern>
141
+ </defs>
142
+ {Array.from({ length: SLAB_COUNT }, (_, index) => (
143
+ <Slab
144
+ // biome-ignore lint/suspicious/noArrayIndexKey: the three slabs are fixed
145
+ key={index}
146
+ index={index}
147
+ spread={spread}
148
+ activeIndex={activeIndex}
149
+ dotsId={dotsId}
150
+ hop={tick.count > 0 && tick.target === index ? tick.phase : null}
151
+ />
152
+ ))}
153
+ {state === "success" ? (
154
+ <g>
155
+ {SPARKS.map((spark, n) => (
156
+ <g key={`${spark.dx}:${spark.dy}`} transform="translate(320 250)">
157
+ {n % 2 ? (
158
+ <circle
159
+ className="ui-auth-spark"
160
+ data-tone={n % 4}
161
+ r="5"
162
+ style={{ "--dx": `${spark.dx}px`, "--dy": `${spark.dy}px` } as CSSProperties}
163
+ />
164
+ ) : (
165
+ <path
166
+ className="ui-auth-spark"
167
+ data-tone={n % 4}
168
+ d={SPARK}
169
+ style={{ "--dx": `${spark.dx}px`, "--dy": `${spark.dy}px` } as CSSProperties}
170
+ />
171
+ )}
172
+ </g>
173
+ ))}
174
+ </g>
175
+ ) : null}
176
+ </svg>
177
+ </>
178
+ );
179
+ }
180
+
181
+ Slabs.variant = "slabs";
@@ -0,0 +1 @@
1
+ export * from "./stack.js";