@gemboss/website-ui 0.4.0 → 0.5.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.
@@ -27,7 +27,8 @@ BEM-ish: `.gw-block`, `.gw-block__part`, `.gw-block--variant`.
27
27
  ## Script (0.4.0)
28
28
 
29
29
  One script wires every part below: the mega menu, the mobile menu, the theme toggle, reveal, the header's scroll
30
- state, the current page, the segmented control and the busy button. It comes in two entries built from one source
30
+ state, the current page, the segmented control, the busy button, an article's contents list and the scroll box of its
31
+ prose tables (0.5.0). It comes in two entries built from one source
31
32
  (`js/website.mjs`; `scripts/build.mjs` writes `js/website.js` from it and `--check` fails when they differ):
32
33
 
33
34
  | entry | file | how it starts |
@@ -42,9 +43,9 @@ state, the current page, the segmented control and the busy button. It comes in
42
43
  to the page (Escape, the outside click, the busy-button guard, the system theme, the scroll) are installed once.
43
44
  - **`destroy(root = document)`** takes back what `init` wired under `root`: its listeners and its marks. An open
44
45
  mega menu or mobile menu is closed first, so an unmounted menu cannot leave the page locked.
45
- - **`version`**: `'0.4.0'`. The classic script exposes the three as `window.gwWebsite`.
46
+ - **`version`**: `'0.5.0'`. The classic script exposes the three as `window.gwWebsite`.
46
47
  - **`data-gw-ready`**: on each wired element, the parts wired on it (`mega`, `menu`, `theme`, `reveal`, `header`,
47
- `segmented`). It is a mark for people and tests, not a switch: markup copied from a live page, attribute and all,
48
+ `segmented`, `toc`, `table`). It is a mark for people and tests, not a switch: markup copied from a live page, attribute and all,
48
49
  is still wired.
49
50
  - **One copy per page.** The first copy that runs owns the page (`window.gwWebsite`); another one (the classic
50
51
  script next to a bundle, two bundles) hands its calls to it, so nothing is wired twice.
@@ -93,9 +94,11 @@ The script tells the page's own code what changed. Every event is a `CustomEvent
93
94
  | `gw:mega` | the trigger (`[data-gw-mega]`) | `{ id, open }`: the panel's `id`, `true` when it opened | a panel opens or closes: click, hover, Escape, a click outside, focus leaving, a link inside, `destroy` of an open one. Moving to another menu fires a close, then an open |
94
95
  | `gw:theme` | `<html>` | `{ theme: 'light' \| 'dark' }`: the theme the page now shows | a press on a theme toggle; also a change of the system's scheme while the page follows it (no `data-theme`) |
95
96
  | `gw:segmented` | the group (`[data-gw-segmented]`) | `{ name, value }`: the group's name, the chosen option's `value` | the reader chooses an option (click, arrows, Home, End) |
97
+ | `gw:toc` | the contents (`[data-gw-toc]`) | `{ id }`: the id of the heading whose section is now marked, `''` above the first one | the section in view changes: scrolling, a contents link, a jump. Also once after load when the page opens inside a section (a link to `#id`): the observer reports after `init`, never during it |
96
98
 
97
99
  ```js
98
100
  document.addEventListener('gw:theme', function (e) { chart.setTheme(e.detail.theme); });
101
+ document.addEventListener('gw:toc', function (e) { analytics.track('section', e.detail.id); });
99
102
  ```
100
103
 
101
104
  ## Header
@@ -157,6 +160,50 @@ Script behaviour:
157
160
  menu's links whose `href` pathname equals `location.pathname` (when the markup did not already). Each `init` takes
158
161
  its own marks back first, so after a client-side navigation they follow the new path; a mark in the markup stays.
159
162
 
163
+ ## Article: contents and prose tables (0.5.0)
164
+
165
+ ```html
166
+ <article class="gw-wrap gw-article">
167
+ <header class="gw-article__head"> .gw-breadcrumbs, <h1>, .gw-article-meta </header>
168
+ <figure class="gw-article__hero"><img …></figure> <!-- optional -->
169
+ <nav class="gw-toc" aria-label="On this page" data-gw-toc>
170
+ <details> <!-- no open: the script opens it from 1080px -->
171
+ <summary>On this page</summary>
172
+ <ol><li><a href="#section-id">The section's heading</a><ol>…h3s…</ol></li> …</ol>
173
+ </details>
174
+ </nav>
175
+ <div class="gw-prose"> <h2 id="section-id">…</h2> … <table><caption>…</caption>…</table> … </div>
176
+ </article>
177
+ ```
178
+
179
+ - **Contents** (`[data-gw-toc]`, a `.gw-toc`): the script reads its links whose `href` is `#id` of an element on the
180
+ page (percent-encoded ids are decoded; links to other pages and to no id are ignored). With none, the list is not
181
+ wired yet and a later `init` tries again.
182
+ - The section in view is the one whose heading is the last above the line 30% down the window. Its link gets
183
+ `aria-current="true"`; the previous link loses it. Above the first heading no link is marked. Each change fires
184
+ `gw:toc` on the nav.
185
+ - One `IntersectionObserver` per list, observing the linked headings, with
186
+ `rootMargin: '100000px 0px -70% 0px'`: its root runs from far above the window down to the line, so a heading
187
+ is "intersecting" exactly while it is above the line, and a jump across many sections is seen as well as a
188
+ scroll. Each report measures every heading again. Without `IntersectionObserver` nothing is marked; the links
189
+ still work.
190
+ - The `<details>` inside: from 1080px (`matchMedia('(min-width: 1080px)')`, the kit's desktop width, where the CSS makes it sticky) the
191
+ script sets `open`; below it, the markup's own state (folded unless the markup says `open`), again on every
192
+ change of width. Below 1080px a click on a link folds it, in the click, before the browser moves to the section.
193
+ - `destroy`: the observer disconnects, the mark goes, the `<details>` takes the markup's state back.
194
+ - **Prose tables**: every `<table>` that is a child of a `.gw-prose` (not one inside the author's own `.gw-table`, a
195
+ figure or another element) is moved into `<div class="gw-prose__table" role="region" tabindex="0" aria-label="…">`
196
+ at its place, and gets `.is-wrapped`.
197
+ - The name is the text of the table's `<caption>`, else of its first `<th>`, else of its first `<td>`, spaces
198
+ collapsed. A table with no text there is left as it is.
199
+ - The CSS keeps a wrapped table `display: table` (some Safari versions stop announcing a table whose display
200
+ changed) and gives the box the scroll, the hairline and the radius. A table without `.is-wrapped` (no script,
201
+ or before it runs) scrolls by itself with `display: block`, as in 0.2.0. Both look the same.
202
+ - Once per table: a second `init` finds it inside its box and leaves it. `destroy` puts the table back in the
203
+ prose, removes the box, and removes `.is-wrapped` unless the markup had it.
204
+ - A framework that renders the prose's table itself (JSX, not HTML from the CMS) should call `destroy(prose)`
205
+ before it re-renders that part, as for every element the script changed.
206
+
160
207
  ## Brand profiles (0.3.0)
161
208
 
162
209
  - `data-gw-action` and `data-gw-radius` sit on `<html>` only, with a name from `system.json` `profiles` (`ink` or
@@ -208,12 +255,19 @@ Script behaviour:
208
255
  | `.gw-segmented` (+ `--block`) | one choice out of two to four (script above) |
209
256
  | `.gw-badge` (+ `--accent`, `--success`, `--warning`) | small status, pill |
210
257
  | `.gw-card` (+ `--soft`, `--link`) | white box, 1px hairline, the card radius; `--link` makes the whole card an `<a>` |
258
+ | `.gw-card__media` (+ `--wide`, `--square`) | the card's picture, first child, edge to edge on top; 16:9, 1.91:1 or 1:1 (0.5.0) |
259
+ | `.gw-callout` (+ `--note`, `--tip`, `--warning`, `__label`) | a note, a tip or a warning in an article, `role="note"`, its kind in words (0.5.0) |
260
+ | `.gw-breadcrumbs` | `<nav aria-label>` + `<ol>`, the last item `aria-current="page"`; separators drawn by the CSS (0.5.0) |
261
+ | `.gw-article-meta` (+ `__avatar`) | author, category, `<time datetime>`, read time (0.5.0) |
262
+ | `.gw-article` (`__head`, `__hero`), `.gw-toc` | the article page and its contents (script above, 0.5.0) |
263
+ | `.gw-post-list` (+ `--compact`), `.gw-post` (`__title`) | post cards; the title's link covers the card (0.5.0) |
264
+ | `.gw-pagination` (`__status`) | previous / next links, `rel="prev"` / `rel="next"`, markup only (0.5.0) |
211
265
  | `.gw-window` (+ `__bar`, `__body`, `__caption`) | a framed screenshot/mock-up, like a browser or app window; `__caption` (last child) says what its numbers are: "Illustrative data." or their source |
212
266
  | `.gw-icon` | 20px inline stroke SVG wrapper |
213
267
  | `.gw-list--check` | list with check marks |
214
268
  | `.gw-table` (+ `--compare`) | data / comparison table; scrolls inside its box on phones |
215
269
  | `.gw-faq` (`<details class="gw-faq__item"><summary>`) | FAQ accordion with no script |
216
- | `.gw-prose` (+ `--sm`) | long-form reading: an article's own HTML, no classes inside |
270
+ | `.gw-prose` (+ `--sm`) | long-form reading: an article's own HTML, no classes inside; its bare tables get a `.gw-prose__table` box from the script (0.5.0) |
217
271
  | `.gw-tabs` (`role="tablist"`) | NOT in the kit yet (a reported gap would add it) |
218
272
 
219
273
  ## Sections
package/js/website.js CHANGED
@@ -1,11 +1,11 @@
1
- /*! @gemboss/website-ui 0.4.0 website.js | GENERATED by scripts/build.mjs from js/website.mjs (the source, with its comments): edit that file | spec: docs/markup-contract.md | load with defer */
1
+ /*! @gemboss/website-ui 0.5.0 website.js | GENERATED by scripts/build.mjs from js/website.mjs (the source, with its comments): edit that file | spec: docs/markup-contract.md | load with defer */
2
2
  (function () {
3
3
  'use strict';
4
4
  if (window.gwWebsite) return;
5
5
 
6
- var version = '0.4.0';
6
+ var version = '0.5.0';
7
7
  var api = { version: version, init: init, destroy: destroy };
8
- var doc, root, mine, fine, sys, live = [], megaOpen = null, megaTimer = 0, queued = false;
8
+ var doc, root, mine, fine, sys, wide, live = [], megaOpen = null, megaTimer = 0, queued = false;
9
9
  var READY = 'data-gw-ready';
10
10
 
11
11
  function mq(q) { return window.matchMedia ? matchMedia(q) : { matches: false }; }
@@ -18,8 +18,9 @@ function esc(e) { return e.key === 'Escape'; }
18
18
  function link(e) { return e.target.closest('a[href]'); }
19
19
  function emit(el, type, detail) { if (window.CustomEvent) el.dispatchEvent(new CustomEvent(type, { bubbles: true, detail: detail })); }
20
20
 
21
- function each(ctx, sel, kind, fn) {
22
- within(sel, ctx).forEach(function (el) {
21
+ function each(ctx, sel, kind, fn) { wire(within(sel, ctx), kind, fn); }
22
+ function wire(els, kind, fn) {
23
+ els.forEach(function (el) {
23
24
  if (live.some(function (r) { return r.el === el && r.kind === kind; })) return;
24
25
  var offs = [], r = fn(el, function (t, type, f, opt) {
25
26
  on(t, type, f, opt);
@@ -191,14 +192,73 @@ function segmented(ctx) {
191
192
  });
192
193
  }
193
194
 
195
+ function toc(ctx) {
196
+ each(ctx, '[data-gw-toc]', 'toc', function (nav, on) {
197
+ var box = nav.querySelector('details'), own = !!(box && box.open), cur = null, io = null;
198
+ var items = all('a[href]', nav).map(function (a) {
199
+ var id = attr(a, 'href', '');
200
+ if (id.charAt(0) !== '#') return null;
201
+ try { id = decodeURIComponent(id.slice(1)); } catch (e) { id = id.slice(1); }
202
+ return { a: a, h: doc.getElementById(id) };
203
+ }).filter(function (x) { return x && x.h; });
204
+ if (!items.length) return;
205
+ function update() {
206
+ var line = window.innerHeight * 0.3, top = -Infinity, next = null;
207
+ items.forEach(function (x) { var t = x.h.getBoundingClientRect().top; if (t <= line && t > top) { top = t; next = x; } });
208
+ if (next === cur) return;
209
+ if (cur) cur.a.removeAttribute('aria-current');
210
+ if (next) next.a.setAttribute('aria-current', 'true');
211
+ cur = next;
212
+ emit(nav, 'gw:toc', { id: next ? next.h.id : '' });
213
+ }
214
+ var r = {
215
+ fit: function () { if (box) box.open = wide.matches || own; },
216
+ stop: function () { if (io) io.disconnect(); if (cur) cur.a.removeAttribute('aria-current'); if (box) box.open = own; }
217
+ };
218
+ on(nav, 'click', function (e) { if (box && !wide.matches && link(e)) box.open = false; });
219
+ if (window.IntersectionObserver) {
220
+ io = new IntersectionObserver(update, { rootMargin: '100000px 0px -70% 0px' });
221
+ items.forEach(function (x) { io.observe(x.h); });
222
+ }
223
+ r.fit();
224
+ return r;
225
+ });
226
+ }
227
+
228
+ function words(el) { return el ? el.textContent.replace(/\s+/g, ' ').trim() : ''; }
229
+ function tables(ctx) {
230
+ var list = [];
231
+ within('.gw-prose', ctx).forEach(function (p) {
232
+ list = list.concat([].filter.call(p.children, function (t) { return t.tagName === 'TABLE'; }));
233
+ });
234
+ wire(list, 'table', function (t) {
235
+ var name = words(t.querySelector('caption')) || words(t.querySelector('th')) || words(t.querySelector('td'));
236
+ if (!name) return;
237
+ var box = doc.createElement('div'), had = t.classList.contains('is-wrapped');
238
+ box.className = 'gw-prose__table';
239
+ box.setAttribute('role', 'region');
240
+ box.setAttribute('tabindex', '0');
241
+ box.setAttribute('aria-label', name);
242
+ t.parentNode.insertBefore(box, t);
243
+ box.appendChild(t);
244
+ t.classList.add('is-wrapped');
245
+ return { stop: function () {
246
+ var p = box.parentNode;
247
+ if (p) { p.insertBefore(t, box); p.removeChild(box); }
248
+ if (!had) t.classList.remove('is-wrapped');
249
+ } };
250
+ });
251
+ }
252
+
194
253
  function install() {
195
254
  doc = document; root = doc.documentElement; mine = new WeakSet();
196
255
  fine = mq('(hover: hover) and (pointer: fine)'); sys = mq('(prefers-color-scheme: dark)');
197
- var wide = mq('(min-width: 1080px)'), stored = null;
256
+ var stored = null;
257
+ wide = mq('(min-width: 1080px)');
198
258
  on(doc, 'click', function (e) { if (megaOpen && !inside(megaOpen, e.target)) hideMega(); });
199
259
  on(doc, 'keydown', function (e) { if (megaOpen && esc(e)) hideMega(inside(megaOpen, doc.activeElement) || megaOpen.mode === 'click'); });
200
260
  on(doc, 'keydown', function (e) { if (esc(e)) closeMenus(true); });
201
- watch(wide, function () { if (wide.matches) closeMenus(); });
261
+ watch(wide, function () { if (wide.matches) closeMenus(); records('toc', function (r) { r.fit(); }); });
202
262
  on(window, 'pageshow', function (e) { if (e.persisted) closeMenus(); });
203
263
  try { stored = localStorage.getItem('gw-theme'); } catch (e) { /* blocked */ }
204
264
  if (!root.hasAttribute('data-theme') && /^(light|dark)$/.test(stored)) root.setAttribute('data-theme', stored);
@@ -223,7 +283,7 @@ function init(ctx) {
223
283
  window.gwWebsite = api;
224
284
  if (!doc) run([install]);
225
285
  live.slice().forEach(function (r) { if (r.el.isConnected === false) drop(r); });
226
- run([mega, mobile, theme, reveal, header, current, segmented], ctx && ctx.querySelectorAll ? ctx : doc);
286
+ run([mega, mobile, theme, reveal, header, current, segmented, toc, tables], ctx && ctx.querySelectorAll ? ctx : doc);
227
287
  }
228
288
 
229
289
  /** Takes back what init() wired under root (default: the whole document): listeners and data-gw-ready marks. */
package/js/website.mjs CHANGED
@@ -6,10 +6,10 @@
6
6
  // the export line and the // comments, plus auto-init): edit this file, then run the build. Keep comments on lines of
7
7
  // their own, so the build can leave them out.
8
8
 
9
- var version = '0.4.0';
9
+ var version = '0.5.0';
10
10
  var api = { version: version, init: init, destroy: destroy };
11
11
  // Page state. Set up by the first init(), never at import: a server can import this file.
12
- var doc, root, mine, fine, sys, live = [], megaOpen = null, megaTimer = 0, queued = false;
12
+ var doc, root, mine, fine, sys, wide, live = [], megaOpen = null, megaTimer = 0, queued = false;
13
13
  var READY = 'data-gw-ready';
14
14
 
15
15
  function mq(q) { return window.matchMedia ? matchMedia(q) : { matches: false }; }
@@ -27,8 +27,10 @@ function emit(el, type, detail) { if (window.CustomEvent) el.dispatchEvent(new C
27
27
  // with the `on` it is given (so destroy can remove them) and returns a record, or nothing when the element cannot be
28
28
  // wired yet (the next init tries again). Records live in `live`. data-gw-ready lists the kinds wired on an element;
29
29
  // the record, not the attribute, decides, so markup copied from a live page, attribute and all, is still wired.
30
- function each(ctx, sel, kind, fn) {
31
- within(sel, ctx).forEach(function (el) {
30
+ // wire() does the same for a list of elements a selector cannot name (the tables straight inside a .gw-prose).
31
+ function each(ctx, sel, kind, fn) { wire(within(sel, ctx), kind, fn); }
32
+ function wire(els, kind, fn) {
33
+ els.forEach(function (el) {
32
34
  if (live.some(function (r) { return r.el === el && r.kind === kind; })) return;
33
35
  var offs = [], r = fn(el, function (t, type, f, opt) {
34
36
  on(t, type, f, opt);
@@ -215,15 +217,86 @@ function segmented(ctx) {
215
217
  });
216
218
  }
217
219
 
220
+ // Contents (.gw-toc, data-gw-toc): links to the #ids of the article's headings, plain links that work without the
221
+ // script. The section in view is the one whose heading last went above the line 30% down the window: its link gets
222
+ // aria-current="true" and the nav fires gw:toc ({ id }, '' above the first heading). One IntersectionObserver per
223
+ // list sees a heading cross that line, both ways; its root runs from far above the window down to the line, so a jump
224
+ // across many sections (a link, End, a dragged scrollbar) still counts. Without IntersectionObserver nothing is
225
+ // marked. The <details> is open from 1080px (the list sits beside the article), below that it keeps the markup's own
226
+ // state (folded) and a link inside folds it before the page moves.
227
+ function toc(ctx) {
228
+ each(ctx, '[data-gw-toc]', 'toc', function (nav, on) {
229
+ var box = nav.querySelector('details'), own = !!(box && box.open), cur = null, io = null;
230
+ var items = all('a[href]', nav).map(function (a) {
231
+ var id = attr(a, 'href', '');
232
+ if (id.charAt(0) !== '#') return null;
233
+ try { id = decodeURIComponent(id.slice(1)); } catch (e) { id = id.slice(1); }
234
+ return { a: a, h: doc.getElementById(id) };
235
+ }).filter(function (x) { return x && x.h; });
236
+ if (!items.length) return;
237
+ function update() {
238
+ var line = window.innerHeight * 0.3, top = -Infinity, next = null;
239
+ items.forEach(function (x) { var t = x.h.getBoundingClientRect().top; if (t <= line && t > top) { top = t; next = x; } });
240
+ if (next === cur) return;
241
+ if (cur) cur.a.removeAttribute('aria-current');
242
+ if (next) next.a.setAttribute('aria-current', 'true');
243
+ cur = next;
244
+ emit(nav, 'gw:toc', { id: next ? next.h.id : '' });
245
+ }
246
+ var r = {
247
+ fit: function () { if (box) box.open = wide.matches || own; },
248
+ stop: function () { if (io) io.disconnect(); if (cur) cur.a.removeAttribute('aria-current'); if (box) box.open = own; }
249
+ };
250
+ on(nav, 'click', function (e) { if (box && !wide.matches && link(e)) box.open = false; });
251
+ if (window.IntersectionObserver) {
252
+ io = new IntersectionObserver(update, { rootMargin: '100000px 0px -70% 0px' });
253
+ items.forEach(function (x) { io.observe(x.h); });
254
+ }
255
+ r.fit();
256
+ return r;
257
+ });
258
+ }
259
+
260
+ // Prose tables (gap #63): each <table> straight inside a .gw-prose goes into a scroll box of its own,
261
+ // div.gw-prose__table, a region named after its caption, else its first header cell, else its first cell, with
262
+ // tabindex="0" so a keyboard can scroll it. The table is marked .is-wrapped and keeps display: table. A table with no
263
+ // words to name it is left as it is (it scrolls by itself, as in 0.2.0). destroy() takes the box away again.
264
+ function words(el) { return el ? el.textContent.replace(/\s+/g, ' ').trim() : ''; }
265
+ function tables(ctx) {
266
+ var list = [];
267
+ within('.gw-prose', ctx).forEach(function (p) {
268
+ list = list.concat([].filter.call(p.children, function (t) { return t.tagName === 'TABLE'; }));
269
+ });
270
+ wire(list, 'table', function (t) {
271
+ var name = words(t.querySelector('caption')) || words(t.querySelector('th')) || words(t.querySelector('td'));
272
+ if (!name) return;
273
+ var box = doc.createElement('div'), had = t.classList.contains('is-wrapped');
274
+ box.className = 'gw-prose__table';
275
+ box.setAttribute('role', 'region');
276
+ box.setAttribute('tabindex', '0');
277
+ box.setAttribute('aria-label', name);
278
+ t.parentNode.insertBefore(box, t);
279
+ box.appendChild(t);
280
+ t.classList.add('is-wrapped');
281
+ return { stop: function () {
282
+ var p = box.parentNode;
283
+ if (p) { p.insertBefore(t, box); p.removeChild(box); }
284
+ if (!had) t.classList.remove('is-wrapped');
285
+ } };
286
+ });
287
+ }
288
+
218
289
  // Once per page: what belongs to the document, the window or a media query rather than to one element.
219
290
  function install() {
220
291
  doc = document; root = doc.documentElement; mine = new WeakSet();
221
292
  fine = mq('(hover: hover) and (pointer: fine)'); sys = mq('(prefers-color-scheme: dark)');
222
- var wide = mq('(min-width: 1080px)'), stored = null;
293
+ var stored = null;
294
+ // 1080px, the kit's desktop width: the header shows its nav, the contents sit beside the article
295
+ wide = mq('(min-width: 1080px)');
223
296
  on(doc, 'click', function (e) { if (megaOpen && !inside(megaOpen, e.target)) hideMega(); });
224
297
  on(doc, 'keydown', function (e) { if (megaOpen && esc(e)) hideMega(inside(megaOpen, doc.activeElement) || megaOpen.mode === 'click'); });
225
298
  on(doc, 'keydown', function (e) { if (esc(e)) closeMenus(true); });
226
- watch(wide, function () { if (wide.matches) closeMenus(); });
299
+ watch(wide, function () { if (wide.matches) closeMenus(); records('toc', function (r) { r.fit(); }); });
227
300
  on(window, 'pageshow', function (e) { if (e.persisted) closeMenus(); });
228
301
  try { stored = localStorage.getItem('gw-theme'); } catch (e) { /* blocked */ }
229
302
  if (!root.hasAttribute('data-theme') && /^(light|dark)$/.test(stored)) root.setAttribute('data-theme', stored);
@@ -254,7 +327,7 @@ function init(ctx) {
254
327
  if (!doc) run([install]);
255
328
  // an element removed from the page since the last init is let go
256
329
  live.slice().forEach(function (r) { if (r.el.isConnected === false) drop(r); });
257
- run([mega, mobile, theme, reveal, header, current, segmented], ctx && ctx.querySelectorAll ? ctx : doc);
330
+ run([mega, mobile, theme, reveal, header, current, segmented, toc, tables], ctx && ctx.querySelectorAll ? ctx : doc);
258
331
  }
259
332
 
260
333
  /** Takes back what init() wired under root (default: the whole document): listeners and data-gw-ready marks. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemboss/website-ui",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The GemBoss website kit: tokens, header, footer, sections and the rules (AGENTS.md) that GemCommerce public websites share, plus a CLI that checks a site, reports kit gaps and upgrades.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/skill/SKILL.md CHANGED
@@ -17,6 +17,9 @@ the kit and its rules are how the page ends up looking designed. Compose from th
17
17
  3. **Build**:
18
18
  - New page: copy `KIT/templates/page.html`, then add sections from `KIT/templates/sections/` in the order the page
19
19
  needs. Fill the words, delete what you did not use.
20
+ - An article page (a blog post, a guide) is `KIT/templates/sections/article.html`: breadcrumbs, the meta row, a
21
+ contents list from the article's h2s, the prose, callouts, the FAQ last. Never a callout told by its colour
22
+ alone (it keeps its label: Note, Tip, Warning). The blog index is `KIT/templates/sections/post-list.html`.
20
23
  - Changed page: keep its kit classes; change words, order and choice of sections.
21
24
  - Site CSS only for what the kit cannot know (an illustration, a product mock-up), with the kit's tokens and
22
25
  scales, classes in the site's own prefix. Never style a `.gw-*` class, never edit `node_modules`.
package/system.json CHANGED
@@ -21,6 +21,7 @@
21
21
  "success": "#007f5f",
22
22
  "success-soft": "#e3f1df",
23
23
  "warning": "#9a6700",
24
+ "warning-soft": "#fbf1dc",
24
25
  "night": "#0c0e14",
25
26
  "night-2": "#141722",
26
27
  "on-night": "#e3e4e8",
@@ -45,6 +46,7 @@
45
46
  "success": "#34c38f",
46
47
  "success-soft": "#132a22",
47
48
  "warning": "#e0b341",
49
+ "warning-soft": "#2b2410",
48
50
  "night": "#0a0b10",
49
51
  "night-2": "#12141c",
50
52
  "on-night": "#e3e4e8",
@@ -60,7 +62,7 @@
60
62
  "roles": {
61
63
  "action": "The thing you click: ink, or the brand's accent when the site chose the accent action profile (profiles.action).",
62
64
  "accent": "Links, focus rings, active state, a chart line, the 8px label square; the primary button only through the accent action profile. Never body text, never words in a heading, never a section band.",
63
- "success/warning": "State only.",
65
+ "success/warning": "State only. Their -soft tints are grounds: a tip or a warning callout, a success badge.",
64
66
  "wash": "The hero wash and illustrations only."
65
67
  }
66
68
  },
@@ -0,0 +1,93 @@
1
+ <!--
2
+ Article: a blog post or a guide, the whole <main> of the page. In this order: breadcrumbs, the title (the page's one
3
+ <h1>), the meta row, a hero image, the contents list, the article's own HTML in .gw-prose, the FAQ last.
4
+ - Breadcrumbs: every level above the page, then the page itself with aria-current="page". No separator characters:
5
+ the kit draws them. A BreadcrumbList JSON-LD is up to the site (example: docs/components.md, Breadcrumbs).
6
+ - Meta row: each item a <span>; the date as <time datetime="YYYY-MM-DD">, "Updated" when it changed after it was
7
+ published; the read time at about 200 words a minute. The avatar is optional (alt="": the name is written next
8
+ to it).
9
+ - Hero: the post's own image, with width and height, not lazy (it is the first screen). Leave the figure out when
10
+ the post has none.
11
+ - Contents: one link per <h2> of the article (a nested <ol> for its <h3>s, if any), each to the heading's id, in the
12
+ article's order, with the heading's words. data-gw-toc lets website.js mark the section in view and fold the list
13
+ on phones; the links work without it. check reports a link to an id that is not on the page.
14
+ - Callouts: a note, a tip or a warning, one idea each, at most one every few sections. Always the label in words
15
+ (Note, Tip, Warning, or the page's language): never a callout told by its colour alone.
16
+ - FAQ: the last <h2> of the article, real questions with short answers. FAQPage JSON-LD only if every answer is
17
+ visible on the page (example: docs/components.md, Article).
18
+ Limits: one article per page; headings in order (h2, then h3), each <h2> with an id; tables straight in the prose
19
+ are boxed by website.js (gap #63), give them a <caption>.
20
+ Then a post list (templates/sections/post-list.html, "More from the blog") and the closing CTA, if the page needs one.
21
+ -->
22
+ <article class="gw-wrap gw-article">
23
+ <header class="gw-article__head">
24
+ <nav class="gw-breadcrumbs" aria-label="Breadcrumb">
25
+ <ol>
26
+ <li><a href="[/blog]">[Blog]</a></li>
27
+ <li><a href="[/blog/category]">[Category]</a></li>
28
+ <li><a href="[/blog/this-post]" aria-current="page">[The post's title]</a></li>
29
+ </ol>
30
+ </nav>
31
+ <h1>[The post's title]</h1>
32
+ <p class="gw-article-meta">
33
+ <span><img class="gw-article-meta__avatar" src="[/img/author.webp]" alt="" width="24" height="24">[Author or team]</span>
34
+ <span><a href="[/blog/category]">[Category]</a></span>
35
+ <span>[Updated] <time datetime="[2026-10-25]">[October 25, 2026]</time></span>
36
+ <span>[5] min read</span>
37
+ </p>
38
+ </header>
39
+ <figure class="gw-article__hero">
40
+ <img src="[/img/post-hero.webp]" alt="[What the picture shows]" width="[1200]" height="[675]" fetchpriority="high">
41
+ </figure>
42
+ <nav class="gw-toc" aria-label="[On this page]" data-gw-toc>
43
+ <details>
44
+ <summary>[On this page]</summary>
45
+ <ol>
46
+ <li><a href="#[first-section]">[The first section's heading]</a></li>
47
+ <li><a href="#[second-section]">[The second section's heading]</a>
48
+ <ol>
49
+ <li><a href="#[a-step]">[A step inside it]</a></li>
50
+ </ol>
51
+ </li>
52
+ <li><a href="#faq">[Frequently asked questions]</a></li>
53
+ </ol>
54
+ </details>
55
+ </nav>
56
+ <div class="gw-prose">
57
+ <p>[The first paragraph: what the reader will know or be able to do by the end.]</p>
58
+ <h2 id="[first-section]">[The first section's heading]</h2>
59
+ <p>[Paragraphs of two to five sentences. Links go where they say: <a href="[link]">[the setup guide]</a>.]</p>
60
+ <div class="gw-callout gw-callout--note" role="note">
61
+ <p class="gw-callout__label">[Note]</p>
62
+ <p>[Something the reader should keep in mind, in one or two sentences.]</p>
63
+ </div>
64
+ <h2 id="[second-section]">[The second section's heading]</h2>
65
+ <p>[A paragraph.]</p>
66
+ <h3 id="[a-step]">[A step inside it]</h3>
67
+ <p>[A paragraph.]</p>
68
+ <table>
69
+ <caption>[What the table compares]</caption>
70
+ <thead><tr><th scope="col">[Column]</th><th scope="col">[Column]</th></tr></thead>
71
+ <tbody><tr><th scope="row">[Row]</th><td>[Value]</td></tr></tbody>
72
+ </table>
73
+ <div class="gw-callout gw-callout--tip" role="note">
74
+ <p class="gw-callout__label">[Tip]</p>
75
+ <p>[A shortcut or a better way, in one or two sentences.]</p>
76
+ </div>
77
+ <div class="gw-callout gw-callout--warning" role="note">
78
+ <p class="gw-callout__label">[Warning]</p>
79
+ <p>[What goes wrong if the reader skips this, in one or two sentences.]</p>
80
+ </div>
81
+ <h2 id="faq">[Frequently asked questions]</h2>
82
+ <div class="gw-faq">
83
+ <details class="gw-faq__item">
84
+ <summary>[A question the reader asks?]</summary>
85
+ <p>[The answer in two to four sentences.]</p>
86
+ </details>
87
+ <details class="gw-faq__item">
88
+ <summary>[A question the reader asks?]</summary>
89
+ <p>[The answer.]</p>
90
+ </details>
91
+ </div>
92
+ </div>
93
+ </article>
@@ -0,0 +1,65 @@
1
+ <!--
2
+ Post list: the blog index, a category page, or "More from the blog" under an article. Cards with a picture
3
+ (.gw-card__media, gap #33), the category as a .gw-label, the title, one or two lines of excerpt and the meta row.
4
+ - The title's link covers the whole card, so the card is one target and its name is the title alone: no other link
5
+ or button inside a card. The picture is alt="" here (the title says what the post is) and loading="lazy".
6
+ - The title is one level below the section's heading (h3 under an h2; h2 on the index, under its h1).
7
+ - --wide on the picture for 1200 x 630 share images (1.91:1), --square for 1:1; the default is 16:9.
8
+ - .gw-post-list--compact: rows without cards or pictures, for a long list or a sidebar.
9
+ - Pagination: previous and next as links (rel="prev" / rel="next"), the page number between them as words. Leave
10
+ out the link that does not exist (no "Newer posts" on page 1).
11
+ Limits: three, six or nine cards in the grid; the same picture shape for every card of a list; real posts, real
12
+ dates.
13
+ -->
14
+ <section class="gw-section" aria-labelledby="[posts-h]">
15
+ <div class="gw-wrap">
16
+ <div class="gw-section__head">
17
+ <p class="gw-label">[Blog]</p>
18
+ <h2 id="[posts-h]">[More from the blog]</h2>
19
+ </div>
20
+ <ul class="gw-post-list" role="list">
21
+ <li>
22
+ <article class="gw-card gw-post">
23
+ <div class="gw-card__media"><img src="[/img/post.webp]" alt="" width="[640]" height="[360]" loading="lazy"></div>
24
+ <p class="gw-label">[Category]</p>
25
+ <h3 class="gw-post__title"><a href="[/blog/post]">[The post's title]</a></h3>
26
+ <p>[One or two lines on what the reader gets from it.]</p>
27
+ <p class="gw-article-meta"><span><time datetime="[2026-10-25]">[Oct 25, 2026]</time></span><span>[5] min read</span></p>
28
+ </article>
29
+ </li>
30
+ <li>
31
+ <article class="gw-card gw-post">
32
+ <div class="gw-card__media"><img src="[/img/post.webp]" alt="" width="[640]" height="[360]" loading="lazy"></div>
33
+ <p class="gw-label">[Category]</p>
34
+ <h3 class="gw-post__title"><a href="[/blog/post]">[The post's title]</a></h3>
35
+ <p>[One or two lines on what the reader gets from it.]</p>
36
+ <p class="gw-article-meta"><span><time datetime="[2026-10-25]">[Oct 25, 2026]</time></span><span>[5] min read</span></p>
37
+ </article>
38
+ </li>
39
+ <li>
40
+ <article class="gw-card gw-post">
41
+ <div class="gw-card__media"><img src="[/img/post.webp]" alt="" width="[640]" height="[360]" loading="lazy"></div>
42
+ <p class="gw-label">[Category]</p>
43
+ <h3 class="gw-post__title"><a href="[/blog/post]">[The post's title]</a></h3>
44
+ <p>[One or two lines on what the reader gets from it.]</p>
45
+ <p class="gw-article-meta"><span><time datetime="[2026-10-25]">[Oct 25, 2026]</time></span><span>[5] min read</span></p>
46
+ </article>
47
+ </li>
48
+ </ul>
49
+ <nav class="gw-pagination" aria-label="[Blog pages]">
50
+ <a class="gw-btn gw-btn--secondary" href="[/blog?page=1]" rel="prev">[Newer posts]</a>
51
+ <p class="gw-pagination__status">[Page 2 of 12]</p>
52
+ <a class="gw-btn gw-btn--secondary" href="[/blog?page=3]" rel="next">[Older posts]</a>
53
+ </nav>
54
+ </div>
55
+ </section>
56
+
57
+ <!-- the compact list: rows, no picture -->
58
+ <ul class="gw-post-list gw-post-list--compact" role="list">
59
+ <li>
60
+ <article class="gw-card gw-post">
61
+ <h3 class="gw-post__title"><a href="[/blog/post]">[The post's title]</a></h3>
62
+ <p class="gw-article-meta"><span>[Category]</span><span><time datetime="[2026-10-25]">[Oct 25, 2026]</time></span><span>[5] min read</span></p>
63
+ </article>
64
+ </li>
65
+ </ul>