@principal-ai/logo-component 0.1.22 → 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/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/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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Theme } from '@principal-ade/industry-theme';
|
|
3
|
+
/**
|
|
4
|
+
* Banner-native sibling of {@link TrailCityDiagram}.
|
|
5
|
+
*
|
|
6
|
+
* Same visual DNA — a seeded top-down city of file "buildings" with a dashed
|
|
7
|
+
* trail threading numbered markers — but composed for wide, short social
|
|
8
|
+
* banners instead of a 700×700 square:
|
|
9
|
+
* • the city is a wide strip whose column/row count derives from the frame,
|
|
10
|
+
* • the trail runs left→right with a gentle wave,
|
|
11
|
+
* • the left edge fades out to reserve room for a platform logo / wordmark,
|
|
12
|
+
* • the tall 280×200 snippet card is replaced by a compact code chip.
|
|
13
|
+
*
|
|
14
|
+
* Presets target the two surfaces we ship:
|
|
15
|
+
* • twitterHeader — 1500 × 500 (3:1)
|
|
16
|
+
* • linkedinCompany — 1128 × 191 (~5.9:1)
|
|
17
|
+
*/
|
|
18
|
+
export type BannerVariant = 'twitterHeader' | 'linkedinCompany' | 'linkedinProfile';
|
|
19
|
+
export interface TrailCityBannerProps {
|
|
20
|
+
/** Theme supplying colors. Falls back to dark-mode defaults when absent. */
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
/** Class applied to the wrapping <svg>. */
|
|
23
|
+
className?: string;
|
|
24
|
+
/** Preset surface. Ignored for sizing if width/height are both given. */
|
|
25
|
+
variant?: BannerVariant;
|
|
26
|
+
/** Override the native frame width (defaults to the variant). */
|
|
27
|
+
width?: number;
|
|
28
|
+
/** Override the native frame height (defaults to the variant). */
|
|
29
|
+
height?: number;
|
|
30
|
+
/** Deterministic layout seed — change it to reshuffle the skyline. */
|
|
31
|
+
seed?: number;
|
|
32
|
+
/** Keep the left portion clear of the trail/markers so a logo or wordmark
|
|
33
|
+
* can overlay there. (No visual fade — just shifts where the trail starts.) */
|
|
34
|
+
reserveLeft?: boolean;
|
|
35
|
+
/** Show the dashed trail + numbered markers. */
|
|
36
|
+
showTrail?: boolean;
|
|
37
|
+
/** Show the compact code chip near the focal marker. Defaults per variant. */
|
|
38
|
+
showChip?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Which marker (1-based) the code chip's leader connects to — also the
|
|
41
|
+
* highlighted/active marker. Defaults to 2.
|
|
42
|
+
*/
|
|
43
|
+
leaderMarker?: number;
|
|
44
|
+
/**
|
|
45
|
+
* When set, the banner drops the random skyline + trail and instead spells
|
|
46
|
+
* this text *out of the city* — primary-colored "buildings" forming the
|
|
47
|
+
* letters against the muted city, the wide-banner sibling of
|
|
48
|
+
* {@link FileCityLogo}'s `mark="P"`. Rendered uppercase, single baseline,
|
|
49
|
+
* centered with a vertical letterbox of city.
|
|
50
|
+
*/
|
|
51
|
+
wordmark?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function TrailCityBanner({ theme, className, variant, width, height, seed, reserveLeft, showTrail, showChip, leaderMarker, wordmark, }: TrailCityBannerProps): React.JSX.Element;
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.TrailCityBanner = TrailCityBanner;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const VARIANTS = {
|
|
40
|
+
twitterHeader: { w: 1500, h: 500, rows: 9, chip: true },
|
|
41
|
+
linkedinCompany: { w: 1128, h: 191, rows: 4, chip: false },
|
|
42
|
+
// Personal/employee profile background — 4:1, taller than the company cover.
|
|
43
|
+
linkedinProfile: { w: 1584, h: 396, rows: 7, chip: true },
|
|
44
|
+
};
|
|
45
|
+
function TrailCityBanner({ theme, className, variant = 'twitterHeader', width, height, seed = 7, reserveLeft = true, showTrail = true, showChip, leaderMarker = 2, wordmark, }) {
|
|
46
|
+
var _a, _b, _c, _d, _e, _f;
|
|
47
|
+
const cfg = VARIANTS[variant];
|
|
48
|
+
const W = width !== null && width !== void 0 ? width : cfg.w;
|
|
49
|
+
const H = height !== null && height !== void 0 ? height : cfg.h;
|
|
50
|
+
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
51
|
+
// --- colors (mirrors TrailCityDiagram) -------------------------------
|
|
52
|
+
const colors = theme === null || theme === void 0 ? void 0 : theme.colors;
|
|
53
|
+
const accent = (_a = colors === null || colors === void 0 ? void 0 : colors.primary) !== null && _a !== void 0 ? _a : '#22d3ee';
|
|
54
|
+
const surface = (_b = colors === null || colors === void 0 ? void 0 : colors.surface) !== null && _b !== void 0 ? _b : '#0f1419';
|
|
55
|
+
const text = (_c = colors === null || colors === void 0 ? void 0 : colors.text) !== null && _c !== void 0 ? _c : '#f8fafc';
|
|
56
|
+
const muted = (_d = colors === null || colors === void 0 ? void 0 : colors.textMuted) !== null && _d !== void 0 ? _d : '#94a3b8';
|
|
57
|
+
const bg = (_e = colors === null || colors === void 0 ? void 0 : colors.background) !== null && _e !== void 0 ? _e : '#0a0f14';
|
|
58
|
+
// Wordmark mode sits on the lighter panel navy (backgroundSecondary) rather
|
|
59
|
+
// than the near-black page background, matching the marketing card's field.
|
|
60
|
+
const bgSecondary = (_f = colors === null || colors === void 0 ? void 0 : colors.backgroundSecondary) !== null && _f !== void 0 ? _f : bg;
|
|
61
|
+
const palette = (0, react_1.useMemo)(() => [
|
|
62
|
+
withAlpha(accent, 0.36),
|
|
63
|
+
withAlpha(accent, 0.55),
|
|
64
|
+
withAlpha(text, 0.18),
|
|
65
|
+
withAlpha(text, 0.3),
|
|
66
|
+
withAlpha(text, 0.45),
|
|
67
|
+
], [accent, text]);
|
|
68
|
+
// --- wordmark mode: spell text out of the city -----------------------
|
|
69
|
+
// The wide-banner sibling of FileCityLogo's mark="P". When `wordmark` is
|
|
70
|
+
// set we abandon the random skyline + trail below and build a full-bleed
|
|
71
|
+
// city whose primary-colored buildings trace the letters, with the muted
|
|
72
|
+
// city filling the rest (and a vertical letterbox of city above/below the
|
|
73
|
+
// single baseline).
|
|
74
|
+
const wordmarkCity = (0, react_1.useMemo)(() => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (!wordmark)
|
|
77
|
+
return null;
|
|
78
|
+
const bitmap = buildWordmarkBitmap(wordmark);
|
|
79
|
+
const bh = bitmap.length; // glyph rows (7)
|
|
80
|
+
const bw = (_b = (_a = bitmap[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
81
|
+
if (!bw)
|
|
82
|
+
return null;
|
|
83
|
+
// Size a cell so the baseline fills ~64% of the height (leaving the
|
|
84
|
+
// letterbox) but never overflows the width.
|
|
85
|
+
const cellSize = Math.min((H * 0.64) / bh, (W * 0.92) / bw);
|
|
86
|
+
const COLS = Math.max(bw, Math.round(W / cellSize));
|
|
87
|
+
const ROWS = Math.max(bh, Math.round(H / cellSize));
|
|
88
|
+
const offX = Math.round((W - COLS * cellSize) / 2);
|
|
89
|
+
const offY = Math.round((H - ROWS * cellSize) / 2);
|
|
90
|
+
// Center the glyph bitmap within the (larger) city grid.
|
|
91
|
+
const gOffC = Math.floor((COLS - bw) / 2);
|
|
92
|
+
const gOffR = Math.floor((ROWS - bh) / 2);
|
|
93
|
+
const sq = cellSize * 0.74; // smaller than the cell → gaps between buildings
|
|
94
|
+
const inset = (cellSize - sq) / 2;
|
|
95
|
+
// 0 = city, 1 = letter, 2 = hole (the letter's counter — left empty so
|
|
96
|
+
// the background shows through as a clean loop).
|
|
97
|
+
const kindAt = (c, r) => {
|
|
98
|
+
const bc = c - gOffC;
|
|
99
|
+
const br = r - gOffR;
|
|
100
|
+
if (br < 0 || br >= bh || bc < 0 || bc >= bw)
|
|
101
|
+
return 0;
|
|
102
|
+
return bitmap[br][bc];
|
|
103
|
+
};
|
|
104
|
+
const touchesLetter = (c, r) => kindAt(c - 1, r) === 1 ||
|
|
105
|
+
kindAt(c + 1, r) === 1 ||
|
|
106
|
+
kindAt(c, r - 1) === 1 ||
|
|
107
|
+
kindAt(c, r + 1) === 1;
|
|
108
|
+
// Diagonal dark→light shading for the letters, matching FileCityLogo.
|
|
109
|
+
const lo = mix(accent, '#000000', 0.12);
|
|
110
|
+
const hi = mix(accent, '#ffffff', 0.4);
|
|
111
|
+
// Muted city tints — much fainter than the skyline palette so the vivid
|
|
112
|
+
// letters read as the figure against a quiet backdrop (mirrors the city
|
|
113
|
+
// weighting in FileCityLogo / the marketing card, not the bright trail
|
|
114
|
+
// palette this banner uses elsewhere).
|
|
115
|
+
const cityPalette = [
|
|
116
|
+
withAlpha(accent, 0.12),
|
|
117
|
+
withAlpha(accent, 0.20),
|
|
118
|
+
withAlpha(text, 0.05),
|
|
119
|
+
withAlpha(text, 0.09),
|
|
120
|
+
withAlpha(text, 0.14),
|
|
121
|
+
];
|
|
122
|
+
const rng = mulberry32(seed);
|
|
123
|
+
const out = [];
|
|
124
|
+
// Fraction of non-letter city tiles to drop, so the wordmark reads against
|
|
125
|
+
// a sparse scatter of buildings rather than a packed grid.
|
|
126
|
+
const CITY_SKIP = 0.5;
|
|
127
|
+
for (let r = 0; r < ROWS; r++) {
|
|
128
|
+
for (let c = 0; c < COLS; c++) {
|
|
129
|
+
const k = kindAt(c, r);
|
|
130
|
+
const skipRoll = rng();
|
|
131
|
+
const colorRoll = rng();
|
|
132
|
+
if (k === 2)
|
|
133
|
+
continue; // hole (letter counter) — always empty
|
|
134
|
+
// City tiles thin out so the letters stand alone — but tiles touching a
|
|
135
|
+
// letter always render, keeping the glyph edges clean.
|
|
136
|
+
if (k === 0 && !touchesLetter(c, r) && skipRoll < CITY_SKIP)
|
|
137
|
+
continue;
|
|
138
|
+
const isLetter = k === 1;
|
|
139
|
+
let fill;
|
|
140
|
+
if (isLetter) {
|
|
141
|
+
const fx = COLS > 1 ? c / (COLS - 1) : 0;
|
|
142
|
+
const fy = ROWS > 1 ? r / (ROWS - 1) : 0;
|
|
143
|
+
fill = mix(lo, hi, (fx + fy) / 2);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
fill = cityPalette[Math.floor(colorRoll * cityPalette.length)];
|
|
147
|
+
}
|
|
148
|
+
out.push({
|
|
149
|
+
x: offX + c * cellSize + inset,
|
|
150
|
+
y: offY + r * cellSize + inset,
|
|
151
|
+
w: sq,
|
|
152
|
+
h: sq,
|
|
153
|
+
fill,
|
|
154
|
+
stroke: isLetter ? withAlpha(accent, 0.55) : withAlpha(text, 0.08),
|
|
155
|
+
sw: isLetter ? Math.max(0.5, cellSize * 0.03) : 0.5,
|
|
156
|
+
rx: Math.max(1.5, sq * 0.08),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}, [wordmark, W, H, accent, text, seed]);
|
|
162
|
+
// --- grid geometry derived from the frame ----------------------------
|
|
163
|
+
const cell = cfg.h / cfg.rows; // building cell size, consistent across variants
|
|
164
|
+
const COLS = Math.max(4, Math.round(W / cell));
|
|
165
|
+
const ROWS = Math.max(2, Math.round(H / cell));
|
|
166
|
+
const gap = Math.max(3, cell * 0.16);
|
|
167
|
+
const offsetX = Math.round((W - COLS * cell) / 2);
|
|
168
|
+
const offsetY = Math.round((H - ROWS * cell) / 2);
|
|
169
|
+
const center = (col, row) => ({
|
|
170
|
+
x: offsetX + col * cell + cell / 2,
|
|
171
|
+
y: offsetY + row * cell + cell / 2,
|
|
172
|
+
});
|
|
173
|
+
// --- markers: walk left→right with a gentle wave ---------------------
|
|
174
|
+
const markerCells = (0, react_1.useMemo)(() => {
|
|
175
|
+
// Start the trail past the reserved-left zone so markers avoid the logo.
|
|
176
|
+
const startCol = Math.round(COLS * (reserveLeft ? 0.34 : 0.12));
|
|
177
|
+
const span = Math.max(1, COLS - startCol - 1);
|
|
178
|
+
const colFracs = [0.0, 0.32, 0.62, 0.9];
|
|
179
|
+
const rowFracs = [0.72, 0.36, 0.66, 0.42];
|
|
180
|
+
return colFracs.map((f, i) => ({
|
|
181
|
+
col: clamp(startCol + Math.round(f * span), 0, COLS - 1),
|
|
182
|
+
row: clamp(Math.round(rowFracs[i] * (ROWS - 1)), 0, ROWS - 1),
|
|
183
|
+
label: String(i + 1),
|
|
184
|
+
}));
|
|
185
|
+
}, [COLS, ROWS, reserveLeft]);
|
|
186
|
+
const pinned = (0, react_1.useMemo)(() => new Set(markerCells.map((m) => `${m.col},${m.row}`)), [markerCells]);
|
|
187
|
+
const buildings = (0, react_1.useMemo)(() => {
|
|
188
|
+
const rng = mulberry32(seed);
|
|
189
|
+
const list = [];
|
|
190
|
+
for (let r = 0; r < ROWS; r++) {
|
|
191
|
+
for (let c = 0; c < COLS; c++) {
|
|
192
|
+
const isPinned = pinned.has(`${c},${r}`);
|
|
193
|
+
const skipRoll = rng();
|
|
194
|
+
// burn two draws to keep the color sequence stable vs. the diagram
|
|
195
|
+
rng();
|
|
196
|
+
rng();
|
|
197
|
+
const colorRoll = rng();
|
|
198
|
+
if (!isPinned && skipRoll < 0.16)
|
|
199
|
+
continue;
|
|
200
|
+
list.push({
|
|
201
|
+
x: offsetX + c * cell + gap / 2,
|
|
202
|
+
y: offsetY + r * cell + gap / 2,
|
|
203
|
+
w: cell - gap,
|
|
204
|
+
h: cell - gap,
|
|
205
|
+
fill: palette[Math.floor(colorRoll * palette.length)],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return list;
|
|
210
|
+
}, [palette, pinned, COLS, ROWS, cell, gap, offsetX, offsetY, seed]);
|
|
211
|
+
const markers = (0, react_1.useMemo)(() => markerCells.map((m) => (Object.assign(Object.assign({}, center(m.col, m.row)), { label: m.label }))),
|
|
212
|
+
// center() is pure over the deps below
|
|
213
|
+
[markerCells, offsetX, offsetY, cell]);
|
|
214
|
+
const trailPath = (0, react_1.useMemo)(() => {
|
|
215
|
+
const [first, ...rest] = markers;
|
|
216
|
+
if (!first)
|
|
217
|
+
return '';
|
|
218
|
+
return [`M ${first.x} ${first.y}`, ...rest.map((m) => `L ${m.x} ${m.y}`)].join(' ');
|
|
219
|
+
}, [markers]);
|
|
220
|
+
const leaderIndex = clamp(Math.round(leaderMarker) - 1, 0, markers.length - 1);
|
|
221
|
+
const focal = markers[leaderIndex];
|
|
222
|
+
const markerSize = clamp(cell * 0.46, 14, 26);
|
|
223
|
+
const chip = showChip !== null && showChip !== void 0 ? showChip : cfg.chip;
|
|
224
|
+
const chipBox = (0, react_1.useMemo)(() => {
|
|
225
|
+
var _a;
|
|
226
|
+
if (!chip || !focal)
|
|
227
|
+
return null;
|
|
228
|
+
const margin = Math.round(cell * 0.5);
|
|
229
|
+
const cw = clamp(cell * 5.2, 150, W - margin * 2);
|
|
230
|
+
const ch = clamp(cell * 1.7, 54, Math.max(54, H * 0.5));
|
|
231
|
+
// Sit the card horizontally near the next marker (#3) — to the right of
|
|
232
|
+
// the leader marker — and dropped down a bit from the top band so the
|
|
233
|
+
// leader reads as a clear run rather than a stub.
|
|
234
|
+
const placeX = ((_a = markers[leaderIndex + 1]) !== null && _a !== void 0 ? _a : focal).x;
|
|
235
|
+
const cx = clamp(placeX - cw / 2, margin, W - margin - cw);
|
|
236
|
+
const cy = clamp(margin + Math.round(cell * 1.4), margin, Math.max(margin, H - ch - margin));
|
|
237
|
+
// Anchor on the chip's bottom edge, nearest the leader marker.
|
|
238
|
+
const ax = clamp(focal.x, cx + 14, cx + cw - 14);
|
|
239
|
+
const ay = cy + ch;
|
|
240
|
+
return { x: cx, y: cy, w: cw, h: ch, ax, ay };
|
|
241
|
+
}, [chip, focal, markers, leaderIndex, cell, W, H]);
|
|
242
|
+
return (react_1.default.createElement("svg", { viewBox: `0 0 ${W} ${H}`, className: className, style: { display: 'block', width: '100%', height: 'auto' }, role: "img", "aria-label": wordmark
|
|
243
|
+
? `A wide top-down city of files spelling "${wordmark}"`
|
|
244
|
+
: 'A trail of code locations connected across a wide top-down city of files' },
|
|
245
|
+
react_1.default.createElement("defs", null,
|
|
246
|
+
react_1.default.createElement("radialGradient", { id: `glow-${uid}`, cx: "50%", cy: "50%", r: "50%" },
|
|
247
|
+
react_1.default.createElement("stop", { offset: "0%", stopColor: accent, stopOpacity: 0.35 }),
|
|
248
|
+
react_1.default.createElement("stop", { offset: "100%", stopColor: accent, stopOpacity: 0 }))),
|
|
249
|
+
react_1.default.createElement("rect", { x: 0, y: 0, width: W, height: H, fill: wordmarkCity ? bgSecondary : bg }),
|
|
250
|
+
wordmarkCity ? (
|
|
251
|
+
/* Wordmark mode — the city spells the text; no trail/markers. */
|
|
252
|
+
react_1.default.createElement("g", null, wordmarkCity.map((b, i) => (react_1.default.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_1.default.createElement(react_1.default.Fragment, null,
|
|
253
|
+
react_1.default.createElement("g", null, buildings.map((b, i) => (react_1.default.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 })))),
|
|
254
|
+
showTrail && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
255
|
+
react_1.default.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 }),
|
|
256
|
+
chipBox && focal && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
257
|
+
react_1.default.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 }),
|
|
258
|
+
react_1.default.createElement("circle", { cx: chipBox.ax, cy: chipBox.ay, r: 3, fill: accent }))),
|
|
259
|
+
markers.map((m, i) => {
|
|
260
|
+
const isActive = i === leaderIndex;
|
|
261
|
+
const half = markerSize / 2;
|
|
262
|
+
return (react_1.default.createElement("g", { key: m.label },
|
|
263
|
+
isActive && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
264
|
+
react_1.default.createElement("circle", { cx: m.x, cy: m.y, r: markerSize * 1.6, fill: `url(#glow-${uid})` }),
|
|
265
|
+
react_1.default.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 },
|
|
266
|
+
react_1.default.createElement("animate", { attributeName: "opacity", values: "0.28;0;0.28", dur: "2.4s", repeatCount: "indefinite" })))),
|
|
267
|
+
react_1.default.createElement("rect", { x: m.x - half, y: m.y - half, width: markerSize, height: markerSize, rx: 4, fill: surface, stroke: accent, strokeWidth: 1.75 }),
|
|
268
|
+
react_1.default.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)));
|
|
269
|
+
}),
|
|
270
|
+
chipBox && (react_1.default.createElement(CodeChip, { x: chipBox.x, y: chipBox.y, w: chipBox.w, h: chipBox.h, surface: surface, text: text, muted: muted, accent: accent }))))))));
|
|
271
|
+
}
|
|
272
|
+
function CodeChip({ x, y, w, h, surface, text, muted, accent, }) {
|
|
273
|
+
const header = clamp(h * 0.32, 18, 30);
|
|
274
|
+
const pad = clamp(w * 0.05, 8, 16);
|
|
275
|
+
const lines = [
|
|
276
|
+
{ w: w * 0.62, c: muted },
|
|
277
|
+
{ w: w * 0.8, c: text },
|
|
278
|
+
{ w: w * 0.45, c: accent },
|
|
279
|
+
];
|
|
280
|
+
const lineGap = (h - header - pad) / (lines.length + 0.5);
|
|
281
|
+
return (react_1.default.createElement("g", { transform: `translate(${x}, ${y})` },
|
|
282
|
+
react_1.default.createElement("rect", { width: w, height: h, rx: 10, fill: surface, stroke: withAlpha(accent, 0.55), strokeWidth: 1.5 }),
|
|
283
|
+
react_1.default.createElement("rect", { width: w, height: header, rx: 10, fill: withAlpha(accent, 0.1) }),
|
|
284
|
+
react_1.default.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"),
|
|
285
|
+
react_1.default.createElement("g", { transform: `translate(${pad}, ${header + pad})` }, lines.map((l, i) => (react_1.default.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 }))))));
|
|
286
|
+
}
|
|
287
|
+
// --- wordmark glyphs ---------------------------------------------------
|
|
288
|
+
// 5-wide × 7-tall uppercase pixel glyphs, the wide-banner cousins of
|
|
289
|
+
// FileCityLogo's GLYPHS. `1` = a letter (primary) building, `H` = the letter's
|
|
290
|
+
// counter (a forced hole so loops read clean), `0` = a city building. Only the
|
|
291
|
+
// letters needed for the shipped wordmarks are defined; unknown chars fall back
|
|
292
|
+
// to a 1-column space.
|
|
293
|
+
const WORDMARK_GLYPHS = {
|
|
294
|
+
' ': ['0', '0', '0', '0', '0', '0', '0'],
|
|
295
|
+
A: ['01110', '1HHH1', '1HHH1', '11111', '10001', '10001', '10001'],
|
|
296
|
+
C: ['01110', '10001', '10000', '10000', '10000', '10001', '01110'],
|
|
297
|
+
D: ['11110', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '11110'],
|
|
298
|
+
E: ['11111', '10000', '10000', '11110', '10000', '10000', '11111'],
|
|
299
|
+
I: ['11111', '00100', '00100', '00100', '00100', '00100', '11111'],
|
|
300
|
+
L: ['10000', '10000', '10000', '10000', '10000', '10000', '11111'],
|
|
301
|
+
O: ['01110', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '1HHH1', '01110'],
|
|
302
|
+
R: ['11110', '1HHH1', '1HHH1', '11110', '10100', '10010', '10001'],
|
|
303
|
+
S: ['01111', '10000', '10000', '01110', '00001', '00001', '11110'],
|
|
304
|
+
T: ['11111', '00100', '00100', '00100', '00100', '00100', '00100'],
|
|
305
|
+
};
|
|
306
|
+
/** Compose the uppercase `text` into a 7-row bitmap (1 = letter, 2 = hole,
|
|
307
|
+
* 0 = city), inserting a single city column between adjacent characters. */
|
|
308
|
+
function buildWordmarkBitmap(text) {
|
|
309
|
+
const rows = 7;
|
|
310
|
+
const out = Array.from({ length: rows }, () => []);
|
|
311
|
+
text
|
|
312
|
+
.toUpperCase()
|
|
313
|
+
.split('')
|
|
314
|
+
.forEach((ch, i) => {
|
|
315
|
+
var _a;
|
|
316
|
+
const glyph = (_a = WORDMARK_GLYPHS[ch]) !== null && _a !== void 0 ? _a : WORDMARK_GLYPHS[' '];
|
|
317
|
+
if (i > 0)
|
|
318
|
+
for (let r = 0; r < rows; r++)
|
|
319
|
+
out[r].push(0);
|
|
320
|
+
for (let r = 0; r < rows; r++) {
|
|
321
|
+
for (const px of glyph[r])
|
|
322
|
+
out[r].push(px === '1' ? 1 : px === 'H' ? 2 : 0);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
// --- local helpers (kept private; mirror TrailCityDiagram) -------------
|
|
328
|
+
function clamp(v, lo, hi) {
|
|
329
|
+
return Math.max(lo, Math.min(hi, v));
|
|
330
|
+
}
|
|
331
|
+
function toRgb(color) {
|
|
332
|
+
if (!/^#([0-9a-f]{3}){1,2}$/i.test(color))
|
|
333
|
+
return null;
|
|
334
|
+
let hex = color.slice(1);
|
|
335
|
+
if (hex.length === 3)
|
|
336
|
+
hex = hex.split('').map((c) => c + c).join('');
|
|
337
|
+
return [
|
|
338
|
+
parseInt(hex.slice(0, 2), 16),
|
|
339
|
+
parseInt(hex.slice(2, 4), 16),
|
|
340
|
+
parseInt(hex.slice(4, 6), 16),
|
|
341
|
+
];
|
|
342
|
+
}
|
|
343
|
+
/** Blend two hex colors. `t` = 0 returns `a`, `t` = 1 returns `b`. Falls
|
|
344
|
+
* back to `a` when either side isn't a parseable hex. */
|
|
345
|
+
function mix(a, b, t) {
|
|
346
|
+
const ca = toRgb(a);
|
|
347
|
+
const cb = toRgb(b);
|
|
348
|
+
if (!ca || !cb)
|
|
349
|
+
return a;
|
|
350
|
+
const ch = (i) => Math.round(ca[i] + (cb[i] - ca[i]) * clamp(t, 0, 1))
|
|
351
|
+
.toString(16)
|
|
352
|
+
.padStart(2, '0');
|
|
353
|
+
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
354
|
+
}
|
|
355
|
+
/** VH leader from `a` (marker) to `b` (chip anchor): exits `a` vertically
|
|
356
|
+
* toward `b.y`, then turns and runs horizontally to `b.x`. */
|
|
357
|
+
function lRoutePath(a, b, radius = 12) {
|
|
358
|
+
const ySign = b.y < a.y ? -1 : 1;
|
|
359
|
+
const xSign = b.x < a.x ? -1 : 1;
|
|
360
|
+
const r = Math.min(radius, Math.abs(a.y - b.y) / 2, Math.abs(a.x - b.x) / 2) || 0;
|
|
361
|
+
return [
|
|
362
|
+
`M ${a.x} ${a.y}`,
|
|
363
|
+
`L ${a.x} ${b.y - ySign * r}`,
|
|
364
|
+
`Q ${a.x} ${b.y} ${a.x + xSign * r} ${b.y}`,
|
|
365
|
+
`L ${b.x} ${b.y}`,
|
|
366
|
+
].join(' ');
|
|
367
|
+
}
|
|
368
|
+
function mulberry32(seed) {
|
|
369
|
+
let t = seed;
|
|
370
|
+
return () => {
|
|
371
|
+
t = (t + 0x6d2b79f5) | 0;
|
|
372
|
+
let r = t;
|
|
373
|
+
r = Math.imul(r ^ (r >>> 15), r | 1);
|
|
374
|
+
r ^= r + Math.imul(r ^ (r >>> 7), r | 61);
|
|
375
|
+
return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function withAlpha(color, alpha) {
|
|
379
|
+
if (/^#([0-9a-f]{3}){1,2}$/i.test(color)) {
|
|
380
|
+
let hex = color.slice(1);
|
|
381
|
+
if (hex.length === 3)
|
|
382
|
+
hex = hex.split('').map((c) => c + c).join('');
|
|
383
|
+
const a = Math.round(Math.max(0, Math.min(1, alpha)) * 255)
|
|
384
|
+
.toString(16)
|
|
385
|
+
.padStart(2, '0');
|
|
386
|
+
return `#${hex}${a}`;
|
|
387
|
+
}
|
|
388
|
+
return color;
|
|
389
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Theme } from '@principal-ade/industry-theme';
|
|
3
|
+
export interface TrailCityProgressProps {
|
|
4
|
+
theme?: Theme;
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Grid columns. Default 14. */
|
|
7
|
+
cols?: number;
|
|
8
|
+
/** Grid rows. Default 14. */
|
|
9
|
+
rows?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Fraction of the map that should be revealed, 0..1. This is the external
|
|
12
|
+
* control: drive it from a typewriter / step counter and the squares
|
|
13
|
+
* populate to match. The component tweens the newly revealed cells in.
|
|
14
|
+
*/
|
|
15
|
+
progress?: number;
|
|
16
|
+
/** Fraction of grid cells that are buildings vs. empty gaps. Default 0.82. */
|
|
17
|
+
density?: number;
|
|
18
|
+
/** Seed for the deterministic layout + reveal order. Default 7. */
|
|
19
|
+
seed?: number;
|
|
20
|
+
/** Per-cell fade-in duration, ms. Default 520. */
|
|
21
|
+
revealMs?: number;
|
|
22
|
+
/** Delay between consecutive cells appearing, ms. Default 70. */
|
|
23
|
+
staggerMs?: number;
|
|
24
|
+
/** Override the building accent color (else taken from theme.colors.primary). */
|
|
25
|
+
primary?: string;
|
|
26
|
+
/** Override the neutral building color (else taken from theme.colors.text). */
|
|
27
|
+
neutral?: string;
|
|
28
|
+
/** Accessible label for the SVG. */
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A top-down "city map" of square buildings that progressively populates as the
|
|
33
|
+
* `progress` prop climbs from 0 to 1. Layout and reveal order are seeded so the
|
|
34
|
+
* fill is deterministic across renders. Pure SVG, theme-aware.
|
|
35
|
+
*/
|
|
36
|
+
export declare function TrailCityProgress({ theme, className, cols, rows, progress, density, seed, revealMs, staggerMs, primary, neutral, ariaLabel, }: TrailCityProgressProps): React.JSX.Element;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.TrailCityProgress = TrailCityProgress;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const CELL = 50;
|
|
40
|
+
function mulberry32(seed) {
|
|
41
|
+
let t = seed;
|
|
42
|
+
return () => {
|
|
43
|
+
t = (t + 0x6d2b79f5) | 0;
|
|
44
|
+
let r = t;
|
|
45
|
+
r = Math.imul(r ^ (r >>> 15), r | 1);
|
|
46
|
+
r ^= r + Math.imul(r ^ (r >>> 7), r | 61);
|
|
47
|
+
return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function withAlpha(color, alpha) {
|
|
51
|
+
if (color.startsWith('#')) {
|
|
52
|
+
let hex = color.slice(1);
|
|
53
|
+
if (hex.length === 3)
|
|
54
|
+
hex = hex.split('').map((ch) => ch + ch).join('');
|
|
55
|
+
const n = parseInt(hex, 16);
|
|
56
|
+
const r = (n >> 16) & 255;
|
|
57
|
+
const g = (n >> 8) & 255;
|
|
58
|
+
const b = n & 255;
|
|
59
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
60
|
+
}
|
|
61
|
+
return color;
|
|
62
|
+
}
|
|
63
|
+
const clamp01 = (n) => (n < 0 ? 0 : n > 1 ? 1 : n);
|
|
64
|
+
function usePrefersReducedMotion() {
|
|
65
|
+
const [reduced, setReduced] = (0, react_1.useState)(false);
|
|
66
|
+
(0, react_1.useEffect)(() => {
|
|
67
|
+
if (typeof window === 'undefined' || !window.matchMedia)
|
|
68
|
+
return;
|
|
69
|
+
const mq = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
70
|
+
setReduced(mq.matches);
|
|
71
|
+
const handler = (e) => setReduced(e.matches);
|
|
72
|
+
mq.addEventListener('change', handler);
|
|
73
|
+
return () => mq.removeEventListener('change', handler);
|
|
74
|
+
}, []);
|
|
75
|
+
return reduced;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A top-down "city map" of square buildings that progressively populates as the
|
|
79
|
+
* `progress` prop climbs from 0 to 1. Layout and reveal order are seeded so the
|
|
80
|
+
* fill is deterministic across renders. Pure SVG, theme-aware.
|
|
81
|
+
*/
|
|
82
|
+
function TrailCityProgress({ theme, className, cols = 14, rows = 14, progress = 0, density = 0.82, seed = 7, revealMs = 520, staggerMs = 70, primary, neutral, ariaLabel = 'A city map filling in square by square', }) {
|
|
83
|
+
var _a, _b, _c, _d;
|
|
84
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
85
|
+
const accent = (_b = primary !== null && primary !== void 0 ? primary : (_a = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _a === void 0 ? void 0 : _a.primary) !== null && _b !== void 0 ? _b : '#22d3ee';
|
|
86
|
+
const text = (_d = neutral !== null && neutral !== void 0 ? neutral : (_c = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : '#f8fafc';
|
|
87
|
+
const { cells, total, viewW, viewH } = (0, react_1.useMemo)(() => {
|
|
88
|
+
const palette = [
|
|
89
|
+
withAlpha(accent, 0.55),
|
|
90
|
+
withAlpha(accent, 0.36),
|
|
91
|
+
withAlpha(text, 0.45),
|
|
92
|
+
withAlpha(text, 0.3),
|
|
93
|
+
withAlpha(text, 0.18),
|
|
94
|
+
];
|
|
95
|
+
const rng = mulberry32(seed);
|
|
96
|
+
const built = [];
|
|
97
|
+
for (let r = 0; r < rows; r++) {
|
|
98
|
+
for (let c = 0; c < cols; c++) {
|
|
99
|
+
const keepRoll = rng();
|
|
100
|
+
const colorRoll = rng();
|
|
101
|
+
const sizeRoll = rng();
|
|
102
|
+
if (keepRoll > density)
|
|
103
|
+
continue; // empty gap between buildings
|
|
104
|
+
const size = CELL - 8 - sizeRoll * 8; // 34..42px, slight jitter
|
|
105
|
+
built.push({
|
|
106
|
+
key: `${c}-${r}`,
|
|
107
|
+
x: c * CELL + (CELL - size) / 2,
|
|
108
|
+
y: r * CELL + (CELL - size) / 2,
|
|
109
|
+
size,
|
|
110
|
+
rx: 3,
|
|
111
|
+
fill: palette[Math.floor(colorRoll * palette.length)],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Deterministic reveal order: shuffle indices with a second seed.
|
|
116
|
+
const order = built.map((_, i) => i);
|
|
117
|
+
const sh = mulberry32(seed * 2 + 1);
|
|
118
|
+
for (let i = order.length - 1; i > 0; i--) {
|
|
119
|
+
const j = Math.floor(sh() * (i + 1));
|
|
120
|
+
[order[i], order[j]] = [order[j], order[i]];
|
|
121
|
+
}
|
|
122
|
+
const rank = new Array(built.length);
|
|
123
|
+
order.forEach((cellIdx, position) => {
|
|
124
|
+
rank[cellIdx] = position;
|
|
125
|
+
});
|
|
126
|
+
const withRank = built.map((b, i) => (Object.assign(Object.assign({}, b), { rank: rank[i] })));
|
|
127
|
+
return {
|
|
128
|
+
cells: withRank,
|
|
129
|
+
total: withRank.length,
|
|
130
|
+
viewW: cols * CELL,
|
|
131
|
+
viewH: rows * CELL,
|
|
132
|
+
};
|
|
133
|
+
}, [accent, text, cols, rows, density, seed]);
|
|
134
|
+
const target = Math.round(clamp01(progress) * total);
|
|
135
|
+
// `shown` tweens toward `target`, one cell every staggerMs, so newly
|
|
136
|
+
// revealed cells fade in one after another instead of all at once.
|
|
137
|
+
const [shown, setShown] = (0, react_1.useState)(reducedMotion ? target : 0);
|
|
138
|
+
(0, react_1.useEffect)(() => {
|
|
139
|
+
if (reducedMotion) {
|
|
140
|
+
setShown(target);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (shown === target)
|
|
144
|
+
return;
|
|
145
|
+
const dir = shown < target ? 1 : -1;
|
|
146
|
+
const id = setTimeout(() => setShown((s) => s + dir), staggerMs);
|
|
147
|
+
return () => clearTimeout(id);
|
|
148
|
+
}, [shown, target, staggerMs, reducedMotion]);
|
|
149
|
+
return (react_1.default.createElement("svg", { className: className, viewBox: `0 0 ${viewW} ${viewH}`, width: "100%", height: "100%", role: "img", "aria-label": ariaLabel, style: { display: 'block', overflow: 'visible' } }, cells.map((cell) => {
|
|
150
|
+
const visible = cell.rank < shown;
|
|
151
|
+
return (react_1.default.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.size, height: cell.size, rx: cell.rx, ry: cell.rx, fill: cell.fill, style: {
|
|
152
|
+
opacity: visible ? 1 : 0,
|
|
153
|
+
transition: reducedMotion ? 'none' : `opacity ${revealMs}ms ease`,
|
|
154
|
+
} }));
|
|
155
|
+
})));
|
|
156
|
+
}
|