@logomarks/lookbook 0.4.0 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,72 @@ All notable changes to `@logomarks/lookbook` are documented here.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.0] — 2026-11-28
9
+
10
+ ### Fixed
11
+
12
+ - **A long name fits its card** (`fitName`, `fitNames`, `fitWatch` in `/live`, ./fit.js): a long name in a wide face ran
13
+ off the card's edge (ROSEMARY in Unbounded showed as ROSEMAF on the duo look). Each name is measured against its
14
+ card and, where it would cross the card's edge less a 5% margin, set smaller until it clears: never clipped, never
15
+ wrapped, never larger than its look made it, and fitted from its look's size each time (`data-fs`), so the expanded
16
+ view's bigger copy isn't left small. `liveCards` keeps every name it watches fitted (as cards come, when a card changes
17
+ size, when the web fonts load, and on `watch()`); `fit: false` leaves them. `refit` (a name typed in the toolbar) fits
18
+ the name too. Measured on the preview with long names in Unbounded, Michroma and Syne at 267 px: 25 of 78 names ran
19
+ off before, none after.
20
+
21
+ ### Added
22
+
23
+ - **The stark set** (./looks/stark.js), on the 2026-11-28 photos; both at weight 0, dealt only where a wall gives them
24
+ one, like the field and glass cards:
25
+ - `brutal` ("Brutalist poster"): a Swiss poster on the brutalist concrete photos (`brutal-*` in the glass set): the
26
+ photo grey and dark, the mark big in white top left, the name in Michroma capitals the full measure over a hairline
27
+ (sized from its width, `wideEms`, `data-fit="wide"`), the trade and the address under it, an issue number. Still.
28
+ - `sortglitch` ("Glitch card"): a pixel-sorted portrait (`pixelsort-*` in the photos), the mark clean in white, the
29
+ name cut into four or five level slices, one pushed well aside and one in an accent, like the photo's sort bands.
30
+ The slices are empty `<i>`s drawn from `data-t` by `::before`, so the name's text is one word for the toolbar and
31
+ screen readers; `refit` cuts them again for a typed name (`slices()`). While live the slices jump twice and settle
32
+ (CSS, 5 s, `LOOK_LOOP`); the still is where they settle. Downloads as a PNG and a looping video.
33
+ - The acid map takes the new close portraits too: `rimlight-*`, `dithered-*` and `offfocus-*`.
34
+ - `wideEms` moved to ./looks/kit.js (still exported from `/looks`).
35
+ - **Two field cards** after the owner's 2026-11-28 backgrounds, at weight 0 like every field (dealt where a wall gives them
36
+ one), drawn by @arraypress/effects-astro 0.14:
37
+ - `fluidfolds` ("Liquid folds", effect `fluid-folds`): glossy folds of liquid colour on a dark ground, poured enamel or
38
+ long silk dunes, an iridescent rim and a highlight on each crest; five colourways (enamel, cobalt and rose, ember,
39
+ graphite silk, acid), the lockup over a dimmed middle. After his Fluid backgrounds.
40
+ - `reededbokeh` ("Reeded bokeh", effect `fluted-bokeh`): coloured lights out of focus behind upright reeds, a thin
41
+ rainbow at each seam, or behind a wall of glass blocks (one card in four); five colourways (stage, cobalt night,
42
+ amber, signal mix, acid). After his Fluted Glass backgrounds.
43
+ - The dithered gradient (`dithergrad`) deals two new shapes, a soft orb and a glowing pill set off the middle, and five
44
+ three-colour ways after his Dithered Gradient backgrounds (coral dusk, ember and ice, violet heat, mint, daylight).
45
+
46
+ ### Dependencies
47
+
48
+ - `@arraypress/effects-astro` ^0.14.0 (the two new fields' effects; publish it first).
49
+
50
+ ## [0.5.0] — 2026-11-26
51
+
52
+ ### Fixed
53
+
54
+ - The hover name pill is solid (a see-through one let the card's corner words bleed through), and a look's top-right
55
+ corner words fade out while the pill is shown there; on touch, where the pill always shows, that corner stays clear.
56
+
57
+ ### Added
58
+
59
+ - **Two glass cards** (`GLASS`, `isGlass`, `./glass.js`): the mark itself drawn live in glass by
60
+ @arraypress/effects-astro 0.13, started on screen like a shader card (ten at a time), the name under it, six colourways
61
+ each, off unless a wall gives it a weight. `glassdrop` ("Liquid glass": a drop lands and spreads into a glass tile with
62
+ the mark rising under it, or into the mark's own shape in tinted glass, holds, melts and leaves the mark flat, on a
63
+ loop) and `glassstack` ("Glass slabs": the mark cut into slices of tinted glass discs in front of a lit card, growing
64
+ from the bottom up, then leaning gently). Our own effects after the ideas of reactdrops.dev's Liquid Glass Logo and
65
+ Glass Slab Logo, not their code (their licence forbids reuse in a component library).
66
+ - Each glass card's still is the mark laid exactly where the effect draws it (liquid glass: the flat mark its loop rests
67
+ on; glass slabs: the mark in bands of its tints on the lit card). The runner reads the mark from the still
68
+ (`markSource` in `/live`) and hands it to the effect, so the paths are in the page once.
69
+
70
+ ### Dependencies
71
+
72
+ - `@arraypress/effects-astro` ^0.13.0.
73
+
8
74
  ## [0.4.0] — 2026-11-26
9
75
 
10
76
  ### Added
package/README.md CHANGED
@@ -37,10 +37,10 @@ holoPointer();
37
37
 
38
38
  ## What's in it
39
39
 
40
- - `@logomarks/lookbook`: `lookbook({ brand, faces, accent?, palettes?, weights?, href?, skip? })` gives `card`, `feed` and `backgrounds` (`weights: { asciinoise: 1 }` deals a field card, which is otherwise off: `FIELDS` lists them, live effects-astro backgrounds such as ASCII noise, light leak, dither, cascade grid, flow field, Voronoi mesh, kinetic grid, dithered gradient, Truchet tiles, pixel horizon and reeded glow); `shuffled`; the promo cards `headlineCard`, `sponsorCard`, `openSlotCard`; `WEIGHTS`, `KIND_LABEL`, `EVERY`, `ACCENT` (`#C8FF00`) and the look tables.
41
- - `@logomarks/lookbook/looks`: the drawn looks, `LOOK_KINDS`, `LOOK_LABEL`, `LOOK_LOOP` (each moving look's loop, for a video), `LOOK_RATIO`, `LOOK_WEIGHTS`, `retarget` (another mark on a card) and `refit`.
40
+ - `@logomarks/lookbook`: `lookbook({ brand, faces, accent?, palettes?, weights?, href?, skip? })` gives `card`, `feed` and `backgrounds` (`weights: { asciinoise: 1 }` deals a field card, which is otherwise off: `FIELDS` lists them, live effects-astro backgrounds such as ASCII noise, light leak, dither, cascade grid, flow field, Voronoi mesh, kinetic grid, dithered gradient, Truchet tiles, pixel horizon, reeded glow, liquid folds and reeded bokeh; and `GLASS`, the glass cards, the mark itself drawn live in glass: liquid glass and glass slabs); `shuffled`; the promo cards `headlineCard`, `sponsorCard`, `openSlotCard`; `WEIGHTS`, `KIND_LABEL`, `EVERY`, `ACCENT` (`#C8FF00`) and the look tables.
41
+ - `@logomarks/lookbook/looks`: the drawn looks, `LOOK_KINDS`, `LOOK_LABEL`, `LOOK_LOOP` (each moving look's loop, for a video), `LOOK_RATIO`, `LOOK_WEIGHTS`, `retarget` (another mark on a card) and `refit` (a typed name sized, sliced and fitted again).
42
42
  - `@logomarks/lookbook/marks`: a mark's box, ink share, optical size (`opticalVars`), cells and heat field; the box, ink, size and cells are `@logomarks/core`'s, re-exported.
43
- - `@logomarks/lookbook/live`: `liveCards`, `shaders` (Paper's shaders and the field cards' effects, each loaded when first needed), `smoke` with its presets `SMOKE`, and `holoPointer`.
43
+ - `@logomarks/lookbook/live`: `liveCards`, `shaders` (Paper's shaders and the field cards' effects, each loaded when first needed), `smoke` with its presets `SMOKE`, `holoPointer`, and `fitName`, `fitNames` and `fitWatch` (every card's name fitted to its card; `liveCards` runs it on what it watches, `fit: false` turns it off). A page that shows cards without `liveCards` calls `fitWatch(scope)` itself.
44
44
  - `wall.css` and `wall-looks.css`: the cards and the drawn looks. They read the page's theme tokens (`--text`, `--muted`, `--border`, `--surface`, `--display`, `--mono`) and the accent `--hi`.
45
45
 
46
46
  The pictures go by their file names: `club-N` the club hall, `club-dancer-N` and `club-crowd-N` its people, portraits (`modern`, `y2k` …) and the rest in `photos`; flowers (`bloom-N`, `dahlia-N`, `iris-N`, `lily-N`, `marigold-N`, `palm-N`) and abstracts in `glass`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@logomarks/lookbook",
3
- "version": "0.4.0",
4
- "description": "A logomark dressed as a made-up brand, in sixty-odd looks: on a photo, glass, a colour, paper or a live gradient, or the mark itself redrawn (traced, constructed, reeded, pixelated, neon, split-flap, contoured, thermal, liquid chrome, holo foil, ASCII, embroidered, frosted, editorial and more). Pure functions returning HTML, the same on the server and in the browser, with their CSS (motion in CSS only, a still final frame, a Plain mode), an optical size for wide, slim or light marks, and a browser runner that starts only what's near the screen.",
3
+ "version": "0.6.0",
4
+ "description": "A logomark dressed as a made-up brand, in sixty-odd looks: on a photo, glass, a colour, paper or a live gradient, or the mark itself redrawn (traced, constructed, reeded, pixelated, neon, split-flap, contoured, thermal, liquid chrome, holo foil, ASCII, embroidered, frosted, editorial, liquid glass, glass slabs and more). Pure functions returning HTML, the same on the server and in the browser, with their CSS (motion in CSS only, a still final frame, a Plain mode), an optical size for wide, slim or light marks, and a browser runner that starts only what's near the screen.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "types": "src/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  "registry": "https://registry.npmjs.org/"
76
76
  },
77
77
  "dependencies": {
78
- "@arraypress/effects-astro": "^0.12.0",
78
+ "@arraypress/effects-astro": "^0.14.0",
79
79
  "@arraypress/og-image": "^1.5.1",
80
80
  "@arraypress/text": "^2.2.0",
81
81
  "@logomarks/core": "^0.2.1"
package/src/fields.d.ts CHANGED
@@ -18,7 +18,9 @@ export type FieldKind =
18
18
  | 'dithergrad'
19
19
  | 'truchet'
20
20
  | 'pixelhorizon'
21
- | 'flutedglow';
21
+ | 'flutedglow'
22
+ | 'fluidfolds'
23
+ | 'reededbokeh';
22
24
 
23
25
  /** What a field card is dealt from: the card's seeded pick and random, the accent, and the wall's monospaced face. */
24
26
  export type FieldDeal = {
package/src/fields.js CHANGED
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * The field cards: a live background drawn by one of @arraypress/effects-astro's fields (ASCII noise, …), started on
5
5
  * screen like a shader card (`./live.js`), the lockup over a quiet middle. Most came from Processing sketches a friend of
6
- * the owner shared (2026-11-20), modernised in effects-astro; four from reference images the owner collected (2026-11-26).
6
+ * the owner shared (2026-11-20), modernised in effects-astro; four from reference images the owner collected (2026-11-26);
7
+ * two more (liquid folds, reeded bokeh) and the dithered gradient's orb, pill and three-colour ways after his Fluid, Fluted
8
+ * Glass and Dithered Gradient backgrounds (2026-11-28).
7
9
  *
8
10
  * Each field says which effect draws it, its label, and how a card deals it: the effect's settings, the card's ground
9
11
  * and ink, what shows before the effect starts (a CSS `still`, or markup laid `under` the canvas), and whether the name
@@ -22,6 +24,8 @@ import { gradientStill } from '@arraypress/effects-astro/runtime/dither-gradient
22
24
  import { truchetStill } from '@arraypress/effects-astro/runtime/truchet-field';
23
25
  import { horizonStill } from '@arraypress/effects-astro/runtime/pixel-horizon';
24
26
  import { glowStill } from '@arraypress/effects-astro/runtime/fluted-glow';
27
+ import { foldsStill } from '@arraypress/effects-astro/runtime/fluid-folds';
28
+ import { bokehStill } from '@arraypress/effects-astro/runtime/fluted-bokeh';
25
29
 
26
30
  /** The glyphs' face when the wall has no monospaced one. */
27
31
  export const MONO_FALLBACK = 'ui-monospace, SFMono-Regular, Menlo, monospace';
@@ -302,14 +306,21 @@ const gradientInksOf = (accent) => [
302
306
  ['#2A0612', ['#0E5A5A', '#4FE3E8'], '#F4F3EF'], // cyan on maroon
303
307
  ['#0B0B0B', ['#5A1A08', '#FF3D00'], '#F4F3EF'], // signal
304
308
  ['#F4F3EF', ['#9AA6C6', '#0038FF'], '#0B0B0B'], // paper
309
+ // after the owner's Dithered Gradient photos (2026-11-28): three colours, dim through a middle to bright
310
+ ['#05070D', ['#16245C', '#FF4A3D', '#FFB48A'], '#F4F3EF'], // coral dusk
311
+ ['#03060A', ['#0B3A4A', '#FF6A2A', '#7FE3FF'], '#F4F3EF'], // ember and ice
312
+ ['#0A0414', ['#3A1A8A', '#FF2F7A', '#FF9A5A'], '#F4F3EF'], // violet heat
313
+ ['#020806', ['#0B4A3A', '#24C98A', '#E8FFF4'], '#F4F3EF'], // mint
314
+ ['#F4F1EC', ['#F7B8A8', '#FF4A3D', '#2A5BFF'], '#0B0B0B'], // daylight
305
315
  ];
306
316
 
307
- /** dithergrad: a soft gradient drawn only in dots (a wavy horizon, a band of light, a swirl, a pinwheel or falling steps),
317
+ /** dithergrad: a soft gradient drawn only in dots (a wavy horizon, a band of light, a swirl, a pinwheel, falling steps, a soft
318
+ * orb or a glowing pill),
308
319
  * square dots an ordered dither thins out or round halftone dots that shrink. */
309
320
  function dithergrad({ pick, r, accent }) {
310
321
  const [ground, colors, ink] = pick(gradientInksOf(accent));
311
- const shape = pick(['wave', 'wave', 'band', 'swirl', 'pinwheel', 'steps']);
312
- const mode = shape === 'band' ? pick(['halftone', 'halftone', 'bayer']) : pick(['bayer', 'bayer', 'halftone']);
322
+ const shape = pick(['wave', 'wave', 'band', 'swirl', 'pinwheel', 'steps', 'orb', 'orb', 'pill']);
323
+ const mode = shape === 'band' || shape === 'orb' || shape === 'pill' ? pick(['halftone', 'halftone', 'bayer']) : pick(['bayer', 'bayer', 'halftone']);
313
324
  const cfg = {
314
325
  colors,
315
326
  background: ground,
@@ -321,9 +332,12 @@ function dithergrad({ pick, r, accent }) {
321
332
  ...(shape === 'swirl' ? { arms: pick([2, 3]), twist: between(r, 1.5, 2.5), soft: 0.5 } : {}),
322
333
  ...(shape === 'pinwheel' ? { arms: pick([4, 5, 6]), twist: between(r, 1, 2), soft: 0.4 } : {}),
323
334
  ...(shape === 'steps' ? { level: between(r, 0.18, 0.24), block: pick([5, 6, 7]) } : {}),
335
+ ...(shape === 'orb' ? { size: between(r, 0.3, 0.38), soft: between(r, 0.7, 0.95), centre: pick([[0.5, 0.84], [0.28, 0.2], [0.72, 0.8]]) } : {}),
336
+ ...(shape === 'pill' ? { size: between(r, 0.24, 0.3), soft: between(r, 0.65, 0.9), angle: pick([90, 90, 75, 105]), centre: pick([[0.5, 0.84], [0.5, 0.18]]) } : {}),
324
337
  rate: between(r, 0.04, 0.07),
325
338
  offset: offsetOf(r),
326
- quiet: { radius: 0.5, depth: 1 },
339
+ // an orb or a pill sits off the middle, so its quiet area is smaller and lighter
340
+ quiet: shape === 'orb' || shape === 'pill' ? { radius: 0.34, depth: 0.85 } : { radius: 0.5, depth: 1 },
327
341
  };
328
342
  return { cfg, ground, ink, still: gradientStill(cfg) };
329
343
  }
@@ -414,6 +428,71 @@ function flutedglow({ pick, r, accent }) {
414
428
  return { cfg, ground, ink, still: glowStill(cfg, CARD) };
415
429
  }
416
430
 
431
+ /* ---------- Liquid folds (effects-astro's fluidFolds, after the owner's Fluid backgrounds, 2026-11-28) ---------- */
432
+
433
+ /** Liquid folds' colours: ground, [deep, mid, hot], the lockup's ink. */
434
+ const foldInksOf = (accent) => [
435
+ ['#050409', ['#1638FF', '#7B2CFF', '#FF4A3D'], '#F4F3EF'], // enamel
436
+ ['#030308', ['#0B2A8A', '#3D6BFF', '#FF3D7A'], '#F4F3EF'], // cobalt and rose
437
+ ['#060304', ['#5A0A1A', '#FF3D2A', '#FFB347'], '#F4F3EF'], // ember
438
+ ['#040507', ['#2A2E3A', '#8C93A6', '#E8ECF4'], '#F4F3EF'], // graphite silk
439
+ ['#030806', ['#0E5A35', accent, '#E8FFE0'], '#F4F3EF'], // acid
440
+ ];
441
+
442
+ /** fluidfolds: glossy folds of liquid colour on a dark ground, poured enamel or long silk dunes, the lockup in a dimmed
443
+ * middle. */
444
+ function fluidfolds({ pick, r, accent }) {
445
+ const [ground, colors, ink] = pick(foldInksOf(accent));
446
+ const style = pick(['liquid', 'liquid', 'dunes']);
447
+ const cfg = {
448
+ colors,
449
+ background: ground,
450
+ style,
451
+ scale: style === 'liquid' ? between(r, 1.7, 2.4) : between(r, 1.2, 1.6),
452
+ warp: between(r, 0.7, 1.1),
453
+ gloss: between(r, 0.6, 0.9),
454
+ light: pick([-35, -20, 25, 40]),
455
+ hue: between(r, 0.35, 0.7),
456
+ ...(style === 'dunes' ? { level: between(r, 0.42, 0.55) } : {}),
457
+ rate: between(r, 0.025, 0.045),
458
+ seed: Math.round(r() * 1000) / 100,
459
+ quiet: { radius: 0.42, depth: 0.55 },
460
+ };
461
+ return { cfg, ground, ink, still: foldsStill(cfg) };
462
+ }
463
+
464
+ /* ---------- Reeded bokeh (effects-astro's flutedBokeh, after the owner's Fluted Glass backgrounds, 2026-11-28) ---------- */
465
+
466
+ /** Reeded bokeh's colours: ground, the lights' colours, the lockup's ink. */
467
+ const bokehInksOf = (accent) => [
468
+ ['#050608', ['#FF4A2A', '#FFB347', '#4FC3FF'], '#F4F3EF'], // stage
469
+ ['#04060C', ['#2A6BFF', '#FF3D6A', '#7FE3FF'], '#F4F3EF'], // cobalt night
470
+ ['#070403', ['#FF6A2A', '#FFD27A', '#FF3D00'], '#F4F3EF'], // amber
471
+ ['#030807', ['#1EC98A', '#FF5A3D', '#3DA9FF'], '#F4F3EF'], // signal mix
472
+ ['#050605', [accent, '#4FC3FF', '#F4F3EF'], '#F4F3EF'], // acid
473
+ ];
474
+
475
+ /** reededbokeh: coloured lights out of focus behind upright reeded glass (a rainbow at each seam) or a wall of glass
476
+ * blocks, drifting slowly. */
477
+ function reededbokeh({ pick, r, accent }) {
478
+ const [ground, colors, ink] = pick(bokehInksOf(accent));
479
+ const mode = pick(['reeds', 'reeds', 'reeds', 'blocks']);
480
+ const cfg = {
481
+ colors,
482
+ background: ground,
483
+ mode,
484
+ flutes: mode === 'blocks' ? pick([7, 8, 9]) : pick([22, 28, 34, 40]),
485
+ squeeze: mode === 'blocks' ? between(r, 0.25, 0.4) : between(r, 0.22, 0.36),
486
+ dispersion: between(r, 0.25, 0.45),
487
+ streak: mode === 'blocks' ? 0.02 : between(r, 0.04, 0.09),
488
+ lights: pick([4, 5, 6]),
489
+ size: between(r, 0.18, 0.26),
490
+ seed: Math.round(r() * 1000) / 10,
491
+ quiet: { radius: 0.4, depth: 0.5 },
492
+ };
493
+ return { cfg, ground, ink, still: bokehStill(cfg, CARD) };
494
+ }
495
+
417
496
  /* ---------- the table ---------- */
418
497
 
419
498
  /** The field cards by kind: the effect that draws each (effects-astro's runtime, by its file name), its label, and its
@@ -430,6 +509,8 @@ export const FIELDS = {
430
509
  truchet: { effect: 'truchet-field', label: 'Truchet tiles', deal: truchet },
431
510
  pixelhorizon: { effect: 'pixel-horizon', label: 'Pixel horizon', deal: pixelhorizon },
432
511
  flutedglow: { effect: 'fluted-glow', label: 'Reeded glow', deal: flutedglow },
512
+ fluidfolds: { effect: 'fluid-folds', label: 'Liquid folds', deal: fluidfolds },
513
+ reededbokeh: { effect: 'fluted-bokeh', label: 'Reeded bokeh', deal: reededbokeh },
433
514
  };
434
515
 
435
516
  /** Whether a kind is a field card. */
package/src/fit.js ADDED
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @module @logomarks/lookbook/fit
3
+ *
4
+ * Every card's name fits its card, in the browser. A look sets its name's size for a name of usual length; a long name
5
+ * in a wide face (ROSEMARY in Unbounded, KALEIDOSCOPE in Michroma) ran off the card's edge. `fitName` measures the name
6
+ * against its card and, where it would cross the card's edge (less a small margin), sets it smaller until it clears:
7
+ * never clipped, never wrapped, never larger than its look made it. The size it had is kept (`data-fs`), so a name fitted
8
+ * on a small card and shown again in a large one (the expanded view's copy) starts from its look's size each time.
9
+ *
10
+ * `fitNames` fits every name under an element, `fitWatch` keeps them fitted as cards come, change size, or the web fonts
11
+ * load (`liveCards` runs it on the wall it watches). A width-sized name (the terminal's, the editorial's: `data-fit`,
12
+ * sized in CSS from `--chars`) is fitted too, in case its face measures wider than the estimate.
13
+ */
14
+
15
+ /** The names a card can show. */
16
+ const NAMES = '.wc-name';
17
+
18
+ /** The card a name is on. */
19
+ const cardOf = (el) => el.closest('.wc, .lv-card');
20
+
21
+ /**
22
+ * The room a name may take: its card's box less a margin each side (5% of the card's width, at least 6 px), so a fitted
23
+ * name never touches the edge.
24
+ *
25
+ * @param card The card.
26
+ */
27
+ function room(card) {
28
+ const r = card.getBoundingClientRect();
29
+ const m = Math.max(6, r.width * 0.05);
30
+ return { left: r.left + m, right: r.right - m };
31
+ }
32
+
33
+ /**
34
+ * Fits one name to its card: back to its look's size first, then, if it would cross the card's edge, smaller by what
35
+ * it crosses (a centred lockup clears by the same measure as a left-aligned one), up to four passes for a face whose
36
+ * width doesn't scale exactly with its size.
37
+ *
38
+ * @param el The name (`.wc-name`).
39
+ * @returns The scale it was set at (1: as its look made it).
40
+ */
41
+ export function fitName(el) {
42
+ const card = cardOf(el);
43
+ if (!card) return 1;
44
+ // back to its look's size: what it had in its style before any fitting
45
+ if (el.dataset.fs === undefined) el.dataset.fs = el.style.fontSize || '';
46
+ el.style.fontSize = el.dataset.fs;
47
+ const r0 = el.getBoundingClientRect();
48
+ if (!r0.width || !r0.height) return 1; // hidden (a Plain card's name while the look shows, or the reverse)
49
+ const base = parseFloat(getComputedStyle(el).fontSize);
50
+ if (!base) return 1;
51
+ let k = 1;
52
+ for (let pass = 0; pass < 4; pass++) {
53
+ const { left, right } = room(card);
54
+ const r = el.getBoundingClientRect();
55
+ const over = Math.max(0, left - r.left) + Math.max(0, r.right - right);
56
+ if (over < 0.5) break;
57
+ k *= Math.max(0.2, (r.width - over) / r.width);
58
+ el.style.fontSize = `${(base * k).toFixed(2)}px`;
59
+ }
60
+ return k;
61
+ }
62
+
63
+ /**
64
+ * Fits every name under `scope`.
65
+ *
66
+ * @param scope Where to look (the document, a wall, a card).
67
+ */
68
+ export function fitNames(scope = document) {
69
+ const own = scope instanceof Element && scope.matches(NAMES) ? [scope] : [];
70
+ for (const el of [...own, ...scope.querySelectorAll(NAMES)]) fitName(el);
71
+ }
72
+
73
+ /**
74
+ * Keeps the names under `scope` fitted: now, when the web fonts finish loading, when a card changes size, and when
75
+ * cards are added under the `observe` elements.
76
+ *
77
+ * @param scope Where the cards are.
78
+ * @param options `observe`: elements whose new cards are fitted as they come (the wall, the expanded view).
79
+ * @returns Stops watching.
80
+ */
81
+ export function fitWatch(scope = document, options = {}) {
82
+ const sizes = new WeakMap();
83
+ const ro =
84
+ typeof ResizeObserver === 'function'
85
+ ? new ResizeObserver((entries) => {
86
+ for (const e of entries) {
87
+ const w = Math.round(e.contentRect.width);
88
+ if (sizes.get(e.target) === w) continue;
89
+ sizes.set(e.target, w);
90
+ fitNames(e.target);
91
+ }
92
+ })
93
+ : null;
94
+ const seen = new WeakSet();
95
+ const add = (root) => {
96
+ for (const card of root.querySelectorAll('.wc, .lv-card')) {
97
+ if (seen.has(card)) continue;
98
+ seen.add(card);
99
+ ro?.observe(card);
100
+ fitNames(card);
101
+ }
102
+ };
103
+ add(scope);
104
+ const fonts = typeof document !== 'undefined' ? document.fonts : undefined;
105
+ const again = () => fitNames(scope);
106
+ fonts?.ready.then(again).catch(() => {});
107
+ fonts?.addEventListener?.('loadingdone', again);
108
+ const mos = (options.observe ?? []).map((el) => {
109
+ const mo = new MutationObserver(() => add(el));
110
+ mo.observe(el, { childList: true, subtree: true });
111
+ return mo;
112
+ });
113
+ return () => {
114
+ ro?.disconnect();
115
+ for (const mo of mos) mo.disconnect();
116
+ fonts?.removeEventListener?.('loadingdone', again);
117
+ };
118
+ }
package/src/glass.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @module @logomarks/lookbook/glass
3
+ *
4
+ * The glass cards: the mark itself drawn live in glass by one of @arraypress/effects-astro's glass logos (liquid glass,
5
+ * glass slabs), started on screen like a shader card, the name under it.
6
+ */
7
+
8
+ /** The glass cards' kinds. */
9
+ export type GlassKind = 'glassdrop' | 'glassstack';
10
+
11
+ /** What a glass card is dealt from: the card's seeded pick and random, the accent, the mark's paths and the card's id. */
12
+ export type GlassDeal = {
13
+ pick: <T>(xs: readonly T[]) => T;
14
+ r: () => number;
15
+ accent: string;
16
+ paths: string;
17
+ uid: string;
18
+ };
19
+
20
+ /** A dealt glass card: the effect's settings, the card's ground and the name's ink, and the still mark laid under the
21
+ * canvas (an `<svg class="wc-gm">` holding the mark's paths in a `data-m` group). */
22
+ export type GlassCard = { cfg: Record<string, unknown>; ground: string; ink: string; under: string };
23
+
24
+ /** A glass card: the effects-astro effect that draws it (its runtime file's name), its label, and its deal. */
25
+ export type Glass = { effect: string; label: string; deal: (d: GlassDeal) => GlassCard };
26
+
27
+ /** The glass cards by kind. */
28
+ export declare const GLASS: Record<GlassKind, Glass>;
29
+ /** Whether a kind is a glass card. */
30
+ export declare const isGlass: (k: string) => k is GlassKind;
31
+ /** A glass card's name and line, under the glass. */
32
+ export declare const glassFoot: (name: string, line: string, type: string) => string;
package/src/glass.js ADDED
@@ -0,0 +1,154 @@
1
+ /**
2
+ * @module @logomarks/lookbook/glass
3
+ *
4
+ * The glass cards: the mark itself drawn live in glass by one of @arraypress/effects-astro's glass logos, started on
5
+ * screen like a shader card (`./live.js`, ten at a time), the name under it. Liquid glass: a drop lands and spreads into
6
+ * a glass tile with the mark rising under it (or into the mark's own shape, in tinted glass), holds, and melts away to
7
+ * leave the mark flat, on a loop. Glass slabs: the mark cut into slices, each a stack of tinted glass discs in front of a
8
+ * lit card, growing from the bottom up, then leaning gently. Both are our own effects after reactdrops.dev's Liquid
9
+ * Glass Logo and Glass Slab Logo (the idea, not their code: their licence forbids reuse in a component library).
10
+ *
11
+ * Each card's still is markup under the canvas, laid exactly where the effect draws the mark: for liquid glass, the
12
+ * flat mark the loop ends on (its final frame); for glass slabs, the mark cut into bands in the glass's tints. The
13
+ * runner reads the mark from the still (`data-m`) and hands it to the effect, so the paths are in the page once.
14
+ *
15
+ * Pure: everything comes from the card's seeded random, so the page and its script deal identical cards.
16
+ */
17
+
18
+ import { escapeHtml } from '@arraypress/text';
19
+ import { dropLayout } from '@arraypress/effects-astro/runtime/glass-drop-plan';
20
+ import { sliceTints, stackLayout } from '@arraypress/effects-astro/runtime/glass-stack';
21
+ import { markBox, inkShare, opticalScale } from './marks.js';
22
+
23
+ /** A glass card's shape, width over height (4:5, like the field cards). */
24
+ const CARD = 4 / 5;
25
+ /** Where the glass sits on a card: the upper part, the name below it. */
26
+ const AREA = { x: 0.08, y: 0.07, width: 0.84, height: 0.62 };
27
+ /** The most a wide, slim or light mark grows (`opticalScale`), so it keeps clear of the name. */
28
+ const MAX_GROW = 1.18;
29
+
30
+ /** A number between two, at two decimals, from the card's random. */
31
+ const between = (r, lo, hi) => Math.round((lo + r() * (hi - lo)) * 100) / 100;
32
+ /** A number at two decimals, as SVG wants it. */
33
+ const f2 = (n) => String(Math.round(n * 100) / 100);
34
+ /** A number as a CSS percentage. */
35
+ const pc = (n) => `${(Math.round(n * 10000) / 100).toString()}%`;
36
+ /** An sRGB triple (0–1) as hex. */
37
+ const hex = (rgb) => `#${rgb.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 255).toString(16).padStart(2, '0')).join('')}`;
38
+
39
+ /** How much a mark grows for its optical size (`./marks.js`), within the room the name leaves. */
40
+ const growOf = (paths) => Math.min(MAX_GROW, Math.max(1, opticalScale(markBox(paths), inkShare(paths))));
41
+
42
+ /**
43
+ * The still mark: an `<svg>` of the 512 canvas laid on the card exactly where the effect draws it (a square box, its
44
+ * middle and edge as shares of the card's height), the mark's paths in a `data-m` group the runner reads.
45
+ *
46
+ * @param centre The box's middle, each 0–1 from the top left.
47
+ * @param edge Its edge, a share of the card's height.
48
+ * @param body What's drawn (the `data-m` group, and any defs).
49
+ * @param extra More attributes for the `<svg>` (` overflow="visible"` to draw past the box).
50
+ */
51
+ function still(centre, edge, body, extra = '') {
52
+ const across = edge / CARD; // the edge as a share of the card's width
53
+ const style = `left:${pc(centre.x - across / 2)};top:${pc(centre.y - edge / 2)};width:${pc(across)};height:${pc(edge)}`;
54
+ return `<svg class="wc-gm" viewBox="0 0 512 512" style="${style}"${extra} aria-hidden="true">${body}</svg>`;
55
+ }
56
+
57
+ /* ---------- Liquid glass (effects-astro's glassDrop) ---------- */
58
+
59
+ /** Liquid glass cards' colours: ground, the mark, the tile's plate, the studio light, the name's ink, and what the drop
60
+ * becomes (a glass tile, or the mark's own shape in glass). */
61
+ const dropInksOf = (accent) => [
62
+ { ground: '#050505', mark: '#FFFFFF', plate: '#0B1226', light: '#FFFFFF', ink: '#F4F3EF', form: 'tile' }, // night
63
+ { ground: '#0B0B0B', mark: accent, plate: '#101405', light: '#F4FFD0', ink: '#F4F3EF', form: 'mark' }, // acid
64
+ { ground: '#0038FF', mark: '#FFFFFF', plate: '#002BB8', light: '#FFFFFF', ink: '#FFFFFF', form: 'tile' }, // cobalt
65
+ { ground: '#0B0B0B', mark: '#FF3D00', plate: '#1A0602', light: '#FFE3D6', ink: '#F4F3EF', form: 'mark' }, // signal
66
+ { ground: '#0E0520', mark: '#E9E2FF', plate: '#21104A', light: '#F2EEFF', ink: '#F4F3EF', form: 'tile' }, // violet
67
+ { ground: '#0B0B0B', mark: '#F4F3EF', plate: '#16171A', light: '#FFFFFF', ink: '#F4F3EF', form: 'mark' }, // clear
68
+ ];
69
+
70
+ /** glassdrop: a drop of liquid glass becomes a tile over the mark (or the mark itself), then melts and leaves it flat. */
71
+ function glassdrop({ pick, r, accent, paths }) {
72
+ const { ground, mark, plate, light, ink, form } = pick(dropInksOf(accent));
73
+ const k = growOf(paths);
74
+ const shape = form === 'mark' ? { size: 0.8, markScale: Math.min(0.92, 0.76 * k), restScale: 1 } : { size: 0.8, markScale: Math.min(0.7, 0.56 * k), restScale: 1.3 };
75
+ const cfg = {
76
+ form,
77
+ area: AREA,
78
+ ...shape,
79
+ background: ground,
80
+ color: mark,
81
+ plate,
82
+ light,
83
+ lightAngle: Math.round(between(r, 105, 150)),
84
+ dispersion: between(r, 0.7, 1.2),
85
+ hold: between(r, 2.2, 3),
86
+ loop: true,
87
+ loopDelay: between(r, 1.4, 2.2),
88
+ delay: between(r, 0.2, 0.9),
89
+ };
90
+ const at = dropLayout(cfg, CARD);
91
+ const under = still(at.centre, at.rest, `<g data-m fill="${mark}">${paths}</g>`);
92
+ return { cfg, ground, ink, under };
93
+ }
94
+
95
+ /* ---------- Glass slabs (effects-astro's glassStack) ---------- */
96
+
97
+ /** Glass slab cards' colours: the glass's tints top to bottom, ground, the lit card, the name's ink. */
98
+ const stackInksOf = (accent) => [
99
+ { colors: ['#F4FFD0', accent, '#39FF88', '#0E8C7E'], ground: '#0B0B0B', light: '#FFFFFF', ink: '#F4F3EF' }, // acid
100
+ { colors: ['#BFF3FF', '#5AD1F0', '#1F8FE0', '#2140C8'], ground: '#F4F3EF', light: '#FFFFFF', ink: '#0B0B0B' }, // lagoon
101
+ { colors: ['#FFD27A', '#FF9B3D', '#FF3D00', '#B3122E'], ground: '#0B0B0B', light: '#FFF3E6', ink: '#F4F3EF' }, // ember
102
+ { colors: ['#FFD9E8', '#FF3EA5', '#7B3FF2', '#2B1B8F'], ground: '#08070C', light: '#F2EEFF', ink: '#F4F3EF' }, // violet
103
+ { colors: ['#7CF5FF', '#2B4BFF', '#0B1A6E'], ground: '#0038FF', light: '#FFFFFF', ink: '#FFFFFF' }, // cobalt
104
+ { colors: ['#E8E8EC', '#9A9CA3', '#3A3A3A', '#0B0B0B'], ground: accent, light: '#FFFFFF', ink: '#0B0B0B' }, // smoke on acid
105
+ ];
106
+
107
+ /** glassstack: the mark as a stack of tinted glass discs in front of a lit card, growing from the bottom up. */
108
+ function glassstack({ pick, r, accent, paths, uid }) {
109
+ const { colors, ground, light, ink } = pick(stackInksOf(accent));
110
+ // chunky slices at a card's size: more and the discs run together
111
+ const slabs = pick([12, 14, 16]);
112
+ const cfg = {
113
+ colors,
114
+ area: AREA,
115
+ logoScale: Math.min(0.86, 0.7 * growOf(paths)),
116
+ background: ground,
117
+ light,
118
+ slabs,
119
+ depth: between(r, 0.4, 0.52),
120
+ thickness: between(r, 0.24, 0.32),
121
+ cardSize: 1.18,
122
+ lightAngle: Math.round(between(r, 100, 140)),
123
+ sway: 0.6,
124
+ delay: between(r, 0.1, 0.5),
125
+ };
126
+ const at = stackLayout(cfg, CARD);
127
+ // the still: the mark cut into its slices, each a band of its tint
128
+ const pitch = 512 / slabs;
129
+ const bands = sliceTints(colors, slabs)
130
+ .map((t, i) => `<rect y="${(i * pitch).toFixed(2)}" width="512" height="${(pitch * 0.74).toFixed(2)}" fill="${hex(t)}" />`)
131
+ .join('');
132
+ // (a mask, not a clip path: a mask keeps the paths' even-odd holes)
133
+ // behind them the lit card, as the effect draws it (a rounded square `cardSize` times the box, past the viewBox)
134
+ const half = 256 * cfg.cardSize;
135
+ const card = `<rect x="${f2(256 - half)}" y="${f2(256 - half)}" width="${f2(half * 2)}" height="${f2(half * 2)}" rx="${f2(512 * 0.06)}" fill="${light}" />`;
136
+ const body = `<defs><mask id="${uid}-c" maskUnits="userSpaceOnUse" x="0" y="0" width="512" height="512"><g data-m fill="#fff">${paths}</g></mask></defs>${card}<g mask="url(#${uid}-c)">${bands}</g>`;
137
+ return { cfg, ground, ink, under: still(at.centre, at.edge, body, ' overflow="visible"') };
138
+ }
139
+
140
+ /* ---------- the table ---------- */
141
+
142
+ /** The glass cards by kind: the effect that draws each (effects-astro's runtime, by its file name), its label, and its
143
+ * deal. */
144
+ export const GLASS = {
145
+ glassdrop: { effect: 'glass-drop', label: 'Liquid glass', deal: glassdrop },
146
+ glassstack: { effect: 'glass-stack', label: 'Glass slabs', deal: glassstack },
147
+ };
148
+
149
+ /** Whether a kind is a glass card. */
150
+ export const isGlass = (k) => Object.hasOwn(GLASS, k);
151
+
152
+ /** The lockup's name and line under the glass. */
153
+ export const glassFoot = (name, line, type) =>
154
+ `<span class="wc-lockup is-stack wc-gfoot"><b class="wc-name" style="${type}">${escapeHtml(name)}</b><i>${escapeHtml(line)}</i></span>`;
package/src/index.d.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  export { ACCENT, EVERY, KIND_LABEL, WEIGHTS, lookbook, shuffled } from './wall.js';
11
11
  export { FIELDS, isField } from './fields.js';
12
12
  export type { FieldKind, Field } from './fields.js';
13
+ export { GLASS, isGlass } from './glass.js';
14
+ export type { GlassKind, Glass } from './glass.js';
13
15
  export type { Brand, BrandPicker, Card, Face, Kind, Lookbook, LookbookOptions, Recent, WallAssets, WallMark } from './wall.js';
14
16
  /** The cards between the marks. */
15
17
  export { headlineCard, sponsorCard, openSlotCard } from './promo.js';
package/src/index.js CHANGED
@@ -11,6 +11,8 @@
11
11
  export { ACCENT, EVERY, KIND_LABEL, WEIGHTS, lookbook, shuffled } from './wall.js';
12
12
  /** The field cards: live effects-astro fields behind a lockup (each off unless a wall gives it a weight). */
13
13
  export { FIELDS, isField } from './fields.js';
14
+ /** The glass cards: the mark itself drawn live in glass (each off unless a wall gives it a weight). */
15
+ export { GLASS, isGlass } from './glass.js';
14
16
 
15
17
  /** The cards between the marks. */
16
18
  export { headlineCard, sponsorCard, openSlotCard } from './promo.js';
package/src/live.d.ts CHANGED
@@ -54,6 +54,10 @@ export declare function smoke(
54
54
  light?: boolean;
55
55
  },
56
56
  ): Stop;
57
+ /** The mark a glass card's effect draws, read from its still's `data-m` group as a white SVG data URL; null for a card
58
+ * without one (a field card). */
59
+ export declare function markSource(card: Element): string | null;
60
+
57
61
  /**
58
62
  * A starter for the shader and gradient cards: each card's live background (its `data-shader` config, Paper's shaders
59
63
  * in effects-astro), at most `cap` at once (a browser drops the oldest WebGL context past about sixteen, and a dropped
@@ -81,10 +85,12 @@ export type LiveOptions = {
81
85
  margin?: string;
82
86
  /** Cards whose motion never waits its turn (the expanded view's, `.lv-card`). */
83
87
  always?: (card: HTMLElement) => boolean;
88
+ /** Keep every card's name fitted to its card (`fitWatch`; true). */
89
+ fit?: boolean;
84
90
  };
85
91
  /** The watcher `liveCards` returns. */
86
92
  export type LiveCards = {
87
- /** Watches cards not yet watched; lets go of any that left the page (or that Plain hid). */
93
+ /** Watches cards not yet watched; lets go of any that left the page (or that Plain hid); fits the names again. */
88
94
  watch: () => void;
89
95
  /** Starts the matching cards again (the smoke, when the theme changes). */
90
96
  restart: (match: (card: HTMLElement) => boolean) => void;
@@ -103,3 +109,21 @@ export declare function liveCards(options?: LiveOptions): LiveCards;
103
109
  * @returns Stops listening.
104
110
  */
105
111
  export declare function holoPointer(target?: Window | HTMLElement): Stop;
112
+
113
+ /**
114
+ * Fits one card name (`.wc-name`) to its card: back to its look's size, then smaller where it would cross the card's
115
+ * edge less a 5% margin; never clipped, never wrapped, never larger than its look made it.
116
+ *
117
+ * @param el The name.
118
+ * @returns The scale it was set at (1: as its look made it).
119
+ */
120
+ export declare function fitName(el: HTMLElement): number;
121
+ /** Fits every card name under `scope` (the document). */
122
+ export declare function fitNames(scope?: ParentNode): void;
123
+ /**
124
+ * Keeps every card name under `scope` fitted: now, when the web fonts load, when a card changes size, and when cards
125
+ * are added under `observe`.
126
+ *
127
+ * @returns Stops watching.
128
+ */
129
+ export declare function fitWatch(scope?: ParentNode, options?: { observe?: Element[] }): Stop;