@principal-ai/logo-component 0.1.21 → 0.1.23
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/FileCityLogoAnimated.d.ts +6 -4
- package/dist/FileCityLogoAnimated.js +99 -39
- package/dist/TrailCityBanner.d.ts +53 -0
- package/dist/TrailCityBanner.js +389 -0
- package/dist/TrailCityProgress.d.ts +36 -0
- package/dist/TrailCityProgress.js +156 -0
- package/dist/TrailMarketingBanner.d.ts +36 -0
- package/dist/TrailMarketingBanner.js +494 -0
- package/dist/esm/FileCityLogoAnimated.js +99 -39
- package/dist/esm/TrailCityBanner.js +353 -0
- package/dist/esm/TrailCityProgress.js +120 -0
- package/dist/esm/TrailMarketingBanner.js +458 -0
- package/dist/esm/index.js +3 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +3 -0
- package/dist/index.js +7 -1
- package/package.json +3 -2
|
@@ -4,6 +4,10 @@ import { computeFileCityLayout, fileCityLabel, FileCityPanel, } from './FileCity
|
|
|
4
4
|
// element remount (unlike SMIL's document-timeline `begin`), so each group's
|
|
5
5
|
// freshly-keyed connector draws from the start.
|
|
6
6
|
const CONN_DRAW = 'fc-conn-draw';
|
|
7
|
+
// Node dots pop in (scale + fade) as the trail reaches each one.
|
|
8
|
+
const DOT_POP = 'fc-dot-pop';
|
|
9
|
+
// Once resolved, a soft sheen sweeps diagonally across the mark.
|
|
10
|
+
const SHEEN = 'fc-sheen';
|
|
7
11
|
function mulberry32(seed) {
|
|
8
12
|
let t = seed;
|
|
9
13
|
return () => {
|
|
@@ -21,10 +25,13 @@ function mulberry32(seed) {
|
|
|
21
25
|
* quickly. Once the summed weights fill in, the logo holds on screen.
|
|
22
26
|
*/
|
|
23
27
|
export const FileCityLogoAnimated = (props) => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
25
29
|
const uid = useId().replace(/:/g, '');
|
|
26
|
-
const { width = 150, height = 150, batchMin =
|
|
27
|
-
|
|
30
|
+
const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, } = props;
|
|
31
|
+
// The trail line is a light grey (close to white); the nodes it threads
|
|
32
|
+
// to are marked with accent-colored dots so the destinations pop.
|
|
33
|
+
const trailColor = connectorColor !== null && connectorColor !== void 0 ? connectorColor : '#e5e7eb';
|
|
34
|
+
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';
|
|
28
35
|
const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = useMemo(() => computeFileCityLayout(props),
|
|
29
36
|
// Re-derive only when an input that affects layout changes.
|
|
30
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -104,6 +111,10 @@ export const FileCityLogoAnimated = (props) => {
|
|
|
104
111
|
return;
|
|
105
112
|
}
|
|
106
113
|
let timer;
|
|
114
|
+
let fadeTimer;
|
|
115
|
+
// Hold the finished trail on screen before it fades, so the completed
|
|
116
|
+
// group lingers a beat. Keep linger + fade within the pause.
|
|
117
|
+
const lingerMs = Math.max(0, Math.min(pauseMs - fadeMs - 40, 450));
|
|
107
118
|
// Reveal one cell per step. Within a group the steps are `cellMs`
|
|
108
119
|
// apart; finishing a group schedules the next one after `pauseMs`.
|
|
109
120
|
const step = () => {
|
|
@@ -123,13 +134,13 @@ export const FileCityLogoAnimated = (props) => {
|
|
|
123
134
|
return next;
|
|
124
135
|
});
|
|
125
136
|
const lastInGroup = mi + 1 >= group.length;
|
|
126
|
-
// Start the connector drawing on when the group begins
|
|
127
|
-
// complete, flip to fading so it dissolves through the pause.
|
|
137
|
+
// Start the connector drawing on when the group begins.
|
|
128
138
|
if (mi === 0)
|
|
129
139
|
setConn({ group: gi, fading: false });
|
|
130
|
-
if (lastInGroup)
|
|
131
|
-
setConn({ group: gi, fading: true });
|
|
132
140
|
if (lastInGroup) {
|
|
141
|
+
// The trail is fully drawn — hold it for `lingerMs`, then flip to
|
|
142
|
+
// fading so it dissolves before the next group begins.
|
|
143
|
+
fadeTimer = setTimeout(() => setConn({ group: gi, fading: true }), lingerMs);
|
|
133
144
|
groupRef.current = gi + 1;
|
|
134
145
|
memberRef.current = 0;
|
|
135
146
|
timer = setTimeout(step, pauseMs);
|
|
@@ -140,7 +151,10 @@ export const FileCityLogoAnimated = (props) => {
|
|
|
140
151
|
}
|
|
141
152
|
};
|
|
142
153
|
timer = setTimeout(step, cellMs);
|
|
143
|
-
return () =>
|
|
154
|
+
return () => {
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
clearTimeout(fadeTimer);
|
|
157
|
+
};
|
|
144
158
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
145
159
|
}, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey]);
|
|
146
160
|
// Easing for the per-cell fill-in so each sample lands softly.
|
|
@@ -154,42 +168,88 @@ export const FileCityLogoAnimated = (props) => {
|
|
|
154
168
|
y: cells[idx].y + cells[idx].sq / 2,
|
|
155
169
|
});
|
|
156
170
|
const connGroup = conn ? groups[conn.group] : null;
|
|
171
|
+
// Build a gently-curved path through the node centers (Catmull-Rom →
|
|
172
|
+
// cubic Béziers). It still passes exactly through every dot, just with a
|
|
173
|
+
// soft bend between them instead of straight segments. `k` is the curve
|
|
174
|
+
// strength — small keeps it subtle.
|
|
175
|
+
const smoothPath = (pts) => {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
if (pts.length < 2)
|
|
178
|
+
return null;
|
|
179
|
+
if (pts.length === 2)
|
|
180
|
+
return `M ${pts[0].x} ${pts[0].y} L ${pts[1].x} ${pts[1].y}`;
|
|
181
|
+
const k = 0.2;
|
|
182
|
+
let d = `M ${pts[0].x} ${pts[0].y}`;
|
|
183
|
+
for (let i = 0; i < pts.length - 1; i++) {
|
|
184
|
+
const p0 = (_a = pts[i - 1]) !== null && _a !== void 0 ? _a : pts[i];
|
|
185
|
+
const p1 = pts[i];
|
|
186
|
+
const p2 = pts[i + 1];
|
|
187
|
+
const p3 = (_b = pts[i + 2]) !== null && _b !== void 0 ? _b : p2;
|
|
188
|
+
const cp1x = p1.x + (p2.x - p0.x) * k;
|
|
189
|
+
const cp1y = p1.y + (p2.y - p0.y) * k;
|
|
190
|
+
const cp2x = p2.x - (p3.x - p1.x) * k;
|
|
191
|
+
const cp2y = p2.y - (p3.y - p1.y) * k;
|
|
192
|
+
d += ` C ${cp1x} ${cp1y} ${cp2x} ${cp2y} ${p2.x} ${p2.y}`;
|
|
193
|
+
}
|
|
194
|
+
return d;
|
|
195
|
+
};
|
|
157
196
|
const connectorPath = connGroup && connGroup.length > 1
|
|
158
|
-
? connGroup
|
|
159
|
-
.map((idx, i) => {
|
|
160
|
-
const p = centerOf(idx);
|
|
161
|
-
return `${i ? 'L' : 'M'} ${p.x} ${p.y}`;
|
|
162
|
-
})
|
|
163
|
-
.join(' ')
|
|
197
|
+
? smoothPath(connGroup.map((idx) => centerOf(idx)))
|
|
164
198
|
: null;
|
|
165
199
|
// Draw the trail on across the group's reveal (so the line reaches each
|
|
166
200
|
// cell about as it lights up); fade should finish inside the pause.
|
|
167
201
|
const drawMs = connGroup ? Math.max(cellMs, (connGroup.length - 1) * cellMs) : 0;
|
|
168
202
|
const fadeMs = Math.max(120, Math.min(pauseMs - 60, 360));
|
|
203
|
+
// One cell as a <rect>.
|
|
204
|
+
const renderCell = (cell, i) => {
|
|
205
|
+
const reveal = done ? 1 : ease(progress[i] / stepsFor[i]);
|
|
206
|
+
if (reveal <= 0)
|
|
207
|
+
return null;
|
|
208
|
+
return (React.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
|
+
const showTrail = connectors && connectorPath && conn && !done;
|
|
211
|
+
const fadeStyle = {
|
|
212
|
+
transition: `opacity ${fadeMs}ms ease`,
|
|
213
|
+
opacity: (conn === null || conn === void 0 ? void 0 : conn.fading) ? 0 : 1,
|
|
214
|
+
};
|
|
215
|
+
const maskId = `conn-mask-${uid}-${(_g = conn === null || conn === void 0 ? void 0 : conn.group) !== null && _g !== void 0 ? _g : 0}`;
|
|
216
|
+
const lineW = Math.max(0.6, sq * 0.12);
|
|
217
|
+
const dotR = Math.max(1.4, sq * 0.27);
|
|
218
|
+
const segCount = connGroup ? connGroup.length - 1 : 0;
|
|
219
|
+
// The trail line (drawn-on dashed path) on its own layer.
|
|
220
|
+
const trailLine = showTrail ? (React.createElement("g", { key: `conn-line-${conn.group}`, style: fadeStyle },
|
|
221
|
+
React.createElement("style", null, `@keyframes ${CONN_DRAW}{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}@keyframes ${DOT_POP}{from{opacity:0;transform:scale(0.2)}to{opacity:1;transform:scale(1)}}`),
|
|
222
|
+
React.createElement("defs", null,
|
|
223
|
+
React.createElement("mask", { id: maskId, maskUnits: "userSpaceOnUse" },
|
|
224
|
+
React.createElement("path", { d: connectorPath, fill: "none", stroke: "#fff", strokeWidth: lineW * 2.6, strokeLinecap: "round", strokeLinejoin: "round", pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1, style: { animation: `${CONN_DRAW} ${drawMs}ms linear forwards` } }))),
|
|
225
|
+
React.createElement("path", { d: connectorPath, fill: "none", stroke: trailColor, strokeWidth: lineW, strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${sq * 0.18} ${sq * 0.14}`, mask: `url(#${maskId})`, opacity: 0.9 }))) : null;
|
|
226
|
+
// The accent node-dots — always the topmost trail layer so they read as
|
|
227
|
+
// markers even when the line tucks behind the blocks.
|
|
228
|
+
const trailDots = showTrail ? (React.createElement("g", { key: `conn-dots-${conn.group}`, style: fadeStyle }, connGroup.map((idx, i) => {
|
|
229
|
+
const p = centerOf(idx);
|
|
230
|
+
const delay = segCount > 0 ? (i / segCount) * drawMs : 0;
|
|
231
|
+
return (React.createElement("circle", { key: `dot-${idx}-${i}`, cx: p.x, cy: p.y, r: dotR, fill: dotColor, style: {
|
|
232
|
+
transformBox: 'fill-box',
|
|
233
|
+
transformOrigin: 'center',
|
|
234
|
+
animation: `${DOT_POP} 220ms ease-out ${delay}ms both`,
|
|
235
|
+
} }));
|
|
236
|
+
}))) : null;
|
|
169
237
|
return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, label: fileCityLabel(mark) },
|
|
170
|
-
cells.map((cell, i) =>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
React.createElement("
|
|
186
|
-
|
|
187
|
-
React.createElement("mask", { id: maskId, maskUnits: "userSpaceOnUse" },
|
|
188
|
-
React.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` } }))),
|
|
189
|
-
React.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: {
|
|
190
|
-
transition: `opacity ${fadeMs}ms ease`,
|
|
191
|
-
opacity: conn.fading ? 0 : 0.9,
|
|
192
|
-
} })));
|
|
193
|
-
})()) : null,
|
|
194
|
-
done ? extras : null));
|
|
238
|
+
cells.map((cell, i) => renderCell(cell, i)),
|
|
239
|
+
trailLine,
|
|
240
|
+
trailDots,
|
|
241
|
+
done ? extras : null,
|
|
242
|
+
done ? (React.createElement(React.Fragment, null,
|
|
243
|
+
React.createElement("style", null, `@keyframes ${SHEEN}{from{transform:translateX(-120px)}to{transform:translateX(120px)}}`),
|
|
244
|
+
React.createElement("defs", null,
|
|
245
|
+
React.createElement("clipPath", { id: `sheen-clip-${uid}` }, cells.map((cell) => (React.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx })))),
|
|
246
|
+
React.createElement("linearGradient", { id: `sheen-grad-${uid}`, x1: "0", y1: "0", x2: "1", y2: "1" },
|
|
247
|
+
React.createElement("stop", { offset: "0%", stopColor: "#fff", stopOpacity: 0 }),
|
|
248
|
+
React.createElement("stop", { offset: "42%", stopColor: "#fff", stopOpacity: 0 }),
|
|
249
|
+
React.createElement("stop", { offset: "50%", stopColor: "#fff", stopOpacity: 0.5 }),
|
|
250
|
+
React.createElement("stop", { offset: "58%", stopColor: "#fff", stopOpacity: 0 }),
|
|
251
|
+
React.createElement("stop", { offset: "100%", stopColor: "#fff", stopOpacity: 0 }))),
|
|
252
|
+
React.createElement("g", { clipPath: `url(#sheen-clip-${uid})`, style: { pointerEvents: 'none' } },
|
|
253
|
+
React.createElement("g", { style: { animation: `${SHEEN} 1.1s ease-in-out forwards` } },
|
|
254
|
+
React.createElement("rect", { x: -20, y: -20, width: 140, height: 140, fill: `url(#sheen-grad-${uid})` }))))) : null));
|
|
195
255
|
};
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useId, useMemo } from 'react';
|
|
3
|
+
const VARIANTS = {
|
|
4
|
+
twitterHeader: { w: 1500, h: 500, rows: 9, chip: true },
|
|
5
|
+
linkedinCompany: { w: 1128, h: 191, rows: 4, chip: false },
|
|
6
|
+
// Personal/employee profile background — 4:1, taller than the company cover.
|
|
7
|
+
linkedinProfile: { w: 1584, h: 396, rows: 7, chip: true },
|
|
8
|
+
};
|
|
9
|
+
export function TrailCityBanner({ theme, className, variant = 'twitterHeader', width, height, seed = 7, reserveLeft = true, showTrail = true, showChip, leaderMarker = 2, wordmark, }) {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
|
+
const cfg = VARIANTS[variant];
|
|
12
|
+
const W = width !== null && width !== void 0 ? width : cfg.w;
|
|
13
|
+
const H = height !== null && height !== void 0 ? height : cfg.h;
|
|
14
|
+
const uid = useId().replace(/:/g, '');
|
|
15
|
+
// --- colors (mirrors TrailCityDiagram) -------------------------------
|
|
16
|
+
const colors = theme === null || theme === void 0 ? void 0 : theme.colors;
|
|
17
|
+
const accent = (_a = colors === null || colors === void 0 ? void 0 : colors.primary) !== null && _a !== void 0 ? _a : '#22d3ee';
|
|
18
|
+
const surface = (_b = colors === null || colors === void 0 ? void 0 : colors.surface) !== null && _b !== void 0 ? _b : '#0f1419';
|
|
19
|
+
const text = (_c = colors === null || colors === void 0 ? void 0 : colors.text) !== null && _c !== void 0 ? _c : '#f8fafc';
|
|
20
|
+
const muted = (_d = colors === null || colors === void 0 ? void 0 : colors.textMuted) !== null && _d !== void 0 ? _d : '#94a3b8';
|
|
21
|
+
const bg = (_e = colors === null || colors === void 0 ? void 0 : colors.background) !== null && _e !== void 0 ? _e : '#0a0f14';
|
|
22
|
+
// Wordmark mode sits on the lighter panel navy (backgroundSecondary) rather
|
|
23
|
+
// than the near-black page background, matching the marketing card's field.
|
|
24
|
+
const bgSecondary = (_f = colors === null || colors === void 0 ? void 0 : colors.backgroundSecondary) !== null && _f !== void 0 ? _f : bg;
|
|
25
|
+
const palette = useMemo(() => [
|
|
26
|
+
withAlpha(accent, 0.36),
|
|
27
|
+
withAlpha(accent, 0.55),
|
|
28
|
+
withAlpha(text, 0.18),
|
|
29
|
+
withAlpha(text, 0.3),
|
|
30
|
+
withAlpha(text, 0.45),
|
|
31
|
+
], [accent, text]);
|
|
32
|
+
// --- wordmark mode: spell text out of the city -----------------------
|
|
33
|
+
// The wide-banner sibling of FileCityLogo's mark="P". When `wordmark` is
|
|
34
|
+
// set we abandon the random skyline + trail below and build a full-bleed
|
|
35
|
+
// city whose primary-colored buildings trace the letters, with the muted
|
|
36
|
+
// city filling the rest (and a vertical letterbox of city above/below the
|
|
37
|
+
// single baseline).
|
|
38
|
+
const wordmarkCity = useMemo(() => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (!wordmark)
|
|
41
|
+
return null;
|
|
42
|
+
const bitmap = buildWordmarkBitmap(wordmark);
|
|
43
|
+
const bh = bitmap.length; // glyph rows (7)
|
|
44
|
+
const bw = (_b = (_a = bitmap[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
45
|
+
if (!bw)
|
|
46
|
+
return null;
|
|
47
|
+
// Size a cell so the baseline fills ~64% of the height (leaving the
|
|
48
|
+
// letterbox) but never overflows the width.
|
|
49
|
+
const cellSize = Math.min((H * 0.64) / bh, (W * 0.92) / bw);
|
|
50
|
+
const COLS = Math.max(bw, Math.round(W / cellSize));
|
|
51
|
+
const ROWS = Math.max(bh, Math.round(H / cellSize));
|
|
52
|
+
const offX = Math.round((W - COLS * cellSize) / 2);
|
|
53
|
+
const offY = Math.round((H - ROWS * cellSize) / 2);
|
|
54
|
+
// Center the glyph bitmap within the (larger) city grid.
|
|
55
|
+
const gOffC = Math.floor((COLS - bw) / 2);
|
|
56
|
+
const gOffR = Math.floor((ROWS - bh) / 2);
|
|
57
|
+
const sq = cellSize * 0.74; // smaller than the cell → gaps between buildings
|
|
58
|
+
const inset = (cellSize - sq) / 2;
|
|
59
|
+
// 0 = city, 1 = letter, 2 = hole (the letter's counter — left empty so
|
|
60
|
+
// the background shows through as a clean loop).
|
|
61
|
+
const kindAt = (c, r) => {
|
|
62
|
+
const bc = c - gOffC;
|
|
63
|
+
const br = r - gOffR;
|
|
64
|
+
if (br < 0 || br >= bh || bc < 0 || bc >= bw)
|
|
65
|
+
return 0;
|
|
66
|
+
return bitmap[br][bc];
|
|
67
|
+
};
|
|
68
|
+
const touchesLetter = (c, r) => kindAt(c - 1, r) === 1 ||
|
|
69
|
+
kindAt(c + 1, r) === 1 ||
|
|
70
|
+
kindAt(c, r - 1) === 1 ||
|
|
71
|
+
kindAt(c, r + 1) === 1;
|
|
72
|
+
// Diagonal dark→light shading for the letters, matching FileCityLogo.
|
|
73
|
+
const lo = mix(accent, '#000000', 0.12);
|
|
74
|
+
const hi = mix(accent, '#ffffff', 0.4);
|
|
75
|
+
// Muted city tints — much fainter than the skyline palette so the vivid
|
|
76
|
+
// letters read as the figure against a quiet backdrop (mirrors the city
|
|
77
|
+
// weighting in FileCityLogo / the marketing card, not the bright trail
|
|
78
|
+
// palette this banner uses elsewhere).
|
|
79
|
+
const cityPalette = [
|
|
80
|
+
withAlpha(accent, 0.12),
|
|
81
|
+
withAlpha(accent, 0.20),
|
|
82
|
+
withAlpha(text, 0.05),
|
|
83
|
+
withAlpha(text, 0.09),
|
|
84
|
+
withAlpha(text, 0.14),
|
|
85
|
+
];
|
|
86
|
+
const rng = mulberry32(seed);
|
|
87
|
+
const out = [];
|
|
88
|
+
// Fraction of non-letter city tiles to drop, so the wordmark reads against
|
|
89
|
+
// a sparse scatter of buildings rather than a packed grid.
|
|
90
|
+
const CITY_SKIP = 0.5;
|
|
91
|
+
for (let r = 0; r < ROWS; r++) {
|
|
92
|
+
for (let c = 0; c < COLS; c++) {
|
|
93
|
+
const k = kindAt(c, r);
|
|
94
|
+
const skipRoll = rng();
|
|
95
|
+
const colorRoll = rng();
|
|
96
|
+
if (k === 2)
|
|
97
|
+
continue; // hole (letter counter) — always empty
|
|
98
|
+
// City tiles thin out so the letters stand alone — but tiles touching a
|
|
99
|
+
// letter always render, keeping the glyph edges clean.
|
|
100
|
+
if (k === 0 && !touchesLetter(c, r) && skipRoll < CITY_SKIP)
|
|
101
|
+
continue;
|
|
102
|
+
const isLetter = k === 1;
|
|
103
|
+
let fill;
|
|
104
|
+
if (isLetter) {
|
|
105
|
+
const fx = COLS > 1 ? c / (COLS - 1) : 0;
|
|
106
|
+
const fy = ROWS > 1 ? r / (ROWS - 1) : 0;
|
|
107
|
+
fill = mix(lo, hi, (fx + fy) / 2);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
fill = cityPalette[Math.floor(colorRoll * cityPalette.length)];
|
|
111
|
+
}
|
|
112
|
+
out.push({
|
|
113
|
+
x: offX + c * cellSize + inset,
|
|
114
|
+
y: offY + r * cellSize + inset,
|
|
115
|
+
w: sq,
|
|
116
|
+
h: sq,
|
|
117
|
+
fill,
|
|
118
|
+
stroke: isLetter ? withAlpha(accent, 0.55) : withAlpha(text, 0.08),
|
|
119
|
+
sw: isLetter ? Math.max(0.5, cellSize * 0.03) : 0.5,
|
|
120
|
+
rx: Math.max(1.5, sq * 0.08),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}, [wordmark, W, H, accent, text, seed]);
|
|
126
|
+
// --- grid geometry derived from the frame ----------------------------
|
|
127
|
+
const cell = cfg.h / cfg.rows; // building cell size, consistent across variants
|
|
128
|
+
const COLS = Math.max(4, Math.round(W / cell));
|
|
129
|
+
const ROWS = Math.max(2, Math.round(H / cell));
|
|
130
|
+
const gap = Math.max(3, cell * 0.16);
|
|
131
|
+
const offsetX = Math.round((W - COLS * cell) / 2);
|
|
132
|
+
const offsetY = Math.round((H - ROWS * cell) / 2);
|
|
133
|
+
const center = (col, row) => ({
|
|
134
|
+
x: offsetX + col * cell + cell / 2,
|
|
135
|
+
y: offsetY + row * cell + cell / 2,
|
|
136
|
+
});
|
|
137
|
+
// --- markers: walk left→right with a gentle wave ---------------------
|
|
138
|
+
const markerCells = useMemo(() => {
|
|
139
|
+
// Start the trail past the reserved-left zone so markers avoid the logo.
|
|
140
|
+
const startCol = Math.round(COLS * (reserveLeft ? 0.34 : 0.12));
|
|
141
|
+
const span = Math.max(1, COLS - startCol - 1);
|
|
142
|
+
const colFracs = [0.0, 0.32, 0.62, 0.9];
|
|
143
|
+
const rowFracs = [0.72, 0.36, 0.66, 0.42];
|
|
144
|
+
return colFracs.map((f, i) => ({
|
|
145
|
+
col: clamp(startCol + Math.round(f * span), 0, COLS - 1),
|
|
146
|
+
row: clamp(Math.round(rowFracs[i] * (ROWS - 1)), 0, ROWS - 1),
|
|
147
|
+
label: String(i + 1),
|
|
148
|
+
}));
|
|
149
|
+
}, [COLS, ROWS, reserveLeft]);
|
|
150
|
+
const pinned = useMemo(() => new Set(markerCells.map((m) => `${m.col},${m.row}`)), [markerCells]);
|
|
151
|
+
const buildings = useMemo(() => {
|
|
152
|
+
const rng = mulberry32(seed);
|
|
153
|
+
const list = [];
|
|
154
|
+
for (let r = 0; r < ROWS; r++) {
|
|
155
|
+
for (let c = 0; c < COLS; c++) {
|
|
156
|
+
const isPinned = pinned.has(`${c},${r}`);
|
|
157
|
+
const skipRoll = rng();
|
|
158
|
+
// burn two draws to keep the color sequence stable vs. the diagram
|
|
159
|
+
rng();
|
|
160
|
+
rng();
|
|
161
|
+
const colorRoll = rng();
|
|
162
|
+
if (!isPinned && skipRoll < 0.16)
|
|
163
|
+
continue;
|
|
164
|
+
list.push({
|
|
165
|
+
x: offsetX + c * cell + gap / 2,
|
|
166
|
+
y: offsetY + r * cell + gap / 2,
|
|
167
|
+
w: cell - gap,
|
|
168
|
+
h: cell - gap,
|
|
169
|
+
fill: palette[Math.floor(colorRoll * palette.length)],
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return list;
|
|
174
|
+
}, [palette, pinned, COLS, ROWS, cell, gap, offsetX, offsetY, seed]);
|
|
175
|
+
const markers = useMemo(() => markerCells.map((m) => (Object.assign(Object.assign({}, center(m.col, m.row)), { label: m.label }))),
|
|
176
|
+
// center() is pure over the deps below
|
|
177
|
+
[markerCells, offsetX, offsetY, cell]);
|
|
178
|
+
const trailPath = useMemo(() => {
|
|
179
|
+
const [first, ...rest] = markers;
|
|
180
|
+
if (!first)
|
|
181
|
+
return '';
|
|
182
|
+
return [`M ${first.x} ${first.y}`, ...rest.map((m) => `L ${m.x} ${m.y}`)].join(' ');
|
|
183
|
+
}, [markers]);
|
|
184
|
+
const leaderIndex = clamp(Math.round(leaderMarker) - 1, 0, markers.length - 1);
|
|
185
|
+
const focal = markers[leaderIndex];
|
|
186
|
+
const markerSize = clamp(cell * 0.46, 14, 26);
|
|
187
|
+
const chip = showChip !== null && showChip !== void 0 ? showChip : cfg.chip;
|
|
188
|
+
const chipBox = useMemo(() => {
|
|
189
|
+
var _a;
|
|
190
|
+
if (!chip || !focal)
|
|
191
|
+
return null;
|
|
192
|
+
const margin = Math.round(cell * 0.5);
|
|
193
|
+
const cw = clamp(cell * 5.2, 150, W - margin * 2);
|
|
194
|
+
const ch = clamp(cell * 1.7, 54, Math.max(54, H * 0.5));
|
|
195
|
+
// Sit the card horizontally near the next marker (#3) — to the right of
|
|
196
|
+
// the leader marker — and dropped down a bit from the top band so the
|
|
197
|
+
// leader reads as a clear run rather than a stub.
|
|
198
|
+
const placeX = ((_a = markers[leaderIndex + 1]) !== null && _a !== void 0 ? _a : focal).x;
|
|
199
|
+
const cx = clamp(placeX - cw / 2, margin, W - margin - cw);
|
|
200
|
+
const cy = clamp(margin + Math.round(cell * 1.4), margin, Math.max(margin, H - ch - margin));
|
|
201
|
+
// Anchor on the chip's bottom edge, nearest the leader marker.
|
|
202
|
+
const ax = clamp(focal.x, cx + 14, cx + cw - 14);
|
|
203
|
+
const ay = cy + ch;
|
|
204
|
+
return { x: cx, y: cy, w: cw, h: ch, ax, ay };
|
|
205
|
+
}, [chip, focal, markers, leaderIndex, cell, W, H]);
|
|
206
|
+
return (React.createElement("svg", { viewBox: `0 0 ${W} ${H}`, className: className, style: { display: 'block', width: '100%', height: 'auto' }, role: "img", "aria-label": wordmark
|
|
207
|
+
? `A wide top-down city of files spelling "${wordmark}"`
|
|
208
|
+
: 'A trail of code locations connected across a wide top-down city of files' },
|
|
209
|
+
React.createElement("defs", null,
|
|
210
|
+
React.createElement("radialGradient", { id: `glow-${uid}`, cx: "50%", cy: "50%", r: "50%" },
|
|
211
|
+
React.createElement("stop", { offset: "0%", stopColor: accent, stopOpacity: 0.35 }),
|
|
212
|
+
React.createElement("stop", { offset: "100%", stopColor: accent, stopOpacity: 0 }))),
|
|
213
|
+
React.createElement("rect", { x: 0, y: 0, width: W, height: H, fill: wordmarkCity ? bgSecondary : bg }),
|
|
214
|
+
wordmarkCity ? (
|
|
215
|
+
/* Wordmark mode — the city spells the text; no trail/markers. */
|
|
216
|
+
React.createElement("g", null, wordmarkCity.map((b, i) => (React.createElement("rect", { key: i, x: b.x, y: b.y, width: b.w, height: b.h, fill: b.fill, stroke: b.stroke, strokeWidth: b.sw, rx: b.rx }))))) : (React.createElement(React.Fragment, null,
|
|
217
|
+
React.createElement("g", null, buildings.map((b, i) => (React.createElement("rect", { key: i, x: b.x, y: b.y, width: b.w, height: b.h, fill: b.fill, stroke: withAlpha(text, 0.08), strokeWidth: 0.5, rx: 2 })))),
|
|
218
|
+
showTrail && (React.createElement(React.Fragment, null,
|
|
219
|
+
React.createElement("path", { d: trailPath, fill: "none", stroke: accent, strokeWidth: clamp(cell * 0.05, 1.5, 3), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.12} ${cell * 0.1}`, opacity: 0.9 }),
|
|
220
|
+
chipBox && focal && (React.createElement(React.Fragment, null,
|
|
221
|
+
React.createElement("path", { d: lRoutePath({ x: focal.x, y: focal.y }, { x: chipBox.ax, y: chipBox.ay }), fill: "none", stroke: accent, strokeWidth: 1.5, strokeDasharray: "5 4", opacity: 0.75 }),
|
|
222
|
+
React.createElement("circle", { cx: chipBox.ax, cy: chipBox.ay, r: 3, fill: accent }))),
|
|
223
|
+
markers.map((m, i) => {
|
|
224
|
+
const isActive = i === leaderIndex;
|
|
225
|
+
const half = markerSize / 2;
|
|
226
|
+
return (React.createElement("g", { key: m.label },
|
|
227
|
+
isActive && (React.createElement(React.Fragment, null,
|
|
228
|
+
React.createElement("circle", { cx: m.x, cy: m.y, r: markerSize * 1.6, fill: `url(#glow-${uid})` }),
|
|
229
|
+
React.createElement("rect", { x: m.x - half - 4, y: m.y - half - 4, width: markerSize + 8, height: markerSize + 8, rx: 6, fill: accent, opacity: 0.18 },
|
|
230
|
+
React.createElement("animate", { attributeName: "opacity", values: "0.28;0;0.28", dur: "2.4s", repeatCount: "indefinite" })))),
|
|
231
|
+
React.createElement("rect", { x: m.x - half, y: m.y - half, width: markerSize, height: markerSize, rx: 4, fill: surface, stroke: accent, strokeWidth: 1.75 }),
|
|
232
|
+
React.createElement("text", { x: m.x, y: m.y + 1, textAnchor: "middle", dominantBaseline: "central", fontSize: markerSize * 0.62, fontWeight: 700, fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fill: text }, m.label)));
|
|
233
|
+
}),
|
|
234
|
+
chipBox && (React.createElement(CodeChip, { x: chipBox.x, y: chipBox.y, w: chipBox.w, h: chipBox.h, surface: surface, text: text, muted: muted, accent: accent }))))))));
|
|
235
|
+
}
|
|
236
|
+
function CodeChip({ x, y, w, h, surface, text, muted, accent, }) {
|
|
237
|
+
const header = clamp(h * 0.32, 18, 30);
|
|
238
|
+
const pad = clamp(w * 0.05, 8, 16);
|
|
239
|
+
const lines = [
|
|
240
|
+
{ w: w * 0.62, c: muted },
|
|
241
|
+
{ w: w * 0.8, c: text },
|
|
242
|
+
{ w: w * 0.45, c: accent },
|
|
243
|
+
];
|
|
244
|
+
const lineGap = (h - header - pad) / (lines.length + 0.5);
|
|
245
|
+
return (React.createElement("g", { transform: `translate(${x}, ${y})` },
|
|
246
|
+
React.createElement("rect", { width: w, height: h, rx: 10, fill: surface, stroke: withAlpha(accent, 0.55), strokeWidth: 1.5 }),
|
|
247
|
+
React.createElement("rect", { width: w, height: header, rx: 10, fill: withAlpha(accent, 0.1) }),
|
|
248
|
+
React.createElement("text", { x: pad, y: header / 2, dominantBaseline: "central", fontSize: clamp(header * 0.46, 10, 14), fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fill: text }, "db/users.ts:42"),
|
|
249
|
+
React.createElement("g", { transform: `translate(${pad}, ${header + pad})` }, lines.map((l, i) => (React.createElement("rect", { key: i, x: 0, y: i * lineGap, width: l.w - pad * 2, height: clamp(h * 0.06, 4, 8), rx: 2, fill: l.c, opacity: 0.75 }))))));
|
|
250
|
+
}
|
|
251
|
+
// --- wordmark glyphs ---------------------------------------------------
|
|
252
|
+
// 5-wide × 7-tall uppercase pixel glyphs, the wide-banner cousins of
|
|
253
|
+
// FileCityLogo's GLYPHS. `1` = a letter (primary) building, `H` = the letter's
|
|
254
|
+
// counter (a forced hole so loops read clean), `0` = a city building. Only the
|
|
255
|
+
// letters needed for the shipped wordmarks are defined; unknown chars fall back
|
|
256
|
+
// to a 1-column space.
|
|
257
|
+
const WORDMARK_GLYPHS = {
|
|
258
|
+
' ': ['0', '0', '0', '0', '0', '0', '0'],
|
|
259
|
+
A: ['01110', '1HHH1', '1HHH1', '11111', '10001', '10001', '10001'],
|
|
260
|
+
C: ['01110', '10001', '10000', '10000', '10000', '10001', '01110'],
|
|
261
|
+
D: ['11110', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '11110'],
|
|
262
|
+
E: ['11111', '10000', '10000', '11110', '10000', '10000', '11111'],
|
|
263
|
+
I: ['11111', '00100', '00100', '00100', '00100', '00100', '11111'],
|
|
264
|
+
L: ['10000', '10000', '10000', '10000', '10000', '10000', '11111'],
|
|
265
|
+
O: ['01110', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '01110'],
|
|
266
|
+
R: ['11110', '1HHH1', '1HHH1', '11110', '10100', '10010', '10001'],
|
|
267
|
+
S: ['01111', '10000', '10000', '01110', '00001', '00001', '11110'],
|
|
268
|
+
T: ['11111', '00100', '00100', '00100', '00100', '00100', '00100'],
|
|
269
|
+
};
|
|
270
|
+
/** Compose the uppercase `text` into a 7-row bitmap (1 = letter, 2 = hole,
|
|
271
|
+
* 0 = city), inserting a single city column between adjacent characters. */
|
|
272
|
+
function buildWordmarkBitmap(text) {
|
|
273
|
+
const rows = 7;
|
|
274
|
+
const out = Array.from({ length: rows }, () => []);
|
|
275
|
+
text
|
|
276
|
+
.toUpperCase()
|
|
277
|
+
.split('')
|
|
278
|
+
.forEach((ch, i) => {
|
|
279
|
+
var _a;
|
|
280
|
+
const glyph = (_a = WORDMARK_GLYPHS[ch]) !== null && _a !== void 0 ? _a : WORDMARK_GLYPHS[' '];
|
|
281
|
+
if (i > 0)
|
|
282
|
+
for (let r = 0; r < rows; r++)
|
|
283
|
+
out[r].push(0);
|
|
284
|
+
for (let r = 0; r < rows; r++) {
|
|
285
|
+
for (const px of glyph[r])
|
|
286
|
+
out[r].push(px === '1' ? 1 : px === 'H' ? 2 : 0);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
return out;
|
|
290
|
+
}
|
|
291
|
+
// --- local helpers (kept private; mirror TrailCityDiagram) -------------
|
|
292
|
+
function clamp(v, lo, hi) {
|
|
293
|
+
return Math.max(lo, Math.min(hi, v));
|
|
294
|
+
}
|
|
295
|
+
function toRgb(color) {
|
|
296
|
+
if (!/^#([0-9a-f]{3}){1,2}$/i.test(color))
|
|
297
|
+
return null;
|
|
298
|
+
let hex = color.slice(1);
|
|
299
|
+
if (hex.length === 3)
|
|
300
|
+
hex = hex.split('').map((c) => c + c).join('');
|
|
301
|
+
return [
|
|
302
|
+
parseInt(hex.slice(0, 2), 16),
|
|
303
|
+
parseInt(hex.slice(2, 4), 16),
|
|
304
|
+
parseInt(hex.slice(4, 6), 16),
|
|
305
|
+
];
|
|
306
|
+
}
|
|
307
|
+
/** Blend two hex colors. `t` = 0 returns `a`, `t` = 1 returns `b`. Falls
|
|
308
|
+
* back to `a` when either side isn't a parseable hex. */
|
|
309
|
+
function mix(a, b, t) {
|
|
310
|
+
const ca = toRgb(a);
|
|
311
|
+
const cb = toRgb(b);
|
|
312
|
+
if (!ca || !cb)
|
|
313
|
+
return a;
|
|
314
|
+
const ch = (i) => Math.round(ca[i] + (cb[i] - ca[i]) * clamp(t, 0, 1))
|
|
315
|
+
.toString(16)
|
|
316
|
+
.padStart(2, '0');
|
|
317
|
+
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
318
|
+
}
|
|
319
|
+
/** VH leader from `a` (marker) to `b` (chip anchor): exits `a` vertically
|
|
320
|
+
* toward `b.y`, then turns and runs horizontally to `b.x`. */
|
|
321
|
+
function lRoutePath(a, b, radius = 12) {
|
|
322
|
+
const ySign = b.y < a.y ? -1 : 1;
|
|
323
|
+
const xSign = b.x < a.x ? -1 : 1;
|
|
324
|
+
const r = Math.min(radius, Math.abs(a.y - b.y) / 2, Math.abs(a.x - b.x) / 2) || 0;
|
|
325
|
+
return [
|
|
326
|
+
`M ${a.x} ${a.y}`,
|
|
327
|
+
`L ${a.x} ${b.y - ySign * r}`,
|
|
328
|
+
`Q ${a.x} ${b.y} ${a.x + xSign * r} ${b.y}`,
|
|
329
|
+
`L ${b.x} ${b.y}`,
|
|
330
|
+
].join(' ');
|
|
331
|
+
}
|
|
332
|
+
function mulberry32(seed) {
|
|
333
|
+
let t = seed;
|
|
334
|
+
return () => {
|
|
335
|
+
t = (t + 0x6d2b79f5) | 0;
|
|
336
|
+
let r = t;
|
|
337
|
+
r = Math.imul(r ^ (r >>> 15), r | 1);
|
|
338
|
+
r ^= r + Math.imul(r ^ (r >>> 7), r | 61);
|
|
339
|
+
return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function withAlpha(color, alpha) {
|
|
343
|
+
if (/^#([0-9a-f]{3}){1,2}$/i.test(color)) {
|
|
344
|
+
let hex = color.slice(1);
|
|
345
|
+
if (hex.length === 3)
|
|
346
|
+
hex = hex.split('').map((c) => c + c).join('');
|
|
347
|
+
const a = Math.round(Math.max(0, Math.min(1, alpha)) * 255)
|
|
348
|
+
.toString(16)
|
|
349
|
+
.padStart(2, '0');
|
|
350
|
+
return `#${hex}${a}`;
|
|
351
|
+
}
|
|
352
|
+
return color;
|
|
353
|
+
}
|