@principal-ai/logo-component 0.1.17 → 0.1.18
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/FileCityLogo.d.ts +74 -0
- package/dist/FileCityLogo.js +124 -20
- package/dist/FileCityLogoAnimated.d.ts +41 -0
- package/dist/FileCityLogoAnimated.js +230 -0
- package/dist/esm/FileCityLogo.js +120 -19
- package/dist/esm/FileCityLogoAnimated.js +193 -0
- package/dist/esm/index.js +2 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +2 -3
- package/dist/index.js +6 -5
- package/package.json +1 -1
- package/dist/SquareLogo.d.ts +0 -9
- package/dist/SquareLogo.js +0 -57
- package/dist/WreathLogo.d.ts +0 -12
- package/dist/WreathLogo.js +0 -92
- package/dist/esm/SquareLogo.js +0 -50
- package/dist/esm/WreathLogo.js +0 -85
package/dist/FileCityLogo.d.ts
CHANGED
|
@@ -62,8 +62,82 @@ export interface FileCityLogoProps {
|
|
|
62
62
|
gradient?: FileCityGradient;
|
|
63
63
|
/** Round the panel corners. Default true. */
|
|
64
64
|
rounded?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Empty ring of city cells around the mark glyph, in cells. `1`
|
|
67
|
+
* (default) gives the mark breathing room; `0` packs the glyph
|
|
68
|
+
* edge-to-edge so each square is larger — e.g. a 3×5 "P" fills a 5×5
|
|
69
|
+
* grid instead of sitting in a 7×7 one.
|
|
70
|
+
*/
|
|
71
|
+
margin?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Drop a small "file card" into the bottom-right of the grid (3 cells
|
|
74
|
+
* across × 2 down) with **AI** as its contents — echoing the filename +
|
|
75
|
+
* snippet card from TrailCityDiagram. Only applies to `mark="P"`; the P
|
|
76
|
+
* is nudged one column left to clear room for the card.
|
|
77
|
+
*/
|
|
78
|
+
aiCard?: boolean;
|
|
65
79
|
opacity?: number;
|
|
66
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* One rendered grid square of the file-city mark, with everything needed
|
|
83
|
+
* to draw it statically or animate it: its position, final fill / stroke,
|
|
84
|
+
* whether it belongs to the letter, and a `weight` (how strongly it
|
|
85
|
+
* contributes to the mark — letter files weigh more than city files) that
|
|
86
|
+
* the animated variant uses to decide how many "samples" a cell needs
|
|
87
|
+
* before it reaches full intensity.
|
|
88
|
+
*/
|
|
89
|
+
export interface FileCityCell {
|
|
90
|
+
key: string;
|
|
91
|
+
c: number;
|
|
92
|
+
r: number;
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
sq: number;
|
|
96
|
+
rx: number;
|
|
97
|
+
fill: string;
|
|
98
|
+
stroke: string;
|
|
99
|
+
strokeWidth: number;
|
|
100
|
+
isLetter: boolean;
|
|
101
|
+
weight: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The resolved geometry + palette for a {@link FileCityLogo}, shared by the
|
|
105
|
+
* static component and {@link FileCityLogoAnimated} so the two never drift.
|
|
106
|
+
*/
|
|
107
|
+
export interface FileCityLayout {
|
|
108
|
+
/** Grid squares, post skip/void culling, in render order. */
|
|
109
|
+
cells: FileCityCell[];
|
|
110
|
+
/** Overlay nodes (trail path/dots, AI card) drawn above the grid. */
|
|
111
|
+
extras: React.ReactNode[];
|
|
112
|
+
bgColor: string;
|
|
113
|
+
baseColor: string;
|
|
114
|
+
rounded: boolean;
|
|
115
|
+
opacity: number;
|
|
116
|
+
mark: FileCityMark;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Compute the full layout (cells + overlays + palette) for a file-city
|
|
120
|
+
* mark from the public props. Pure — no hooks — so both the static and
|
|
121
|
+
* animated components can build their SVG from the identical cell list.
|
|
122
|
+
*/
|
|
123
|
+
export declare function computeFileCityLayout({ mark, primary, accent, color, background, theme, cells, highlight, trail, gradient, rounded, margin, aiCard, opacity, }: FileCityLogoProps): FileCityLayout;
|
|
124
|
+
/** Accessible label for a given mark, shared by both components. */
|
|
125
|
+
export declare function fileCityLabel(mark: FileCityMark): string;
|
|
126
|
+
/**
|
|
127
|
+
* SVG panel chrome shared by the static and animated components: the
|
|
128
|
+
* rounded background panel (clipping its children) and the edge hairline.
|
|
129
|
+
* `children` are the grid + overlays drawn inside the clip.
|
|
130
|
+
*/
|
|
131
|
+
export declare const FileCityPanel: React.FC<{
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
bgColor: string;
|
|
135
|
+
baseColor: string;
|
|
136
|
+
rounded: boolean;
|
|
137
|
+
opacity: number;
|
|
138
|
+
label: string;
|
|
139
|
+
children: React.ReactNode;
|
|
140
|
+
}>;
|
|
67
141
|
/**
|
|
68
142
|
* A compact, iconic "file city" mark — the same top-down grid of file
|
|
69
143
|
* squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
|
package/dist/FileCityLogo.js
CHANGED
|
@@ -33,9 +33,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FileCityLogo = void 0;
|
|
36
|
+
exports.FileCityLogo = exports.FileCityPanel = void 0;
|
|
37
|
+
exports.computeFileCityLayout = computeFileCityLayout;
|
|
38
|
+
exports.fileCityLabel = fileCityLabel;
|
|
37
39
|
const react_1 = __importStar(require("react"));
|
|
38
40
|
const VIEW = 100;
|
|
41
|
+
// Corner radius for the rounded panel, as a fraction of the panel side.
|
|
42
|
+
// macOS app icons use a ~22.4% continuous-corner ("squircle") radius; the
|
|
43
|
+
// Electron app supplies the transparent safe-area padding, so the panel
|
|
44
|
+
// fills the whole viewBox and just needs the right corner curvature to
|
|
45
|
+
// read as a native dock icon. A plain SVG rx is a close approximation.
|
|
46
|
+
const PANEL_RADIUS = VIEW * 0.2237;
|
|
47
|
+
// Width of the edge hairline (in viewBox units) that keeps the icon
|
|
48
|
+
// defined against the dock background.
|
|
49
|
+
const HAIRLINE = 0.75;
|
|
39
50
|
// 5-row pixel glyphs — the primary-colored files trace these.
|
|
40
51
|
// `1` = a mark (primary) file
|
|
41
52
|
// `H` = the letter's counter — a forced hole (background shows through,
|
|
@@ -117,15 +128,12 @@ function mix(a, b, t) {
|
|
|
117
128
|
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
118
129
|
}
|
|
119
130
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
124
|
-
* from the muted city.
|
|
131
|
+
* Compute the full layout (cells + overlays + palette) for a file-city
|
|
132
|
+
* mark from the public props. Pure — no hooks — so both the static and
|
|
133
|
+
* animated components can build their SVG from the identical cell list.
|
|
125
134
|
*/
|
|
126
|
-
|
|
135
|
+
function computeFileCityLayout({ mark = 'P', primary, accent, color, background, theme, cells = 5, highlight = true, trail = false, gradient = 'diagonal', rounded = true, margin = 1, aiCard = false, opacity = 0.9, }) {
|
|
127
136
|
var _a, _b, _c, _d;
|
|
128
|
-
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
129
137
|
const primaryColor = (_a = primary !== null && primary !== void 0 ? primary : theme === null || theme === void 0 ? void 0 : theme.colors.primary) !== null && _a !== void 0 ? _a : '#22d3ee';
|
|
130
138
|
const accentColor = (_b = accent !== null && accent !== void 0 ? accent : theme === null || theme === void 0 ? void 0 : theme.colors.accent) !== null && _b !== void 0 ? _b : primaryColor;
|
|
131
139
|
const baseColor = (_c = color !== null && color !== void 0 ? color : theme === null || theme === void 0 ? void 0 : theme.colors.text) !== null && _c !== void 0 ? _c : '#f8fafc';
|
|
@@ -166,8 +174,8 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
166
174
|
// Build a square grid. For `mark="none"` it's a plain `cells × cells`
|
|
167
175
|
// city; otherwise the glyph bitmap sits inside a square grid (side =
|
|
168
176
|
// longest glyph dimension + a margin ring) so the city reads square.
|
|
169
|
-
const margin = 1;
|
|
170
177
|
const trailEnabled = trail && (mark === 'P' || mark === 'PAI');
|
|
178
|
+
const aiCardOn = aiCard && mark === 'P';
|
|
171
179
|
let side;
|
|
172
180
|
let offX = 0;
|
|
173
181
|
let offY = 0;
|
|
@@ -216,6 +224,9 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
216
224
|
// With a trail, shove the letter to the left so the trail has room
|
|
217
225
|
// on the right; otherwise center it in the square.
|
|
218
226
|
offX = trailEnabled ? margin : Math.floor((side - bw) / 2);
|
|
227
|
+
// Nudge the P one column left so the AI card has room on the right.
|
|
228
|
+
if (aiCardOn)
|
|
229
|
+
offX = Math.max(0, offX - 1);
|
|
219
230
|
offY = Math.floor((side - bh) / 2);
|
|
220
231
|
kindAt = (c, r) => {
|
|
221
232
|
const bc = c - offX;
|
|
@@ -228,6 +239,18 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
228
239
|
}
|
|
229
240
|
const cols = side;
|
|
230
241
|
const rows = side;
|
|
242
|
+
// The AI card occupies the bottom-right 4×3 block of cells. Those cells
|
|
243
|
+
// render no building — the card covers them.
|
|
244
|
+
const AI_CARD_COLS = 3;
|
|
245
|
+
const AI_CARD_ROWS = 2;
|
|
246
|
+
// Inset one cell up and left from the bottom-right corner.
|
|
247
|
+
const aiCardC0 = cols - AI_CARD_COLS - 1;
|
|
248
|
+
const aiCardR0 = rows - AI_CARD_ROWS - 1;
|
|
249
|
+
// Nudge the card down half a cell so it straddles the row line — its
|
|
250
|
+
// body sits over the bottom of the top row and the top of the bottom
|
|
251
|
+
// row. The city renders behind it, so squares show around its edges.
|
|
252
|
+
const AI_CARD_ROW_SHIFT = 0.5;
|
|
253
|
+
const AI_CARD_COL_SHIFT = 0.5;
|
|
231
254
|
// Trail to the right of the letter — starts in the top-right corner,
|
|
232
255
|
// crosses 2 cells diagonally to its first node, zigzags down, and ends
|
|
233
256
|
// in the bottom-right corner. The dots sit on city files, which are
|
|
@@ -284,7 +307,8 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
284
307
|
const startX = (VIEW - cell * cols) / 2;
|
|
285
308
|
const startY = (VIEW - cell * rows) / 2;
|
|
286
309
|
const rng = mulberry32(7);
|
|
287
|
-
const
|
|
310
|
+
const cellsOut = [];
|
|
311
|
+
const extras = [];
|
|
288
312
|
// Track the previous cell to the left (per row) and above (per column)
|
|
289
313
|
// so we never leave two empty squares back to back in either
|
|
290
314
|
// direction — that's what produced the long blank runs.
|
|
@@ -325,31 +349,111 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
325
349
|
: gradientShade(baseFor(kind), c, r);
|
|
326
350
|
const x = startX + c * cell + inset;
|
|
327
351
|
const y = startY + r * cell + inset;
|
|
328
|
-
|
|
352
|
+
cellsOut.push({
|
|
353
|
+
key: `${c}-${r}`,
|
|
354
|
+
c,
|
|
355
|
+
r,
|
|
356
|
+
x,
|
|
357
|
+
y,
|
|
358
|
+
sq,
|
|
359
|
+
rx: Math.max(1, sq * 0.12),
|
|
360
|
+
fill: isLetter
|
|
329
361
|
? letterFill
|
|
330
|
-
: palette[Math.floor(colorRoll * palette.length)],
|
|
362
|
+
: palette[Math.floor(colorRoll * palette.length)],
|
|
363
|
+
stroke: isLetter ? withAlpha(letterColor, 0.55) : withAlpha(baseColor, 0.08),
|
|
364
|
+
strokeWidth: isLetter ? 0.6 : 0.4,
|
|
365
|
+
isLetter,
|
|
366
|
+
// Letter files weigh the most so they build up over several
|
|
367
|
+
// samples; city files weigh less and resolve in one or two hits.
|
|
368
|
+
weight: isLetter ? 1 : 0.4,
|
|
369
|
+
});
|
|
331
370
|
}
|
|
332
371
|
}
|
|
372
|
+
// AI card — a small file card (filename header band + "AI" contents)
|
|
373
|
+
// dropped into the bottom-right block, mirroring TrailCityDiagram's
|
|
374
|
+
// snippet card.
|
|
375
|
+
if (aiCardOn) {
|
|
376
|
+
const cx0 = startX + (aiCardC0 + AI_CARD_COL_SHIFT) * cell + inset;
|
|
377
|
+
const cy0 = startY + (aiCardR0 + AI_CARD_ROW_SHIFT) * cell + inset;
|
|
378
|
+
const cw = AI_CARD_COLS * cell - inset * 2;
|
|
379
|
+
const chh = AI_CARD_ROWS * cell - inset * 2;
|
|
380
|
+
const headerH = chh * 0.28;
|
|
381
|
+
const cardR = Math.max(2, cell * 0.2);
|
|
382
|
+
const barH = Math.max(1, headerH * 0.26);
|
|
383
|
+
const fs = Math.min(cw * 0.42, (chh - headerH) * 0.64);
|
|
384
|
+
// Leader — anchored at the center of the P's bottom square. Routed
|
|
385
|
+
// with right-angle segments: down, right, up, then right into the
|
|
386
|
+
// card's left edge, "opening" the block. Dot at each end.
|
|
387
|
+
const aX = startX + (offX + 0.5) * cell; // center of the stem column
|
|
388
|
+
const aY = startY + (offY + 4.5) * cell; // middle of the bottom square
|
|
389
|
+
const bX = cx0; // left edge of the card
|
|
390
|
+
const bY = cy0 + chh * 0.2; // near the top of that edge
|
|
391
|
+
// Route along grid centerlines so the runs thread through square
|
|
392
|
+
// centers: dip to the row below the P, climb at the column just left
|
|
393
|
+
// of the card.
|
|
394
|
+
const valleyY = startY + (offY + 5.5) * cell; // center of the next row down
|
|
395
|
+
const turnX = startX + 2.5 * cell; // center of the 3rd column
|
|
396
|
+
const dot = Math.max(1, cell * 0.12);
|
|
397
|
+
const leaderPath = `M ${aX} ${aY} L ${aX} ${valleyY} L ${turnX} ${valleyY} L ${turnX} ${bY} L ${bX} ${bY}`;
|
|
398
|
+
extras.push(react_1.default.createElement("g", { key: "ai-leader", opacity: 0.75 },
|
|
399
|
+
react_1.default.createElement("path", { d: leaderPath, fill: "none", stroke: accentColor, strokeWidth: Math.max(0.6, cell * 0.07), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.2} ${cell * 0.15}` }),
|
|
400
|
+
react_1.default.createElement("circle", { cx: aX, cy: aY, r: dot, fill: accentColor }),
|
|
401
|
+
react_1.default.createElement("circle", { cx: bX, cy: bY, r: dot, fill: accentColor })));
|
|
402
|
+
extras.push(react_1.default.createElement("g", { key: "ai-card" },
|
|
403
|
+
react_1.default.createElement("rect", { x: cx0, y: cy0, width: cw, height: chh, rx: cardR, fill: mix(bgColor, '#ffffff', 0.06), stroke: withAlpha(accentColor, 0.55), strokeWidth: 0.8 }),
|
|
404
|
+
react_1.default.createElement("path", { d: `M ${cx0} ${cy0 + headerH} L ${cx0} ${cy0 + cardR} Q ${cx0} ${cy0} ${cx0 + cardR} ${cy0} L ${cx0 + cw - cardR} ${cy0} Q ${cx0 + cw} ${cy0} ${cx0 + cw} ${cy0 + cardR} L ${cx0 + cw} ${cy0 + headerH} Z`, fill: withAlpha(accentColor, 0.14) }),
|
|
405
|
+
react_1.default.createElement("rect", { x: cx0 + cw * 0.16, y: cy0 + headerH / 2 - barH / 2, width: cw * 0.44, height: barH, rx: barH / 2, fill: withAlpha(baseColor, 0.5) }),
|
|
406
|
+
react_1.default.createElement("text", { x: cx0 + cw / 2, y: cy0 + headerH + (chh - headerH) / 2, textAnchor: "middle", dominantBaseline: "central", fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontWeight: 700, fontSize: fs, letterSpacing: "0.06em", fill: accentColor }, "AI")));
|
|
407
|
+
}
|
|
333
408
|
// Trail overlay — a dashed accent path to the right of the letter with
|
|
334
409
|
// a marker dot on each node.
|
|
335
410
|
if (trailEnabled && trailGrid.length > 1) {
|
|
336
411
|
const linePts = trailGrid.map(([c, r]) => centerOf(c, r));
|
|
337
412
|
const d = linePts.map((p, i) => `${i ? 'L' : 'M'} ${p.x} ${p.y}`).join(' ');
|
|
338
413
|
const dot = Math.max(1.5, sq * 0.3);
|
|
339
|
-
|
|
414
|
+
extras.push(react_1.default.createElement("path", { key: "trail-path", d: d, fill: "none", stroke: accentColor, strokeWidth: Math.max(1, cell * 0.12), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.18} ${cell * 0.18}`, opacity: 0.9 }));
|
|
340
415
|
trailGrid.forEach(([c, r], i) => {
|
|
341
416
|
const p = centerOf(c, r);
|
|
342
|
-
|
|
417
|
+
extras.push(react_1.default.createElement("circle", { key: `trail-dot-${i}`, cx: p.x, cy: p.y, r: dot, fill: mix(accentColor, '#ffffff', 0.15), stroke: bgColor, strokeWidth: 0.5 }));
|
|
343
418
|
});
|
|
344
419
|
}
|
|
345
|
-
return
|
|
346
|
-
|
|
347
|
-
|
|
420
|
+
return { cells: cellsOut, extras, bgColor, baseColor, rounded, opacity, mark };
|
|
421
|
+
}
|
|
422
|
+
/** Accessible label for a given mark, shared by both components. */
|
|
423
|
+
function fileCityLabel(mark) {
|
|
424
|
+
return mark === 'none'
|
|
425
|
+
? 'A top-down grid of file squares'
|
|
426
|
+
: `A top-down grid of file squares spelling ${mark}`;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* SVG panel chrome shared by the static and animated components: the
|
|
430
|
+
* rounded background panel (clipping its children) and the edge hairline.
|
|
431
|
+
* `children` are the grid + overlays drawn inside the clip.
|
|
432
|
+
*/
|
|
433
|
+
const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, children }) => {
|
|
434
|
+
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
435
|
+
return (react_1.default.createElement("svg", { width: width, height: height, viewBox: `0 0 ${VIEW} ${VIEW}`, xmlns: "http://www.w3.org/2000/svg", style: { opacity, display: 'block', overflow: 'visible' }, role: "img", "aria-label": label },
|
|
348
436
|
react_1.default.createElement("defs", null,
|
|
349
437
|
react_1.default.createElement("clipPath", { id: `panel-${uid}` },
|
|
350
|
-
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ?
|
|
438
|
+
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ? PANEL_RADIUS : 0 }))),
|
|
351
439
|
react_1.default.createElement("g", { clipPath: `url(#panel-${uid})` },
|
|
352
|
-
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ?
|
|
353
|
-
|
|
440
|
+
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ? PANEL_RADIUS : 0 }),
|
|
441
|
+
children),
|
|
442
|
+
react_1.default.createElement("rect", { x: HAIRLINE / 2, y: HAIRLINE / 2, width: VIEW - HAIRLINE, height: VIEW - HAIRLINE, rx: rounded ? Math.max(0, PANEL_RADIUS - HAIRLINE / 2) : 0, fill: "none", stroke: withAlpha(baseColor, 0.14), strokeWidth: HAIRLINE })));
|
|
443
|
+
};
|
|
444
|
+
exports.FileCityPanel = FileCityPanel;
|
|
445
|
+
/**
|
|
446
|
+
* A compact, iconic "file city" mark — the same top-down grid of file
|
|
447
|
+
* squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
|
|
448
|
+
* of smaller buildings, no trail / markers / snippet. The primary-colored
|
|
449
|
+
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
450
|
+
* from the muted city.
|
|
451
|
+
*/
|
|
452
|
+
const FileCityLogo = (props) => {
|
|
453
|
+
const { width = 150, height = 150 } = props;
|
|
454
|
+
const { cells, extras, bgColor, baseColor, rounded, opacity, mark } = computeFileCityLayout(props);
|
|
455
|
+
return (react_1.default.createElement(exports.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, label: fileCityLabel(mark) },
|
|
456
|
+
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, fill: cell.fill, stroke: cell.stroke, strokeWidth: cell.strokeWidth }))),
|
|
457
|
+
extras));
|
|
354
458
|
};
|
|
355
459
|
exports.FileCityLogo = FileCityLogo;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FileCityLogoProps } from './FileCityLogo';
|
|
3
|
+
export interface FileCityLogoAnimatedProps extends FileCityLogoProps {
|
|
4
|
+
/**
|
|
5
|
+
* Min / max number of cells in each group. The cells in a group reveal
|
|
6
|
+
* one at a time (`cellMs` apart); then the build holds for `pauseMs`
|
|
7
|
+
* before the next group. Default 3–6.
|
|
8
|
+
*/
|
|
9
|
+
batchMin?: number;
|
|
10
|
+
batchMax?: number;
|
|
11
|
+
/** Milliseconds between cells within a group. Default 130. */
|
|
12
|
+
cellMs?: number;
|
|
13
|
+
/** Milliseconds to hold after a group completes, before the next. Default 700. */
|
|
14
|
+
pauseMs?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Draw a connector line threading the cells of the active group in reveal
|
|
17
|
+
* order — it grows as each cell appears, then fades out during the pause.
|
|
18
|
+
* Default true.
|
|
19
|
+
*/
|
|
20
|
+
connectors?: boolean;
|
|
21
|
+
/** Connector color. Defaults to the accent (falling back to primary). */
|
|
22
|
+
connectorColor?: string;
|
|
23
|
+
/**
|
|
24
|
+
* How many samples a full-weight (letter) cell needs before it reaches
|
|
25
|
+
* full intensity. City files need proportionally fewer (by their lower
|
|
26
|
+
* weight), so the letter builds up gradually while the city pops in. */
|
|
27
|
+
buildSteps?: number;
|
|
28
|
+
/** Start playing on mount. Default true. */
|
|
29
|
+
autoPlay?: boolean;
|
|
30
|
+
/** Replay key — change this value to restart the animation. */
|
|
31
|
+
playKey?: string | number;
|
|
32
|
+
/** Called once the heatmap has fully resolved. */
|
|
33
|
+
onComplete?: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Animated file-city mark: the squares accumulate like a heatmap. Each tick
|
|
37
|
+
* a batch of cells gets a "sample" added; letter cells weigh more so they
|
|
38
|
+
* take several samples to reach full intensity while city files resolve
|
|
39
|
+
* quickly. Once the summed weights fill in, the logo holds on screen.
|
|
40
|
+
*/
|
|
41
|
+
export declare const FileCityLogoAnimated: React.FC<FileCityLogoAnimatedProps>;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FileCityLogoAnimated = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const FileCityLogo_1 = require("./FileCityLogo");
|
|
39
|
+
// CSS keyframe name for the connector draw-on. CSS animations restart on
|
|
40
|
+
// element remount (unlike SMIL's document-timeline `begin`), so each group's
|
|
41
|
+
// freshly-keyed connector draws from the start.
|
|
42
|
+
const CONN_DRAW = 'fc-conn-draw';
|
|
43
|
+
function mulberry32(seed) {
|
|
44
|
+
let t = seed;
|
|
45
|
+
return () => {
|
|
46
|
+
t = (t + 0x6d2b79f5) | 0;
|
|
47
|
+
let r = t;
|
|
48
|
+
r = Math.imul(r ^ (r >>> 15), r | 1);
|
|
49
|
+
r ^= r + Math.imul(r ^ (r >>> 7), r | 61);
|
|
50
|
+
return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Animated file-city mark: the squares accumulate like a heatmap. Each tick
|
|
55
|
+
* a batch of cells gets a "sample" added; letter cells weigh more so they
|
|
56
|
+
* take several samples to reach full intensity while city files resolve
|
|
57
|
+
* quickly. Once the summed weights fill in, the logo holds on screen.
|
|
58
|
+
*/
|
|
59
|
+
const FileCityLogoAnimated = (props) => {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f;
|
|
61
|
+
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
62
|
+
const { width = 150, height = 150, batchMin = 3, batchMax = 6, cellMs = 130, pauseMs = 700, buildSteps = 3, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, } = props;
|
|
63
|
+
const accentColor = (_f = (_d = (_c = (_a = connectorColor !== null && connectorColor !== void 0 ? connectorColor : 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';
|
|
64
|
+
const { cells, extras, bgColor, baseColor, rounded, opacity, mark } = (0, react_1.useMemo)(() => (0, FileCityLogo_1.computeFileCityLayout)(props),
|
|
65
|
+
// Re-derive only when an input that affects layout changes.
|
|
66
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
+
[
|
|
68
|
+
props.mark,
|
|
69
|
+
props.primary,
|
|
70
|
+
props.accent,
|
|
71
|
+
props.color,
|
|
72
|
+
props.background,
|
|
73
|
+
props.theme,
|
|
74
|
+
props.cells,
|
|
75
|
+
props.highlight,
|
|
76
|
+
props.trail,
|
|
77
|
+
props.gradient,
|
|
78
|
+
props.rounded,
|
|
79
|
+
props.margin,
|
|
80
|
+
props.aiCard,
|
|
81
|
+
props.opacity,
|
|
82
|
+
]);
|
|
83
|
+
// Per-cell number of samples to fully reveal it (>=1; letter cells take
|
|
84
|
+
// `buildSteps`, city cells proportionally fewer by their weight).
|
|
85
|
+
const stepsFor = (0, react_1.useMemo)(() => cells.map((cell) => Math.max(1, Math.round(cell.weight * buildSteps))), [cells, buildSteps]);
|
|
86
|
+
// The pool of pending samples: each cell index repeated `steps` times,
|
|
87
|
+
// shuffled deterministically so the batches scatter across the grid,
|
|
88
|
+
// then sliced into groups of `batchMin`..`batchMax`.
|
|
89
|
+
const groups = (0, react_1.useMemo)(() => {
|
|
90
|
+
const p = [];
|
|
91
|
+
stepsFor.forEach((n, i) => {
|
|
92
|
+
for (let k = 0; k < n; k++)
|
|
93
|
+
p.push(i);
|
|
94
|
+
});
|
|
95
|
+
const shuffle = mulberry32(0x5eed + cells.length);
|
|
96
|
+
for (let i = p.length - 1; i > 0; i--) {
|
|
97
|
+
const j = Math.floor(shuffle() * (i + 1));
|
|
98
|
+
[p[i], p[j]] = [p[j], p[i]];
|
|
99
|
+
}
|
|
100
|
+
const sizeRand = mulberry32(0xb47c4 + cells.length);
|
|
101
|
+
const g = [];
|
|
102
|
+
let i = 0;
|
|
103
|
+
while (i < p.length) {
|
|
104
|
+
const size = batchMin + Math.floor(sizeRand() * (batchMax - batchMin + 1));
|
|
105
|
+
g.push(p.slice(i, i + size));
|
|
106
|
+
i += size;
|
|
107
|
+
}
|
|
108
|
+
return g;
|
|
109
|
+
}, [stepsFor, cells.length, batchMin, batchMax]);
|
|
110
|
+
// `progress[i]` = samples applied to cell i. Once every group has been
|
|
111
|
+
// walked the animation is done and the logo holds.
|
|
112
|
+
const [progress, setProgress] = (0, react_1.useState)(() => cells.map(() => 0));
|
|
113
|
+
const [done, setDone] = (0, react_1.useState)(false);
|
|
114
|
+
// The connector for the active group: which group it traces, and whether
|
|
115
|
+
// it's drawing on (during the reveal) or fading out (during the pause).
|
|
116
|
+
const [conn, setConn] = (0, react_1.useState)(null);
|
|
117
|
+
const groupRef = (0, react_1.useRef)(0);
|
|
118
|
+
const memberRef = (0, react_1.useRef)(0);
|
|
119
|
+
const onCompleteRef = (0, react_1.useRef)(onComplete);
|
|
120
|
+
onCompleteRef.current = onComplete;
|
|
121
|
+
// Drive the accumulation. Re-runs whenever the layout, timing, or the
|
|
122
|
+
// explicit `playKey` changes — that's our "replay."
|
|
123
|
+
(0, react_1.useEffect)(() => {
|
|
124
|
+
var _a;
|
|
125
|
+
// Respect reduced-motion: jump straight to the resolved logo.
|
|
126
|
+
const reduce = typeof window !== 'undefined' &&
|
|
127
|
+
window.matchMedia &&
|
|
128
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
129
|
+
groupRef.current = 0;
|
|
130
|
+
memberRef.current = 0;
|
|
131
|
+
setProgress(cells.map(() => 0));
|
|
132
|
+
setConn(null);
|
|
133
|
+
setDone(false);
|
|
134
|
+
if (!autoPlay || cells.length === 0 || reduce) {
|
|
135
|
+
setProgress(stepsFor.slice());
|
|
136
|
+
setDone(true);
|
|
137
|
+
(_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let timer;
|
|
141
|
+
// Reveal one cell per step. Within a group the steps are `cellMs`
|
|
142
|
+
// apart; finishing a group schedules the next one after `pauseMs`.
|
|
143
|
+
const step = () => {
|
|
144
|
+
var _a;
|
|
145
|
+
const gi = groupRef.current;
|
|
146
|
+
if (gi >= groups.length) {
|
|
147
|
+
setDone(true);
|
|
148
|
+
(_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const group = groups[gi];
|
|
152
|
+
const mi = memberRef.current;
|
|
153
|
+
const idx = group[mi];
|
|
154
|
+
setProgress((prev) => {
|
|
155
|
+
const next = prev.slice();
|
|
156
|
+
next[idx] = Math.min(stepsFor[idx], next[idx] + 1);
|
|
157
|
+
return next;
|
|
158
|
+
});
|
|
159
|
+
const lastInGroup = mi + 1 >= group.length;
|
|
160
|
+
// Start the connector drawing on when the group begins; once it's
|
|
161
|
+
// complete, flip to fading so it dissolves through the pause.
|
|
162
|
+
if (mi === 0)
|
|
163
|
+
setConn({ group: gi, fading: false });
|
|
164
|
+
if (lastInGroup)
|
|
165
|
+
setConn({ group: gi, fading: true });
|
|
166
|
+
if (lastInGroup) {
|
|
167
|
+
groupRef.current = gi + 1;
|
|
168
|
+
memberRef.current = 0;
|
|
169
|
+
timer = setTimeout(step, pauseMs);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
memberRef.current = mi + 1;
|
|
173
|
+
timer = setTimeout(step, cellMs);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
timer = setTimeout(step, cellMs);
|
|
177
|
+
return () => clearTimeout(timer);
|
|
178
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
179
|
+
}, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey]);
|
|
180
|
+
// Easing for the per-cell fill-in so each sample lands softly.
|
|
181
|
+
const ease = (t) => 1 - Math.pow(1 - t, 2);
|
|
182
|
+
// Connector geometry — the full path through the active group's cell
|
|
183
|
+
// centers (drawn on with stroke-dashoffset, so we render every point up
|
|
184
|
+
// front and animate the reveal).
|
|
185
|
+
const sq = cells.length ? cells[0].sq : 1;
|
|
186
|
+
const centerOf = (idx) => ({
|
|
187
|
+
x: cells[idx].x + cells[idx].sq / 2,
|
|
188
|
+
y: cells[idx].y + cells[idx].sq / 2,
|
|
189
|
+
});
|
|
190
|
+
const connGroup = conn ? groups[conn.group] : null;
|
|
191
|
+
const connectorPath = connGroup && connGroup.length > 1
|
|
192
|
+
? connGroup
|
|
193
|
+
.map((idx, i) => {
|
|
194
|
+
const p = centerOf(idx);
|
|
195
|
+
return `${i ? 'L' : 'M'} ${p.x} ${p.y}`;
|
|
196
|
+
})
|
|
197
|
+
.join(' ')
|
|
198
|
+
: null;
|
|
199
|
+
// Draw the trail on across the group's reveal (so the line reaches each
|
|
200
|
+
// cell about as it lights up); fade should finish inside the pause.
|
|
201
|
+
const drawMs = connGroup ? Math.max(cellMs, (connGroup.length - 1) * cellMs) : 0;
|
|
202
|
+
const fadeMs = Math.max(120, Math.min(pauseMs - 60, 360));
|
|
203
|
+
return (react_1.default.createElement(FileCityLogo_1.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, label: (0, FileCityLogo_1.fileCityLabel)(mark) },
|
|
204
|
+
cells.map((cell, i) => {
|
|
205
|
+
const reveal = done ? 1 : ease(progress[i] / stepsFor[i]);
|
|
206
|
+
if (reveal <= 0)
|
|
207
|
+
return null;
|
|
208
|
+
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 }));
|
|
209
|
+
}),
|
|
210
|
+
connectors && connectorPath && conn && !done ? (
|
|
211
|
+
// The trail is a dashed (dotted) path, revealed progressively by a
|
|
212
|
+
// mask: a solid line draws itself on (stroke-dashoffset 1 → 0 with
|
|
213
|
+
// pathLength normalized to 1), uncovering the dots block by block as
|
|
214
|
+
// the trail extends.
|
|
215
|
+
(() => {
|
|
216
|
+
const maskId = `conn-mask-${uid}-${conn.group}`;
|
|
217
|
+
const w = Math.max(0.6, sq * 0.12);
|
|
218
|
+
return (react_1.default.createElement("g", { key: `conn-${conn.group}` },
|
|
219
|
+
react_1.default.createElement("style", null, `@keyframes ${CONN_DRAW}{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}`),
|
|
220
|
+
react_1.default.createElement("defs", null,
|
|
221
|
+
react_1.default.createElement("mask", { id: maskId, maskUnits: "userSpaceOnUse" },
|
|
222
|
+
react_1.default.createElement("path", { d: connectorPath, fill: "none", stroke: "#fff", strokeWidth: w * 2.6, strokeLinecap: "round", strokeLinejoin: "round", pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1, style: { animation: `${CONN_DRAW} ${drawMs}ms linear forwards` } }))),
|
|
223
|
+
react_1.default.createElement("path", { d: connectorPath, fill: "none", stroke: accentColor, strokeWidth: w, strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${sq * 0.18} ${sq * 0.14}`, mask: `url(#${maskId})`, style: {
|
|
224
|
+
transition: `opacity ${fadeMs}ms ease`,
|
|
225
|
+
opacity: conn.fading ? 0 : 0.9,
|
|
226
|
+
} })));
|
|
227
|
+
})()) : null,
|
|
228
|
+
done ? extras : null));
|
|
229
|
+
};
|
|
230
|
+
exports.FileCityLogoAnimated = FileCityLogoAnimated;
|