@mccaskie-labs/workbench-ui 0.9.0 → 0.10.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.
@@ -0,0 +1,473 @@
1
+ // Written by `npm run library` from packages/ui/library/. Don't edit: change the JSON files and run it again.
2
+ export const PACKAGED_LIBRARY = [
3
+ {
4
+ "kind": "palette",
5
+ "id": "bold",
6
+ "title": "Bold magenta",
7
+ "group": "pink",
8
+ "about": "Black and white with a hot magenta",
9
+ "light": {
10
+ "background": "#ffffff",
11
+ "text": "#121212",
12
+ "muted": "#555555",
13
+ "accent": "#b0136a",
14
+ "danger": "#b42318",
15
+ "success": "#15803d",
16
+ "warning": "#a15c07"
17
+ },
18
+ "dark": {
19
+ "background": "#121212",
20
+ "text": "#ffffff",
21
+ "muted": "#b3b3b3",
22
+ "accent": "#ff5cb0",
23
+ "danger": "#ff7a73",
24
+ "success": "#5cc87a",
25
+ "warning": "#f0a43a"
26
+ },
27
+ "status": "released",
28
+ "source": "Workbench, theming step 1 (24 November 2026)",
29
+ "since": "0.7.0"
30
+ },
31
+ {
32
+ "kind": "palette",
33
+ "id": "bright",
34
+ "title": "Bright primary",
35
+ "group": "bright",
36
+ "about": "Deep indigo with a bright blue, sunny yellow in the dark",
37
+ "light": {
38
+ "background": "#ffffff",
39
+ "text": "#1e1b4b",
40
+ "muted": "#55527a",
41
+ "accent": "#1d64c8",
42
+ "danger": "#b42318",
43
+ "success": "#15803d",
44
+ "warning": "#a15c07"
45
+ },
46
+ "dark": {
47
+ "background": "#151337",
48
+ "text": "#f1f0ff",
49
+ "muted": "#b4b1d9",
50
+ "accent": "#fbbf24",
51
+ "danger": "#ff7a73",
52
+ "success": "#5cc87a",
53
+ "warning": "#f0a43a"
54
+ },
55
+ "status": "released",
56
+ "source": "Workbench, theming step 1 (24 November 2026)",
57
+ "since": "0.7.0"
58
+ },
59
+ {
60
+ "kind": "palette",
61
+ "id": "calm",
62
+ "title": "Calm sage",
63
+ "group": "green",
64
+ "about": "Soft stone and sage green",
65
+ "light": {
66
+ "background": "#f6f4ef",
67
+ "text": "#2b2f2a",
68
+ "muted": "#5d635b",
69
+ "accent": "#4a6b46",
70
+ "danger": "#b42318",
71
+ "success": "#15803d",
72
+ "warning": "#a15c07"
73
+ },
74
+ "dark": {
75
+ "background": "#161a16",
76
+ "text": "#e6ebe4",
77
+ "muted": "#a7b0a4",
78
+ "accent": "#9cc596",
79
+ "danger": "#ff7a73",
80
+ "success": "#5cc87a",
81
+ "warning": "#f0a43a"
82
+ },
83
+ "status": "released",
84
+ "source": "Workbench, theming step 1 (24 November 2026)",
85
+ "since": "0.7.0"
86
+ },
87
+ {
88
+ "kind": "palette",
89
+ "id": "clean",
90
+ "title": "Clean blue",
91
+ "group": "blue",
92
+ "about": "Crisp white and a confident blue",
93
+ "light": {
94
+ "background": "#ffffff",
95
+ "text": "#1f2937",
96
+ "muted": "#5b6472",
97
+ "accent": "#2563eb",
98
+ "danger": "#b42318",
99
+ "success": "#15803d",
100
+ "warning": "#a15c07"
101
+ },
102
+ "dark": {
103
+ "background": "#121214",
104
+ "text": "#e8e8ec",
105
+ "muted": "#a0a0ac",
106
+ "accent": "#6aa1ff",
107
+ "danger": "#ff7a73",
108
+ "success": "#5cc87a",
109
+ "warning": "#f0a43a"
110
+ },
111
+ "status": "released",
112
+ "source": "Workbench, theming step 1 (24 November 2026)",
113
+ "since": "0.7.0"
114
+ },
115
+ {
116
+ "kind": "palette",
117
+ "id": "friendly",
118
+ "title": "Friendly teal",
119
+ "group": "teal",
120
+ "about": "Off-white and an open teal",
121
+ "light": {
122
+ "background": "#fafaf7",
123
+ "text": "#273036",
124
+ "muted": "#58636a",
125
+ "accent": "#0f766e",
126
+ "danger": "#b42318",
127
+ "success": "#15803d",
128
+ "warning": "#a15c07"
129
+ },
130
+ "dark": {
131
+ "background": "#121a19",
132
+ "text": "#e7efed",
133
+ "muted": "#a5b4b1",
134
+ "accent": "#4fd1c5",
135
+ "danger": "#ff7a73",
136
+ "success": "#5cc87a",
137
+ "warning": "#f0a43a"
138
+ },
139
+ "status": "released",
140
+ "source": "Workbench, theming step 1 (24 November 2026)",
141
+ "since": "0.7.0"
142
+ },
143
+ {
144
+ "kind": "palette",
145
+ "id": "sturdy",
146
+ "title": "Sturdy navy",
147
+ "group": "orange",
148
+ "about": "Navy text with a safety orange",
149
+ "light": {
150
+ "background": "#ffffff",
151
+ "text": "#14213d",
152
+ "muted": "#4d5873",
153
+ "accent": "#c2410c",
154
+ "danger": "#b42318",
155
+ "success": "#15803d",
156
+ "warning": "#a15c07"
157
+ },
158
+ "dark": {
159
+ "background": "#0f1626",
160
+ "text": "#e9edf5",
161
+ "muted": "#a3adc2",
162
+ "accent": "#fb8c3c",
163
+ "danger": "#ff7a73",
164
+ "success": "#5cc87a",
165
+ "warning": "#f0a43a"
166
+ },
167
+ "status": "released",
168
+ "source": "Workbench, theming step 1 (24 November 2026)",
169
+ "since": "0.7.0"
170
+ },
171
+ {
172
+ "kind": "palette",
173
+ "id": "warm",
174
+ "title": "Warm clay",
175
+ "group": "earth",
176
+ "about": "Cream and terracotta, like a kitchen",
177
+ "light": {
178
+ "background": "#fbf6ef",
179
+ "text": "#3b2a20",
180
+ "muted": "#6e5a4c",
181
+ "accent": "#a8441f",
182
+ "danger": "#b42318",
183
+ "success": "#15803d",
184
+ "warning": "#a15c07"
185
+ },
186
+ "dark": {
187
+ "background": "#1c1612",
188
+ "text": "#f3e9df",
189
+ "muted": "#bfae9f",
190
+ "accent": "#f08a5d",
191
+ "danger": "#ff7a73",
192
+ "success": "#5cc87a",
193
+ "warning": "#f0a43a"
194
+ },
195
+ "status": "released",
196
+ "source": "Workbench, theming step 1 (24 November 2026)",
197
+ "since": "0.7.0"
198
+ },
199
+ {
200
+ "kind": "pairing",
201
+ "id": "archivo",
202
+ "title": "Archivo throughout",
203
+ "about": "A strong grotesque for loud headings",
204
+ "heading": {
205
+ "family": "Archivo",
206
+ "fallback": "sans"
207
+ },
208
+ "body": {
209
+ "family": "Archivo",
210
+ "fallback": "sans"
211
+ },
212
+ "status": "released",
213
+ "source": "Workbench, theming step 1 (24 November 2026)",
214
+ "since": "0.10.0"
215
+ },
216
+ {
217
+ "kind": "pairing",
218
+ "id": "baloo-nunito",
219
+ "title": "Round and playful",
220
+ "about": "Bouncy headings over a rounded sans",
221
+ "heading": {
222
+ "family": "Baloo 2",
223
+ "fallback": "sans"
224
+ },
225
+ "body": {
226
+ "family": "Nunito",
227
+ "fallback": "sans"
228
+ },
229
+ "status": "released",
230
+ "source": "Workbench, theming step 1 (24 November 2026)",
231
+ "since": "0.10.0"
232
+ },
233
+ {
234
+ "kind": "pairing",
235
+ "id": "barlow",
236
+ "title": "Condensed headings and plain text",
237
+ "about": "Tall, narrow headings over a plain sans",
238
+ "heading": {
239
+ "family": "Barlow Condensed",
240
+ "fallback": "sans"
241
+ },
242
+ "body": {
243
+ "family": "Barlow",
244
+ "fallback": "sans"
245
+ },
246
+ "status": "released",
247
+ "source": "Workbench, theming step 1 (24 November 2026)",
248
+ "since": "0.10.0"
249
+ },
250
+ {
251
+ "kind": "pairing",
252
+ "id": "fraunces-source-sans",
253
+ "title": "Warm serif and clean sans",
254
+ "about": "A soft serif for headings over an easy sans",
255
+ "heading": {
256
+ "family": "Fraunces",
257
+ "fallback": "serif"
258
+ },
259
+ "body": {
260
+ "family": "Source Sans 3",
261
+ "fallback": "sans"
262
+ },
263
+ "status": "released",
264
+ "source": "Workbench, theming step 1 (24 November 2026)",
265
+ "since": "0.10.0"
266
+ },
267
+ {
268
+ "kind": "pairing",
269
+ "id": "inter",
270
+ "title": "Inter throughout",
271
+ "about": "One clean sans for headings and text",
272
+ "heading": {
273
+ "family": "Inter",
274
+ "fallback": "sans"
275
+ },
276
+ "body": {
277
+ "family": "Inter",
278
+ "fallback": "sans"
279
+ },
280
+ "status": "released",
281
+ "source": "Workbench, theming step 1 (24 November 2026)",
282
+ "since": "0.10.0"
283
+ },
284
+ {
285
+ "kind": "pairing",
286
+ "id": "nunito-sans",
287
+ "title": "Nunito Sans throughout",
288
+ "about": "A rounded, quiet sans",
289
+ "heading": {
290
+ "family": "Nunito Sans",
291
+ "fallback": "sans"
292
+ },
293
+ "body": {
294
+ "family": "Nunito Sans",
295
+ "fallback": "sans"
296
+ },
297
+ "status": "released",
298
+ "source": "Workbench, theming step 1 (24 November 2026)",
299
+ "since": "0.10.0"
300
+ },
301
+ {
302
+ "kind": "pairing",
303
+ "id": "work-sans",
304
+ "title": "Work Sans throughout",
305
+ "about": "An open, friendly sans",
306
+ "heading": {
307
+ "family": "Work Sans",
308
+ "fallback": "sans"
309
+ },
310
+ "body": {
311
+ "family": "Work Sans",
312
+ "fallback": "sans"
313
+ },
314
+ "status": "released",
315
+ "source": "Workbench, theming step 1 (24 November 2026)",
316
+ "since": "0.10.0"
317
+ },
318
+ {
319
+ "kind": "layout",
320
+ "id": "centred",
321
+ "title": "Centred and airy",
322
+ "bestFor": "Quiet sites with few pages: the name centred over the menu, more space between sections",
323
+ "header": "centred",
324
+ "footer": "centred",
325
+ "width": "standard",
326
+ "spacing": "airy",
327
+ "hero": "over-picture",
328
+ "status": "released",
329
+ "source": "Workbench, theming step 1 (24 November 2026)",
330
+ "since": "0.10.0"
331
+ },
332
+ {
333
+ "kind": "layout",
334
+ "id": "showcase",
335
+ "title": "Showcase",
336
+ "bestFor": "Sites that sell a night out or a hire: a wide page, one button in the header, columns at the foot",
337
+ "header": "menu-centre",
338
+ "footer": "columns",
339
+ "width": "wide",
340
+ "spacing": "standard",
341
+ "hero": "over-picture",
342
+ "status": "released",
343
+ "source": "Workbench, theming step 1 (24 November 2026)",
344
+ "since": "0.10.0"
345
+ },
346
+ {
347
+ "kind": "layout",
348
+ "id": "standard",
349
+ "title": "Standard",
350
+ "bestFor": "Most sites: name left, menu right, one line of links at the foot",
351
+ "header": "menu-right",
352
+ "footer": "line",
353
+ "width": "standard",
354
+ "spacing": "standard",
355
+ "hero": "plain",
356
+ "status": "released",
357
+ "source": "Workbench, theming step 1 (24 November 2026)",
358
+ "since": "0.10.0"
359
+ },
360
+ {
361
+ "kind": "look",
362
+ "id": "bold",
363
+ "title": "Bold",
364
+ "feel": "Lively, for nights out",
365
+ "suggestedFor": [
366
+ "Venues, hire and tours"
367
+ ],
368
+ "palette": "bold",
369
+ "pairing": "archivo",
370
+ "layout": "showcase",
371
+ "shape": "soft",
372
+ "status": "released",
373
+ "source": "Workbench, theming step 1 (24 November 2026)",
374
+ "since": "0.7.0"
375
+ },
376
+ {
377
+ "kind": "look",
378
+ "id": "bright",
379
+ "title": "Bright",
380
+ "feel": "Playful and friendly to kids",
381
+ "suggestedFor": [
382
+ "Learning and kids"
383
+ ],
384
+ "palette": "bright",
385
+ "pairing": "baloo-nunito",
386
+ "layout": "standard",
387
+ "shape": "round",
388
+ "status": "released",
389
+ "source": "Workbench, theming step 1 (24 November 2026)",
390
+ "since": "0.7.0"
391
+ },
392
+ {
393
+ "kind": "look",
394
+ "id": "calm",
395
+ "title": "Calm",
396
+ "feel": "Quiet and airy",
397
+ "suggestedFor": [
398
+ "Health, beauty and fitness"
399
+ ],
400
+ "palette": "calm",
401
+ "pairing": "nunito-sans",
402
+ "layout": "centred",
403
+ "shape": "round",
404
+ "status": "released",
405
+ "source": "Workbench, theming step 1 (24 November 2026)",
406
+ "since": "0.7.0"
407
+ },
408
+ {
409
+ "kind": "look",
410
+ "id": "clean",
411
+ "title": "Clean",
412
+ "feel": "Plain and trustworthy",
413
+ "suggestedFor": [
414
+ "General",
415
+ "Professional and creative"
416
+ ],
417
+ "palette": "clean",
418
+ "pairing": "inter",
419
+ "layout": "standard",
420
+ "shape": "soft",
421
+ "status": "released",
422
+ "source": "Workbench, theming step 1 (24 November 2026)",
423
+ "since": "0.7.0"
424
+ },
425
+ {
426
+ "kind": "look",
427
+ "id": "friendly",
428
+ "title": "Friendly",
429
+ "feel": "Open, for community groups",
430
+ "suggestedFor": [
431
+ "Community"
432
+ ],
433
+ "palette": "friendly",
434
+ "pairing": "work-sans",
435
+ "layout": "standard",
436
+ "shape": "soft",
437
+ "status": "released",
438
+ "source": "Workbench, theming step 1 (24 November 2026)",
439
+ "since": "0.7.0"
440
+ },
441
+ {
442
+ "kind": "look",
443
+ "id": "sturdy",
444
+ "title": "Sturdy",
445
+ "feel": "Solid and no-nonsense",
446
+ "suggestedFor": [
447
+ "Trades and home"
448
+ ],
449
+ "palette": "sturdy",
450
+ "pairing": "barlow",
451
+ "layout": "standard",
452
+ "shape": "square",
453
+ "status": "released",
454
+ "source": "Workbench, theming step 1 (24 November 2026)",
455
+ "since": "0.7.0"
456
+ },
457
+ {
458
+ "kind": "look",
459
+ "id": "warm",
460
+ "title": "Warm",
461
+ "feel": "Welcoming and homely",
462
+ "suggestedFor": [
463
+ "Food and stays"
464
+ ],
465
+ "palette": "warm",
466
+ "pairing": "fraunces-source-sans",
467
+ "layout": "standard",
468
+ "shape": "soft",
469
+ "status": "released",
470
+ "source": "Workbench, theming step 1 (24 November 2026)",
471
+ "since": "0.7.0"
472
+ }
473
+ ];
@@ -0,0 +1,134 @@
1
+ // The look library (docs/look-studio.md §4, Robert, 24 November 2026): the
2
+ // palettes, font pairings, site layouts and looks every project can use, as
3
+ // small checked data files instead of a fixed list in code. The package's own
4
+ // items live in packages/ui/library/<kind>s/<id>.json and are compiled into
5
+ // library.generated.ts by `npm run library`; a project may add its own in
6
+ // workbench/looks/*.json (same shape), which is how an item from the look
7
+ // studio works in an owner's projects before it is in a release.
8
+ //
9
+ // Every item has a state: `testing` (usable, not offered by default),
10
+ // `released` (offered everywhere; a released item never changes, a change is
11
+ // a new id) or `withdrawn` (no longer offered; projects naming it keep working).
12
+ import { PACKAGED_LIBRARY } from "./library.generated.js";
13
+ /** The choices a site layout makes (docs/look-studio.md §6), each list's first is the default. */
14
+ export const SITE_LAYOUT_CHOICES = {
15
+ header: ["menu-right", "centred", "menu-centre"],
16
+ footer: ["line", "columns", "centred"],
17
+ width: ["standard", "narrow", "wide"],
18
+ spacing: ["standard", "compact", "airy"],
19
+ hero: ["plain", "over-picture", "beside-picture"],
20
+ };
21
+ export const LIBRARY_KINDS = ["palette", "pairing", "layout", "look"];
22
+ const KEY = { palette: "palettes", pairing: "pairings", layout: "layouts", look: "looks" };
23
+ /** Sorts items into a library, by kind then in the order given. */
24
+ export function libraryOf(items) {
25
+ const lib = { palettes: [], pairings: [], layouts: [], looks: [] };
26
+ for (const item of items)
27
+ lib[KEY[item.kind]].push(item);
28
+ return lib;
29
+ }
30
+ /** The library that ships in this version of workbench-ui. */
31
+ export const LIBRARY = libraryOf(PACKAGED_LIBRARY);
32
+ /** The package's library with a project's own items added after it. */
33
+ export function withProjectItems(items, base = LIBRARY) {
34
+ return libraryOf([...base.palettes, ...base.pairings, ...base.layouts, ...base.looks, ...items]);
35
+ }
36
+ export function findItem(lib, kind, id) {
37
+ return lib[KEY[kind]].find((i) => i.id === id);
38
+ }
39
+ /** Items a project or the New project form may choose: not withdrawn. Released ones first. */
40
+ export function usable(items) {
41
+ return items.filter((i) => i.status !== "withdrawn").sort((a, b) => Number(b.status === "released") - Number(a.status === "released"));
42
+ }
43
+ // ---- checking one item's shape -------------------------------------------------------
44
+ const HEX = /^#[0-9a-f]{6}$/;
45
+ const ID = /^[a-z][a-z0-9-]{1,39}$/;
46
+ const FAMILY = /^[\w .'-]{1,100}$/;
47
+ const PALETTE_KEYS = ["background", "text", "muted", "accent", "danger", "success", "warning"];
48
+ const STATUSES = ["testing", "released", "withdrawn"];
49
+ const SHAPES = ["square", "soft", "round"];
50
+ const isObj = (x) => !!x && typeof x === "object" && !Array.isArray(x);
51
+ const line = (x, max = 120) => typeof x === "string" && x.trim().length > 0 && x.length <= max && !/[<>\n]/.test(x);
52
+ /** Fields every kind has, and the ones each kind adds. Anything else is refused, so a file can't smuggle in CSS. */
53
+ const FIELDS = {
54
+ palette: ["group", "about", "light", "dark"],
55
+ pairing: ["about", "heading", "body"],
56
+ layout: ["bestFor", ...Object.keys(SITE_LAYOUT_CHOICES)],
57
+ look: ["feel", "suggestedFor", "palette", "pairing", "layout", "shape"],
58
+ };
59
+ const BASE_FIELDS = ["kind", "id", "title", "status", "source", "since"];
60
+ /**
61
+ * What is wrong with one library file's contents, in plain words (empty when
62
+ * it is a good item). Checks shape only; whether its colours read and whether
63
+ * it names real parts are `libraryProblems`'.
64
+ */
65
+ export function itemProblems(raw) {
66
+ if (!isObj(raw))
67
+ return ["must hold an object"];
68
+ const kind = raw.kind;
69
+ if (!LIBRARY_KINDS.includes(kind))
70
+ return [`kind must be one of ${LIBRARY_KINDS.join(", ")}`];
71
+ const p = [];
72
+ for (const k of Object.keys(raw))
73
+ if (!BASE_FIELDS.includes(k) && !FIELDS[kind].includes(k))
74
+ p.push(`${k} isn't a field of a ${kind}`);
75
+ if (typeof raw.id !== "string" || !ID.test(raw.id))
76
+ p.push("id must be 2 to 40 lower-case letters, digits and dashes, starting with a letter");
77
+ if (!line(raw.title, 60))
78
+ p.push("title must be one line of up to 60 characters");
79
+ if (!STATUSES.includes(raw.status))
80
+ p.push(`status must be one of ${STATUSES.join(", ")}`);
81
+ if (!line(raw.source, 200))
82
+ p.push("source must say who or what made it, and when");
83
+ if (!line(raw.since, 20))
84
+ p.push('since must be a workbench-ui version, or "project"');
85
+ if (kind === "palette") {
86
+ if (typeof raw.group !== "string" || !ID.test(raw.group))
87
+ p.push("group must be a short lower-case word such as green");
88
+ if (!line(raw.about))
89
+ p.push("about must be one line");
90
+ for (const scheme of ["light", "dark"]) {
91
+ const pal = raw[scheme];
92
+ if (!isObj(pal)) {
93
+ p.push(`${scheme} must hold the palette's ${scheme} colours`);
94
+ continue;
95
+ }
96
+ for (const k of Object.keys(pal))
97
+ if (!PALETTE_KEYS.includes(k))
98
+ p.push(`${scheme}.${k} isn't a palette colour`);
99
+ for (const k of PALETTE_KEYS)
100
+ if (typeof pal[k] !== "string" || !HEX.test(pal[k]))
101
+ p.push(`${scheme}.${k} must be a lower-case colour like #1f6feb`);
102
+ }
103
+ }
104
+ if (kind === "pairing") {
105
+ if (!line(raw.about))
106
+ p.push("about must be one line");
107
+ for (const part of ["heading", "body"]) {
108
+ const f = raw[part];
109
+ if (!isObj(f) || typeof f.family !== "string" || !FAMILY.test(f.family) || (f.fallback !== "sans" && f.fallback !== "serif") || Object.keys(f).length !== 2) {
110
+ p.push(`${part} must be { "family": a font name, "fallback": "sans" or "serif" }`);
111
+ }
112
+ }
113
+ }
114
+ if (kind === "layout") {
115
+ if (!line(raw.bestFor))
116
+ p.push("bestFor must be one line");
117
+ for (const [choice, options] of Object.entries(SITE_LAYOUT_CHOICES)) {
118
+ if (!options.includes(raw[choice]))
119
+ p.push(`${choice} must be one of ${options.join(", ")}`);
120
+ }
121
+ }
122
+ if (kind === "look") {
123
+ if (!line(raw.feel, 60))
124
+ p.push("feel must be one line");
125
+ if (!Array.isArray(raw.suggestedFor) || !raw.suggestedFor.every((g) => line(g, 60)))
126
+ p.push("suggestedFor must list starter groups");
127
+ for (const k of ["palette", "pairing", "layout"])
128
+ if (typeof raw[k] !== "string" || !ID.test(raw[k]))
129
+ p.push(`${k} must name a ${k} by its id`);
130
+ if (!SHAPES.includes(raw.shape))
131
+ p.push(`shape must be one of ${SHAPES.join(", ")}`);
132
+ }
133
+ return p;
134
+ }