@logomarks/brand-kit 0.5.2 → 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,19 @@ All notable changes to `@logomarks/brand-kit` 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-15
9
+
10
+ ### Added
11
+
12
+ - `faviconSet(brand, { adaptive: true })`: `favicon.svg` as the mark alone, transparent, in the palette's ink for the browser's light mode and its paper for dark mode, cropped close for a tab (`adaptiveIcon`). The `.ico` and the PNGs are unchanged. From the Logomarks studio's favicon kit, which had its own.
13
+ - `lightDarkSet(brand, { rasterize })`: the mark for light and dark grounds, as SVG (ink, paper, and one that follows the reader's mode), transparent PNGs at 512, 1024 and 2048 (`LIGHT_DARK_PNG_SIZES`), and a preview on each ground. From the studio's light/dark pack.
14
+
15
+ ## [0.5.3] — 2026-11-12
16
+
17
+ ### Fixed
18
+
19
+ - A long swatch name in a wide face no longer runs into its hex ("Medium Violet Red" in Krona One). The fit measured about half an em a letter; the names are now measured from their outlines in the brand's face (`swatchNameWidths()`, exported), and the swatch cards, the brand sheet and the deck's palette slide pass them to `swatchStack` as `widths`. Without `widths` it guesses as before.
20
+
8
21
  ## [0.5.2] — 2026-11-07
9
22
 
10
23
  ### Changed
package/docs/api.md CHANGED
@@ -78,7 +78,8 @@ One of the styles on a canvas of your own (a business card, a poster, a sleeve,
78
78
  | Export | |
79
79
  |---|---|
80
80
  | `resolveBrand(input)` | The brand resolved: mark, palette, font, the name as outlines (`nameSet`, `nameType`), the lockups' tagline (`taglineSet`, `taglineType`, or null), `grounds`, `lockup(layout, colors)`. |
81
- | `faviconSet(brand, { small, rasterize })` | The favicon files, for a site's root. |
81
+ | `faviconSet(brand, { small, rasterize, adaptive })` | The favicon files, for a site's root. `adaptive`: `favicon.svg` is the mark alone, in ink for the browser's light mode and paper for its dark mode (`adaptiveIcon`), not on a tile. |
82
+ | `lightDarkSet(brand, { rasterize })` | The mark for light and dark grounds: `svg/mark-for-light.svg` (ink), `svg/mark-for-dark.svg` (paper), `svg/mark-auto.svg` (follows the reader's mode), transparent PNGs at 512, 1024 and 2048, and `preview/on-light.png` / `on-dark.png`. |
82
83
  | `markFiles`, `lockupFiles` | The mark's and lockups' files. |
83
84
  | `brandSheet(brand)` | `{ svg, png }`. |
84
85
  | `brandJson(brand, files)` | `brand.json`'s contents. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logomarks/brand-kit",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "A complete brand kit from a logomark, a name, a colour and a typeface: the mark on light, dark and colour, favicons and a real .ico, outlined lockups and a round seal, a 50-950 OKLCH palette with WCAG pairings and named swatch cards, CSS and design tokens, brand.json, a brand sheet and a guidelines deck (PNG, SVG and PDF). Plus texture-collaged and letterpress, riso or stamp-printed marks, and a social pack at every platform's current sizes in four styles, with animated SVGs and seal avatars.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -25,6 +25,8 @@ export const SWATCH_CARDS: Readonly<{ width: number; margin: number; band: numbe
25
25
  /** The palette's swatches, light to dark: paper, 100, 300, the brand colour, 700, 900, ink. */
26
26
  export function swatches(palette: Palette): Swatch[];
27
27
  /** The swatches as stacked cards, as covers layers placed in a box (a card close to `ground` gets a hairline). */
28
- export function swatchStack(brand: Brand, list: Swatch[], box: { x: number; y: number; width: number; band: number; last: number; radius: number; size?: number; ground?: string }): { layers: object[]; height: number };
28
+ export function swatchStack(brand: Brand, list: Swatch[], box: { x: number; y: number; width: number; band: number; last: number; radius: number; size?: number; ground?: string; widths?: number[] }): { layers: object[]; height: number };
29
+ /** Each swatch name's width per px of size in the brand's face (for `swatchStack`'s `widths`). */
30
+ export function swatchNameWidths(brand: Brand, list: Swatch[]): Promise<number[]>;
29
31
  /** The palette as stacked swatch cards: SVG (outlines) and PNG, 1080 wide by default. */
30
32
  export function swatchCards(brand: Brand, options?: { width?: number; rasterize?: Rasterize }): Promise<{ svg: string; png: Uint8Array; width: number; height: number; swatches: Swatch[] }>;
@@ -9,6 +9,7 @@
9
9
  import { nearestColorNames, contrastRatio, formatOklch, hexToRgb, mixOklab, toOklch, pickReadable } from '@arraypress/color-utils';
10
10
  import { createPage, renderPage } from '../util/page.js';
11
11
  import { toPng } from '../render/png.js';
12
+ import { typeset, SIZE } from '../brand/type.js';
12
13
 
13
14
  /** The cards' proportions at 1080 wide: margin, a card's visible band, the last card's height, corner radius. */
14
15
  export const SWATCH_CARDS = Object.freeze({ width: 1080, margin: 110, band: 120, last: 260, radius: 36 });
@@ -79,15 +80,35 @@ export function swatches(p) {
79
80
  });
80
81
  }
81
82
 
83
+ /** The names' letter-spacing in the cards, in em (covers' `letterSpacing`). */
84
+ const NAME_TRACKING = -0.03;
85
+
86
+ /**
87
+ * Each swatch name's width per px of size in the brand's face, measured
88
+ * from its outlines, so a long name in a wide face ("Medium Violet Red" in
89
+ * Krona One) can be shrunk to clear the hex. Pass it to
90
+ * {@link swatchStack} as `widths`.
91
+ *
92
+ * @param {import('../brand/brand.js').Brand} brand - The brand.
93
+ * @param {import('./swatches.js').Swatch[]} list - The swatches.
94
+ * @returns {Promise<number[]>} A width per px of size, each name.
95
+ */
96
+ export async function swatchNameWidths(brand, list) {
97
+ return Promise.all(list.map(async (s) => {
98
+ const t = await typeset(s.name, brand.font, { tracking: NAME_TRACKING * 1000, caps: false });
99
+ return t.box.w / SIZE;
100
+ }));
101
+ }
102
+
82
103
  /**
83
104
  * The swatches as stacked cards, as covers layers on a page.
84
105
  *
85
106
  * @param {import('../brand/brand.js').Brand} brand - The brand.
86
107
  * @param {import('./swatches.js').Swatch[]} list - The swatches.
87
- * @param {{ x: number, y: number, width: number, band: number, last: number, radius: number, size?: number, ground?: string }} box - Where the stack goes and its proportions; `size` the names' size; the page's `ground` (a card close to it gets a hairline).
108
+ * @param {{ x: number, y: number, width: number, band: number, last: number, radius: number, size?: number, ground?: string, widths?: number[] }} box - Where the stack goes and its proportions; `size` the names' size; the page's `ground` (a card close to it gets a hairline); `widths`, each name's measured width per px ({@link swatchNameWidths}; else about half an em a letter).
88
109
  * @returns {{ layers: object[], height: number }} The layers and the stack's height.
89
110
  */
90
- export function swatchStack(brand, list, { x, y, width, band, last, radius, size = band * 0.6, ground }) {
111
+ export function swatchStack(brand, list, { x, y, width, band, last, radius, size = band * 0.6, ground, widths }) {
91
112
  const page = createPage({ quiet: brand.palette.ink, line: brand.palette.ink });
92
113
  const f = brand.font;
93
114
  const room = width - band * 2.6;
@@ -95,9 +116,10 @@ export function swatchStack(brand, list, { x, y, width, band, last, radius, size
95
116
  const top = y + i * band, h = i === list.length - 1 ? last : band + radius;
96
117
  const faint = ground && contrastRatio(s.hex, ground) < NEAR_GROUND;
97
118
  page.rect(x, top, width, h, s.hex, radius, faint ? mixOklab(ground, brand.palette.ink, 0.14) : undefined);
98
- // Long names shrink to the room left of the hex (about half an em a letter).
99
- const fit = Math.min(size, room / Math.max(1, s.name.length * 0.52));
100
- page.text(x + band * 0.33, top + band * 0.33 + fit * 0.72, s.name, { size: Math.round(fit), font: f.name, weight: f.weight, letterSpacing: -0.03, color: s.text });
119
+ // Long names shrink to the room left of the hex: measured in the face when `widths` is given, else about half an em a letter.
120
+ const per = widths?.[i] ?? s.name.length * 0.52;
121
+ const fit = Math.min(size, room / Math.max(0.01, per));
122
+ page.text(x + band * 0.33, top + band * 0.33 + fit * 0.72, s.name, { size: Math.floor(fit), font: f.name, weight: f.weight, letterSpacing: NAME_TRACKING, color: s.text });
101
123
  page.text(x + width - band * 0.27, top + band * 0.4, s.hex.toUpperCase(), { size: Math.round(band * 0.2), weight: 500, color: s.text, align: 'right' });
102
124
  page.label(x + width - band * 0.27, top + band * 0.68, s.role, s.text, { size: Math.round(band * 0.12), align: 'right' });
103
125
  });
@@ -115,7 +137,7 @@ export async function swatchCards(brand, { width = SWATCH_CARDS.width, rasterize
115
137
  const k = width / SWATCH_CARDS.width, S = SWATCH_CARDS;
116
138
  const list = swatches(brand.palette);
117
139
  const margin = S.margin * k;
118
- const stack = swatchStack(brand, list, { x: margin, y: margin, width: width - 2 * margin, band: S.band * k, last: S.last * k, radius: S.radius * k });
140
+ const stack = swatchStack(brand, list, { x: margin, y: margin, width: width - 2 * margin, band: S.band * k, last: S.last * k, radius: S.radius * k, widths: await swatchNameWidths(brand, list) });
119
141
  const height = Math.round(stack.height + 2 * margin);
120
142
  const svg = await renderPage(brand, stack.layers, { width, height, ground: mixOklab(brand.palette.paper, brand.palette.ink, 0.1) });
121
143
  return { svg, png: await toPng(svg, { width, height, rasterize }), width, height, swatches: list };
@@ -5,7 +5,7 @@
5
5
  * @module deck/slides/palette
6
6
  */
7
7
 
8
- import { swatches, swatchStack } from '../../color/swatches.js';
8
+ import { swatches, swatchStack, swatchNameWidths } from '../../color/swatches.js';
9
9
  import { DECK, slide, display } from '../frame.js';
10
10
 
11
11
  /** @type {import('../index.js').DeckSlide} */
@@ -17,7 +17,7 @@ export const palette = {
17
17
  const { page, quiet, line } = slide(brand, { ground: p.paper, text: p.ink, title: 'Palette', n, total });
18
18
  const list = swatches(p), top = 150, room = H - top - M;
19
19
  const band = Math.round((room - 220) / (list.length - 1));
20
- const stack = swatchStack(brand, list, { x: M, y: top, width: 800, band, last: room - band * (list.length - 1), radius: 28, size: 56, ground: p.paper });
20
+ const stack = swatchStack(brand, list, { x: M, y: top, width: 800, band, last: room - band * (list.length - 1), radius: 28, size: 56, ground: p.paper, widths: await swatchNameWidths(brand, list) });
21
21
  page.layers.push(...stack.layers);
22
22
  const rx = M + 800 + 120, rw = W - M - rx;
23
23
  page.text(rx, 250, 'Pairings', display(brand, 52, p.ink));
@@ -9,6 +9,8 @@ export interface FaviconOptions {
9
9
  small?: string;
10
10
  /** Draw PNGs with this instead of sharp or a canvas. */
11
11
  rasterize?: Rasterize;
12
+ /** `favicon.svg` as the mark alone, its ink following the browser's light or dark mode, instead of on a tile. */
13
+ adaptive?: boolean;
12
14
  }
13
15
 
14
16
  /** How each icon is drawn. */
@@ -24,5 +26,7 @@ export const ICO_SIZES: readonly number[];
24
26
  export const HEAD_HTML: string;
25
27
  /** The web app manifest. */
26
28
  export function manifest(name: string, color: string): object;
29
+ /** The mark alone, transparent, one ink in light mode and another in dark, cropped close for a tab. */
30
+ export function adaptiveIcon(mark: { paths: string }, light: string, dark: string): string;
27
31
  /** The favicon set, as files for a site's root. */
28
32
  export function faviconSet(brand: BrandInput | Brand, options?: FaviconOptions): Promise<FileMap>;
@@ -57,14 +57,28 @@ export const manifest = (name, color) => ({
57
57
  display: 'standalone',
58
58
  });
59
59
 
60
+ /**
61
+ * A favicon that follows the browser: the mark alone, transparent, in one
62
+ * ink for light mode and another for dark, cropped close (a 480 window on
63
+ * the 512 canvas) so it is as large as a tab allows.
64
+ *
65
+ * @param {{ paths: string }} mark - The mark.
66
+ * @param {string} light - Its colour in light mode.
67
+ * @param {string} dark - Its colour in dark mode.
68
+ * @returns {string} The SVG.
69
+ */
70
+ export const adaptiveIcon = (mark, light, dark) =>
71
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="16 16 480 480"><style>g{fill:${light}}@media (prefers-color-scheme:dark){g{fill:${dark}}}</style><g>${mark.paths}</g></svg>\n`;
72
+
60
73
  /**
61
74
  * The favicon set, as files for a site's root.
62
75
  *
63
76
  * @param {import('../brand/brand.js').BrandInput | import('../brand/brand.js').Brand} input - The brand.
64
- * @param {import('./favicons.js').FaviconOptions} [o] - A simplified mark for the small sizes, and a rasteriser.
77
+ * @param {import('./favicons.js').FaviconOptions} [o] - A simplified mark for the small sizes, a rasteriser, and
78
+ * `adaptive` for a `favicon.svg` that follows the browser's light or dark mode instead of sitting on a tile.
65
79
  * @returns {Promise<import('../util/files.js').FileMap>} `favicon.ico`, `favicon.svg`, the PNGs, `site.webmanifest` and `head.html`.
66
80
  */
67
- export async function faviconSet(input, { small, rasterize } = {}) {
81
+ export async function faviconSet(input, { small, rasterize, adaptive = false } = {}) {
68
82
  const brand = await resolveBrand(input);
69
83
  const { mark, palette: p } = brand;
70
84
  const tiny = small ? loadMark(small) : mark;
@@ -73,7 +87,7 @@ export async function faviconSet(input, { small, rasterize } = {}) {
73
87
  const maskPad = padForCircle(mark, ICONS.maskable.circle);
74
88
  const files = fileMap();
75
89
  files.set('favicon.ico', ico(await Promise.all(ICO_SIZES.map(async (size) => ({ size, png: await png(markTile(tiny, { size, ...icon, ...ICONS.tile }), size) })))));
76
- files.set('favicon.svg', markTile(tiny, { size: 32, ...icon, ...ICONS.tile }).replace(' width="32" height="32"', ''));
90
+ files.set('favicon.svg', adaptive ? adaptiveIcon(tiny, p.ink, p.paper) : markTile(tiny, { size: 32, ...icon, ...ICONS.tile }).replace(' width="32" height="32"', ''));
77
91
  files.set('apple-touch-icon.png', await png(markTile(mark, { size: 180, ...icon, ...ICONS.apple }), 180));
78
92
  for (const size of [192, 512]) {
79
93
  files.set(`icon-${size}.png`, await png(markTile(mark, { size, ...icon, ...ICONS.any }), size));
package/src/index.d.ts CHANGED
@@ -10,10 +10,11 @@ export { lockup, LOCKUP, LAYOUTS } from './lockup/lockup.js';
10
10
  export { sealLockup, sealOn, sealGeometry, SEAL, SEAL_DETAIL, SEAL_PRINT, SEPARATORS } from './lockup/seal.js';
11
11
  export { palette, pairing } from './color/palette.js';
12
12
  export { paletteCss, paletteTailwind, paletteTokens } from './color/tokens.js';
13
- export { swatches, swatchStack, swatchCards, SWATCH_CARDS } from './color/swatches.js';
14
- export { faviconSet, manifest, ICONS, ICO_SIZES, HEAD_HTML } from './favicon/favicons.js';
13
+ export { swatches, swatchStack, swatchNameWidths, swatchCards, SWATCH_CARDS } from './color/swatches.js';
14
+ export { faviconSet, adaptiveIcon, manifest, ICONS, ICO_SIZES, HEAD_HTML } from './favicon/favicons.js';
15
15
  export { ico, readIco } from './favicon/ico.js';
16
16
  export { markFiles, MARK_PNG_SIZES } from './kit/marks.js';
17
+ export { lightDarkSet, LIGHT_DARK_PNG_SIZES } from './kit/light-dark.js';
17
18
  export { lockupFiles, LOCKUP_PNG_WIDTH, SEAL_PNG_WIDTH } from './kit/lockups.js';
18
19
  export { brandSheet, SHEET } from './kit/sheet.js';
19
20
  export { guidelinesDeck, deckSlideSvg, SLIDES, SLIDE_IDS } from './deck/index.js';
package/src/index.js CHANGED
@@ -15,10 +15,11 @@ export { lockup, LOCKUP, LAYOUTS } from './lockup/lockup.js';
15
15
  export { sealLockup, sealOn, sealGeometry, SEAL, SEAL_DETAIL, SEAL_PRINT, SEPARATORS } from './lockup/seal.js';
16
16
  export { palette, pairing } from './color/palette.js';
17
17
  export { paletteCss, paletteTailwind, paletteTokens } from './color/tokens.js';
18
- export { swatches, swatchStack, swatchCards, SWATCH_CARDS } from './color/swatches.js';
19
- export { faviconSet, manifest, ICONS, ICO_SIZES, HEAD_HTML } from './favicon/favicons.js';
18
+ export { swatches, swatchStack, swatchNameWidths, swatchCards, SWATCH_CARDS } from './color/swatches.js';
19
+ export { faviconSet, adaptiveIcon, manifest, ICONS, ICO_SIZES, HEAD_HTML } from './favicon/favicons.js';
20
20
  export { ico, readIco } from './favicon/ico.js';
21
21
  export { markFiles, MARK_PNG_SIZES } from './kit/marks.js';
22
+ export { lightDarkSet, LIGHT_DARK_PNG_SIZES } from './kit/light-dark.js';
22
23
  export { lockupFiles, LOCKUP_PNG_WIDTH, SEAL_PNG_WIDTH } from './kit/lockups.js';
23
24
  export { brandSheet, SHEET } from './kit/sheet.js';
24
25
  export { guidelinesDeck, deckSlideSvg, SLIDES, SLIDE_IDS } from './deck/index.js';
@@ -0,0 +1,9 @@
1
+ // The mark for light and dark grounds.
2
+ import type { Brand, BrandInput } from '../brand/brand.js';
3
+ import type { FileMap } from '../util/files.js';
4
+ import type { Rasterize } from '../render/png.js';
5
+
6
+ /** The transparent PNGs' sizes: 512, 1024, 2048. */
7
+ export const LIGHT_DARK_PNG_SIZES: readonly number[];
8
+ /** The mark in ink for light grounds and paper for dark ones (SVG and PNG), an SVG that follows the reader's mode, and a preview of each. */
9
+ export function lightDarkSet(brand: BrandInput | Brand, options?: { rasterize?: Rasterize }): Promise<FileMap>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The mark for light and dark grounds: in the palette's ink for light
3
+ * grounds and its paper for dark ones, as SVG and transparent PNG, one SVG
4
+ * that follows the reader's light or dark mode, and a preview of each on
5
+ * its ground.
6
+ *
7
+ * @module kit/light-dark
8
+ */
9
+
10
+ import { resolveBrand } from '../brand/brand.js';
11
+ import { markSvg, markTile, markAutoSvg } from '../brand/mark.js';
12
+ import { toPng } from '../render/png.js';
13
+ import { fileMap } from '../util/files.js';
14
+
15
+ /** The transparent PNGs' sizes. */
16
+ export const LIGHT_DARK_PNG_SIZES = Object.freeze([512, 1024, 2048]);
17
+
18
+ /** The previews' size. */
19
+ const PREVIEW = 1024;
20
+
21
+ /**
22
+ * The light and dark set.
23
+ *
24
+ * @param {import('../brand/brand.js').BrandInput | import('../brand/brand.js').Brand} input - The brand.
25
+ * @param {{ rasterize?: import('../render/png.js').Rasterize }} [o] - A rasteriser.
26
+ * @returns {Promise<import('../util/files.js').FileMap>} `svg/mark-for-light.svg`, `svg/mark-for-dark.svg`,
27
+ * `svg/mark-auto.svg`, `png/mark-for-{light,dark}-<size>.png` and `preview/on-{light,dark}.png`.
28
+ */
29
+ export async function lightDarkSet(input, { rasterize } = {}) {
30
+ const { mark, palette: p } = await resolveBrand(input);
31
+ const ways = /** @type {const} */ ([['for-light', p.ink, p.paper], ['for-dark', p.paper, p.ink]]);
32
+ const files = fileMap();
33
+ for (const [way, ink] of ways) files.set(`svg/mark-${way}.svg`, markSvg(mark, ink));
34
+ files.set('svg/mark-auto.svg', markAutoSvg(mark, p.ink, p.paper));
35
+ for (const [way, ink] of ways) {
36
+ for (const size of LIGHT_DARK_PNG_SIZES) files.set(`png/mark-${way}-${size}.png`, await toPng(markTile(mark, { size, color: ink }), { width: size, height: size, rasterize }));
37
+ }
38
+ for (const [way, ink, ground] of ways) {
39
+ const on = way === 'for-light' ? 'on-light' : 'on-dark';
40
+ files.set(`preview/${on}.png`, await toPng(markTile(mark, { size: PREVIEW, color: ink, ground }), { width: PREVIEW, height: PREVIEW, rasterize }));
41
+ }
42
+ return files;
43
+ }
package/src/kit/sheet.js CHANGED
@@ -21,7 +21,7 @@ import { artwork, artworkSpec } from '../social/artwork.js';
21
21
  import { muted, tone } from '../social/styles/tone.js';
22
22
  import { nest, prefixIds } from '../util/svg.js';
23
23
  import { createPage, renderPage } from '../util/page.js';
24
- import { swatches, swatchStack } from '../color/swatches.js';
24
+ import { swatches, swatchStack, swatchNameWidths } from '../color/swatches.js';
25
25
  import { sealOn } from '../lockup/seal.js';
26
26
  import { toPng } from '../render/png.js';
27
27
 
@@ -134,7 +134,8 @@ async function compose(brand) {
134
134
  ];
135
135
  // The named swatches stacked on the left, the roles and their contrast in a grid on the right.
136
136
  const stackW = Math.round(INNER * 0.44);
137
- const stack = swatchStack(brand, swatches(p), { x: M, y, width: stackW, band: 66, last: 150, radius: 20, size: 34, ground: p.paper });
137
+ const list = swatches(p);
138
+ const stack = swatchStack(brand, list, { x: M, y, width: stackW, band: 66, last: 150, radius: 20, size: 34, ground: p.paper, widths: await swatchNameWidths(brand, list) });
138
139
  layers.push(...stack.layers);
139
140
  const cw = (INNER - stackW - 2 * G) / 2, ch = (stack.height - G) / 2;
140
141
  roles.forEach((c, i) => {
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** This library's version, written into `brand.json`. */
2
- export const VERSION = '0.5.2';
2
+ export const VERSION = '0.5.3';