@logomarks/brand-kit 0.8.0 → 0.9.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 +19 -0
- package/docs/api.md +2 -2
- package/package.json +1 -1
- package/src/brand/brand.d.ts +5 -0
- package/src/brand/brand.js +24 -1
- package/src/deck/slides/logo.js +4 -3
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/kit/brand-json.js +2 -1
- package/src/kit/lockups.js +3 -2
- package/src/kit/sheet.js +6 -4
- package/src/lockup/lockup.d.ts +6 -2
- package/src/lockup/lockup.js +56 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ 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.9.0] — 2026-11-28
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **The split lockup** (`layout: 'split'`): the name's first word, the mark at about cap height between, the rest of the
|
|
13
|
+
name, in one line, as fashion brands set two-word names (WORD · mark · WORD). A one-word name pairs with its tagline
|
|
14
|
+
when that is short (≤ 3 words, ≤ 24 characters), and the tagline is then not set again under it; a two-word name keeps
|
|
15
|
+
a lockup tagline centred under the line. The space either side of the mark grows with the letter-spacing, so widely
|
|
16
|
+
tracked capitals keep the mark a word apart. Without two words to part (a drawn wordmark, a one-word name without a
|
|
17
|
+
short tagline) `split` draws as `horizontal`. `splitOf(name, tagline)` gives the two words; a brand's `splitSet` holds
|
|
18
|
+
them as outlines; `LOCKUP.split` its proportions.
|
|
19
|
+
- The kit writes `lockup/split-on-{light,dark,color}.{svg,png}` when the name parts, brand.json lists `split` in
|
|
20
|
+
`logo.layouts` (and `logo.split`, the two words), the brand sheet gets a split row and the deck's logo slide shows the
|
|
21
|
+
split on the colour.
|
|
22
|
+
|
|
23
|
+
### Unchanged
|
|
24
|
+
|
|
25
|
+
- The horizontal, stacked and mark lockups are byte-identical to 0.8.0's (checked over every test brand and ground).
|
|
26
|
+
|
|
8
27
|
## [0.8.0] — 2026-11-26
|
|
9
28
|
|
|
10
29
|
### Added
|
package/docs/api.md
CHANGED
|
@@ -37,7 +37,7 @@ It returns `{ files, brand }`, where `brand` is `brand.json`'s contents.
|
|
|
37
37
|
| `mark/…-<finish>` | With `finish`: `svg/mark-on-{light,dark,color}-<finish>.svg` and `png/…-1024.png` |
|
|
38
38
|
| `mark/texture/` | With `texture`: `mark-textured.svg`, `mark-textured-1024.png` |
|
|
39
39
|
| `favicon/` | `favicon.ico` (16/32/48), `favicon.svg`, `apple-touch-icon.png`, `icon-{192,512}.png`, `icon-maskable-{192,512}.png`, `site.webmanifest`, `head.html` |
|
|
40
|
-
| `lockup/` | `{horizontal,stacked}-on-{light,dark,color}.{svg,png}`, `seal-on-{light,dark,color}.{svg,png}` (and `-<finish>`) |
|
|
40
|
+
| `lockup/` | `{horizontal,stacked}-on-{light,dark,color}.{svg,png}`, `split-on-{light,dark,color}.{svg,png}` when the name parts in two, `seal-on-{light,dark,color}.{svg,png}` (and `-<finish>`) |
|
|
41
41
|
| `colors/` | `palette.css` (custom properties, OKLCH noted), `tailwind.css` (a v4 `@theme`), `tokens.json` (W3C design tokens, with WCAG pairings), `swatches.{png,svg}` (named swatch cards) |
|
|
42
42
|
| `brand-sheet.{png,svg}` | The one-page brand sheet |
|
|
43
43
|
| `deck/` | `01-cover.{png,svg}` … `09-in-use.{png,svg}`, `guidelines.pdf` |
|
|
@@ -87,7 +87,7 @@ One of the styles on a canvas of your own (a business card, a poster, a sleeve,
|
|
|
87
87
|
| `brandJson(brand, files)` | `brand.json`'s contents. |
|
|
88
88
|
| `palette(hex)` | `{ primary, onPrimary, ink, paper, step, scale, text, mark, pairings, steps }`. The mark keeps the brand colour, or moves one scale step at most, where it clears 3:1 (4.5:1 when a step allows); otherwise it's ink or paper. Text clears 4.5:1. |
|
|
89
89
|
| `paletteCss`, `paletteTailwind`, `paletteTokens` | The palette as files. |
|
|
90
|
-
| `lockup({ mark, name, tagline, layout, markColor, textColor, taglineColor, ground, clear })` | `{ svg, body, width, height, mark }`. The name's cap height is 0.42 of the mark's height beside it and 0.3 under it, with a quarter of the mark's height clear all round; a tagline's is 0.4 of the name's. |
|
|
90
|
+
| `lockup({ mark, name, tagline, split, layout, markColor, textColor, taglineColor, ground, clear })` | Layouts `horizontal`, `stacked`, `split` (the first word, the mark, the rest: `split` holds the two words as outlines; without them it draws as `horizontal`) and `mark`. `{ svg, body, width, height, mark }`. The name's cap height is 0.42 of the mark's height beside it and 0.3 under it, with a quarter of the mark's height clear all round; a tagline's is 0.4 of the name's. |
|
|
91
91
|
| `typeset(text, font, { tracking, caps })` | The text as outlines at 100 px: `{ paths, box, cap, text, tracking, missing }`. |
|
|
92
92
|
| `hasGlyph(ch, font)`, `missingGlyphs(text, font)` | Whether a face draws a character; the characters of a line it doesn't. |
|
|
93
93
|
| `loadMark(svg)`, `markSvg`, `markAutoSvg`, `markTile`, `markBody`, `padForCircle` | The mark: fitted, painted, tiled, kept inside a circle. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/brand-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
package/src/brand/brand.d.ts
CHANGED
|
@@ -115,6 +115,8 @@ export interface Brand {
|
|
|
115
115
|
/** The lockups' tagline as outlines, when there is one (`missing` lists characters its face lacks; nothing drawn when it lacks them all). */
|
|
116
116
|
taglineSet: TypeSet | null;
|
|
117
117
|
grounds: Grounds;
|
|
118
|
+
/** The split line's two words as outlines (`splitOf`), or null when there aren't two to part (a drawn wordmark, a one-word name with no short tagline). */
|
|
119
|
+
splitSet: [TypeSet, TypeSet] | null;
|
|
118
120
|
/** A lockup in a layout and colours; `tagline: false` leaves the tagline out. */
|
|
119
121
|
lockup(layout: LockupLayout, colors: Pick<LockupInput, 'markColor' | 'textColor' | 'taglineColor' | 'ground' | 'clear'> & { tagline?: boolean }): Lockup;
|
|
120
122
|
}
|
|
@@ -135,3 +137,6 @@ export function resolveBrand(input: BrandInput | Brand): Promise<Brand>;
|
|
|
135
137
|
export type MarkBrand = Pick<Brand, 'name' | 'mark' | 'palette'>;
|
|
136
138
|
/** Only the mark and the palette (and the name as given), without setting the name in type. */
|
|
137
139
|
export function resolveMarkBrand(input: Pick<BrandInput, 'svg' | 'color'> & { name?: string } | Brand): MarkBrand;
|
|
140
|
+
|
|
141
|
+
/** The split line's two words: a multi-word name parts after its first word; a one-word name pairs with a short tagline (≤ 3 words, ≤ 24 characters). */
|
|
142
|
+
export function splitOf(name: string, tagline?: string): [string, string] | null;
|
package/src/brand/brand.js
CHANGED
|
@@ -80,6 +80,11 @@ export async function resolveBrand(input) {
|
|
|
80
80
|
const line = lacks.length ? withoutChars(tagline.trim(), lacks) : tagline;
|
|
81
81
|
const tt = lockupTagline && tagline.trim() ? taglineType(lockupTagline, face) : null;
|
|
82
82
|
const tagSet = tt ? await typeset(tagline.trim(), tt.font, { tracking: tt.tracking, caps: tt.caps }) : null;
|
|
83
|
+
// the split line's two words: the name's first word and the rest, or a one-word name and its tagline (short enough to
|
|
84
|
+
// stand beside it), in the name's own type; none for a drawn wordmark
|
|
85
|
+
const splitWords = wordmark ? null : splitOf(name.trim(), tagline.trim());
|
|
86
|
+
const splitSet = splitWords ? await Promise.all(splitWords.map((w) => typeset(w, face, { tracking, caps }))) : null;
|
|
87
|
+
const splitTagged = Boolean(splitWords && splitWords[1] === tagline.trim() && !/\s/.test(name.trim()));
|
|
83
88
|
const mark = loadMark(svg);
|
|
84
89
|
const palette = makePalette(color);
|
|
85
90
|
const slug = slugify(name);
|
|
@@ -88,10 +93,28 @@ export async function resolveBrand(input) {
|
|
|
88
93
|
...(wordmark && { wordmark: { ...(wordmark.font && { font: wordmark.font }), ...(wordmark.license && { license: wordmark.license }), ...(wordmark.note && { note: wordmark.note }) } }),
|
|
89
94
|
mark, palette, font: face, nameSet: set, grounds: grounds(palette),
|
|
90
95
|
nameType: wordmark ? { tracking: 0, caps: false } : { tracking: set.tracking, caps: caps ?? face.case === 'uppercase' }, taglineType: tt, taglineSet: tagSet,
|
|
91
|
-
|
|
96
|
+
splitSet,
|
|
97
|
+
// in the split the tagline is a word of the line when the name is one word, so it isn't set again under it
|
|
98
|
+
lockup: (layout, { tagline: withTagline = true, ...colors }) => makeLockup({ mark, name: set, tagline: withTagline && !(layout === 'split' && splitTagged) ? tagSet : null, split: splitSet, layout, ...colors }),
|
|
92
99
|
};
|
|
93
100
|
}
|
|
94
101
|
|
|
102
|
+
/**
|
|
103
|
+
* The split line's two words: a name of two or more words parts after its first; a one-word name pairs with its
|
|
104
|
+
* tagline when that is short (three words and 24 characters at most); otherwise none.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} name - The name.
|
|
107
|
+
* @param {string} tagline - The tagline, or ''.
|
|
108
|
+
* @returns {[string, string] | null} The two words, or null.
|
|
109
|
+
*/
|
|
110
|
+
export function splitOf(name, tagline = '') {
|
|
111
|
+
const words = name.split(/\s+/).filter(Boolean);
|
|
112
|
+
if (words.length >= 2) return [words[0], words.slice(1).join(' ')];
|
|
113
|
+
const t = tagline.trim();
|
|
114
|
+
if (words.length === 1 && t && t.length <= 24 && t.split(/\s+/).length <= 3) return [words[0], t];
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
95
118
|
/**
|
|
96
119
|
* Only what the mark's own files need (the favicons, the light and dark
|
|
97
120
|
* set): the mark fitted and the palette, without setting the name in type,
|
package/src/deck/slides/logo.js
CHANGED
|
@@ -16,11 +16,12 @@ import { DECK, slide, LABEL, pageNumber } from '../frame.js';
|
|
|
16
16
|
* @param {import('../../brand/brand.js').Ground} g - The ground's colours.
|
|
17
17
|
* @param {[number, number, number, number]} box - `[x, y, w, h]`.
|
|
18
18
|
* @param {number} share - The lockup's width as a share of the box's.
|
|
19
|
+
* @param {'horizontal' | 'split'} [layout] - The lockup (the split line on the colour, when the name parts in two).
|
|
19
20
|
* @returns {void}
|
|
20
21
|
*/
|
|
21
|
-
function centred(page, brand, g, [x, y, w, h], share) {
|
|
22
|
+
function centred(page, brand, g, [x, y, w, h], share, layout = 'horizontal') {
|
|
22
23
|
page.rect(x, y, w, h, g.ground);
|
|
23
|
-
const l = brand.lockup(
|
|
24
|
+
const l = brand.lockup(layout, { markColor: g.mark, textColor: g.text, clear: 0 });
|
|
24
25
|
const k = Math.min((w * share) / l.width, (h * 0.34) / l.height);
|
|
25
26
|
page.place(l.svg, x + (w - l.width * k) / 2, y + (h - l.height * k) / 2, l.width * k, l.height * k);
|
|
26
27
|
}
|
|
@@ -34,7 +35,7 @@ export const logo = {
|
|
|
34
35
|
const { page } = slide(brand, { ground: gr['on-dark'].ground, text: gr['on-dark'].text, title: 'Logo', n, total, header: false });
|
|
35
36
|
centred(page, brand, gr['on-dark'], [0, 0, W / 2, H], 0.62);
|
|
36
37
|
centred(page, brand, gr['on-light'], [W / 2, 0, W / 2, H / 2], 0.5);
|
|
37
|
-
centred(page, brand, gr['on-color'], [W / 2, H / 2, W / 2, H / 2], 0.5);
|
|
38
|
+
centred(page, brand, gr['on-color'], [W / 2, H / 2, W / 2, H / 2], brand.splitSet ? 0.72 : 0.5, brand.splitSet ? 'split' : 'horizontal');
|
|
38
39
|
const small = LABEL;
|
|
39
40
|
page.label(M, M - 24, 'Logo', gr['on-dark'].text, small);
|
|
40
41
|
page.label(W - M, M - 24, pageNumber(n, total), muted(gr['on-light'].text, gr['on-light'].ground), { ...small, align: 'right' });
|
package/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export { brandKit } from './kit/index.js';
|
|
4
4
|
export { socialPack, ANIMATED_KINDS } from './social/index.js';
|
|
5
|
-
export { resolveBrand, resolveMarkBrand, wordmarkSet, grounds, taglineType, DEFAULT_COLOR, TAGLINE_TYPE } from './brand/brand.js';
|
|
5
|
+
export { resolveBrand, resolveMarkBrand, wordmarkSet, splitOf, grounds, taglineType, DEFAULT_COLOR, TAGLINE_TYPE } from './brand/brand.js';
|
|
6
6
|
export { loadMark, markBody, markSvg, markAutoSvg, markTile, tileSvg, padForCircle } from './brand/mark.js';
|
|
7
7
|
export { resolveFont, DEFAULT_FONT } from './brand/font.js';
|
|
8
8
|
export { typeset, hasGlyph, missingGlyphs, withoutChars } from './brand/type.js';
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
export { brandKit } from './kit/index.js';
|
|
9
9
|
export { socialPack, ANIMATED_KINDS } from './social/index.js';
|
|
10
|
-
export { resolveBrand, resolveMarkBrand, wordmarkSet, grounds, taglineType, DEFAULT_COLOR, TAGLINE_TYPE } from './brand/brand.js';
|
|
10
|
+
export { resolveBrand, resolveMarkBrand, wordmarkSet, splitOf, grounds, taglineType, DEFAULT_COLOR, TAGLINE_TYPE } from './brand/brand.js';
|
|
11
11
|
export { loadMark, markBody, markSvg, markAutoSvg, markTile, tileSvg, padForCircle } from './brand/mark.js';
|
|
12
12
|
export { resolveFont, DEFAULT_FONT } from './brand/font.js';
|
|
13
13
|
export { typeset, hasGlyph, missingGlyphs, withoutChars } from './brand/type.js';
|
package/src/kit/brand-json.js
CHANGED
|
@@ -30,7 +30,8 @@ export function brandJson(brand, files) {
|
|
|
30
30
|
colors: { primary: p.primary, onPrimary: p.onPrimary, ink: p.ink, paper: p.paper, step: p.step, scale: p.scale, text: p.text, mark: p.mark, pairings: p.pairings, swatches: swatches(p).map(({ role, name, hex }) => ({ role, name, hex })) },
|
|
31
31
|
font: { name: f.name, weight: f.weight, tracking: f.tracking, case: f.case, url: f.url, license: f.license },
|
|
32
32
|
logo: {
|
|
33
|
-
layouts: ['horizontal', 'stacked', 'mark', 'seal'],
|
|
33
|
+
layouts: brand.splitSet ? ['horizontal', 'stacked', 'split', 'mark', 'seal'] : ['horizontal', 'stacked', 'mark', 'seal'],
|
|
34
|
+
...(brand.splitSet && { split: brand.splitSet.map((t) => t.text) }),
|
|
34
35
|
clearSpace: `${LOCKUP.clear} × the mark's height on every side`,
|
|
35
36
|
minimum: { screen: '16px', print: '8mm', withName: '24px' },
|
|
36
37
|
name: brand.wordmark ? { drawn: true, ...brand.wordmark } : { tracking: brand.nameType.tracking, caps: brand.nameType.caps },
|
package/src/kit/lockups.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The lockups as files: horizontal, stacked
|
|
2
|
+
* The lockups as files: horizontal, stacked, the split line (when the name
|
|
3
|
+
* parts into two words) and the round seal, on light,
|
|
3
4
|
* dark and colour, as SVG (outlined, no fonts) and PNG; with a finish, the
|
|
4
5
|
* seal printed too.
|
|
5
6
|
*
|
|
@@ -27,7 +28,7 @@ export const SEAL_PNG_WIDTH = 1200;
|
|
|
27
28
|
*/
|
|
28
29
|
export async function lockupFiles(brand, { rasterize, seal = true, finish } = {}) {
|
|
29
30
|
const files = fileMap();
|
|
30
|
-
for (const layout of /** @type {const} */ (['horizontal', 'stacked'])) {
|
|
31
|
+
for (const layout of /** @type {const} */ (brand.splitSet ? ['horizontal', 'stacked', 'split'] : ['horizontal', 'stacked'])) {
|
|
31
32
|
for (const [way, g] of Object.entries(brand.grounds)) {
|
|
32
33
|
const l = brand.lockup(layout, { markColor: g.mark, textColor: g.text, ground: way === 'on-color' ? g.ground : undefined });
|
|
33
34
|
files.set(`${layout}-${way}.svg`, l.svg);
|
package/src/kit/sheet.js
CHANGED
|
@@ -67,19 +67,21 @@ async function compose(brand) {
|
|
|
67
67
|
y += heroH + SHEET.section;
|
|
68
68
|
|
|
69
69
|
// 01 Logo
|
|
70
|
-
heading('Logo', 'Horizontal, stacked and the seal, on light, dark and colour');
|
|
70
|
+
heading('Logo', brand.splitSet ? 'Horizontal, stacked, split and the seal, on light, dark and colour' : 'Horizontal, stacked and the seal, on light, dark and colour');
|
|
71
71
|
const tw = (INNER - 2 * G) / 3, th = 300;
|
|
72
|
-
|
|
72
|
+
/** @type {Array<[number, 'horizontal' | 'stacked' | 'split']>} */
|
|
73
|
+
const rows = brand.splitSet ? [[0, 'horizontal'], [1, 'stacked'], [2, 'split']] : [[0, 'horizontal'], [1, 'stacked']];
|
|
74
|
+
for (const [row, layout] of rows) {
|
|
73
75
|
Object.entries(brand.grounds).forEach(([way, g], i) => {
|
|
74
76
|
const x = M + i * (tw + G), top = y + row * (th + G);
|
|
75
77
|
const l = brand.lockup(layout, { markColor: g.mark, textColor: g.text, clear: 0 });
|
|
76
78
|
panel(x, top, tw, th, g.ground, 14);
|
|
77
|
-
const k = Math.min((tw * (layout === '
|
|
79
|
+
const k = Math.min((tw * (layout === 'stacked' ? 0.5 : layout === 'split' ? 0.78 : 0.66)) / l.width, (th * 0.48) / l.height);
|
|
78
80
|
place(l.svg, x + (tw - l.width * k) / 2, top + (th - 36 - l.height * k) / 2 + 6, l.width * k, l.height * k);
|
|
79
81
|
label(x + 20, top + th - 20, `${layout} · ${way.replace('-', ' ')}`, muted(g.text, g.ground));
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
|
-
y +=
|
|
84
|
+
y += rows.length * (th + G);
|
|
83
85
|
for (const [i, way] of /** @type {const} */ (['on-light', 'on-dark', 'on-color']).entries()) {
|
|
84
86
|
const g = brand.grounds[way], x = M + i * (tw + G), seal = await sealOn(brand, way);
|
|
85
87
|
const d = th * 0.72;
|
package/src/lockup/lockup.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Mark } from '../brand/mark.js';
|
|
|
3
3
|
import type { TypeSet, Box } from '../brand/type.js';
|
|
4
4
|
|
|
5
5
|
/** How a lockup is arranged. */
|
|
6
|
-
export type LockupLayout = 'horizontal' | 'stacked' | 'mark';
|
|
6
|
+
export type LockupLayout = 'horizontal' | 'stacked' | 'split' | 'mark';
|
|
7
7
|
|
|
8
8
|
/** What a lockup is made of. */
|
|
9
9
|
export interface LockupInput {
|
|
@@ -12,6 +12,8 @@ export interface LockupInput {
|
|
|
12
12
|
name?: TypeSet | null;
|
|
13
13
|
/** A smaller second line under the name (from `typeset`), its cap height {@link LOCKUP}`.tagline.cap` of the name's. */
|
|
14
14
|
tagline?: TypeSet | null;
|
|
15
|
+
/** The two words the `split` layout parts round the mark (from `typeset`); without them `split` draws as `horizontal`. */
|
|
16
|
+
split?: [TypeSet, TypeSet] | null;
|
|
15
17
|
/** Default `'horizontal'`. */
|
|
16
18
|
layout?: LockupLayout;
|
|
17
19
|
markColor: string;
|
|
@@ -48,8 +50,10 @@ export const LOCKUP: Readonly<{
|
|
|
48
50
|
/** The tagline's cap height, and the space from the name's baseline to its capitals, as shares of the name's cap height. */
|
|
49
51
|
tagline: Readonly<{ cap: number; gap: number }>;
|
|
50
52
|
clear: number;
|
|
53
|
+
/** The split line: the words' cap height, and the mark's height and the space either side of it as shares of that cap height. */
|
|
54
|
+
split: Readonly<{ cap: number; mark: number; gap: number }>;
|
|
51
55
|
}>;
|
|
52
56
|
/** The layouts. */
|
|
53
|
-
export const LAYOUTS: readonly ['horizontal', 'stacked', 'mark'];
|
|
57
|
+
export const LAYOUTS: readonly ['horizontal', 'stacked', 'split', 'mark'];
|
|
54
58
|
/** A lockup: the name's cap height a set share of the mark's (a tagline under it, smaller), clear space a quarter of it. */
|
|
55
59
|
export function lockup(input: LockupInput): Lockup;
|
package/src/lockup/lockup.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The mark and the name together: side by side (`horizontal`), the name
|
|
3
|
-
* under the mark (`stacked`),
|
|
3
|
+
* under the mark (`stacked`), the mark between the name's two words
|
|
4
|
+
* (`split`, the fashion line: WORD · mark · WORD), or the mark alone
|
|
5
|
+
* (`mark`), with an optional
|
|
4
6
|
* tagline as a smaller second line under the name. Laid out on the ink,
|
|
5
7
|
* not the canvas, so every mark sits the same way: the name's cap height a
|
|
6
8
|
* set share of the mark's height and centred on it (with a tagline, the
|
|
@@ -27,10 +29,12 @@ export const LOCKUP = Object.freeze({
|
|
|
27
29
|
tagline: Object.freeze({ cap: 0.4, gap: 0.55 }),
|
|
28
30
|
/** Clear space all round. */
|
|
29
31
|
clear: 0.25,
|
|
32
|
+
/** The split line: the words' cap height (as beside the mark), the mark's height and the space either side of it, as shares of that cap height. */
|
|
33
|
+
split: Object.freeze({ cap: 0.42, mark: 1.3, gap: 0.62 }),
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
/** The layouts. */
|
|
33
|
-
export const LAYOUTS = Object.freeze(/** @type {const} */ (['horizontal', 'stacked', 'mark']));
|
|
37
|
+
export const LAYOUTS = Object.freeze(/** @type {const} */ (['horizontal', 'stacked', 'split', 'mark']));
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
40
|
* Whether a set line has any ink.
|
|
@@ -67,7 +71,8 @@ function wordBlock(name, tagline, cap) {
|
|
|
67
71
|
* @param {import('./lockup.js').LockupInput} o - The mark, the name (and tagline) set as outlines, the layout and colours.
|
|
68
72
|
* @returns {import('./lockup.js').Lockup} The SVG, its inner markup, its size and where the mark sits.
|
|
69
73
|
*/
|
|
70
|
-
export function lockup({ mark, name, tagline, layout = 'horizontal', markColor, textColor = markColor, taglineColor = textColor, ground, clear = LOCKUP.clear }) {
|
|
74
|
+
export function lockup({ mark, name, tagline, split, layout = 'horizontal', markColor, textColor = markColor, taglineColor = textColor, ground, clear = LOCKUP.clear }) {
|
|
75
|
+
if (layout === 'split' && split && inked(split[0]) && inked(split[1])) return splitLockup({ mark, split, tagline, markColor, textColor, taglineColor, ground, clear });
|
|
71
76
|
const ink = mark.box;
|
|
72
77
|
const H = LOCKUP.mark;
|
|
73
78
|
const k = H / Math.max(ink.h, ink.w / LOCKUP.wide);
|
|
@@ -82,6 +87,7 @@ export function lockup({ mark, name, tagline, layout = 'horizontal', markColor,
|
|
|
82
87
|
box = { x: 0, y: 0, w: mw, h: mh };
|
|
83
88
|
markAt = { x: 0, y: 0, w: mw, h: mh };
|
|
84
89
|
} else {
|
|
90
|
+
// a split without two words to part falls back to the horizontal
|
|
85
91
|
const L = layout === 'stacked' ? 'stacked' : 'horizontal';
|
|
86
92
|
const tag = inked(tagline) ? tagline : null;
|
|
87
93
|
const cap = LOCKUP.cap[L] * H;
|
|
@@ -115,3 +121,50 @@ export function lockup({ mark, name, tagline, layout = 'horizontal', markColor,
|
|
|
115
121
|
mark: { x: markAt.x + dx, y: markAt.y + dy, w: markAt.w, h: markAt.h },
|
|
116
122
|
};
|
|
117
123
|
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The split line: the first word, the mark at about cap height between, the rest; a tagline (when given) centred
|
|
127
|
+
* under the whole line. The mark is sized to the words, not the words to the mark, and its clear space is a quarter
|
|
128
|
+
* of its own height, as in the other layouts.
|
|
129
|
+
*
|
|
130
|
+
* @param {{ mark: import('../brand/mark.js').Mark, split: [import('../brand/type.js').TypeSet, import('../brand/type.js').TypeSet], tagline?: import('../brand/type.js').TypeSet | null, markColor: string, textColor: string, taglineColor: string, ground?: string, clear: number }} o - The parts.
|
|
131
|
+
* @returns {import('./lockup.js').Lockup} The lockup.
|
|
132
|
+
*/
|
|
133
|
+
function splitLockup({ mark, split: [a, b], tagline, markColor, textColor, taglineColor, ground, clear }) {
|
|
134
|
+
const S = LOCKUP.split, cap = S.cap * LOCKUP.mark;
|
|
135
|
+
const ink = mark.box;
|
|
136
|
+
// the mark's height at the line's scale; a wide mark by its width, so it doesn't run long
|
|
137
|
+
const target = S.mark * cap, k = target / Math.max(ink.h, ink.w / LOCKUP.wide);
|
|
138
|
+
const mw = ink.w * k, mh = ink.h * k;
|
|
139
|
+
const sa = cap / a.cap, sb = cap / b.cap;
|
|
140
|
+
// the space either side of the mark grows with the letter-spacing, so in widely tracked capitals the mark still sits a
|
|
141
|
+
// word apart, not a letter apart (a set line is drawn at SIZE 100 em units: its tracking in those units is tracking/10)
|
|
142
|
+
const track = Math.max(0, a.tracking || 0) / 10 * sa;
|
|
143
|
+
const gap = S.gap * cap + 1.6 * track;
|
|
144
|
+
const aw = a.box.w * sa, bw = b.box.w * sb;
|
|
145
|
+
const baseline = 0;
|
|
146
|
+
// the mark centred on the capitals' band
|
|
147
|
+
const my = baseline - cap / 2 - mh / 2;
|
|
148
|
+
const xb = aw + gap + mw + gap;
|
|
149
|
+
let parts = `<g transform="translate(${num(-a.box.x * sa, 3)} ${num(baseline, 3)}) scale(${num(sa, 5)})" fill="${textColor}">${a.paths}</g>`;
|
|
150
|
+
parts += `<g transform="translate(${num(aw + gap - ink.x * k, 3)} ${num(my - ink.y * k, 3)}) scale(${num(k, 5)})">${markBody(mark, markColor)}</g>`;
|
|
151
|
+
parts += `<g transform="translate(${num(xb - b.box.x * sb, 3)} ${num(baseline, 3)}) scale(${num(sb, 5)})" fill="${textColor}">${b.paths}</g>`;
|
|
152
|
+
const w = xb + bw;
|
|
153
|
+
let top = Math.min(my, baseline + a.box.y * sa, baseline + b.box.y * sb);
|
|
154
|
+
let bottom = Math.max(my + mh, baseline + (a.box.y + a.box.h) * sa, baseline + (b.box.y + b.box.h) * sb);
|
|
155
|
+
if (inked(tagline)) {
|
|
156
|
+
const tcap = LOCKUP.tagline.cap * cap, ts = tcap / tagline.cap;
|
|
157
|
+
const tb = Math.max(bottom, baseline) + LOCKUP.tagline.gap * cap + tcap, tw = tagline.box.w * ts;
|
|
158
|
+
parts += `<g transform="translate(${num((w - tw) / 2 - tagline.box.x * ts, 3)} ${num(tb, 3)}) scale(${num(ts, 5)})" fill="${taglineColor}">${tagline.paths}</g>`;
|
|
159
|
+
bottom = Math.max(bottom, tb + (tagline.box.y + tagline.box.h) * ts);
|
|
160
|
+
}
|
|
161
|
+
const pad = clear * mh;
|
|
162
|
+
const width = Number(num(w + 2 * pad)), height = Number(num(bottom - top + 2 * pad));
|
|
163
|
+
const dx = pad, dy = pad - top;
|
|
164
|
+
const body = `${ground ? `<rect width="${width}" height="${height}" fill="${ground}"/>` : ''}<g transform="translate(${num(dx, 3)} ${num(dy, 3)})">${parts}</g>`;
|
|
165
|
+
return {
|
|
166
|
+
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}">${body}</svg>\n`,
|
|
167
|
+
body, width, height,
|
|
168
|
+
mark: { x: aw + gap + dx, y: my + dy, w: mw, h: mh },
|
|
169
|
+
};
|
|
170
|
+
}
|