@principal-ai/logo-component 0.1.16 → 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 +148 -0
- package/dist/FileCityLogo.js +459 -0
- package/dist/FileCityLogoAnimated.d.ts +41 -0
- package/dist/FileCityLogoAnimated.js +230 -0
- package/dist/esm/FileCityLogo.js +419 -0
- package/dist/esm/FileCityLogoAnimated.js +193 -0
- package/dist/esm/index.js +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.js +8 -5
- package/package.json +2 -2
- 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
|
@@ -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;
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import React, { useId } from 'react';
|
|
2
|
+
const VIEW = 100;
|
|
3
|
+
// Corner radius for the rounded panel, as a fraction of the panel side.
|
|
4
|
+
// macOS app icons use a ~22.4% continuous-corner ("squircle") radius; the
|
|
5
|
+
// Electron app supplies the transparent safe-area padding, so the panel
|
|
6
|
+
// fills the whole viewBox and just needs the right corner curvature to
|
|
7
|
+
// read as a native dock icon. A plain SVG rx is a close approximation.
|
|
8
|
+
const PANEL_RADIUS = VIEW * 0.2237;
|
|
9
|
+
// Width of the edge hairline (in viewBox units) that keeps the icon
|
|
10
|
+
// defined against the dock background.
|
|
11
|
+
const HAIRLINE = 0.75;
|
|
12
|
+
// 5-row pixel glyphs — the primary-colored files trace these.
|
|
13
|
+
// `1` = a mark (primary) file
|
|
14
|
+
// `H` = the letter's counter — a forced hole (background shows through,
|
|
15
|
+
// no city file) so the loop reads as a real hole
|
|
16
|
+
// `0` = a city file (muted backdrop)
|
|
17
|
+
const GLYPHS = {
|
|
18
|
+
// Closed bowl with a single hole punched in its center.
|
|
19
|
+
P: ['111', '1H1', '111', '100', '100'],
|
|
20
|
+
A: ['0110', '1HH1', '1111', '1001', '1001'],
|
|
21
|
+
I: ['111', '010', '010', '010', '111'],
|
|
22
|
+
};
|
|
23
|
+
const MARK_LETTERS = {
|
|
24
|
+
P: ['P'],
|
|
25
|
+
AI: ['A', 'I'],
|
|
26
|
+
PAI: ['P', 'A', 'I'],
|
|
27
|
+
};
|
|
28
|
+
/** Compose letters side by side (1 city column between them) into a
|
|
29
|
+
* single kind map: 1 = mark, 2 = void/hole, 0 = city. */
|
|
30
|
+
function composeMark(letters, gap = 1) {
|
|
31
|
+
const rows = 5;
|
|
32
|
+
const out = Array.from({ length: rows }, () => []);
|
|
33
|
+
letters.forEach((key, li) => {
|
|
34
|
+
if (li > 0)
|
|
35
|
+
for (let r = 0; r < rows; r++)
|
|
36
|
+
out[r].push(...new Array(gap).fill(0));
|
|
37
|
+
const glyph = GLYPHS[key];
|
|
38
|
+
for (let r = 0; r < rows; r++) {
|
|
39
|
+
for (const ch of glyph[r])
|
|
40
|
+
out[r].push(ch === '1' ? 1 : ch === 'H' ? 2 : 0);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
function mulberry32(seed) {
|
|
46
|
+
let t = seed;
|
|
47
|
+
return () => {
|
|
48
|
+
t = (t + 0x6d2b79f5) | 0;
|
|
49
|
+
let r = t;
|
|
50
|
+
r = Math.imul(r ^ (r >>> 15), r | 1);
|
|
51
|
+
r ^= r + Math.imul(r ^ (r >>> 7), r | 61);
|
|
52
|
+
return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function withAlpha(color, alpha) {
|
|
56
|
+
// Accept #rgb / #rrggbb — leave non-hex as-is and rely on the caller.
|
|
57
|
+
if (/^#([0-9a-f]{3}){1,2}$/i.test(color)) {
|
|
58
|
+
let hex = color.slice(1);
|
|
59
|
+
if (hex.length === 3)
|
|
60
|
+
hex = hex.split('').map(c => c + c).join('');
|
|
61
|
+
const a = Math.round(Math.max(0, Math.min(1, alpha)) * 255)
|
|
62
|
+
.toString(16)
|
|
63
|
+
.padStart(2, '0');
|
|
64
|
+
return `#${hex}${a}`;
|
|
65
|
+
}
|
|
66
|
+
return color;
|
|
67
|
+
}
|
|
68
|
+
function toRgb(color) {
|
|
69
|
+
if (!/^#([0-9a-f]{3}){1,2}$/i.test(color))
|
|
70
|
+
return null;
|
|
71
|
+
let hex = color.slice(1);
|
|
72
|
+
if (hex.length === 3)
|
|
73
|
+
hex = hex.split('').map(c => c + c).join('');
|
|
74
|
+
return [
|
|
75
|
+
parseInt(hex.slice(0, 2), 16),
|
|
76
|
+
parseInt(hex.slice(2, 4), 16),
|
|
77
|
+
parseInt(hex.slice(4, 6), 16),
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
/** Blend two colors. `t` = 0 returns `a`, `t` = 1 returns `b`. Falls
|
|
81
|
+
* back to `a` when either side isn't a parseable hex. */
|
|
82
|
+
function mix(a, b, t) {
|
|
83
|
+
const ca = toRgb(a);
|
|
84
|
+
const cb = toRgb(b);
|
|
85
|
+
if (!ca || !cb)
|
|
86
|
+
return a;
|
|
87
|
+
const ch = (i) => Math.round(ca[i] + (cb[i] - ca[i]) * Math.max(0, Math.min(1, t)))
|
|
88
|
+
.toString(16)
|
|
89
|
+
.padStart(2, '0');
|
|
90
|
+
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Compute the full layout (cells + overlays + palette) for a file-city
|
|
94
|
+
* mark from the public props. Pure — no hooks — so both the static and
|
|
95
|
+
* animated components can build their SVG from the identical cell list.
|
|
96
|
+
*/
|
|
97
|
+
export 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, }) {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
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';
|
|
100
|
+
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;
|
|
101
|
+
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';
|
|
102
|
+
const bgColor = (_d = background !== null && background !== void 0 ? background : theme === null || theme === void 0 ? void 0 : theme.colors.background) !== null && _d !== void 0 ? _d : '#0a0f14';
|
|
103
|
+
// Same palette weighting as TrailCityDiagram so the two read as a set.
|
|
104
|
+
const palette = [
|
|
105
|
+
withAlpha(primaryColor, 0.18),
|
|
106
|
+
withAlpha(primaryColor, 0.32),
|
|
107
|
+
withAlpha(baseColor, 0.08),
|
|
108
|
+
withAlpha(baseColor, 0.14),
|
|
109
|
+
withAlpha(baseColor, 0.22),
|
|
110
|
+
];
|
|
111
|
+
// The mark files vary in shade so the letter doesn't read as one flat
|
|
112
|
+
// block, but every shade stays vivid so it still stands out from the
|
|
113
|
+
// muted city behind it.
|
|
114
|
+
const markPalette = [
|
|
115
|
+
primaryColor,
|
|
116
|
+
mix(primaryColor, '#ffffff', 0.22),
|
|
117
|
+
mix(primaryColor, '#ffffff', 0.1),
|
|
118
|
+
withAlpha(primaryColor, 0.82),
|
|
119
|
+
];
|
|
120
|
+
// Same idea for `accent` cells (e.g. the AI in the lockup), so they
|
|
121
|
+
// read in the accent color while the P stays primary.
|
|
122
|
+
const accentPalette = [
|
|
123
|
+
accentColor,
|
|
124
|
+
mix(accentColor, '#ffffff', 0.22),
|
|
125
|
+
mix(accentColor, '#ffffff', 0.1),
|
|
126
|
+
withAlpha(accentColor, 0.82),
|
|
127
|
+
];
|
|
128
|
+
// Dimmed accent — used for the A in the lockup so it sits back from the
|
|
129
|
+
// brighter I.
|
|
130
|
+
const accentDimPalette = [
|
|
131
|
+
withAlpha(accentColor, 0.5),
|
|
132
|
+
withAlpha(accentColor, 0.62),
|
|
133
|
+
withAlpha(accentColor, 0.42),
|
|
134
|
+
withAlpha(accentColor, 0.55),
|
|
135
|
+
];
|
|
136
|
+
// Build a square grid. For `mark="none"` it's a plain `cells × cells`
|
|
137
|
+
// city; otherwise the glyph bitmap sits inside a square grid (side =
|
|
138
|
+
// longest glyph dimension + a margin ring) so the city reads square.
|
|
139
|
+
const trailEnabled = trail && (mark === 'P' || mark === 'PAI');
|
|
140
|
+
const aiCardOn = aiCard && mark === 'P';
|
|
141
|
+
let side;
|
|
142
|
+
let offX = 0;
|
|
143
|
+
let offY = 0;
|
|
144
|
+
let kindAt;
|
|
145
|
+
if (mark === 'none') {
|
|
146
|
+
side = cells;
|
|
147
|
+
const hi = Math.floor((cells - 1) / 2);
|
|
148
|
+
kindAt = (c, r) => (highlight && c === hi && r === hi ? 'mark' : 'city');
|
|
149
|
+
}
|
|
150
|
+
else if (mark === 'lockup') {
|
|
151
|
+
// Brand lockup: P on the left (cols 0-2, vertically centered), a gap
|
|
152
|
+
// column, then a stacked "AI" filling the right 3 columns — A in the
|
|
153
|
+
// top 4 rows, I in the bottom 3.
|
|
154
|
+
side = 7;
|
|
155
|
+
const pGlyph = GLYPHS.P; // 3 × 5
|
|
156
|
+
const aGlyph = ['111', '1H1', '111', '101']; // 3 × 4
|
|
157
|
+
const iGlyph = ['111', '010', '111']; // 3 × 3
|
|
158
|
+
const at = (g, gc, gr) => {
|
|
159
|
+
if (gr < 0 || gr >= g.length)
|
|
160
|
+
return null;
|
|
161
|
+
const row = g[gr];
|
|
162
|
+
return gc < 0 || gc >= row.length ? null : row[gc];
|
|
163
|
+
};
|
|
164
|
+
kindAt = (c, r) => {
|
|
165
|
+
// P is primary; the stacked AI is accent.
|
|
166
|
+
const pch = at(pGlyph, c, r - 1); // P: cols 0-2, rows 1-5
|
|
167
|
+
if (pch != null) {
|
|
168
|
+
return pch === '1' ? 'mark' : pch === 'H' ? 'void' : 'city';
|
|
169
|
+
}
|
|
170
|
+
const ach = at(aGlyph, c - 4, r); // A: cols 4-6, rows 0-3 (dimmer)
|
|
171
|
+
if (ach != null) {
|
|
172
|
+
return ach === '1' ? 'accentDim' : ach === 'H' ? 'void' : 'city';
|
|
173
|
+
}
|
|
174
|
+
const ich = at(iGlyph, c - 4, r - 4); // I: cols 4-6, rows 4-6 (brighter)
|
|
175
|
+
if (ich != null) {
|
|
176
|
+
return ich === '1' ? 'accent' : ich === 'H' ? 'void' : 'city';
|
|
177
|
+
}
|
|
178
|
+
return 'city';
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const bitmap = composeMark(MARK_LETTERS[mark]);
|
|
183
|
+
const bw = bitmap[0].length;
|
|
184
|
+
const bh = bitmap.length;
|
|
185
|
+
side = Math.max(bw, bh) + margin * 2;
|
|
186
|
+
// With a trail, shove the letter to the left so the trail has room
|
|
187
|
+
// on the right; otherwise center it in the square.
|
|
188
|
+
offX = trailEnabled ? margin : Math.floor((side - bw) / 2);
|
|
189
|
+
// Nudge the P one column left so the AI card has room on the right.
|
|
190
|
+
if (aiCardOn)
|
|
191
|
+
offX = Math.max(0, offX - 1);
|
|
192
|
+
offY = Math.floor((side - bh) / 2);
|
|
193
|
+
kindAt = (c, r) => {
|
|
194
|
+
const bc = c - offX;
|
|
195
|
+
const br = r - offY;
|
|
196
|
+
if (br < 0 || br >= bh || bc < 0 || bc >= bw)
|
|
197
|
+
return 'city';
|
|
198
|
+
const v = bitmap[br][bc];
|
|
199
|
+
return v === 1 ? 'mark' : v === 2 ? 'void' : 'city';
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const cols = side;
|
|
203
|
+
const rows = side;
|
|
204
|
+
// The AI card occupies the bottom-right 4×3 block of cells. Those cells
|
|
205
|
+
// render no building — the card covers them.
|
|
206
|
+
const AI_CARD_COLS = 3;
|
|
207
|
+
const AI_CARD_ROWS = 2;
|
|
208
|
+
// Inset one cell up and left from the bottom-right corner.
|
|
209
|
+
const aiCardC0 = cols - AI_CARD_COLS - 1;
|
|
210
|
+
const aiCardR0 = rows - AI_CARD_ROWS - 1;
|
|
211
|
+
// Nudge the card down half a cell so it straddles the row line — its
|
|
212
|
+
// body sits over the bottom of the top row and the top of the bottom
|
|
213
|
+
// row. The city renders behind it, so squares show around its edges.
|
|
214
|
+
const AI_CARD_ROW_SHIFT = 0.5;
|
|
215
|
+
const AI_CARD_COL_SHIFT = 0.5;
|
|
216
|
+
// Trail to the right of the letter — starts in the top-right corner,
|
|
217
|
+
// crosses 2 cells diagonally to its first node, zigzags down, and ends
|
|
218
|
+
// in the bottom-right corner. The dots sit on city files, which are
|
|
219
|
+
// forced to render under them.
|
|
220
|
+
const trailGrid = trailEnabled
|
|
221
|
+
? [
|
|
222
|
+
[cols - 1, 0], // start: top-right corner
|
|
223
|
+
[cols - 3, 2], // first segment crosses 2 diagonally
|
|
224
|
+
[cols - 2, 4],
|
|
225
|
+
[cols - 1, rows - 1], // end: bottom-right corner
|
|
226
|
+
]
|
|
227
|
+
: [];
|
|
228
|
+
const trailKeys = new Set(trailGrid.map(([c, r]) => `${c}-${r}`));
|
|
229
|
+
const centerOf = (c, r) => ({
|
|
230
|
+
x: startX + c * cell + cell / 2,
|
|
231
|
+
y: startY + r * cell + cell / 2,
|
|
232
|
+
});
|
|
233
|
+
// True when an edge neighbor is a letter file (mark or accent) — those
|
|
234
|
+
// city cells must always render so no empty square shares a side with
|
|
235
|
+
// the letter (and breaks a stroke). Diagonal corners are allowed to go
|
|
236
|
+
// empty, so the margins around the letter still get some missing squares.
|
|
237
|
+
const isLetterKind = (k) => k === 'mark' || k === 'accent' || k === 'accentDim';
|
|
238
|
+
const touchesMark = (c, r) => isLetterKind(kindAt(c - 1, r)) ||
|
|
239
|
+
isLetterKind(kindAt(c + 1, r)) ||
|
|
240
|
+
isLetterKind(kindAt(c, r - 1)) ||
|
|
241
|
+
isLetterKind(kindAt(c, r + 1));
|
|
242
|
+
// Per-file shade for a letter cell. `scatter` keeps the random-shade
|
|
243
|
+
// texture; the directional modes interpolate the letter's base color
|
|
244
|
+
// dark→light across the grid.
|
|
245
|
+
const baseFor = (kind) => kind === 'accent'
|
|
246
|
+
? accentColor
|
|
247
|
+
: kind === 'accentDim'
|
|
248
|
+
? mix(accentColor, bgColor, 0.45)
|
|
249
|
+
: primaryColor;
|
|
250
|
+
const gradientShade = (base, c, r) => {
|
|
251
|
+
const fx = cols > 1 ? c / (cols - 1) : 0;
|
|
252
|
+
const fy = rows > 1 ? r / (rows - 1) : 0;
|
|
253
|
+
const t = gradient === 'vertical'
|
|
254
|
+
? fy
|
|
255
|
+
: gradient === 'horizontal'
|
|
256
|
+
? fx
|
|
257
|
+
: (fx + fy) / 2; // diagonal
|
|
258
|
+
const lo = mix(base, '#000000', 0.12);
|
|
259
|
+
const hi = mix(base, '#ffffff', 0.4);
|
|
260
|
+
return mix(lo, hi, t);
|
|
261
|
+
};
|
|
262
|
+
// Square files centered in the panel; letterboxed when the mark is
|
|
263
|
+
// wider than it is tall (AI / PAI).
|
|
264
|
+
const pad = 12;
|
|
265
|
+
const avail = VIEW - pad * 2;
|
|
266
|
+
const cell = Math.min(avail / cols, avail / rows);
|
|
267
|
+
const sq = cell * 0.74; // smaller than the cell → gaps between buildings
|
|
268
|
+
const inset = (cell - sq) / 2;
|
|
269
|
+
const startX = (VIEW - cell * cols) / 2;
|
|
270
|
+
const startY = (VIEW - cell * rows) / 2;
|
|
271
|
+
const rng = mulberry32(7);
|
|
272
|
+
const cellsOut = [];
|
|
273
|
+
const extras = [];
|
|
274
|
+
// Track the previous cell to the left (per row) and above (per column)
|
|
275
|
+
// so we never leave two empty squares back to back in either
|
|
276
|
+
// direction — that's what produced the long blank runs.
|
|
277
|
+
const colEmpty = new Array(cols).fill(false);
|
|
278
|
+
for (let r = 0; r < rows; r++) {
|
|
279
|
+
let lastEmpty = false;
|
|
280
|
+
for (let c = 0; c < cols; c++) {
|
|
281
|
+
const kind = kindAt(c, r);
|
|
282
|
+
const skipRoll = rng();
|
|
283
|
+
const colorRoll = rng();
|
|
284
|
+
// Void cells are the letter's counter — leave them empty so the
|
|
285
|
+
// background shows through as a real hole. Mark files always
|
|
286
|
+
// render; city files skip occasionally so the primary letters read
|
|
287
|
+
// against a sparser, muted backdrop — but only when the square to
|
|
288
|
+
// the left and the square above are both filled, so gaps stay
|
|
289
|
+
// isolated.
|
|
290
|
+
if (kind === 'void') {
|
|
291
|
+
lastEmpty = true;
|
|
292
|
+
colEmpty[c] = true;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (kind === 'city' && !lastEmpty && !colEmpty[c] && !touchesMark(c, r) && !trailKeys.has(`${c}-${r}`) && skipRoll < 0.2) {
|
|
296
|
+
lastEmpty = true;
|
|
297
|
+
colEmpty[c] = true;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
lastEmpty = false;
|
|
301
|
+
colEmpty[c] = false;
|
|
302
|
+
const isLetter = isLetterKind(kind);
|
|
303
|
+
const letterPalette = kind === 'accent'
|
|
304
|
+
? accentPalette
|
|
305
|
+
: kind === 'accentDim'
|
|
306
|
+
? accentDimPalette
|
|
307
|
+
: markPalette;
|
|
308
|
+
const letterColor = kind === 'accent' || kind === 'accentDim' ? accentColor : primaryColor;
|
|
309
|
+
const letterFill = gradient === 'scatter'
|
|
310
|
+
? letterPalette[Math.floor(colorRoll * letterPalette.length)]
|
|
311
|
+
: gradientShade(baseFor(kind), c, r);
|
|
312
|
+
const x = startX + c * cell + inset;
|
|
313
|
+
const y = startY + r * cell + inset;
|
|
314
|
+
cellsOut.push({
|
|
315
|
+
key: `${c}-${r}`,
|
|
316
|
+
c,
|
|
317
|
+
r,
|
|
318
|
+
x,
|
|
319
|
+
y,
|
|
320
|
+
sq,
|
|
321
|
+
rx: Math.max(1, sq * 0.12),
|
|
322
|
+
fill: isLetter
|
|
323
|
+
? letterFill
|
|
324
|
+
: palette[Math.floor(colorRoll * palette.length)],
|
|
325
|
+
stroke: isLetter ? withAlpha(letterColor, 0.55) : withAlpha(baseColor, 0.08),
|
|
326
|
+
strokeWidth: isLetter ? 0.6 : 0.4,
|
|
327
|
+
isLetter,
|
|
328
|
+
// Letter files weigh the most so they build up over several
|
|
329
|
+
// samples; city files weigh less and resolve in one or two hits.
|
|
330
|
+
weight: isLetter ? 1 : 0.4,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// AI card — a small file card (filename header band + "AI" contents)
|
|
335
|
+
// dropped into the bottom-right block, mirroring TrailCityDiagram's
|
|
336
|
+
// snippet card.
|
|
337
|
+
if (aiCardOn) {
|
|
338
|
+
const cx0 = startX + (aiCardC0 + AI_CARD_COL_SHIFT) * cell + inset;
|
|
339
|
+
const cy0 = startY + (aiCardR0 + AI_CARD_ROW_SHIFT) * cell + inset;
|
|
340
|
+
const cw = AI_CARD_COLS * cell - inset * 2;
|
|
341
|
+
const chh = AI_CARD_ROWS * cell - inset * 2;
|
|
342
|
+
const headerH = chh * 0.28;
|
|
343
|
+
const cardR = Math.max(2, cell * 0.2);
|
|
344
|
+
const barH = Math.max(1, headerH * 0.26);
|
|
345
|
+
const fs = Math.min(cw * 0.42, (chh - headerH) * 0.64);
|
|
346
|
+
// Leader — anchored at the center of the P's bottom square. Routed
|
|
347
|
+
// with right-angle segments: down, right, up, then right into the
|
|
348
|
+
// card's left edge, "opening" the block. Dot at each end.
|
|
349
|
+
const aX = startX + (offX + 0.5) * cell; // center of the stem column
|
|
350
|
+
const aY = startY + (offY + 4.5) * cell; // middle of the bottom square
|
|
351
|
+
const bX = cx0; // left edge of the card
|
|
352
|
+
const bY = cy0 + chh * 0.2; // near the top of that edge
|
|
353
|
+
// Route along grid centerlines so the runs thread through square
|
|
354
|
+
// centers: dip to the row below the P, climb at the column just left
|
|
355
|
+
// of the card.
|
|
356
|
+
const valleyY = startY + (offY + 5.5) * cell; // center of the next row down
|
|
357
|
+
const turnX = startX + 2.5 * cell; // center of the 3rd column
|
|
358
|
+
const dot = Math.max(1, cell * 0.12);
|
|
359
|
+
const leaderPath = `M ${aX} ${aY} L ${aX} ${valleyY} L ${turnX} ${valleyY} L ${turnX} ${bY} L ${bX} ${bY}`;
|
|
360
|
+
extras.push(React.createElement("g", { key: "ai-leader", opacity: 0.75 },
|
|
361
|
+
React.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}` }),
|
|
362
|
+
React.createElement("circle", { cx: aX, cy: aY, r: dot, fill: accentColor }),
|
|
363
|
+
React.createElement("circle", { cx: bX, cy: bY, r: dot, fill: accentColor })));
|
|
364
|
+
extras.push(React.createElement("g", { key: "ai-card" },
|
|
365
|
+
React.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 }),
|
|
366
|
+
React.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) }),
|
|
367
|
+
React.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) }),
|
|
368
|
+
React.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")));
|
|
369
|
+
}
|
|
370
|
+
// Trail overlay — a dashed accent path to the right of the letter with
|
|
371
|
+
// a marker dot on each node.
|
|
372
|
+
if (trailEnabled && trailGrid.length > 1) {
|
|
373
|
+
const linePts = trailGrid.map(([c, r]) => centerOf(c, r));
|
|
374
|
+
const d = linePts.map((p, i) => `${i ? 'L' : 'M'} ${p.x} ${p.y}`).join(' ');
|
|
375
|
+
const dot = Math.max(1.5, sq * 0.3);
|
|
376
|
+
extras.push(React.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 }));
|
|
377
|
+
trailGrid.forEach(([c, r], i) => {
|
|
378
|
+
const p = centerOf(c, r);
|
|
379
|
+
extras.push(React.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 }));
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return { cells: cellsOut, extras, bgColor, baseColor, rounded, opacity, mark };
|
|
383
|
+
}
|
|
384
|
+
/** Accessible label for a given mark, shared by both components. */
|
|
385
|
+
export function fileCityLabel(mark) {
|
|
386
|
+
return mark === 'none'
|
|
387
|
+
? 'A top-down grid of file squares'
|
|
388
|
+
: `A top-down grid of file squares spelling ${mark}`;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* SVG panel chrome shared by the static and animated components: the
|
|
392
|
+
* rounded background panel (clipping its children) and the edge hairline.
|
|
393
|
+
* `children` are the grid + overlays drawn inside the clip.
|
|
394
|
+
*/
|
|
395
|
+
export const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, children }) => {
|
|
396
|
+
const uid = useId().replace(/:/g, '');
|
|
397
|
+
return (React.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 },
|
|
398
|
+
React.createElement("defs", null,
|
|
399
|
+
React.createElement("clipPath", { id: `panel-${uid}` },
|
|
400
|
+
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ? PANEL_RADIUS : 0 }))),
|
|
401
|
+
React.createElement("g", { clipPath: `url(#panel-${uid})` },
|
|
402
|
+
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ? PANEL_RADIUS : 0 }),
|
|
403
|
+
children),
|
|
404
|
+
React.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 })));
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* A compact, iconic "file city" mark — the same top-down grid of file
|
|
408
|
+
* squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
|
|
409
|
+
* of smaller buildings, no trail / markers / snippet. The primary-colored
|
|
410
|
+
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
411
|
+
* from the muted city.
|
|
412
|
+
*/
|
|
413
|
+
export const FileCityLogo = (props) => {
|
|
414
|
+
const { width = 150, height = 150 } = props;
|
|
415
|
+
const { cells, extras, bgColor, baseColor, rounded, opacity, mark } = computeFileCityLayout(props);
|
|
416
|
+
return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, label: fileCityLabel(mark) },
|
|
417
|
+
cells.map((cell) => (React.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 }))),
|
|
418
|
+
extras));
|
|
419
|
+
};
|