@principal-ai/logo-component 0.1.22 → 0.1.24

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.
@@ -36,6 +36,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.FileCityLogoAnimated = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const FileCityLogo_1 = require("./FileCityLogo");
39
+ // Each lit file of the P and the face square it slides to, as [col, row] on
40
+ // the 7×7 grid. The P has ten files and the face needs eleven (two 2×2 eyes
41
+ // and a three-file mouth), so the last one starts stacked on the P's foot.
42
+ const FACE_MOVES = [
43
+ { home: [2, 1], face: [1, 1], part: 'eyeL' },
44
+ { home: [3, 1], face: [2, 1], part: 'eyeL' },
45
+ { home: [2, 2], face: [1, 2], part: 'eyeL' },
46
+ { home: [2, 3], face: [2, 2], part: 'eyeL' },
47
+ { home: [4, 1], face: [5, 1], part: 'eyeR' },
48
+ { home: [4, 2], face: [5, 2], part: 'eyeR' },
49
+ { home: [3, 3], face: [4, 1], part: 'eyeR' },
50
+ { home: [4, 3], face: [4, 2], part: 'eyeR' },
51
+ { home: [2, 4], face: [2, 5], part: 'mouth' },
52
+ { home: [2, 5], face: [3, 5], part: 'mouth' },
53
+ { home: [2, 5], face: [4, 5], part: 'mouth' },
54
+ ];
55
+ // The smile's upturned corners, which pop in beside the mouth.
56
+ const SMILE_CORNERS = [
57
+ [1, 4],
58
+ [5, 4],
59
+ ];
60
+ function lighten(color, t) {
61
+ if (!/^#[0-9a-f]{6}$/i.test(color))
62
+ return color;
63
+ const ch = (i) => {
64
+ const v = parseInt(color.slice(1 + i * 2, 3 + i * 2), 16);
65
+ return Math.round(v + (255 - v) * t)
66
+ .toString(16)
67
+ .padStart(2, '0');
68
+ };
69
+ return `#${ch(0)}${ch(1)}${ch(2)}`;
70
+ }
39
71
  // CSS keyframe name for the connector draw-on. CSS animations restart on
40
72
  // element remount (unlike SMIL's document-timeline `begin`), so each group's
41
73
  // freshly-keyed connector draws from the start.
@@ -63,12 +95,14 @@ function mulberry32(seed) {
63
95
  const FileCityLogoAnimated = (props) => {
64
96
  var _a, _b, _c, _d, _e, _f, _g;
65
97
  const uid = (0, react_1.useId)().replace(/:/g, '');
66
- const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, } = props;
98
+ const { width = 150, height = 150, batchMin = 5, batchMax = 10, cellMs = 185, pauseMs = 900, buildSteps = 1, connectors = true, connectorColor, autoPlay = true, playKey, onComplete, face: faceMode = 'none', } = props;
99
+ const watch = faceMode === 'watch';
100
+ const wake = faceMode === 'wake';
67
101
  // The trail line is a light grey (close to white); the nodes it threads
68
102
  // to are marked with accent-colored dots so the destinations pop.
69
103
  const trailColor = connectorColor !== null && connectorColor !== void 0 ? connectorColor : '#e5e7eb';
70
104
  const dotColor = (_f = (_d = (_c = (_a = props.accent) !== null && _a !== void 0 ? _a : (_b = props.theme) === null || _b === void 0 ? void 0 : _b.colors.accent) !== null && _c !== void 0 ? _c : props.primary) !== null && _d !== void 0 ? _d : (_e = props.theme) === null || _e === void 0 ? void 0 : _e.colors.primary) !== null && _f !== void 0 ? _f : '#22d3ee';
71
- const { cells, extras, bgColor, baseColor, rounded, opacity, mark, gloss } = (0, react_1.useMemo)(() => (0, FileCityLogo_1.computeFileCityLayout)(props),
105
+ const { cells, extras, ribbon, bgColor, baseColor, rounded, opacity, mark, gloss } = (0, react_1.useMemo)(() => (0, FileCityLogo_1.computeFileCityLayout)(props),
72
106
  // Re-derive only when an input that affects layout changes.
73
107
  // eslint-disable-next-line react-hooks/exhaustive-deps
74
108
  [
@@ -88,6 +122,7 @@ const FileCityLogoAnimated = (props) => {
88
122
  props.opacity,
89
123
  props.gloss,
90
124
  props.squareRadius,
125
+ props.devRibbon,
91
126
  ]);
92
127
  // Per-cell number of samples to fully reveal it (>=1; letter cells take
93
128
  // `buildSteps`, city cells proportionally fewer by their weight).
@@ -120,6 +155,65 @@ const FileCityLogoAnimated = (props) => {
120
155
  // walked the animation is done and the logo holds.
121
156
  const [progress, setProgress] = (0, react_1.useState)(() => cells.map(() => 0));
122
157
  const [done, setDone] = (0, react_1.useState)(false);
158
+ // The sheen used to start the moment the build finished; with a watching
159
+ // face it waits until the face has merged into the P.
160
+ const [sheen, setSheen] = (0, react_1.useState)(false);
161
+ const [face, setFace] = (0, react_1.useState)(null);
162
+ // Which way the eyes are looking, in grid squares.
163
+ const [look, setLook] = (0, react_1.useState)([0, 0]);
164
+ // Face geometry — only for the plain centred P on its 7×7 grid, where the
165
+ // face's squares line up with the logo's.
166
+ const faceGeo = (0, react_1.useMemo)(() => {
167
+ var _a, _b, _c;
168
+ if (faceMode === 'none' || mark !== 'P' || cells.length < 2)
169
+ return null;
170
+ const letters = cells.filter((cell) => cell.isLetter);
171
+ const side = Math.max(...cells.map((cell) => cell.c)) + 1;
172
+ const minC = Math.min(...letters.map((cell) => cell.c));
173
+ const minR = Math.min(...letters.map((cell) => cell.r));
174
+ // The face is authored with the P at column 2, row 1 (the 7×7 logo).
175
+ // Shift it to wherever the P actually sits — e.g. the edge-to-edge 5×5
176
+ // `margin={0}` mark — and bail if it wouldn't fit on the grid.
177
+ const dc = minC - 2;
178
+ const dr = minR - 1;
179
+ const fits = [...FACE_MOVES.map((m) => m.face), ...SMILE_CORNERS].every(([c, r]) => c + dc >= 0 && c + dc < side && r + dr >= 0 && r + dr < side);
180
+ const isPlainP = FACE_MOVES.every((m) => letters.some((l) => l.c === m.home[0] + dc && l.r === m.home[1] + dr));
181
+ if (letters.length !== 10 || !fits || !isPlainP)
182
+ return null;
183
+ const a = cells[0];
184
+ const b = cells.find((cell) => cell.c !== a.c);
185
+ const pitch = (b.x - a.x) / (b.c - a.c);
186
+ const at = (c, r) => ({
187
+ x: a.x + (c + dc - a.c) * pitch,
188
+ y: a.y + (r + dr - a.r) * pitch,
189
+ });
190
+ const primary = (_c = (_a = props.primary) !== null && _a !== void 0 ? _a : (_b = props.theme) === null || _b === void 0 ? void 0 : _b.colors.primary) !== null && _c !== void 0 ? _c : '#22d3ee';
191
+ const tiles = FACE_MOVES.map((move, i) => {
192
+ const cell = letters.find((l) => l.c === move.home[0] + dc && l.r === move.home[1] + dr);
193
+ return {
194
+ key: `face-${i}`,
195
+ part: move.part,
196
+ home: at(...move.home),
197
+ face: at(...move.face),
198
+ fill: cell.fill,
199
+ stroke: cell.stroke,
200
+ strokeWidth: cell.strokeWidth,
201
+ };
202
+ });
203
+ const block = (c) => (Object.assign(Object.assign({}, at(c, 1)), { size: pitch + a.sq }));
204
+ return {
205
+ pitch,
206
+ sq: a.sq,
207
+ rx: a.rx,
208
+ tiles,
209
+ eyeColor: lighten(primary, 0.6),
210
+ // Match the mouth's own files, which carry the P's gradient shade.
211
+ mouthColor: tiles[tiles.length - 1].fill,
212
+ eyes: { eyeL: block(1), eyeR: block(4) },
213
+ corners: SMILE_CORNERS.map(([c, r]) => at(c, r)),
214
+ };
215
+ // eslint-disable-next-line react-hooks/exhaustive-deps
216
+ }, [cells, mark, faceMode, props.primary, props.theme]);
123
217
  // The connector for the active group: which group it traces, and whether
124
218
  // it's drawing on (during the reveal) or fading out (during the pause).
125
219
  const [conn, setConn] = (0, react_1.useState)(null);
@@ -140,14 +234,34 @@ const FileCityLogoAnimated = (props) => {
140
234
  setProgress(cells.map(() => 0));
141
235
  setConn(null);
142
236
  setDone(false);
237
+ setSheen(false);
238
+ setLook([0, 0]);
239
+ setFace(null);
143
240
  if (!autoPlay || cells.length === 0 || reduce) {
144
241
  setProgress(stepsFor.slice());
145
242
  setDone(true);
243
+ setSheen(true);
146
244
  (_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef);
147
245
  return;
148
246
  }
149
247
  let timer;
150
248
  let fadeTimer;
249
+ let blinkTimer;
250
+ let enterTimer;
251
+ // The watching face is on stage before the first file appears.
252
+ if (watch && faceGeo) {
253
+ setFace({
254
+ at: 'face',
255
+ blocks: true,
256
+ mouth: false,
257
+ smile: false,
258
+ blink: false,
259
+ wink: false,
260
+ visible: false,
261
+ hideLetters: false,
262
+ });
263
+ enterTimer = setTimeout(() => setFace((f) => f && Object.assign(Object.assign({}, f), { visible: true })), 40);
264
+ }
151
265
  // Hold the finished trail on screen before it fades, so the completed
152
266
  // group lingers a beat. Keep linger + fade within the pause.
153
267
  const lingerMs = Math.max(0, Math.min(pauseMs - fadeMs - 40, 450));
@@ -164,6 +278,14 @@ const FileCityLogoAnimated = (props) => {
164
278
  const group = groups[gi];
165
279
  const mi = memberRef.current;
166
280
  const idx = group[mi];
281
+ // The eyes turn once per group, towards where most of it is, rather
282
+ // than darting to every file as it lights up.
283
+ if (watch && faceGeo && mi === 0) {
284
+ const c = group.reduce((sum, i) => sum + cells[i].c, 0) / group.length;
285
+ const r = group.reduce((sum, i) => sum + cells[i].r, 0) / group.length;
286
+ const mid = (Math.max(...cells.map((cell) => cell.c)) + 0) / 2;
287
+ setLook([c < mid - 0.4 ? -1 : c > mid + 0.4 ? 1 : 0, r < mid - 0.6 ? -1 : r > mid + 0.6 ? 1 : 0]);
288
+ }
167
289
  setProgress((prev) => {
168
290
  const next = prev.slice();
169
291
  next[idx] = Math.min(stepsFor[idx], next[idx] + 1);
@@ -177,6 +299,11 @@ const FileCityLogoAnimated = (props) => {
177
299
  // The trail is fully drawn — hold it for `lingerMs`, then flip to
178
300
  // fading so it dissolves before the next group begins.
179
301
  fadeTimer = setTimeout(() => setConn({ group: gi, fading: true }), lingerMs);
302
+ // …and blink once the group is done.
303
+ if (watch && faceGeo) {
304
+ setFace((f) => f && Object.assign(Object.assign({}, f), { blink: true }));
305
+ blinkTimer = setTimeout(() => setFace((f) => f && Object.assign(Object.assign({}, f), { blink: false })), 140);
306
+ }
180
307
  groupRef.current = gi + 1;
181
308
  memberRef.current = 0;
182
309
  timer = setTimeout(step, pauseMs);
@@ -190,9 +317,69 @@ const FileCityLogoAnimated = (props) => {
190
317
  return () => {
191
318
  clearTimeout(timer);
192
319
  clearTimeout(fadeTimer);
320
+ clearTimeout(blinkTimer);
321
+ clearTimeout(enterTimer);
193
322
  };
194
323
  // eslint-disable-next-line react-hooks/exhaustive-deps
195
- }, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey]);
324
+ }, [cells, groups, stepsFor, cellMs, pauseMs, autoPlay, playKey, watch, faceGeo]);
325
+ // Everything after the build: the watching face merges into the P, the
326
+ // sheen plays, then (for `wake`) the P turns into a face and back.
327
+ (0, react_1.useEffect)(() => {
328
+ if (!done)
329
+ return;
330
+ const reduce = typeof window !== 'undefined' &&
331
+ window.matchMedia &&
332
+ window.matchMedia('(prefers-reduced-motion: reduce)').matches;
333
+ if (!faceGeo || reduce || !autoPlay) {
334
+ setFace(null);
335
+ setSheen(true);
336
+ return;
337
+ }
338
+ const timers = [];
339
+ let t = 0;
340
+ const at = (delay, fn) => {
341
+ t += delay;
342
+ timers.push(setTimeout(fn, t));
343
+ };
344
+ const pose = (patch) => setFace((f) => f && Object.assign(Object.assign({}, f), patch));
345
+ if (watch) {
346
+ // The eyes settle, blink once at the finished mark, then their files
347
+ // slide home into the P.
348
+ setLook([0, 0]);
349
+ pose({ blink: false });
350
+ at(650, () => pose({ blink: true }));
351
+ at(150, () => pose({ blink: false }));
352
+ at(350, () => pose({ blocks: false, at: 'home' }));
353
+ at(700, () => setFace(null));
354
+ }
355
+ // The waking face is the flourish for `wake`, so it skips the sheen.
356
+ if (!wake)
357
+ at(0, () => setSheen(true));
358
+ if (wake) {
359
+ // A beat on the finished mark, then stand-in files take over from the
360
+ // P's own and slide into a face.
361
+ at(700, () => setFace({
362
+ at: 'home',
363
+ blocks: false,
364
+ mouth: true,
365
+ smile: false,
366
+ blink: false,
367
+ wink: false,
368
+ visible: true,
369
+ hideLetters: true,
370
+ }));
371
+ at(60, () => pose({ at: 'face' }));
372
+ at(600, () => pose({ blocks: true, smile: true }));
373
+ at(700, () => pose({ blink: true }));
374
+ at(140, () => pose({ blink: false }));
375
+ at(600, () => pose({ wink: true }));
376
+ at(420, () => pose({ wink: false }));
377
+ at(650, () => pose({ blocks: false, smile: false, at: 'home' }));
378
+ at(700, () => setFace(null));
379
+ }
380
+ return () => timers.forEach(clearTimeout);
381
+ // eslint-disable-next-line react-hooks/exhaustive-deps
382
+ }, [done, playKey, faceGeo, watch, wake, autoPlay]);
196
383
  // Easing for the per-cell fill-in so each sample lands softly.
197
384
  const ease = (t) => 1 - Math.pow(1 - t, 2);
198
385
  // Connector geometry — the full path through the active group's cell
@@ -241,6 +428,9 @@ const FileCityLogoAnimated = (props) => {
241
428
  const reveal = done ? 1 : ease(progress[i] / stepsFor[i]);
242
429
  if (reveal <= 0)
243
430
  return null;
431
+ // While the stand-in files are performing, they are the P.
432
+ if (cell.isLetter && (face === null || face === void 0 ? void 0 : face.hideLetters))
433
+ return null;
244
434
  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 }));
245
435
  };
246
436
  const showTrail = connectors && connectorPath && conn && !done;
@@ -270,12 +460,52 @@ const FileCityLogoAnimated = (props) => {
270
460
  animation: `${DOT_POP} 220ms ease-out ${delay}ms both`,
271
461
  } }));
272
462
  }))) : null;
273
- 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) },
463
+ // The face: eleven files that slide between the P's squares and the face's,
464
+ // a solid block over each eye, and the smile's two corner files.
465
+ const slide = 'cubic-bezier(0.3, 1.25, 0.5, 1)';
466
+ const faceLayer = face && faceGeo ? (react_1.default.createElement("g", { style: { opacity: face.visible ? 1 : 0, transition: 'opacity 320ms ease', pointerEvents: 'none' } },
467
+ faceGeo.tiles.map((tile, i) => {
468
+ const pos = face.at === 'face' ? tile.face : tile.home;
469
+ const isEye = tile.part !== 'mouth';
470
+ const covered = isEye && face.blocks;
471
+ return (react_1.default.createElement("rect", { key: tile.key, x: 0, y: 0, width: faceGeo.sq, height: faceGeo.sq, rx: faceGeo.rx, stroke: tile.stroke, strokeWidth: tile.strokeWidth, style: {
472
+ transform: `translate(${pos.x}px, ${pos.y}px)`,
473
+ fill: face.at === 'face' && isEye ? faceGeo.eyeColor : tile.fill,
474
+ opacity: covered || (!isEye && !face.mouth) ? 0 : 1,
475
+ // Hide under the eye block only once it has faded in.
476
+ transition: `transform 560ms ${slide} ${i * 22}ms, fill 420ms ease ${i * 22}ms, opacity 0ms linear ${covered ? 170 : 0}ms`,
477
+ } }));
478
+ }),
479
+ react_1.default.createElement("g", { style: {
480
+ transform: `translate(${look[0] * faceGeo.pitch}px, ${look[1] * faceGeo.pitch}px)`,
481
+ // A slow, even glide — no snap or overshoot.
482
+ transition: 'transform 700ms cubic-bezier(0.45, 0, 0.25, 1)',
483
+ } }, ['eyeL', 'eyeR'].map((key) => {
484
+ const eye = faceGeo.eyes[key];
485
+ const shut = face.blink || (face.wink && key === 'eyeR');
486
+ return (react_1.default.createElement("rect", { key: key, x: eye.x, y: eye.y, width: eye.size, height: eye.size, rx: Math.max(faceGeo.rx, faceGeo.sq * 0.14), fill: faceGeo.eyeColor, style: {
487
+ opacity: face.blocks ? 1 : 0,
488
+ transformBox: 'fill-box',
489
+ transformOrigin: '50% 100%',
490
+ transform: `scaleY(${shut ? 0.16 : 1})`,
491
+ transition: 'opacity 170ms ease, transform 110ms ease-out',
492
+ } }));
493
+ })),
494
+ faceGeo.corners.map((corner, i) => (react_1.default.createElement("rect", { key: `corner-${i}`, x: corner.x, y: corner.y, width: faceGeo.sq, height: faceGeo.sq, rx: faceGeo.rx, fill: faceGeo.mouthColor, style: {
495
+ opacity: face.smile ? 1 : 0,
496
+ transformBox: 'fill-box',
497
+ transformOrigin: 'center',
498
+ transform: `scale(${face.smile ? 1 : 0.3})`,
499
+ transition: `opacity 200ms ease, transform 260ms ${slide}`,
500
+ } }))))) : null;
501
+ return (react_1.default.createElement(FileCityLogo_1.FileCityPanel, { width: width, height: height, bgColor: bgColor, baseColor: baseColor, rounded: rounded, opacity: opacity, gloss: gloss, ribbon: ribbon, label: (0, FileCityLogo_1.fileCityLabel)(mark) },
502
+ face && !face.hideLetters ? faceLayer : null,
274
503
  cells.map((cell, i) => renderCell(cell, i)),
504
+ face && face.hideLetters ? faceLayer : null,
275
505
  trailLine,
276
506
  trailDots,
277
507
  done ? extras : null,
278
- done ? (react_1.default.createElement(react_1.default.Fragment, null,
508
+ sheen ? (react_1.default.createElement(react_1.default.Fragment, null,
279
509
  react_1.default.createElement("style", null, `@keyframes ${SHEEN}{from{transform:translateX(-120px)}to{transform:translateX(120px)}}`),
280
510
  react_1.default.createElement("defs", null,
281
511
  react_1.default.createElement("clipPath", { id: `sheen-clip-${uid}` }, 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 })))),
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import type { Theme } from '@principal-ade/industry-theme';
3
+ /**
4
+ * Banner-native sibling of {@link TrailCityDiagram}.
5
+ *
6
+ * Same visual DNA — a seeded top-down city of file "buildings" with a dashed
7
+ * trail threading numbered markers — but composed for wide, short social
8
+ * banners instead of a 700×700 square:
9
+ * • the city is a wide strip whose column/row count derives from the frame,
10
+ * • the trail runs left→right with a gentle wave,
11
+ * • the left edge fades out to reserve room for a platform logo / wordmark,
12
+ * • the tall 280×200 snippet card is replaced by a compact code chip.
13
+ *
14
+ * Presets target the two surfaces we ship:
15
+ * • twitterHeader — 1500 × 500 (3:1)
16
+ * • linkedinCompany — 1128 × 191 (~5.9:1)
17
+ */
18
+ export type BannerVariant = 'twitterHeader' | 'linkedinCompany' | 'linkedinProfile';
19
+ export interface TrailCityBannerProps {
20
+ /** Theme supplying colors. Falls back to dark-mode defaults when absent. */
21
+ theme?: Theme;
22
+ /** Class applied to the wrapping <svg>. */
23
+ className?: string;
24
+ /** Preset surface. Ignored for sizing if width/height are both given. */
25
+ variant?: BannerVariant;
26
+ /** Override the native frame width (defaults to the variant). */
27
+ width?: number;
28
+ /** Override the native frame height (defaults to the variant). */
29
+ height?: number;
30
+ /** Deterministic layout seed — change it to reshuffle the skyline. */
31
+ seed?: number;
32
+ /** Keep the left portion clear of the trail/markers so a logo or wordmark
33
+ * can overlay there. (No visual fade — just shifts where the trail starts.) */
34
+ reserveLeft?: boolean;
35
+ /** Show the dashed trail + numbered markers. */
36
+ showTrail?: boolean;
37
+ /** Show the compact code chip near the focal marker. Defaults per variant. */
38
+ showChip?: boolean;
39
+ /**
40
+ * Which marker (1-based) the code chip's leader connects to — also the
41
+ * highlighted/active marker. Defaults to 2.
42
+ */
43
+ leaderMarker?: number;
44
+ /**
45
+ * When set, the banner drops the random skyline + trail and instead spells
46
+ * this text *out of the city* — primary-colored "buildings" forming the
47
+ * letters against the muted city, the wide-banner sibling of
48
+ * {@link FileCityLogo}'s `mark="P"`. Rendered uppercase, single baseline,
49
+ * centered with a vertical letterbox of city.
50
+ */
51
+ wordmark?: string;
52
+ }
53
+ export declare function TrailCityBanner({ theme, className, variant, width, height, seed, reserveLeft, showTrail, showChip, leaderMarker, wordmark, }: TrailCityBannerProps): React.JSX.Element;