@principal-ai/logo-component 0.1.23 → 0.1.24
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/FileCityBotAvatar.d.ts +31 -0
- package/dist/FileCityBotAvatar.js +161 -0
- package/dist/FileCityLogo.d.ts +35 -1
- package/dist/FileCityLogo.js +39 -6
- package/dist/FileCityLogoAnimated.d.ts +13 -0
- package/dist/FileCityLogoAnimated.js +235 -5
- package/dist/botAvatarLayout.d.ts +205 -0
- package/dist/botAvatarLayout.js +353 -0
- package/dist/esm/FileCityBotAvatar.js +124 -0
- package/dist/esm/FileCityLogo.js +39 -6
- package/dist/esm/FileCityLogoAnimated.js +235 -5
- package/dist/esm/botAvatarLayout.js +348 -0
- package/dist/esm/index.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.js +7 -1
- package/package.json +2 -2
|
@@ -36,6 +36,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.FileCityLogoAnimated = void 0;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const FileCityLogo_1 = require("./FileCityLogo");
|
|
39
|
+
// Each lit file of the P and the face square it slides to, as [col, row] on
|
|
40
|
+
// the 7×7 grid. The P has ten files and the face needs eleven (two 2×2 eyes
|
|
41
|
+
// and a three-file mouth), so the last one starts stacked on the P's foot.
|
|
42
|
+
const FACE_MOVES = [
|
|
43
|
+
{ home: [2, 1], face: [1, 1], part: 'eyeL' },
|
|
44
|
+
{ home: [3, 1], face: [2, 1], part: 'eyeL' },
|
|
45
|
+
{ home: [2, 2], face: [1, 2], part: 'eyeL' },
|
|
46
|
+
{ home: [2, 3], face: [2, 2], part: 'eyeL' },
|
|
47
|
+
{ home: [4, 1], face: [5, 1], part: 'eyeR' },
|
|
48
|
+
{ home: [4, 2], face: [5, 2], part: 'eyeR' },
|
|
49
|
+
{ home: [3, 3], face: [4, 1], part: 'eyeR' },
|
|
50
|
+
{ home: [4, 3], face: [4, 2], part: 'eyeR' },
|
|
51
|
+
{ home: [2, 4], face: [2, 5], part: 'mouth' },
|
|
52
|
+
{ home: [2, 5], face: [3, 5], part: 'mouth' },
|
|
53
|
+
{ home: [2, 5], face: [4, 5], part: 'mouth' },
|
|
54
|
+
];
|
|
55
|
+
// The smile's upturned corners, which pop in beside the mouth.
|
|
56
|
+
const SMILE_CORNERS = [
|
|
57
|
+
[1, 4],
|
|
58
|
+
[5, 4],
|
|
59
|
+
];
|
|
60
|
+
function lighten(color, t) {
|
|
61
|
+
if (!/^#[0-9a-f]{6}$/i.test(color))
|
|
62
|
+
return color;
|
|
63
|
+
const ch = (i) => {
|
|
64
|
+
const v = parseInt(color.slice(1 + i * 2, 3 + i * 2), 16);
|
|
65
|
+
return Math.round(v + (255 - v) * t)
|
|
66
|
+
.toString(16)
|
|
67
|
+
.padStart(2, '0');
|
|
68
|
+
};
|
|
69
|
+
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
70
|
+
}
|
|
39
71
|
// CSS keyframe name for the connector draw-on. CSS animations restart on
|
|
40
72
|
// element remount (unlike SMIL's document-timeline `begin`), so each group's
|
|
41
73
|
// freshly-keyed connector draws from the start.
|
|
@@ -63,12 +95,14 @@ function mulberry32(seed) {
|
|
|
63
95
|
const FileCityLogoAnimated = (props) => {
|
|
64
96
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
65
97
|
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
66
|
-
const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, } = props;
|
|
98
|
+
const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, face: faceMode = 'none', } = props;
|
|
99
|
+
const watch = faceMode === 'watch';
|
|
100
|
+
const wake = faceMode === 'wake';
|
|
67
101
|
// The trail line is a light grey (close to white); the nodes it threads
|
|
68
102
|
// to are marked with accent-colored dots so the destinations pop.
|
|
69
103
|
const trailColor = connectorColor !== null && connectorColor !== void 0 ? connectorColor : '#e5e7eb';
|
|
70
104
|
const dotColor = (_f = (_d = (_c = (_a = props.accent) !== null && _a !== void 0 ? _a : (_b = props.theme) === null || _b === void 0 ? void 0 : _b.colors.accent) !== null && _c !== void 0 ? _c : props.primary) !== null && _d !== void 0 ? _d : (_e = props.theme) === null || _e === void 0 ? void 0 : _e.colors.primary) !== null && _f !== void 0 ? _f : '#22d3ee';
|
|
71
|
-
const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = (0, react_1.useMemo)(() => (0, FileCityLogo_1.computeFileCityLayout)(props),
|
|
105
|
+
const { cells, extras, ribbon, bgColor, baseColor, rounded, opacity, mark, gloss } = (0, react_1.useMemo)(() => (0, FileCityLogo_1.computeFileCityLayout)(props),
|
|
72
106
|
// Re-derive only when an input that affects layout changes.
|
|
73
107
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
108
|
[
|
|
@@ -88,6 +122,7 @@ const FileCityLogoAnimated = (props) => {
|
|
|
88
122
|
props.opacity,
|
|
89
123
|
props.gloss,
|
|
90
124
|
props.squareRadius,
|
|
125
|
+
props.devRibbon,
|
|
91
126
|
]);
|
|
92
127
|
// Per-cell number of samples to fully reveal it (>=1; letter cells take
|
|
93
128
|
// `buildSteps`, city cells proportionally fewer by their weight).
|
|
@@ -120,6 +155,65 @@ const FileCityLogoAnimated = (props) => {
|
|
|
120
155
|
// walked the animation is done and the logo holds.
|
|
121
156
|
const [progress, setProgress] = (0, react_1.useState)(() => cells.map(() => 0));
|
|
122
157
|
const [done, setDone] = (0, react_1.useState)(false);
|
|
158
|
+
// The sheen used to start the moment the build finished; with a watching
|
|
159
|
+
// face it waits until the face has merged into the P.
|
|
160
|
+
const [sheen, setSheen] = (0, react_1.useState)(false);
|
|
161
|
+
const [face, setFace] = (0, react_1.useState)(null);
|
|
162
|
+
// Which way the eyes are looking, in grid squares.
|
|
163
|
+
const [look, setLook] = (0, react_1.useState)([0, 0]);
|
|
164
|
+
// Face geometry — only for the plain centred P on its 7×7 grid, where the
|
|
165
|
+
// face's squares line up with the logo's.
|
|
166
|
+
const faceGeo = (0, react_1.useMemo)(() => {
|
|
167
|
+
var _a, _b, _c;
|
|
168
|
+
if (faceMode === 'none' || mark !== 'P' || cells.length < 2)
|
|
169
|
+
return null;
|
|
170
|
+
const letters = cells.filter((cell) => cell.isLetter);
|
|
171
|
+
const side = Math.max(...cells.map((cell) => cell.c)) + 1;
|
|
172
|
+
const minC = Math.min(...letters.map((cell) => cell.c));
|
|
173
|
+
const minR = Math.min(...letters.map((cell) => cell.r));
|
|
174
|
+
// The face is authored with the P at column 2, row 1 (the 7×7 logo).
|
|
175
|
+
// Shift it to wherever the P actually sits — e.g. the edge-to-edge 5×5
|
|
176
|
+
// `margin={0}` mark — and bail if it wouldn't fit on the grid.
|
|
177
|
+
const dc = minC - 2;
|
|
178
|
+
const dr = minR - 1;
|
|
179
|
+
const fits = [...FACE_MOVES.map((m) => m.face), ...SMILE_CORNERS].every(([c, r]) => c + dc >= 0 && c + dc < side && r + dr >= 0 && r + dr < side);
|
|
180
|
+
const isPlainP = FACE_MOVES.every((m) => letters.some((l) => l.c === m.home[0] + dc && l.r === m.home[1] + dr));
|
|
181
|
+
if (letters.length !== 10 || !fits || !isPlainP)
|
|
182
|
+
return null;
|
|
183
|
+
const a = cells[0];
|
|
184
|
+
const b = cells.find((cell) => cell.c !== a.c);
|
|
185
|
+
const pitch = (b.x - a.x) / (b.c - a.c);
|
|
186
|
+
const at = (c, r) => ({
|
|
187
|
+
x: a.x + (c + dc - a.c) * pitch,
|
|
188
|
+
y: a.y + (r + dr - a.r) * pitch,
|
|
189
|
+
});
|
|
190
|
+
const primary = (_c = (_a = props.primary) !== null && _a !== void 0 ? _a : (_b = props.theme) === null || _b === void 0 ? void 0 : _b.colors.primary) !== null && _c !== void 0 ? _c : '#22d3ee';
|
|
191
|
+
const tiles = FACE_MOVES.map((move, i) => {
|
|
192
|
+
const cell = letters.find((l) => l.c === move.home[0] + dc && l.r === move.home[1] + dr);
|
|
193
|
+
return {
|
|
194
|
+
key: `face-${i}`,
|
|
195
|
+
part: move.part,
|
|
196
|
+
home: at(...move.home),
|
|
197
|
+
face: at(...move.face),
|
|
198
|
+
fill: cell.fill,
|
|
199
|
+
stroke: cell.stroke,
|
|
200
|
+
strokeWidth: cell.strokeWidth,
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
const block = (c) => (Object.assign(Object.assign({}, at(c, 1)), { size: pitch + a.sq }));
|
|
204
|
+
return {
|
|
205
|
+
pitch,
|
|
206
|
+
sq: a.sq,
|
|
207
|
+
rx: a.rx,
|
|
208
|
+
tiles,
|
|
209
|
+
eyeColor: lighten(primary, 0.6),
|
|
210
|
+
// Match the mouth's own files, which carry the P's gradient shade.
|
|
211
|
+
mouthColor: tiles[tiles.length - 1].fill,
|
|
212
|
+
eyes: { eyeL: block(1), eyeR: block(4) },
|
|
213
|
+
corners: SMILE_CORNERS.map(([c, r]) => at(c, r)),
|
|
214
|
+
};
|
|
215
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
216
|
+
}, [cells, mark, faceMode, props.primary, props.theme]);
|
|
123
217
|
// The connector for the active group: which group it traces, and whether
|
|
124
218
|
// it's drawing on (during the reveal) or fading out (during the pause).
|
|
125
219
|
const [conn, setConn] = (0, react_1.useState)(null);
|
|
@@ -140,14 +234,34 @@ const FileCityLogoAnimated = (props) => {
|
|
|
140
234
|
setProgress(cells.map(() => 0));
|
|
141
235
|
setConn(null);
|
|
142
236
|
setDone(false);
|
|
237
|
+
setSheen(false);
|
|
238
|
+
setLook([0, 0]);
|
|
239
|
+
setFace(null);
|
|
143
240
|
if (!autoPlay || cells.length === 0 || reduce) {
|
|
144
241
|
setProgress(stepsFor.slice());
|
|
145
242
|
setDone(true);
|
|
243
|
+
setSheen(true);
|
|
146
244
|
(_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
|
|
147
245
|
return;
|
|
148
246
|
}
|
|
149
247
|
let timer;
|
|
150
248
|
let fadeTimer;
|
|
249
|
+
let blinkTimer;
|
|
250
|
+
let enterTimer;
|
|
251
|
+
// The watching face is on stage before the first file appears.
|
|
252
|
+
if (watch && faceGeo) {
|
|
253
|
+
setFace({
|
|
254
|
+
at: 'face',
|
|
255
|
+
blocks: true,
|
|
256
|
+
mouth: false,
|
|
257
|
+
smile: false,
|
|
258
|
+
blink: false,
|
|
259
|
+
wink: false,
|
|
260
|
+
visible: false,
|
|
261
|
+
hideLetters: false,
|
|
262
|
+
});
|
|
263
|
+
enterTimer = setTimeout(() => setFace((f) => f && Object.assign(Object.assign({}, f), { visible: true })), 40);
|
|
264
|
+
}
|
|
151
265
|
// Hold the finished trail on screen before it fades, so the completed
|
|
152
266
|
// group lingers a beat. Keep linger + fade within the pause.
|
|
153
267
|
const lingerMs = Math.max(0, Math.min(pauseMs - fadeMs - 40, 450));
|
|
@@ -164,6 +278,14 @@ const FileCityLogoAnimated = (props) => {
|
|
|
164
278
|
const group = groups[gi];
|
|
165
279
|
const mi = memberRef.current;
|
|
166
280
|
const idx = group[mi];
|
|
281
|
+
// The eyes turn once per group, towards where most of it is, rather
|
|
282
|
+
// than darting to every file as it lights up.
|
|
283
|
+
if (watch && faceGeo && mi === 0) {
|
|
284
|
+
const c = group.reduce((sum, i) => sum + cells[i].c, 0) / group.length;
|
|
285
|
+
const r = group.reduce((sum, i) => sum + cells[i].r, 0) / group.length;
|
|
286
|
+
const mid = (Math.max(...cells.map((cell) => cell.c)) + 0) / 2;
|
|
287
|
+
setLook([c < mid - 0.4 ? -1 : c > mid + 0.4 ? 1 : 0, r < mid - 0.6 ? -1 : r > mid + 0.6 ? 1 : 0]);
|
|
288
|
+
}
|
|
167
289
|
setProgress((prev) => {
|
|
168
290
|
const next = prev.slice();
|
|
169
291
|
next[idx] = Math.min(stepsFor[idx], next[idx] + 1);
|
|
@@ -177,6 +299,11 @@ const FileCityLogoAnimated = (props) => {
|
|
|
177
299
|
// The trail is fully drawn — hold it for `lingerMs`, then flip to
|
|
178
300
|
// fading so it dissolves before the next group begins.
|
|
179
301
|
fadeTimer = setTimeout(() => setConn({ group: gi, fading: true }), lingerMs);
|
|
302
|
+
// …and blink once the group is done.
|
|
303
|
+
if (watch && faceGeo) {
|
|
304
|
+
setFace((f) => f && Object.assign(Object.assign({}, f), { blink: true }));
|
|
305
|
+
blinkTimer = setTimeout(() => setFace((f) => f && Object.assign(Object.assign({}, f), { blink: false })), 140);
|
|
306
|
+
}
|
|
180
307
|
groupRef.current = gi + 1;
|
|
181
308
|
memberRef.current = 0;
|
|
182
309
|
timer = setTimeout(step, pauseMs);
|
|
@@ -190,9 +317,69 @@ const FileCityLogoAnimated = (props) => {
|
|
|
190
317
|
return () => {
|
|
191
318
|
clearTimeout(timer);
|
|
192
319
|
clearTimeout(fadeTimer);
|
|
320
|
+
clearTimeout(blinkTimer);
|
|
321
|
+
clearTimeout(enterTimer);
|
|
193
322
|
};
|
|
194
323
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
195
|
-
}, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey]);
|
|
324
|
+
}, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey, watch, faceGeo]);
|
|
325
|
+
// Everything after the build: the watching face merges into the P, the
|
|
326
|
+
// sheen plays, then (for `wake`) the P turns into a face and back.
|
|
327
|
+
(0, react_1.useEffect)(() => {
|
|
328
|
+
if (!done)
|
|
329
|
+
return;
|
|
330
|
+
const reduce = typeof window !== 'undefined' &&
|
|
331
|
+
window.matchMedia &&
|
|
332
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
333
|
+
if (!faceGeo || reduce || !autoPlay) {
|
|
334
|
+
setFace(null);
|
|
335
|
+
setSheen(true);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const timers = [];
|
|
339
|
+
let t = 0;
|
|
340
|
+
const at = (delay, fn) => {
|
|
341
|
+
t += delay;
|
|
342
|
+
timers.push(setTimeout(fn, t));
|
|
343
|
+
};
|
|
344
|
+
const pose = (patch) => setFace((f) => f && Object.assign(Object.assign({}, f), patch));
|
|
345
|
+
if (watch) {
|
|
346
|
+
// The eyes settle, blink once at the finished mark, then their files
|
|
347
|
+
// slide home into the P.
|
|
348
|
+
setLook([0, 0]);
|
|
349
|
+
pose({ blink: false });
|
|
350
|
+
at(650, () => pose({ blink: true }));
|
|
351
|
+
at(150, () => pose({ blink: false }));
|
|
352
|
+
at(350, () => pose({ blocks: false, at: 'home' }));
|
|
353
|
+
at(700, () => setFace(null));
|
|
354
|
+
}
|
|
355
|
+
// The waking face is the flourish for `wake`, so it skips the sheen.
|
|
356
|
+
if (!wake)
|
|
357
|
+
at(0, () => setSheen(true));
|
|
358
|
+
if (wake) {
|
|
359
|
+
// A beat on the finished mark, then stand-in files take over from the
|
|
360
|
+
// P's own and slide into a face.
|
|
361
|
+
at(700, () => setFace({
|
|
362
|
+
at: 'home',
|
|
363
|
+
blocks: false,
|
|
364
|
+
mouth: true,
|
|
365
|
+
smile: false,
|
|
366
|
+
blink: false,
|
|
367
|
+
wink: false,
|
|
368
|
+
visible: true,
|
|
369
|
+
hideLetters: true,
|
|
370
|
+
}));
|
|
371
|
+
at(60, () => pose({ at: 'face' }));
|
|
372
|
+
at(600, () => pose({ blocks: true, smile: true }));
|
|
373
|
+
at(700, () => pose({ blink: true }));
|
|
374
|
+
at(140, () => pose({ blink: false }));
|
|
375
|
+
at(600, () => pose({ wink: true }));
|
|
376
|
+
at(420, () => pose({ wink: false }));
|
|
377
|
+
at(650, () => pose({ blocks: false, smile: false, at: 'home' }));
|
|
378
|
+
at(700, () => setFace(null));
|
|
379
|
+
}
|
|
380
|
+
return () => timers.forEach(clearTimeout);
|
|
381
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
382
|
+
}, [done, playKey, faceGeo, watch, wake, autoPlay]);
|
|
196
383
|
// Easing for the per-cell fill-in so each sample lands softly.
|
|
197
384
|
const ease = (t) => 1 - Math.pow(1 - t, 2);
|
|
198
385
|
// Connector geometry — the full path through the active group's cell
|
|
@@ -241,6 +428,9 @@ const FileCityLogoAnimated = (props) => {
|
|
|
241
428
|
const reveal = done ? 1 : ease(progress[i] / stepsFor[i]);
|
|
242
429
|
if (reveal <= 0)
|
|
243
430
|
return null;
|
|
431
|
+
// While the stand-in files are performing, they are the P.
|
|
432
|
+
if (cell.isLetter && (face === null || face === void 0 ? void 0 : face.hideLetters))
|
|
433
|
+
return null;
|
|
244
434
|
return (react_1.default.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx, fill: cell.fill, fillOpacity: reveal, stroke: cell.stroke, strokeWidth: cell.strokeWidth, strokeOpacity: reveal }));
|
|
245
435
|
};
|
|
246
436
|
const showTrail = connectors && connectorPath && conn && !done;
|
|
@@ -270,12 +460,52 @@ const FileCityLogoAnimated = (props) => {
|
|
|
270
460
|
animation: `${DOT_POP} 220ms ease-out ${delay}ms both`,
|
|
271
461
|
} }));
|
|
272
462
|
}))) : null;
|
|
273
|
-
|
|
463
|
+
// The face: eleven files that slide between the P's squares and the face's,
|
|
464
|
+
// a solid block over each eye, and the smile's two corner files.
|
|
465
|
+
const slide = 'cubic-bezier(0.3, 1.25, 0.5, 1)';
|
|
466
|
+
const faceLayer = face && faceGeo ? (react_1.default.createElement("g", { style: { opacity: face.visible ? 1 : 0, transition: 'opacity 320ms ease', pointerEvents: 'none' } },
|
|
467
|
+
faceGeo.tiles.map((tile, i) => {
|
|
468
|
+
const pos = face.at === 'face' ? tile.face : tile.home;
|
|
469
|
+
const isEye = tile.part !== 'mouth';
|
|
470
|
+
const covered = isEye && face.blocks;
|
|
471
|
+
return (react_1.default.createElement("rect", { key: tile.key, x: 0, y: 0, width: faceGeo.sq, height: faceGeo.sq, rx: faceGeo.rx, stroke: tile.stroke, strokeWidth: tile.strokeWidth, style: {
|
|
472
|
+
transform: `translate(${pos.x}px, ${pos.y}px)`,
|
|
473
|
+
fill: face.at === 'face' && isEye ? faceGeo.eyeColor : tile.fill,
|
|
474
|
+
opacity: covered || (!isEye && !face.mouth) ? 0 : 1,
|
|
475
|
+
// Hide under the eye block only once it has faded in.
|
|
476
|
+
transition: `transform 560ms ${slide} ${i * 22}ms, fill 420ms ease ${i * 22}ms, opacity 0ms linear ${covered ? 170 : 0}ms`,
|
|
477
|
+
} }));
|
|
478
|
+
}),
|
|
479
|
+
react_1.default.createElement("g", { style: {
|
|
480
|
+
transform: `translate(${look[0] * faceGeo.pitch}px, ${look[1] * faceGeo.pitch}px)`,
|
|
481
|
+
// A slow, even glide — no snap or overshoot.
|
|
482
|
+
transition: 'transform 700ms cubic-bezier(0.45, 0, 0.25, 1)',
|
|
483
|
+
} }, ['eyeL', 'eyeR'].map((key) => {
|
|
484
|
+
const eye = faceGeo.eyes[key];
|
|
485
|
+
const shut = face.blink || (face.wink && key === 'eyeR');
|
|
486
|
+
return (react_1.default.createElement("rect", { key: key, x: eye.x, y: eye.y, width: eye.size, height: eye.size, rx: Math.max(faceGeo.rx, faceGeo.sq * 0.14), fill: faceGeo.eyeColor, style: {
|
|
487
|
+
opacity: face.blocks ? 1 : 0,
|
|
488
|
+
transformBox: 'fill-box',
|
|
489
|
+
transformOrigin: '50% 100%',
|
|
490
|
+
transform: `scaleY(${shut ? 0.16 : 1})`,
|
|
491
|
+
transition: 'opacity 170ms ease, transform 110ms ease-out',
|
|
492
|
+
} }));
|
|
493
|
+
})),
|
|
494
|
+
faceGeo.corners.map((corner, i) => (react_1.default.createElement("rect", { key: `corner-${i}`, x: corner.x, y: corner.y, width: faceGeo.sq, height: faceGeo.sq, rx: faceGeo.rx, fill: faceGeo.mouthColor, style: {
|
|
495
|
+
opacity: face.smile ? 1 : 0,
|
|
496
|
+
transformBox: 'fill-box',
|
|
497
|
+
transformOrigin: 'center',
|
|
498
|
+
transform: `scale(${face.smile ? 1 : 0.3})`,
|
|
499
|
+
transition: `opacity 200ms ease, transform 260ms ${slide}`,
|
|
500
|
+
} }))))) : null;
|
|
501
|
+
return (react_1.default.createElement(FileCityLogo_1.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, ribbon: ribbon, label: (0, FileCityLogo_1.fileCityLabel)(mark) },
|
|
502
|
+
face && !face.hideLetters ? faceLayer : null,
|
|
274
503
|
cells.map((cell, i) => renderCell(cell, i)),
|
|
504
|
+
face && face.hideLetters ? faceLayer : null,
|
|
275
505
|
trailLine,
|
|
276
506
|
trailDots,
|
|
277
507
|
done ? extras : null,
|
|
278
|
-
|
|
508
|
+
sheen ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
279
509
|
react_1.default.createElement("style", null, `@keyframes ${SHEEN}{from{transform:translateX(-120px)}to{transform:translateX(120px)}}`),
|
|
280
510
|
react_1.default.createElement("defs", null,
|
|
281
511
|
react_1.default.createElement("clipPath", { id: `sheen-clip-${uid}` }, cells.map((cell) => (react_1.default.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx })))),
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout for {@link FileCityBotAvatar} — a Bot's avatar drawn in the same
|
|
3
|
+
* top-down "file city" grid as the brand mark, but on a denser 7×7 grid so
|
|
4
|
+
* the lit files can spell a letter / initials *or* form a face (two eyes and
|
|
5
|
+
* a mouth) that can change expression and look around.
|
|
6
|
+
*
|
|
7
|
+
* Pure and dependency-free (no React, no DOM) so the React Native port can
|
|
8
|
+
* use this file verbatim and only swap the renderer.
|
|
9
|
+
*/
|
|
10
|
+
/** What the lit files draw. */
|
|
11
|
+
export type BotAvatarVariant = 'face' | 'letter';
|
|
12
|
+
/** Face presets — eye shape + mouth shape. */
|
|
13
|
+
export type BotExpression = 'neutral' | 'happy' | 'wink' | 'thinking' | 'talking' | 'surprised' | 'sad' | 'sleeping';
|
|
14
|
+
/** Where the eyes point: both eyes slide one file in that direction. */
|
|
15
|
+
export type BotLook = 'center' | 'left' | 'right' | 'up' | 'down' | 'up-left' | 'up-right';
|
|
16
|
+
/**
|
|
17
|
+
* Eyebrows — a thin bar over each eye. `skeptical` raises just one;
|
|
18
|
+
* `angry` tilts the inner ends down, `worried` tilts them up.
|
|
19
|
+
*/
|
|
20
|
+
export type BotBrows = 'none' | 'flat' | 'raised' | 'skeptical' | 'angry' | 'worried';
|
|
21
|
+
export type BotAvatarShape = 'squircle' | 'circle';
|
|
22
|
+
export interface BotAvatarLayoutOptions {
|
|
23
|
+
/** `'face'` (default) draws eyes + mouth; `'letter'` spells `text`. */
|
|
24
|
+
variant?: BotAvatarVariant;
|
|
25
|
+
/** Letter variant: 1–2 characters (A–Z, 0–9). Extra characters are dropped. */
|
|
26
|
+
text?: string;
|
|
27
|
+
/** Face variant: the expression preset. Default `'neutral'`. */
|
|
28
|
+
expression?: BotExpression;
|
|
29
|
+
/** Face variant: eye direction. Defaults to the expression's own (`thinking` looks up-right). */
|
|
30
|
+
look?: BotLook;
|
|
31
|
+
/**
|
|
32
|
+
* Face variant: eyebrows. Defaults to the expression's own — most have
|
|
33
|
+
* none; `surprised` raises them, `sad` worries them, `thinking` cocks one.
|
|
34
|
+
*/
|
|
35
|
+
brows?: BotBrows;
|
|
36
|
+
/** Brow length as a fraction of the eye's width. Default 1 (as wide as the eye). */
|
|
37
|
+
browLength?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Brow thickness as a fraction of a square's side. Default 0.42 (a thin
|
|
40
|
+
* bar); 1 is a full square tall.
|
|
41
|
+
*/
|
|
42
|
+
browThickness?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Nudges the brows up (positive) or down (negative), in squares, on top of
|
|
45
|
+
* the style's own position. They're kept between the eye and the top of
|
|
46
|
+
* the row of squares above it. Default 0.
|
|
47
|
+
*/
|
|
48
|
+
browLift?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Taper the brow so its thickness slopes along its length. 0 (default) is
|
|
51
|
+
* an even bar; towards 1 it stays full thickness by the nose and thins to
|
|
52
|
+
* a point at the outer end; negative values thin the inner end instead.
|
|
53
|
+
*/
|
|
54
|
+
browTaper?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Extra tilt in degrees, on top of the brow style's own. Positive drops
|
|
57
|
+
* the inner ends (sterner), negative raises them (softer).
|
|
58
|
+
*/
|
|
59
|
+
browSlope?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Shade the brow along its length. 0 (default) is one flat colour; towards
|
|
62
|
+
* 1 the inner end (by the nose) deepens to the Bot's colour while the
|
|
63
|
+
* outer end lightens to the eye colour. Negative values reverse it.
|
|
64
|
+
*/
|
|
65
|
+
browGradient?: number;
|
|
66
|
+
/** Brow end rounding: 0 = square ends, 1 = fully rounded (a pill). Default 0.7. */
|
|
67
|
+
browRound?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Face variant: force both eyes shut for this frame. For renderers that
|
|
70
|
+
* animate a blink by re-rendering (React Native) rather than with CSS.
|
|
71
|
+
*/
|
|
72
|
+
blink?: boolean;
|
|
73
|
+
/** The Bot's id — picks its colour when `primary` isn't passed. */
|
|
74
|
+
seed?: string;
|
|
75
|
+
/** The Bot's colour — letter / mouth files and the city tint. */
|
|
76
|
+
primary?: string;
|
|
77
|
+
/** Neutral base the city tints and the eyes derive from (theme text colour). */
|
|
78
|
+
color?: string;
|
|
79
|
+
/** Panel background. */
|
|
80
|
+
background?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Grid side in files. Default 7 — the smallest that fits a face or two
|
|
83
|
+
* initials. Raise it (e.g. 9) to put a ring of city around the features.
|
|
84
|
+
*/
|
|
85
|
+
cells?: number;
|
|
86
|
+
/** Corner radius of each file, as a fraction of its side. Default 0.15. */
|
|
87
|
+
squareRadius?: number;
|
|
88
|
+
/** Panel shape. Default `'squircle'` (matches the app icon). */
|
|
89
|
+
shape?: BotAvatarShape;
|
|
90
|
+
/**
|
|
91
|
+
* How present the backdrop city is, relative to FileCityLogo's (1 = the
|
|
92
|
+
* same as the logo, 0 = no visible city). Default 0.3.
|
|
93
|
+
*/
|
|
94
|
+
cityStrength?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Draw a thin outline on every file, as FileCityLogo does. Off by default:
|
|
97
|
+
* at avatar sizes the strokes are sub-pixel and only soften the squares.
|
|
98
|
+
*/
|
|
99
|
+
tileOutline?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Face variant: how much of the Bot's colour the eyes take on. 0 = the
|
|
102
|
+
* plain neutral (stark white on dark themes), 1 = the Bot's colour.
|
|
103
|
+
* Default 0.4.
|
|
104
|
+
*/
|
|
105
|
+
eyeTint?: number;
|
|
106
|
+
}
|
|
107
|
+
export type BotAvatarCellRole = 'city' | 'letter';
|
|
108
|
+
export interface BotAvatarCell {
|
|
109
|
+
key: string;
|
|
110
|
+
c: number;
|
|
111
|
+
r: number;
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
sq: number;
|
|
115
|
+
rx: number;
|
|
116
|
+
fill: string;
|
|
117
|
+
stroke: string;
|
|
118
|
+
strokeWidth: number;
|
|
119
|
+
role: BotAvatarCellRole;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* One eye: a single solid block laid over the files it covers, so it reads
|
|
123
|
+
* and moves as one thing rather than as a cluster of squares.
|
|
124
|
+
*/
|
|
125
|
+
export interface BotAvatarEye {
|
|
126
|
+
side: 'left' | 'right';
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
width: number;
|
|
130
|
+
height: number;
|
|
131
|
+
rx: number;
|
|
132
|
+
fill: string;
|
|
133
|
+
/** Shut (one file tall) — a wink or sleeping; shut eyes don't blink. */
|
|
134
|
+
closed: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* One of the mouth's five files. All five are always present so a renderer
|
|
138
|
+
* can keep them mounted and slide them between expressions; the ones an
|
|
139
|
+
* expression doesn't use are `visible: false`.
|
|
140
|
+
*/
|
|
141
|
+
export interface BotAvatarMouthFile {
|
|
142
|
+
/** 0–4, left to right. Stable across expressions — use it as the key. */
|
|
143
|
+
index: number;
|
|
144
|
+
x: number;
|
|
145
|
+
y: number;
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
rx: number;
|
|
149
|
+
fill: string;
|
|
150
|
+
visible: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* One eyebrow. Both are always present (like the mouth's files) so a
|
|
154
|
+
* renderer can keep them mounted and move them; `visible: false` when the
|
|
155
|
+
* face has none. `cx` / `cy` is the bar's centre, `rotate` is in degrees
|
|
156
|
+
* about that centre.
|
|
157
|
+
*/
|
|
158
|
+
export interface BotAvatarBrow {
|
|
159
|
+
side: 'left' | 'right';
|
|
160
|
+
cx: number;
|
|
161
|
+
cy: number;
|
|
162
|
+
width: number;
|
|
163
|
+
/** Thickness at its thickest. */
|
|
164
|
+
height: number;
|
|
165
|
+
/** Thickness at the end nearest the other eye. */
|
|
166
|
+
heightInner: number;
|
|
167
|
+
/** Thickness at the outer end. */
|
|
168
|
+
heightOuter: number;
|
|
169
|
+
rx: number;
|
|
170
|
+
rotate: number;
|
|
171
|
+
/** Flat colour — also the midpoint of the gradient. */
|
|
172
|
+
fill: string;
|
|
173
|
+
/** Colour at the end nearest the other eye. Equals `fill` when there's no gradient. */
|
|
174
|
+
fillInner: string;
|
|
175
|
+
/** Colour at the outer end. Equals `fill` when there's no gradient. */
|
|
176
|
+
fillOuter: string;
|
|
177
|
+
visible: boolean;
|
|
178
|
+
}
|
|
179
|
+
export interface BotAvatarLayout {
|
|
180
|
+
/** Files in render order. The files under the eyes and mouth are plain city files. */
|
|
181
|
+
cells: BotAvatarCell[];
|
|
182
|
+
/** Face variant: the two eyes, drawn over the grid. Empty for letters. */
|
|
183
|
+
eyes: BotAvatarEye[];
|
|
184
|
+
/** Face variant: the two eyebrows, drawn over the grid. Empty for letters. */
|
|
185
|
+
brows: BotAvatarBrow[];
|
|
186
|
+
/** Face variant: the mouth's five files, drawn over the grid. Empty for letters. */
|
|
187
|
+
mouth: BotAvatarMouthFile[];
|
|
188
|
+
/** viewBox side. */
|
|
189
|
+
view: number;
|
|
190
|
+
/** Panel corner radius in viewBox units (half the side for a circle). */
|
|
191
|
+
radius: number;
|
|
192
|
+
bgColor: string;
|
|
193
|
+
baseColor: string;
|
|
194
|
+
primaryColor: string;
|
|
195
|
+
variant: BotAvatarVariant;
|
|
196
|
+
expression: BotExpression;
|
|
197
|
+
/** Accessible description of what's drawn. */
|
|
198
|
+
label: string;
|
|
199
|
+
}
|
|
200
|
+
export declare const BOT_AVATAR_VIEW = 100;
|
|
201
|
+
/** Default per-Bot colours; {@link botAvatarColor} picks one from a seed. */
|
|
202
|
+
export declare const BOT_AVATAR_COLORS: string[];
|
|
203
|
+
/** Stable colour for a Bot, picked from its id. */
|
|
204
|
+
export declare function botAvatarColor(seed: string): string;
|
|
205
|
+
export declare function computeBotAvatarLayout({ variant, text, expression, look, brows, browLength, browRound, browThickness, browLift, browGradient, browTaper, browSlope, blink, seed, primary, color, background, cells, squareRadius, shape, cityStrength, tileOutline, eyeTint, }: BotAvatarLayoutOptions): BotAvatarLayout;
|