@principal-ai/logo-component 0.1.17 → 0.1.19
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 +116 -2
- package/dist/FileCityLogo.js +162 -27
- package/dist/FileCityLogoAnimated.d.ts +41 -0
- package/dist/FileCityLogoAnimated.js +232 -0
- package/dist/TrailCityDiagram.js +6 -6
- package/dist/esm/FileCityLogo.js +158 -26
- package/dist/esm/FileCityLogoAnimated.js +195 -0
- package/dist/esm/TrailCityDiagram.js +6 -6
- package/dist/esm/index.js +2 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +2 -3
- package/dist/index.js +6 -5
- package/package.json +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,232 @@
|
|
|
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, gloss } = (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
|
+
props.gloss,
|
|
83
|
+
props.squareRadius,
|
|
84
|
+
]);
|
|
85
|
+
// Per-cell number of samples to fully reveal it (>=1; letter cells take
|
|
86
|
+
// `buildSteps`, city cells proportionally fewer by their weight).
|
|
87
|
+
const stepsFor = (0, react_1.useMemo)(() => cells.map((cell) => Math.max(1, Math.round(cell.weight * buildSteps))), [cells, buildSteps]);
|
|
88
|
+
// The pool of pending samples: each cell index repeated `steps` times,
|
|
89
|
+
// shuffled deterministically so the batches scatter across the grid,
|
|
90
|
+
// then sliced into groups of `batchMin`..`batchMax`.
|
|
91
|
+
const groups = (0, react_1.useMemo)(() => {
|
|
92
|
+
const p = [];
|
|
93
|
+
stepsFor.forEach((n, i) => {
|
|
94
|
+
for (let k = 0; k < n; k++)
|
|
95
|
+
p.push(i);
|
|
96
|
+
});
|
|
97
|
+
const shuffle = mulberry32(0x5eed + cells.length);
|
|
98
|
+
for (let i = p.length - 1; i > 0; i--) {
|
|
99
|
+
const j = Math.floor(shuffle() * (i + 1));
|
|
100
|
+
[p[i], p[j]] = [p[j], p[i]];
|
|
101
|
+
}
|
|
102
|
+
const sizeRand = mulberry32(0xb47c4 + cells.length);
|
|
103
|
+
const g = [];
|
|
104
|
+
let i = 0;
|
|
105
|
+
while (i < p.length) {
|
|
106
|
+
const size = batchMin + Math.floor(sizeRand() * (batchMax - batchMin + 1));
|
|
107
|
+
g.push(p.slice(i, i + size));
|
|
108
|
+
i += size;
|
|
109
|
+
}
|
|
110
|
+
return g;
|
|
111
|
+
}, [stepsFor, cells.length, batchMin, batchMax]);
|
|
112
|
+
// `progress[i]` = samples applied to cell i. Once every group has been
|
|
113
|
+
// walked the animation is done and the logo holds.
|
|
114
|
+
const [progress, setProgress] = (0, react_1.useState)(() => cells.map(() => 0));
|
|
115
|
+
const [done, setDone] = (0, react_1.useState)(false);
|
|
116
|
+
// The connector for the active group: which group it traces, and whether
|
|
117
|
+
// it's drawing on (during the reveal) or fading out (during the pause).
|
|
118
|
+
const [conn, setConn] = (0, react_1.useState)(null);
|
|
119
|
+
const groupRef = (0, react_1.useRef)(0);
|
|
120
|
+
const memberRef = (0, react_1.useRef)(0);
|
|
121
|
+
const onCompleteRef = (0, react_1.useRef)(onComplete);
|
|
122
|
+
onCompleteRef.current = onComplete;
|
|
123
|
+
// Drive the accumulation. Re-runs whenever the layout, timing, or the
|
|
124
|
+
// explicit `playKey` changes — that's our "replay."
|
|
125
|
+
(0, react_1.useEffect)(() => {
|
|
126
|
+
var _a;
|
|
127
|
+
// Respect reduced-motion: jump straight to the resolved logo.
|
|
128
|
+
const reduce = typeof window !== 'undefined' &&
|
|
129
|
+
window.matchMedia &&
|
|
130
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
131
|
+
groupRef.current = 0;
|
|
132
|
+
memberRef.current = 0;
|
|
133
|
+
setProgress(cells.map(() => 0));
|
|
134
|
+
setConn(null);
|
|
135
|
+
setDone(false);
|
|
136
|
+
if (!autoPlay || cells.length === 0 || reduce) {
|
|
137
|
+
setProgress(stepsFor.slice());
|
|
138
|
+
setDone(true);
|
|
139
|
+
(_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
let timer;
|
|
143
|
+
// Reveal one cell per step. Within a group the steps are `cellMs`
|
|
144
|
+
// apart; finishing a group schedules the next one after `pauseMs`.
|
|
145
|
+
const step = () => {
|
|
146
|
+
var _a;
|
|
147
|
+
const gi = groupRef.current;
|
|
148
|
+
if (gi >= groups.length) {
|
|
149
|
+
setDone(true);
|
|
150
|
+
(_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const group = groups[gi];
|
|
154
|
+
const mi = memberRef.current;
|
|
155
|
+
const idx = group[mi];
|
|
156
|
+
setProgress((prev) => {
|
|
157
|
+
const next = prev.slice();
|
|
158
|
+
next[idx] = Math.min(stepsFor[idx], next[idx] + 1);
|
|
159
|
+
return next;
|
|
160
|
+
});
|
|
161
|
+
const lastInGroup = mi + 1 >= group.length;
|
|
162
|
+
// Start the connector drawing on when the group begins; once it's
|
|
163
|
+
// complete, flip to fading so it dissolves through the pause.
|
|
164
|
+
if (mi === 0)
|
|
165
|
+
setConn({ group: gi, fading: false });
|
|
166
|
+
if (lastInGroup)
|
|
167
|
+
setConn({ group: gi, fading: true });
|
|
168
|
+
if (lastInGroup) {
|
|
169
|
+
groupRef.current = gi + 1;
|
|
170
|
+
memberRef.current = 0;
|
|
171
|
+
timer = setTimeout(step, pauseMs);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
memberRef.current = mi + 1;
|
|
175
|
+
timer = setTimeout(step, cellMs);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
timer = setTimeout(step, cellMs);
|
|
179
|
+
return () => clearTimeout(timer);
|
|
180
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
181
|
+
}, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey]);
|
|
182
|
+
// Easing for the per-cell fill-in so each sample lands softly.
|
|
183
|
+
const ease = (t) => 1 - Math.pow(1 - t, 2);
|
|
184
|
+
// Connector geometry — the full path through the active group's cell
|
|
185
|
+
// centers (drawn on with stroke-dashoffset, so we render every point up
|
|
186
|
+
// front and animate the reveal).
|
|
187
|
+
const sq = cells.length ? cells[0].sq : 1;
|
|
188
|
+
const centerOf = (idx) => ({
|
|
189
|
+
x: cells[idx].x + cells[idx].sq / 2,
|
|
190
|
+
y: cells[idx].y + cells[idx].sq / 2,
|
|
191
|
+
});
|
|
192
|
+
const connGroup = conn ? groups[conn.group] : null;
|
|
193
|
+
const connectorPath = connGroup && connGroup.length > 1
|
|
194
|
+
? connGroup
|
|
195
|
+
.map((idx, i) => {
|
|
196
|
+
const p = centerOf(idx);
|
|
197
|
+
return `${i ? 'L' : 'M'} ${p.x} ${p.y}`;
|
|
198
|
+
})
|
|
199
|
+
.join(' ')
|
|
200
|
+
: null;
|
|
201
|
+
// Draw the trail on across the group's reveal (so the line reaches each
|
|
202
|
+
// cell about as it lights up); fade should finish inside the pause.
|
|
203
|
+
const drawMs = connGroup ? Math.max(cellMs, (connGroup.length - 1) * cellMs) : 0;
|
|
204
|
+
const fadeMs = Math.max(120, Math.min(pauseMs - 60, 360));
|
|
205
|
+
return (react_1.default.createElement(FileCityLogo_1.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, label: (0, FileCityLogo_1.fileCityLabel)(mark) },
|
|
206
|
+
cells.map((cell, i) => {
|
|
207
|
+
const reveal = done ? 1 : ease(progress[i] / stepsFor[i]);
|
|
208
|
+
if (reveal <= 0)
|
|
209
|
+
return null;
|
|
210
|
+
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 }));
|
|
211
|
+
}),
|
|
212
|
+
connectors && connectorPath && conn && !done ? (
|
|
213
|
+
// The trail is a dashed (dotted) path, revealed progressively by a
|
|
214
|
+
// mask: a solid line draws itself on (stroke-dashoffset 1 → 0 with
|
|
215
|
+
// pathLength normalized to 1), uncovering the dots block by block as
|
|
216
|
+
// the trail extends.
|
|
217
|
+
(() => {
|
|
218
|
+
const maskId = `conn-mask-${uid}-${conn.group}`;
|
|
219
|
+
const w = Math.max(0.6, sq * 0.12);
|
|
220
|
+
return (react_1.default.createElement("g", { key: `conn-${conn.group}` },
|
|
221
|
+
react_1.default.createElement("style", null, `@keyframes ${CONN_DRAW}{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}`),
|
|
222
|
+
react_1.default.createElement("defs", null,
|
|
223
|
+
react_1.default.createElement("mask", { id: maskId, maskUnits: "userSpaceOnUse" },
|
|
224
|
+
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` } }))),
|
|
225
|
+
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: {
|
|
226
|
+
transition: `opacity ${fadeMs}ms ease`,
|
|
227
|
+
opacity: conn.fading ? 0 : 0.9,
|
|
228
|
+
} })));
|
|
229
|
+
})()) : null,
|
|
230
|
+
done ? extras : null));
|
|
231
|
+
};
|
|
232
|
+
exports.FileCityLogoAnimated = FileCityLogoAnimated;
|
package/dist/TrailCityDiagram.js
CHANGED
|
@@ -140,11 +140,11 @@ function TrailCityDiagram({ theme, className, hideSnippet = false, snippetVisibl
|
|
|
140
140
|
// reads cleanly against the dark city.
|
|
141
141
|
const silver = '#d1d8e0';
|
|
142
142
|
const palette = (0, react_1.useMemo)(() => [
|
|
143
|
-
withAlpha(accent, 0.
|
|
144
|
-
withAlpha(accent, 0.
|
|
145
|
-
withAlpha(text, 0.
|
|
146
|
-
withAlpha(text, 0.
|
|
147
|
-
withAlpha(text, 0.
|
|
143
|
+
withAlpha(accent, 0.36),
|
|
144
|
+
withAlpha(accent, 0.55),
|
|
145
|
+
withAlpha(text, 0.18),
|
|
146
|
+
withAlpha(text, 0.3),
|
|
147
|
+
withAlpha(text, 0.45),
|
|
148
148
|
], [accent, text]);
|
|
149
149
|
const markerCells = (0, react_1.useMemo)(() => [
|
|
150
150
|
{ col: 1, row: 10, label: '1' },
|
|
@@ -176,7 +176,7 @@ function TrailCityDiagram({ theme, className, hideSnippet = false, snippetVisibl
|
|
|
176
176
|
react_1.default.createElement("stop", { offset: "100%", stopColor: bg, stopOpacity: 0.7 }))),
|
|
177
177
|
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW_W, height: VIEW_H, fill: bg, rx: 12 }),
|
|
178
178
|
react_1.default.createElement("g", { style: {
|
|
179
|
-
opacity: highlightTrail ? 0.
|
|
179
|
+
opacity: highlightTrail ? 0.4 : 1,
|
|
180
180
|
transition: 'opacity 300ms ease',
|
|
181
181
|
} }, 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 })))),
|
|
182
182
|
!hideSnippet && (() => {
|
package/dist/esm/FileCityLogo.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import React, { useId } from 'react';
|
|
2
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;
|
|
3
12
|
// 5-row pixel glyphs — the primary-colored files trace these.
|
|
4
13
|
// `1` = a mark (primary) file
|
|
5
14
|
// `H` = the letter's counter — a forced hole (background shows through,
|
|
@@ -81,26 +90,26 @@ function mix(a, b, t) {
|
|
|
81
90
|
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
82
91
|
}
|
|
83
92
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
88
|
-
* from the muted city.
|
|
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.
|
|
89
96
|
*/
|
|
90
|
-
export
|
|
91
|
-
var _a, _b, _c, _d;
|
|
92
|
-
const uid = useId().replace(/:/g, '');
|
|
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 = 1, gloss = false, squareRadius = 0, }) {
|
|
98
|
+
var _a, _b, _c, _d, _e;
|
|
93
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';
|
|
94
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;
|
|
95
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';
|
|
96
|
-
const bgColor = (_d = background !== null && background !== void 0 ? background : theme === null || theme === void 0 ? void 0 : theme.colors.
|
|
102
|
+
const bgColor = (_e = (_d = background !== null && background !== void 0 ? background : theme === null || theme === void 0 ? void 0 : theme.colors.backgroundSecondary) !== null && _d !== void 0 ? _d : theme === null || theme === void 0 ? void 0 : theme.colors.background) !== null && _e !== void 0 ? _e : '#0a0f14';
|
|
97
103
|
// Same palette weighting as TrailCityDiagram so the two read as a set.
|
|
104
|
+
// Alphas bumped up from the original (0.36/0.55/0.18/0.3/0.45) so the
|
|
105
|
+
// muted city tiles keep enough contrast against the lighter
|
|
106
|
+
// `backgroundSecondary` panel and don't wash out.
|
|
98
107
|
const palette = [
|
|
99
|
-
withAlpha(primaryColor, 0.
|
|
100
|
-
withAlpha(primaryColor, 0.
|
|
101
|
-
withAlpha(baseColor, 0.
|
|
102
|
-
withAlpha(baseColor, 0.
|
|
103
|
-
withAlpha(baseColor, 0.
|
|
108
|
+
withAlpha(primaryColor, 0.46),
|
|
109
|
+
withAlpha(primaryColor, 0.68),
|
|
110
|
+
withAlpha(baseColor, 0.28),
|
|
111
|
+
withAlpha(baseColor, 0.42),
|
|
112
|
+
withAlpha(baseColor, 0.58),
|
|
104
113
|
];
|
|
105
114
|
// The mark files vary in shade so the letter doesn't read as one flat
|
|
106
115
|
// block, but every shade stays vivid so it still stands out from the
|
|
@@ -130,8 +139,8 @@ export const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, a
|
|
|
130
139
|
// Build a square grid. For `mark="none"` it's a plain `cells × cells`
|
|
131
140
|
// city; otherwise the glyph bitmap sits inside a square grid (side =
|
|
132
141
|
// longest glyph dimension + a margin ring) so the city reads square.
|
|
133
|
-
const margin = 1;
|
|
134
142
|
const trailEnabled = trail && (mark === 'P' || mark === 'PAI');
|
|
143
|
+
const aiCardOn = aiCard && mark === 'P';
|
|
135
144
|
let side;
|
|
136
145
|
let offX = 0;
|
|
137
146
|
let offY = 0;
|
|
@@ -180,6 +189,9 @@ export const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, a
|
|
|
180
189
|
// With a trail, shove the letter to the left so the trail has room
|
|
181
190
|
// on the right; otherwise center it in the square.
|
|
182
191
|
offX = trailEnabled ? margin : Math.floor((side - bw) / 2);
|
|
192
|
+
// Nudge the P one column left so the AI card has room on the right.
|
|
193
|
+
if (aiCardOn)
|
|
194
|
+
offX = Math.max(0, offX - 1);
|
|
183
195
|
offY = Math.floor((side - bh) / 2);
|
|
184
196
|
kindAt = (c, r) => {
|
|
185
197
|
const bc = c - offX;
|
|
@@ -192,6 +204,18 @@ export const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, a
|
|
|
192
204
|
}
|
|
193
205
|
const cols = side;
|
|
194
206
|
const rows = side;
|
|
207
|
+
// The AI card occupies the bottom-right 4×3 block of cells. Those cells
|
|
208
|
+
// render no building — the card covers them.
|
|
209
|
+
const AI_CARD_COLS = 3;
|
|
210
|
+
const AI_CARD_ROWS = 2;
|
|
211
|
+
// Inset one cell up and left from the bottom-right corner.
|
|
212
|
+
const aiCardC0 = cols - AI_CARD_COLS - 1;
|
|
213
|
+
const aiCardR0 = rows - AI_CARD_ROWS - 1;
|
|
214
|
+
// Nudge the card down half a cell so it straddles the row line — its
|
|
215
|
+
// body sits over the bottom of the top row and the top of the bottom
|
|
216
|
+
// row. The city renders behind it, so squares show around its edges.
|
|
217
|
+
const AI_CARD_ROW_SHIFT = 0.5;
|
|
218
|
+
const AI_CARD_COL_SHIFT = 0.5;
|
|
195
219
|
// Trail to the right of the letter — starts in the top-right corner,
|
|
196
220
|
// crosses 2 cells diagonally to its first node, zigzags down, and ends
|
|
197
221
|
// in the bottom-right corner. The dots sit on city files, which are
|
|
@@ -248,7 +272,8 @@ export const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, a
|
|
|
248
272
|
const startX = (VIEW - cell * cols) / 2;
|
|
249
273
|
const startY = (VIEW - cell * rows) / 2;
|
|
250
274
|
const rng = mulberry32(7);
|
|
251
|
-
const
|
|
275
|
+
const cellsOut = [];
|
|
276
|
+
const extras = [];
|
|
252
277
|
// Track the previous cell to the left (per row) and above (per column)
|
|
253
278
|
// so we never leave two empty squares back to back in either
|
|
254
279
|
// direction — that's what produced the long blank runs.
|
|
@@ -289,30 +314,137 @@ export const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, a
|
|
|
289
314
|
: gradientShade(baseFor(kind), c, r);
|
|
290
315
|
const x = startX + c * cell + inset;
|
|
291
316
|
const y = startY + r * cell + inset;
|
|
292
|
-
|
|
317
|
+
cellsOut.push({
|
|
318
|
+
key: `${c}-${r}`,
|
|
319
|
+
c,
|
|
320
|
+
r,
|
|
321
|
+
x,
|
|
322
|
+
y,
|
|
323
|
+
sq,
|
|
324
|
+
rx: squareRadius > 0 ? Math.max(1, sq * squareRadius) : 0,
|
|
325
|
+
fill: isLetter
|
|
293
326
|
? letterFill
|
|
294
|
-
: palette[Math.floor(colorRoll * palette.length)],
|
|
327
|
+
: palette[Math.floor(colorRoll * palette.length)],
|
|
328
|
+
stroke: isLetter ? withAlpha(letterColor, 0.55) : withAlpha(baseColor, 0.08),
|
|
329
|
+
strokeWidth: isLetter ? 0.6 : 0.4,
|
|
330
|
+
isLetter,
|
|
331
|
+
// Letter files weigh the most so they build up over several
|
|
332
|
+
// samples; city files weigh less and resolve in one or two hits.
|
|
333
|
+
weight: isLetter ? 1 : 0.4,
|
|
334
|
+
});
|
|
295
335
|
}
|
|
296
336
|
}
|
|
337
|
+
// AI card — a small file card (filename header band + "AI" contents)
|
|
338
|
+
// dropped into the bottom-right block, mirroring TrailCityDiagram's
|
|
339
|
+
// snippet card.
|
|
340
|
+
if (aiCardOn) {
|
|
341
|
+
const cx0 = startX + (aiCardC0 + AI_CARD_COL_SHIFT) * cell + inset;
|
|
342
|
+
const cy0 = startY + (aiCardR0 + AI_CARD_ROW_SHIFT) * cell + inset;
|
|
343
|
+
const cw = AI_CARD_COLS * cell - inset * 2;
|
|
344
|
+
const chh = AI_CARD_ROWS * cell - inset * 2;
|
|
345
|
+
const headerH = chh * 0.28;
|
|
346
|
+
const cardR = Math.max(2, cell * 0.2);
|
|
347
|
+
const barH = Math.max(1, headerH * 0.26);
|
|
348
|
+
const fs = Math.min(cw * 0.42, (chh - headerH) * 0.64);
|
|
349
|
+
// Leader — anchored at the center of the P's bottom square. Routed
|
|
350
|
+
// with right-angle segments: down, right, up, then right into the
|
|
351
|
+
// card's left edge, "opening" the block. Dot at each end.
|
|
352
|
+
const aX = startX + (offX + 0.5) * cell; // center of the stem column
|
|
353
|
+
const aY = startY + (offY + 4.5) * cell; // middle of the bottom square
|
|
354
|
+
const bX = cx0; // left edge of the card
|
|
355
|
+
const bY = cy0 + chh * 0.2; // near the top of that edge
|
|
356
|
+
// Route along grid centerlines so the runs thread through square
|
|
357
|
+
// centers: dip to the row below the P, climb at the column just left
|
|
358
|
+
// of the card.
|
|
359
|
+
const valleyY = startY + (offY + 5.5) * cell; // center of the next row down
|
|
360
|
+
const turnX = startX + 2.5 * cell; // center of the 3rd column
|
|
361
|
+
const dot = Math.max(1, cell * 0.12);
|
|
362
|
+
const leaderPath = `M ${aX} ${aY} L ${aX} ${valleyY} L ${turnX} ${valleyY} L ${turnX} ${bY} L ${bX} ${bY}`;
|
|
363
|
+
extras.push(React.createElement("g", { key: "ai-leader", opacity: 0.75 },
|
|
364
|
+
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}` }),
|
|
365
|
+
React.createElement("circle", { cx: aX, cy: aY, r: dot, fill: accentColor }),
|
|
366
|
+
React.createElement("circle", { cx: bX, cy: bY, r: dot, fill: accentColor })));
|
|
367
|
+
extras.push(React.createElement("g", { key: "ai-card" },
|
|
368
|
+
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 }),
|
|
369
|
+
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) }),
|
|
370
|
+
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) }),
|
|
371
|
+
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")));
|
|
372
|
+
}
|
|
297
373
|
// Trail overlay — a dashed accent path to the right of the letter with
|
|
298
374
|
// a marker dot on each node.
|
|
299
375
|
if (trailEnabled && trailGrid.length > 1) {
|
|
300
376
|
const linePts = trailGrid.map(([c, r]) => centerOf(c, r));
|
|
301
377
|
const d = linePts.map((p, i) => `${i ? 'L' : 'M'} ${p.x} ${p.y}`).join(' ');
|
|
302
378
|
const dot = Math.max(1.5, sq * 0.3);
|
|
303
|
-
|
|
379
|
+
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 }));
|
|
304
380
|
trailGrid.forEach(([c, r], i) => {
|
|
305
381
|
const p = centerOf(c, r);
|
|
306
|
-
|
|
382
|
+
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 }));
|
|
307
383
|
});
|
|
308
384
|
}
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
|
|
385
|
+
return { cells: cellsOut, extras, bgColor, baseColor, rounded, opacity, mark, gloss };
|
|
386
|
+
}
|
|
387
|
+
/** Accessible label for a given mark, shared by both components. */
|
|
388
|
+
export function fileCityLabel(mark) {
|
|
389
|
+
return mark === 'none'
|
|
390
|
+
? 'A top-down grid of file squares'
|
|
391
|
+
: `A top-down grid of file squares spelling ${mark}`;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* SVG panel chrome shared by the static and animated components: the
|
|
395
|
+
* rounded background panel (clipping its children) and the edge hairline.
|
|
396
|
+
* `children` are the grid + overlays drawn inside the clip.
|
|
397
|
+
*/
|
|
398
|
+
export const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, gloss = false, children }) => {
|
|
399
|
+
const uid = useId().replace(/:/g, '');
|
|
400
|
+
// Normalize the gloss option → a config (or null when flat). `true`
|
|
401
|
+
// means "use all defaults"; an object overrides individual fields.
|
|
402
|
+
const g = gloss === false
|
|
403
|
+
? null
|
|
404
|
+
: Object.assign({ side: 'top-right', intensity: 0.09, spread: 0.46, glint: false }, (gloss === true ? {} : gloss));
|
|
405
|
+
// Light direction → linear-gradient endpoints (the lit edge is the
|
|
406
|
+
// start point) and the glint's corner, both in 0–1 object-bounding-box
|
|
407
|
+
// coordinates.
|
|
408
|
+
const GLOSS_DIRS = {
|
|
409
|
+
top: { x1: 0, y1: 0, x2: 0, y2: 1, gx: 0.5, gy: 0.05 },
|
|
410
|
+
'top-left': { x1: 0, y1: 0, x2: 1, y2: 1, gx: 0.22, gy: 0.08 },
|
|
411
|
+
'top-right': { x1: 1, y1: 0, x2: 0, y2: 1, gx: 0.78, gy: 0.08 },
|
|
412
|
+
left: { x1: 0, y1: 0, x2: 1, y2: 0, gx: 0.06, gy: 0.30 },
|
|
413
|
+
right: { x1: 1, y1: 0, x2: 0, y2: 0, gx: 0.94, gy: 0.30 },
|
|
414
|
+
};
|
|
415
|
+
const dir = g ? GLOSS_DIRS[g.side] : GLOSS_DIRS.top;
|
|
416
|
+
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 },
|
|
312
417
|
React.createElement("defs", null,
|
|
313
418
|
React.createElement("clipPath", { id: `panel-${uid}` },
|
|
314
|
-
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ?
|
|
419
|
+
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ? PANEL_RADIUS : 0 })),
|
|
420
|
+
g && (React.createElement(React.Fragment, null,
|
|
421
|
+
React.createElement("linearGradient", { id: `gloss-top-${uid}`, x1: dir.x1, y1: dir.y1, x2: dir.x2, y2: dir.y2 },
|
|
422
|
+
React.createElement("stop", { offset: "0%", stopColor: "#ffffff", stopOpacity: g.intensity }),
|
|
423
|
+
React.createElement("stop", { offset: `${g.spread * 60}%`, stopColor: "#ffffff", stopOpacity: g.intensity * 0.22 }),
|
|
424
|
+
React.createElement("stop", { offset: `${g.spread * 100}%`, stopColor: "#ffffff", stopOpacity: 0 })),
|
|
425
|
+
g.glint && (React.createElement("radialGradient", { id: `gloss-spec-${uid}`, cx: dir.gx, cy: dir.gy, r: 0.7 },
|
|
426
|
+
React.createElement("stop", { offset: "0%", stopColor: "#ffffff", stopOpacity: g.intensity * 1.6 }),
|
|
427
|
+
React.createElement("stop", { offset: "55%", stopColor: "#ffffff", stopOpacity: g.intensity * 0.3 }),
|
|
428
|
+
React.createElement("stop", { offset: "100%", stopColor: "#ffffff", stopOpacity: 0 })))))),
|
|
315
429
|
React.createElement("g", { clipPath: `url(#panel-${uid})` },
|
|
316
|
-
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ?
|
|
317
|
-
|
|
430
|
+
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ? PANEL_RADIUS : 0 }),
|
|
431
|
+
children,
|
|
432
|
+
g && (React.createElement("g", { style: { pointerEvents: 'none' } },
|
|
433
|
+
React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-top-${uid})` }),
|
|
434
|
+
g.glint && (React.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-spec-${uid})` }))))),
|
|
435
|
+
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 })));
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* A compact, iconic "file city" mark — the same top-down grid of file
|
|
439
|
+
* squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
|
|
440
|
+
* of smaller buildings, no trail / markers / snippet. The primary-colored
|
|
441
|
+
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
442
|
+
* from the muted city.
|
|
443
|
+
*/
|
|
444
|
+
export const FileCityLogo = (props) => {
|
|
445
|
+
const { width = 150, height = 150 } = props;
|
|
446
|
+
const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = computeFileCityLayout(props);
|
|
447
|
+
return (React.createElement(FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, label: fileCityLabel(mark) },
|
|
448
|
+
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 }))),
|
|
449
|
+
extras));
|
|
318
450
|
};
|