@mccaskie-labs/workbench-ui 0.11.0 → 0.12.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
@@ -1,5 +1,17 @@
1
1
  # @mccaskie-labs/workbench-ui
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Two theme tokens from the site layout (theming step 5): `--wb-page-width` (standard 72rem, narrow 56rem, wide 90rem) and `--wb-section-space` (standard 2.5rem, compact 1.5rem, airy 4rem), worked out from brand.json's `layout` or the look's own. workbench-site's frame reads them. Calm (centred layout) gets airy spacing and Bold (showcase) a wide page; the other looks are unchanged.
8
+
9
+ ## 0.11.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Short answers get sensible widths in every tool (Robert, 24 November 2026). A tool's own one-line fields for an email, a phone number, a date, a time, a small number, an amount or a postcode now carry workbench-ui's `wb-ui-size-<n>` class, so they are about as wide as what they hold instead of the full width, and never wider than their column. The "type this word to confirm" box in "Are you sure?" is as wide as its word. Names, addresses and other long text keep the full width. A project restyles the widths in project.css by the same class names. Needs workbench-ui 0.10.0 or later in the project, whose workbench.css carries the classes.
14
+
3
15
  ## 0.11.0
4
16
 
5
17
  ### Minor Changes
package/dist/confirm.js CHANGED
@@ -18,8 +18,10 @@ export function renderConfirm(o) {
18
18
  const reason = o.reason
19
19
  ? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.reason.label)}</span><input class="${p}-confirm-input" type="text" name="${esc(o.reason.name ?? "reason")}" maxlength="${o.reason.maxlength ?? 200}"${o.reason.required ? " required" : ""}></label>`
20
20
  : "";
21
+ // The word box is as wide as the word (workbench-ui's wb-ui-size-<n>, in characters), not the width of the page.
22
+ const wordSize = o.type ? [5, 6, 8, 10, 12, 14, 16, 20, 24, 30, 40].find((n) => n > o.type.word.length) : undefined;
21
23
  const type = o.type
22
- ? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.type.label)}</span><input class="${p}-confirm-input" type="text" name="confirm_word" required pattern="${esc(pattern(o.type.word))}" autocomplete="off" autocapitalize="off" spellcheck="false"></label>`
24
+ ? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.type.label)}</span><input class="${p}-confirm-input${wordSize ? ` wb-ui-size-${wordSize}` : ""}" type="text" name="confirm_word" required pattern="${esc(pattern(o.type.word))}" autocomplete="off" autocapitalize="off" spellcheck="false"></label>`
23
25
  : "";
24
26
  return `<details class="${p}-confirm"${o.open ? " open" : ""}><summary class="${p}-confirm-open ${esc(o.askClass)}"><span class="${p}-confirm-ask">${esc(o.ask)}</span><span class="${p}-confirm-keep">${esc(o.no)}</span></summary><form class="${p}-confirm-form" method="post" action="${esc(o.endpoint)}">${hidden}<p class="${p}-confirm-question">${esc(o.question)}</p>${o.consequence ? `<p class="${p}-confirm-consequence">${esc(o.consequence)}</p>` : ""}${reason}${o.extra ?? ""}${type}<button class="${p}-confirm-yes" type="submit">${esc(o.yes)}</button></form></details>`;
25
27
  }
package/dist/theme.js CHANGED
@@ -32,6 +32,8 @@ export const THEME_TOKENS = [
32
32
  { name: "--wb-radius-small", about: "Corner rounding of buttons and fields", from: "set" },
33
33
  { name: "--wb-space", about: "The base gap that spacing multiplies", from: "set" },
34
34
  { name: "--wb-control-height", about: "Least height of a button or field (a touch target)", from: "fixed" },
35
+ { name: "--wb-page-width", about: "The widest a site page's header, footer and sections get (the site layout's width)", from: "set" },
36
+ { name: "--wb-section-space", about: "The space above and below each section of a site page (the site layout's spacing)", from: "set" },
35
37
  ];
36
38
  const SANS = 'system-ui,-apple-system,"Segoe UI",Roboto,sans-serif';
37
39
  const SERIF = 'Georgia,"Times New Roman",serif';
@@ -128,8 +130,11 @@ function untilContrast(colour, against, towards, ratio) {
128
130
  // ---- the theme ---------------------------------------------------------------------
129
131
  /** Text on a filled accent button: near-black or white, whichever reads better. */
130
132
  const onAccent = (accent) => (contrast(accent, "#111111") >= contrast(accent, "#ffffff") ? "#111111" : "#ffffff");
133
+ /** What a site layout's width and spacing words come to (docs/look-studio.md §6). */
134
+ const PAGE_WIDTHS = { standard: "72rem", narrow: "56rem", wide: "90rem" };
135
+ const SECTION_SPACES = { standard: "2.5rem", compact: "1.5rem", airy: "4rem" };
131
136
  /** The palette and fonts behind a theme, before the in-between values are worked out. */
132
- function themeFrom(p, scheme, fonts, shape) {
137
+ function themeFrom(p, scheme, fonts, shape, layout = { width: "standard", spacing: "standard" }) {
133
138
  const dark = scheme === "dark";
134
139
  const { radius, small } = RADII[shape];
135
140
  const tokens = {
@@ -154,6 +159,8 @@ function themeFrom(p, scheme, fonts, shape) {
154
159
  "--wb-radius-small": small,
155
160
  "--wb-space": "1rem",
156
161
  "--wb-control-height": "2.75rem",
162
+ "--wb-page-width": PAGE_WIDTHS[layout.width],
163
+ "--wb-section-space": SECTION_SPACES[layout.spacing],
157
164
  };
158
165
  return { scheme, tokens };
159
166
  }
@@ -184,7 +191,7 @@ export function resolveTheme(input = {}, lib = LIBRARY) {
184
191
  heading: family(input.fonts?.heading, lookFonts.heading) ?? lookFonts.heading,
185
192
  body: family(input.fonts?.body, lookFonts.body) ?? lookFonts.body,
186
193
  };
187
- return themeFrom(p, scheme, fonts, input.shape ?? look.shape);
194
+ return themeFrom(p, scheme, fonts, input.shape ?? look.shape, resolveSiteLayout(input, lib));
188
195
  }
189
196
  /**
190
197
  * The look of a project's own admin pages (Robert, 24 November 2026): the
@@ -196,7 +203,7 @@ export function resolveAdminTheme(input = {}, lib = LIBRARY) {
196
203
  const site = resolveTheme(input, lib);
197
204
  const clean = lookById("clean", lib).light;
198
205
  const accent = untilContrast(site.tokens["--wb-accent"], clean.background, "#000000", 4.5);
199
- return themeFrom({ ...clean, accent }, "light", { heading: site.tokens["--wb-font-heading"], body: site.tokens["--wb-font"] }, input.shape ?? lookById(input.look ?? DEFAULT_LOOK, lib).shape);
206
+ return themeFrom({ ...clean, accent }, "light", { heading: site.tokens["--wb-font-heading"], body: site.tokens["--wb-font"] }, input.shape ?? lookById(input.look ?? DEFAULT_LOOK, lib).shape, resolveSiteLayout(input, lib));
200
207
  }
201
208
  /** A project's site layout: brand.json's `layout`, else its look's (docs/look-studio.md §6). */
202
209
  export function resolveSiteLayout(input = {}, lib = LIBRARY) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-ui",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Workbench pages: one dark look, a top bar with the environment tag, cards, outcome pills, and one format for times, money and durations.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",