@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
package/dist/FileCityLogo.d.ts
CHANGED
|
@@ -8,6 +8,28 @@ export type FileCityMark = 'P' | 'AI' | 'PAI' | 'lockup' | 'none';
|
|
|
8
8
|
* across the grid, dark → light.
|
|
9
9
|
*/
|
|
10
10
|
export type FileCityGradient = 'scatter' | 'vertical' | 'horizontal' | 'diagonal';
|
|
11
|
+
/**
|
|
12
|
+
* Which edge the imaginary light comes from for the glass sheen. The
|
|
13
|
+
* highlight is brightest at that edge and fades to clear across the panel;
|
|
14
|
+
* the optional glint sits in the corresponding corner.
|
|
15
|
+
*/
|
|
16
|
+
export type GlossSide = 'top' | 'top-left' | 'top-right' | 'left' | 'right';
|
|
17
|
+
/**
|
|
18
|
+
* Fine control over the glass sheen. All fields optional — `gloss={true}`
|
|
19
|
+
* is the same as `gloss={{}}` (a faint top-lit sheen).
|
|
20
|
+
*/
|
|
21
|
+
export interface GlossConfig {
|
|
22
|
+
/** Edge the light comes from. Default `'top-right'`. */
|
|
23
|
+
side?: GlossSide;
|
|
24
|
+
/** Peak white opacity at the lit edge. ~0.09 = faint, ~0.2 = shiny. Default 0.09. */
|
|
25
|
+
intensity?: number;
|
|
26
|
+
/** How far across the panel the highlight reaches before clearing (0–1). Default 0.46. */
|
|
27
|
+
spread?: number;
|
|
28
|
+
/** Add a concentrated specular hot-spot in the lit corner. Default false. */
|
|
29
|
+
glint?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** `true` = faint top sheen (defaults), an object = tuned sheen, `false` = flat. */
|
|
32
|
+
export type GlossOption = boolean | GlossConfig;
|
|
11
33
|
export interface FileCityLogoProps {
|
|
12
34
|
width?: number;
|
|
13
35
|
height?: number;
|
|
@@ -33,8 +55,11 @@ export interface FileCityLogoProps {
|
|
|
33
55
|
*/
|
|
34
56
|
color?: string;
|
|
35
57
|
/**
|
|
36
|
-
* Panel background behind the grid.
|
|
37
|
-
*
|
|
58
|
+
* Panel background behind the grid. Defaults to the theme's
|
|
59
|
+
* `backgroundSecondary` (falling back to `background`), so the icon
|
|
60
|
+
* sits on the panel/surface color rather than the page background. Pass
|
|
61
|
+
* `"transparent"` to drop the panel and let the mark sit directly on
|
|
62
|
+
* its surface.
|
|
38
63
|
*/
|
|
39
64
|
background?: string;
|
|
40
65
|
/**
|
|
@@ -62,8 +87,97 @@ export interface FileCityLogoProps {
|
|
|
62
87
|
gradient?: FileCityGradient;
|
|
63
88
|
/** Round the panel corners. Default true. */
|
|
64
89
|
rounded?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Corner radius of each building square, as a fraction of the square's
|
|
92
|
+
* side. `0` (default) gives sharp-cornered squares; raise it (e.g.
|
|
93
|
+
* `0.12`) for softly rounded tiles.
|
|
94
|
+
*/
|
|
95
|
+
squareRadius?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Lay a glass sheen over the panel so the icon reads a touch glossy.
|
|
98
|
+
* `false` (default) is flat; `true` is a faint top-lit sheen; pass a
|
|
99
|
+
* {@link GlossConfig} object to tune the light's direction, strength,
|
|
100
|
+
* spread, and whether it has a specular glint.
|
|
101
|
+
*/
|
|
102
|
+
gloss?: GlossOption;
|
|
103
|
+
/**
|
|
104
|
+
* Empty ring of city cells around the mark glyph, in cells. `1`
|
|
105
|
+
* (default) gives the mark breathing room; `0` packs the glyph
|
|
106
|
+
* edge-to-edge so each square is larger — e.g. a 3×5 "P" fills a 5×5
|
|
107
|
+
* grid instead of sitting in a 7×7 one.
|
|
108
|
+
*/
|
|
109
|
+
margin?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Drop a small "file card" into the bottom-right of the grid (3 cells
|
|
112
|
+
* across × 2 down) with **AI** as its contents — echoing the filename +
|
|
113
|
+
* snippet card from TrailCityDiagram. Only applies to `mark="P"`; the P
|
|
114
|
+
* is nudged one column left to clear room for the card.
|
|
115
|
+
*/
|
|
116
|
+
aiCard?: boolean;
|
|
65
117
|
opacity?: number;
|
|
66
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* One rendered grid square of the file-city mark, with everything needed
|
|
121
|
+
* to draw it statically or animate it: its position, final fill / stroke,
|
|
122
|
+
* whether it belongs to the letter, and a `weight` (how strongly it
|
|
123
|
+
* contributes to the mark — letter files weigh more than city files) that
|
|
124
|
+
* the animated variant uses to decide how many "samples" a cell needs
|
|
125
|
+
* before it reaches full intensity.
|
|
126
|
+
*/
|
|
127
|
+
export interface FileCityCell {
|
|
128
|
+
key: string;
|
|
129
|
+
c: number;
|
|
130
|
+
r: number;
|
|
131
|
+
x: number;
|
|
132
|
+
y: number;
|
|
133
|
+
sq: number;
|
|
134
|
+
rx: number;
|
|
135
|
+
fill: string;
|
|
136
|
+
stroke: string;
|
|
137
|
+
strokeWidth: number;
|
|
138
|
+
isLetter: boolean;
|
|
139
|
+
weight: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The resolved geometry + palette for a {@link FileCityLogo}, shared by the
|
|
143
|
+
* static component and {@link FileCityLogoAnimated} so the two never drift.
|
|
144
|
+
*/
|
|
145
|
+
export interface FileCityLayout {
|
|
146
|
+
/** Grid squares, post skip/void culling, in render order. */
|
|
147
|
+
cells: FileCityCell[];
|
|
148
|
+
/** Overlay nodes (trail path/dots, AI card) drawn above the grid. */
|
|
149
|
+
extras: React.ReactNode[];
|
|
150
|
+
bgColor: string;
|
|
151
|
+
baseColor: string;
|
|
152
|
+
rounded: boolean;
|
|
153
|
+
opacity: number;
|
|
154
|
+
mark: FileCityMark;
|
|
155
|
+
gloss: GlossOption;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Compute the full layout (cells + overlays + palette) for a file-city
|
|
159
|
+
* mark from the public props. Pure — no hooks — so both the static and
|
|
160
|
+
* animated components can build their SVG from the identical cell list.
|
|
161
|
+
*/
|
|
162
|
+
export declare function computeFileCityLayout({ mark, primary, accent, color, background, theme, cells, highlight, trail, gradient, rounded, margin, aiCard, opacity, gloss, squareRadius, }: FileCityLogoProps): FileCityLayout;
|
|
163
|
+
/** Accessible label for a given mark, shared by both components. */
|
|
164
|
+
export declare function fileCityLabel(mark: FileCityMark): string;
|
|
165
|
+
/**
|
|
166
|
+
* SVG panel chrome shared by the static and animated components: the
|
|
167
|
+
* rounded background panel (clipping its children) and the edge hairline.
|
|
168
|
+
* `children` are the grid + overlays drawn inside the clip.
|
|
169
|
+
*/
|
|
170
|
+
export declare const FileCityPanel: React.FC<{
|
|
171
|
+
width: number;
|
|
172
|
+
height: number;
|
|
173
|
+
bgColor: string;
|
|
174
|
+
baseColor: string;
|
|
175
|
+
rounded: boolean;
|
|
176
|
+
opacity: number;
|
|
177
|
+
label: string;
|
|
178
|
+
gloss?: GlossOption;
|
|
179
|
+
children: React.ReactNode;
|
|
180
|
+
}>;
|
|
67
181
|
/**
|
|
68
182
|
* A compact, iconic "file city" mark — the same top-down grid of file
|
|
69
183
|
* squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
|
package/dist/FileCityLogo.js
CHANGED
|
@@ -33,9 +33,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FileCityLogo = void 0;
|
|
36
|
+
exports.FileCityLogo = exports.FileCityPanel = void 0;
|
|
37
|
+
exports.computeFileCityLayout = computeFileCityLayout;
|
|
38
|
+
exports.fileCityLabel = fileCityLabel;
|
|
37
39
|
const react_1 = __importStar(require("react"));
|
|
38
40
|
const VIEW = 100;
|
|
41
|
+
// Corner radius for the rounded panel, as a fraction of the panel side.
|
|
42
|
+
// macOS app icons use a ~22.4% continuous-corner ("squircle") radius; the
|
|
43
|
+
// Electron app supplies the transparent safe-area padding, so the panel
|
|
44
|
+
// fills the whole viewBox and just needs the right corner curvature to
|
|
45
|
+
// read as a native dock icon. A plain SVG rx is a close approximation.
|
|
46
|
+
const PANEL_RADIUS = VIEW * 0.2237;
|
|
47
|
+
// Width of the edge hairline (in viewBox units) that keeps the icon
|
|
48
|
+
// defined against the dock background.
|
|
49
|
+
const HAIRLINE = 0.75;
|
|
39
50
|
// 5-row pixel glyphs — the primary-colored files trace these.
|
|
40
51
|
// `1` = a mark (primary) file
|
|
41
52
|
// `H` = the letter's counter — a forced hole (background shows through,
|
|
@@ -117,26 +128,26 @@ function mix(a, b, t) {
|
|
|
117
128
|
return `#${ch(0)}${ch(1)}${ch(2)}`;
|
|
118
129
|
}
|
|
119
130
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
124
|
-
* from the muted city.
|
|
131
|
+
* Compute the full layout (cells + overlays + palette) for a file-city
|
|
132
|
+
* mark from the public props. Pure — no hooks — so both the static and
|
|
133
|
+
* animated components can build their SVG from the identical cell list.
|
|
125
134
|
*/
|
|
126
|
-
|
|
127
|
-
var _a, _b, _c, _d;
|
|
128
|
-
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
135
|
+
function computeFileCityLayout({ mark = 'P', primary, accent, color, background, theme, cells = 5, highlight = true, trail = false, gradient = 'diagonal', rounded = true, margin = 1, aiCard = false, opacity = 1, gloss = false, squareRadius = 0, }) {
|
|
136
|
+
var _a, _b, _c, _d, _e;
|
|
129
137
|
const primaryColor = (_a = primary !== null && primary !== void 0 ? primary : theme === null || theme === void 0 ? void 0 : theme.colors.primary) !== null && _a !== void 0 ? _a : '#22d3ee';
|
|
130
138
|
const accentColor = (_b = accent !== null && accent !== void 0 ? accent : theme === null || theme === void 0 ? void 0 : theme.colors.accent) !== null && _b !== void 0 ? _b : primaryColor;
|
|
131
139
|
const baseColor = (_c = color !== null && color !== void 0 ? color : theme === null || theme === void 0 ? void 0 : theme.colors.text) !== null && _c !== void 0 ? _c : '#f8fafc';
|
|
132
|
-
const bgColor = (_d = background !== null && background !== void 0 ? background : theme === null || theme === void 0 ? void 0 : theme.colors.
|
|
140
|
+
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';
|
|
133
141
|
// Same palette weighting as TrailCityDiagram so the two read as a set.
|
|
142
|
+
// Alphas bumped up from the original (0.36/0.55/0.18/0.3/0.45) so the
|
|
143
|
+
// muted city tiles keep enough contrast against the lighter
|
|
144
|
+
// `backgroundSecondary` panel and don't wash out.
|
|
134
145
|
const palette = [
|
|
135
|
-
withAlpha(primaryColor, 0.
|
|
136
|
-
withAlpha(primaryColor, 0.
|
|
137
|
-
withAlpha(baseColor, 0.
|
|
138
|
-
withAlpha(baseColor, 0.
|
|
139
|
-
withAlpha(baseColor, 0.
|
|
146
|
+
withAlpha(primaryColor, 0.46),
|
|
147
|
+
withAlpha(primaryColor, 0.68),
|
|
148
|
+
withAlpha(baseColor, 0.28),
|
|
149
|
+
withAlpha(baseColor, 0.42),
|
|
150
|
+
withAlpha(baseColor, 0.58),
|
|
140
151
|
];
|
|
141
152
|
// The mark files vary in shade so the letter doesn't read as one flat
|
|
142
153
|
// block, but every shade stays vivid so it still stands out from the
|
|
@@ -166,8 +177,8 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
166
177
|
// Build a square grid. For `mark="none"` it's a plain `cells × cells`
|
|
167
178
|
// city; otherwise the glyph bitmap sits inside a square grid (side =
|
|
168
179
|
// longest glyph dimension + a margin ring) so the city reads square.
|
|
169
|
-
const margin = 1;
|
|
170
180
|
const trailEnabled = trail && (mark === 'P' || mark === 'PAI');
|
|
181
|
+
const aiCardOn = aiCard && mark === 'P';
|
|
171
182
|
let side;
|
|
172
183
|
let offX = 0;
|
|
173
184
|
let offY = 0;
|
|
@@ -216,6 +227,9 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
216
227
|
// With a trail, shove the letter to the left so the trail has room
|
|
217
228
|
// on the right; otherwise center it in the square.
|
|
218
229
|
offX = trailEnabled ? margin : Math.floor((side - bw) / 2);
|
|
230
|
+
// Nudge the P one column left so the AI card has room on the right.
|
|
231
|
+
if (aiCardOn)
|
|
232
|
+
offX = Math.max(0, offX - 1);
|
|
219
233
|
offY = Math.floor((side - bh) / 2);
|
|
220
234
|
kindAt = (c, r) => {
|
|
221
235
|
const bc = c - offX;
|
|
@@ -228,6 +242,18 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
228
242
|
}
|
|
229
243
|
const cols = side;
|
|
230
244
|
const rows = side;
|
|
245
|
+
// The AI card occupies the bottom-right 4×3 block of cells. Those cells
|
|
246
|
+
// render no building — the card covers them.
|
|
247
|
+
const AI_CARD_COLS = 3;
|
|
248
|
+
const AI_CARD_ROWS = 2;
|
|
249
|
+
// Inset one cell up and left from the bottom-right corner.
|
|
250
|
+
const aiCardC0 = cols - AI_CARD_COLS - 1;
|
|
251
|
+
const aiCardR0 = rows - AI_CARD_ROWS - 1;
|
|
252
|
+
// Nudge the card down half a cell so it straddles the row line — its
|
|
253
|
+
// body sits over the bottom of the top row and the top of the bottom
|
|
254
|
+
// row. The city renders behind it, so squares show around its edges.
|
|
255
|
+
const AI_CARD_ROW_SHIFT = 0.5;
|
|
256
|
+
const AI_CARD_COL_SHIFT = 0.5;
|
|
231
257
|
// Trail to the right of the letter — starts in the top-right corner,
|
|
232
258
|
// crosses 2 cells diagonally to its first node, zigzags down, and ends
|
|
233
259
|
// in the bottom-right corner. The dots sit on city files, which are
|
|
@@ -284,7 +310,8 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
284
310
|
const startX = (VIEW - cell * cols) / 2;
|
|
285
311
|
const startY = (VIEW - cell * rows) / 2;
|
|
286
312
|
const rng = mulberry32(7);
|
|
287
|
-
const
|
|
313
|
+
const cellsOut = [];
|
|
314
|
+
const extras = [];
|
|
288
315
|
// Track the previous cell to the left (per row) and above (per column)
|
|
289
316
|
// so we never leave two empty squares back to back in either
|
|
290
317
|
// direction — that's what produced the long blank runs.
|
|
@@ -325,31 +352,139 @@ const FileCityLogo = ({ width = 150, height = 150, mark = 'P', primary, accent,
|
|
|
325
352
|
: gradientShade(baseFor(kind), c, r);
|
|
326
353
|
const x = startX + c * cell + inset;
|
|
327
354
|
const y = startY + r * cell + inset;
|
|
328
|
-
|
|
355
|
+
cellsOut.push({
|
|
356
|
+
key: `${c}-${r}`,
|
|
357
|
+
c,
|
|
358
|
+
r,
|
|
359
|
+
x,
|
|
360
|
+
y,
|
|
361
|
+
sq,
|
|
362
|
+
rx: squareRadius > 0 ? Math.max(1, sq * squareRadius) : 0,
|
|
363
|
+
fill: isLetter
|
|
329
364
|
? letterFill
|
|
330
|
-
: palette[Math.floor(colorRoll * palette.length)],
|
|
365
|
+
: palette[Math.floor(colorRoll * palette.length)],
|
|
366
|
+
stroke: isLetter ? withAlpha(letterColor, 0.55) : withAlpha(baseColor, 0.08),
|
|
367
|
+
strokeWidth: isLetter ? 0.6 : 0.4,
|
|
368
|
+
isLetter,
|
|
369
|
+
// Letter files weigh the most so they build up over several
|
|
370
|
+
// samples; city files weigh less and resolve in one or two hits.
|
|
371
|
+
weight: isLetter ? 1 : 0.4,
|
|
372
|
+
});
|
|
331
373
|
}
|
|
332
374
|
}
|
|
375
|
+
// AI card — a small file card (filename header band + "AI" contents)
|
|
376
|
+
// dropped into the bottom-right block, mirroring TrailCityDiagram's
|
|
377
|
+
// snippet card.
|
|
378
|
+
if (aiCardOn) {
|
|
379
|
+
const cx0 = startX + (aiCardC0 + AI_CARD_COL_SHIFT) * cell + inset;
|
|
380
|
+
const cy0 = startY + (aiCardR0 + AI_CARD_ROW_SHIFT) * cell + inset;
|
|
381
|
+
const cw = AI_CARD_COLS * cell - inset * 2;
|
|
382
|
+
const chh = AI_CARD_ROWS * cell - inset * 2;
|
|
383
|
+
const headerH = chh * 0.28;
|
|
384
|
+
const cardR = Math.max(2, cell * 0.2);
|
|
385
|
+
const barH = Math.max(1, headerH * 0.26);
|
|
386
|
+
const fs = Math.min(cw * 0.42, (chh - headerH) * 0.64);
|
|
387
|
+
// Leader — anchored at the center of the P's bottom square. Routed
|
|
388
|
+
// with right-angle segments: down, right, up, then right into the
|
|
389
|
+
// card's left edge, "opening" the block. Dot at each end.
|
|
390
|
+
const aX = startX + (offX + 0.5) * cell; // center of the stem column
|
|
391
|
+
const aY = startY + (offY + 4.5) * cell; // middle of the bottom square
|
|
392
|
+
const bX = cx0; // left edge of the card
|
|
393
|
+
const bY = cy0 + chh * 0.2; // near the top of that edge
|
|
394
|
+
// Route along grid centerlines so the runs thread through square
|
|
395
|
+
// centers: dip to the row below the P, climb at the column just left
|
|
396
|
+
// of the card.
|
|
397
|
+
const valleyY = startY + (offY + 5.5) * cell; // center of the next row down
|
|
398
|
+
const turnX = startX + 2.5 * cell; // center of the 3rd column
|
|
399
|
+
const dot = Math.max(1, cell * 0.12);
|
|
400
|
+
const leaderPath = `M ${aX} ${aY} L ${aX} ${valleyY} L ${turnX} ${valleyY} L ${turnX} ${bY} L ${bX} ${bY}`;
|
|
401
|
+
extras.push(react_1.default.createElement("g", { key: "ai-leader", opacity: 0.75 },
|
|
402
|
+
react_1.default.createElement("path", { d: leaderPath, fill: "none", stroke: accentColor, strokeWidth: Math.max(0.6, cell * 0.07), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.2} ${cell * 0.15}` }),
|
|
403
|
+
react_1.default.createElement("circle", { cx: aX, cy: aY, r: dot, fill: accentColor }),
|
|
404
|
+
react_1.default.createElement("circle", { cx: bX, cy: bY, r: dot, fill: accentColor })));
|
|
405
|
+
extras.push(react_1.default.createElement("g", { key: "ai-card" },
|
|
406
|
+
react_1.default.createElement("rect", { x: cx0, y: cy0, width: cw, height: chh, rx: cardR, fill: mix(bgColor, '#ffffff', 0.06), stroke: withAlpha(accentColor, 0.55), strokeWidth: 0.8 }),
|
|
407
|
+
react_1.default.createElement("path", { d: `M ${cx0} ${cy0 + headerH} L ${cx0} ${cy0 + cardR} Q ${cx0} ${cy0} ${cx0 + cardR} ${cy0} L ${cx0 + cw - cardR} ${cy0} Q ${cx0 + cw} ${cy0} ${cx0 + cw} ${cy0 + cardR} L ${cx0 + cw} ${cy0 + headerH} Z`, fill: withAlpha(accentColor, 0.14) }),
|
|
408
|
+
react_1.default.createElement("rect", { x: cx0 + cw * 0.16, y: cy0 + headerH / 2 - barH / 2, width: cw * 0.44, height: barH, rx: barH / 2, fill: withAlpha(baseColor, 0.5) }),
|
|
409
|
+
react_1.default.createElement("text", { x: cx0 + cw / 2, y: cy0 + headerH + (chh - headerH) / 2, textAnchor: "middle", dominantBaseline: "central", fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontWeight: 700, fontSize: fs, letterSpacing: "0.06em", fill: accentColor }, "AI")));
|
|
410
|
+
}
|
|
333
411
|
// Trail overlay — a dashed accent path to the right of the letter with
|
|
334
412
|
// a marker dot on each node.
|
|
335
413
|
if (trailEnabled && trailGrid.length > 1) {
|
|
336
414
|
const linePts = trailGrid.map(([c, r]) => centerOf(c, r));
|
|
337
415
|
const d = linePts.map((p, i) => `${i ? 'L' : 'M'} ${p.x} ${p.y}`).join(' ');
|
|
338
416
|
const dot = Math.max(1.5, sq * 0.3);
|
|
339
|
-
|
|
417
|
+
extras.push(react_1.default.createElement("path", { key: "trail-path", d: d, fill: "none", stroke: accentColor, strokeWidth: Math.max(1, cell * 0.12), strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: `${cell * 0.18} ${cell * 0.18}`, opacity: 0.9 }));
|
|
340
418
|
trailGrid.forEach(([c, r], i) => {
|
|
341
419
|
const p = centerOf(c, r);
|
|
342
|
-
|
|
420
|
+
extras.push(react_1.default.createElement("circle", { key: `trail-dot-${i}`, cx: p.x, cy: p.y, r: dot, fill: mix(accentColor, '#ffffff', 0.15), stroke: bgColor, strokeWidth: 0.5 }));
|
|
343
421
|
});
|
|
344
422
|
}
|
|
345
|
-
return
|
|
346
|
-
|
|
347
|
-
|
|
423
|
+
return { cells: cellsOut, extras, bgColor, baseColor, rounded, opacity, mark, gloss };
|
|
424
|
+
}
|
|
425
|
+
/** Accessible label for a given mark, shared by both components. */
|
|
426
|
+
function fileCityLabel(mark) {
|
|
427
|
+
return mark === 'none'
|
|
428
|
+
? 'A top-down grid of file squares'
|
|
429
|
+
: `A top-down grid of file squares spelling ${mark}`;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* SVG panel chrome shared by the static and animated components: the
|
|
433
|
+
* rounded background panel (clipping its children) and the edge hairline.
|
|
434
|
+
* `children` are the grid + overlays drawn inside the clip.
|
|
435
|
+
*/
|
|
436
|
+
const FileCityPanel = ({ width, height, bgColor, baseColor, rounded, opacity, label, gloss = false, children }) => {
|
|
437
|
+
const uid = (0, react_1.useId)().replace(/:/g, '');
|
|
438
|
+
// Normalize the gloss option → a config (or null when flat). `true`
|
|
439
|
+
// means "use all defaults"; an object overrides individual fields.
|
|
440
|
+
const g = gloss === false
|
|
441
|
+
? null
|
|
442
|
+
: Object.assign({ side: 'top-right', intensity: 0.09, spread: 0.46, glint: false }, (gloss === true ? {} : gloss));
|
|
443
|
+
// Light direction → linear-gradient endpoints (the lit edge is the
|
|
444
|
+
// start point) and the glint's corner, both in 0–1 object-bounding-box
|
|
445
|
+
// coordinates.
|
|
446
|
+
const GLOSS_DIRS = {
|
|
447
|
+
top: { x1: 0, y1: 0, x2: 0, y2: 1, gx: 0.5, gy: 0.05 },
|
|
448
|
+
'top-left': { x1: 0, y1: 0, x2: 1, y2: 1, gx: 0.22, gy: 0.08 },
|
|
449
|
+
'top-right': { x1: 1, y1: 0, x2: 0, y2: 1, gx: 0.78, gy: 0.08 },
|
|
450
|
+
left: { x1: 0, y1: 0, x2: 1, y2: 0, gx: 0.06, gy: 0.30 },
|
|
451
|
+
right: { x1: 1, y1: 0, x2: 0, y2: 0, gx: 0.94, gy: 0.30 },
|
|
452
|
+
};
|
|
453
|
+
const dir = g ? GLOSS_DIRS[g.side] : GLOSS_DIRS.top;
|
|
454
|
+
return (react_1.default.createElement("svg", { width: width, height: height, viewBox: `0 0 ${VIEW} ${VIEW}`, xmlns: "http://www.w3.org/2000/svg", style: { opacity, display: 'block', overflow: 'visible' }, role: "img", "aria-label": label },
|
|
348
455
|
react_1.default.createElement("defs", null,
|
|
349
456
|
react_1.default.createElement("clipPath", { id: `panel-${uid}` },
|
|
350
|
-
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ?
|
|
457
|
+
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, rx: rounded ? PANEL_RADIUS : 0 })),
|
|
458
|
+
g && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
459
|
+
react_1.default.createElement("linearGradient", { id: `gloss-top-${uid}`, x1: dir.x1, y1: dir.y1, x2: dir.x2, y2: dir.y2 },
|
|
460
|
+
react_1.default.createElement("stop", { offset: "0%", stopColor: "#ffffff", stopOpacity: g.intensity }),
|
|
461
|
+
react_1.default.createElement("stop", { offset: `${g.spread * 60}%`, stopColor: "#ffffff", stopOpacity: g.intensity * 0.22 }),
|
|
462
|
+
react_1.default.createElement("stop", { offset: `${g.spread * 100}%`, stopColor: "#ffffff", stopOpacity: 0 })),
|
|
463
|
+
g.glint && (react_1.default.createElement("radialGradient", { id: `gloss-spec-${uid}`, cx: dir.gx, cy: dir.gy, r: 0.7 },
|
|
464
|
+
react_1.default.createElement("stop", { offset: "0%", stopColor: "#ffffff", stopOpacity: g.intensity * 1.6 }),
|
|
465
|
+
react_1.default.createElement("stop", { offset: "55%", stopColor: "#ffffff", stopOpacity: g.intensity * 0.3 }),
|
|
466
|
+
react_1.default.createElement("stop", { offset: "100%", stopColor: "#ffffff", stopOpacity: 0 })))))),
|
|
351
467
|
react_1.default.createElement("g", { clipPath: `url(#panel-${uid})` },
|
|
352
|
-
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ?
|
|
353
|
-
|
|
468
|
+
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: bgColor, rx: rounded ? PANEL_RADIUS : 0 }),
|
|
469
|
+
children,
|
|
470
|
+
g && (react_1.default.createElement("g", { style: { pointerEvents: 'none' } },
|
|
471
|
+
react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-top-${uid})` }),
|
|
472
|
+
g.glint && (react_1.default.createElement("rect", { x: 0, y: 0, width: VIEW, height: VIEW, fill: `url(#gloss-spec-${uid})` }))))),
|
|
473
|
+
react_1.default.createElement("rect", { x: HAIRLINE / 2, y: HAIRLINE / 2, width: VIEW - HAIRLINE, height: VIEW - HAIRLINE, rx: rounded ? Math.max(0, PANEL_RADIUS - HAIRLINE / 2) : 0, fill: "none", stroke: withAlpha(baseColor, 0.14), strokeWidth: HAIRLINE })));
|
|
474
|
+
};
|
|
475
|
+
exports.FileCityPanel = FileCityPanel;
|
|
476
|
+
/**
|
|
477
|
+
* A compact, iconic "file city" mark — the same top-down grid of file
|
|
478
|
+
* squares as {@link TrailCityDiagram}, distilled to a logo: a small grid
|
|
479
|
+
* of smaller buildings, no trail / markers / snippet. The primary-colored
|
|
480
|
+
* files spell out the brand mark (P / AI / PAI) so the letters emerge
|
|
481
|
+
* from the muted city.
|
|
482
|
+
*/
|
|
483
|
+
const FileCityLogo = (props) => {
|
|
484
|
+
const { width = 150, height = 150 } = props;
|
|
485
|
+
const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = computeFileCityLayout(props);
|
|
486
|
+
return (react_1.default.createElement(exports.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, label: fileCityLabel(mark) },
|
|
487
|
+
cells.map((cell) => (react_1.default.createElement("rect", { key: cell.key, x: cell.x, y: cell.y, width: cell.sq, height: cell.sq, rx: cell.rx, fill: cell.fill, stroke: cell.stroke, strokeWidth: cell.strokeWidth }))),
|
|
488
|
+
extras));
|
|
354
489
|
};
|
|
355
490
|
exports.FileCityLogo = FileCityLogo;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FileCityLogoProps } from './FileCityLogo';
|
|
3
|
+
export interface FileCityLogoAnimatedProps extends FileCityLogoProps {
|
|
4
|
+
/**
|
|
5
|
+
* Min / max number of cells in each group. The cells in a group reveal
|
|
6
|
+
* one at a time (`cellMs` apart); then the build holds for `pauseMs`
|
|
7
|
+
* before the next group. Default 3–6.
|
|
8
|
+
*/
|
|
9
|
+
batchMin?: number;
|
|
10
|
+
batchMax?: number;
|
|
11
|
+
/** Milliseconds between cells within a group. Default 130. */
|
|
12
|
+
cellMs?: number;
|
|
13
|
+
/** Milliseconds to hold after a group completes, before the next. Default 700. */
|
|
14
|
+
pauseMs?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Draw a connector line threading the cells of the active group in reveal
|
|
17
|
+
* order — it grows as each cell appears, then fades out during the pause.
|
|
18
|
+
* Default true.
|
|
19
|
+
*/
|
|
20
|
+
connectors?: boolean;
|
|
21
|
+
/** Connector color. Defaults to the accent (falling back to primary). */
|
|
22
|
+
connectorColor?: string;
|
|
23
|
+
/**
|
|
24
|
+
* How many samples a full-weight (letter) cell needs before it reaches
|
|
25
|
+
* full intensity. City files need proportionally fewer (by their lower
|
|
26
|
+
* weight), so the letter builds up gradually while the city pops in. */
|
|
27
|
+
buildSteps?: number;
|
|
28
|
+
/** Start playing on mount. Default true. */
|
|
29
|
+
autoPlay?: boolean;
|
|
30
|
+
/** Replay key — change this value to restart the animation. */
|
|
31
|
+
playKey?: string | number;
|
|
32
|
+
/** Called once the heatmap has fully resolved. */
|
|
33
|
+
onComplete?: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Animated file-city mark: the squares accumulate like a heatmap. Each tick
|
|
37
|
+
* a batch of cells gets a "sample" added; letter cells weigh more so they
|
|
38
|
+
* take several samples to reach full intensity while city files resolve
|
|
39
|
+
* quickly. Once the summed weights fill in, the logo holds on screen.
|
|
40
|
+
*/
|
|
41
|
+
export declare const FileCityLogoAnimated: React.FC<FileCityLogoAnimatedProps>;
|