@mark1russell7/site-pages 0.4.11 → 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.
- package/README.md +43 -0
- package/build/demo.d.ts +50 -0
- package/build/demo.d.ts.map +1 -0
- package/build/demo.js +109 -0
- package/build/demo.js.map +1 -0
- package/package.json +8 -2
- package/styles/demo.css +257 -0
package/README.md
CHANGED
|
@@ -543,6 +543,49 @@ The theme `auto` removes `data-theme`, and the CSS of the site then obeys `prefe
|
|
|
543
543
|
</script>
|
|
544
544
|
```
|
|
545
545
|
|
|
546
|
+
## The parts of a live demo
|
|
547
|
+
|
|
548
|
+
A home page shows the package at work: a visitor types or clicks, and the page shows the result of the real functions. The entry `@mark1russell7/site-pages/demo` has the parts that each demo uses. Like `./chrome`, it imports no Node.js module. The file `@mark1russell7/site-pages/demo.css` has their style.
|
|
549
|
+
|
|
550
|
+
| Function | Operation |
|
|
551
|
+
| --- | --- |
|
|
552
|
+
| `examples(row, items, pick)` | Fills a row with one button for each example `[label, value]`. A click starts `pick` with the value. |
|
|
553
|
+
| `verdict(pass, title, ...reason)` | Makes the line of a verdict: a check or a cross, a title in bold and a reason. The mark has the label "Pass" or "Fail". |
|
|
554
|
+
| `setField(field, value)` | Sets the value of a field and sends an `input` event, as typing does. |
|
|
555
|
+
| `partsAt(text, ranges)` | Divides a text into parts at ranges `[start, end)`. Ranges that overlap become one part. |
|
|
556
|
+
| `partsOf(text, find)` | Divides a text into parts at each copy of `find`. |
|
|
557
|
+
| `markedText(parts, label)` | Shows a text in a box, with a `mark` element on each part with `hit`. |
|
|
558
|
+
|
|
559
|
+
The style gives these classes:
|
|
560
|
+
|
|
561
|
+
| Class | Element |
|
|
562
|
+
| --- | --- |
|
|
563
|
+
| `sp-demo` | A section of the page with one demo. |
|
|
564
|
+
| `sp-field` | A label with its input, its text box or its range. Put the text of the label in a `span`. |
|
|
565
|
+
| `sp-pair` | Two or three fields side by side. On a phone, they are in one column. |
|
|
566
|
+
| `sp-examples` | The row of `examples`. A button with `aria-pressed="true"` shows as chosen. |
|
|
567
|
+
| `sp-choices` | A row of choices, for example a radio group. The button with `aria-checked="true"` shows as chosen. |
|
|
568
|
+
| `sp-cards`, `sp-card` | One card for each version of a result. |
|
|
569
|
+
|
|
570
|
+
```ts
|
|
571
|
+
import "@mark1russell7/site-pages/demo.css";
|
|
572
|
+
import { byId } from "@mark1russell7/site-pages/chrome";
|
|
573
|
+
import { examples, markedText, partsOf, setField, verdict } from "@mark1russell7/site-pages/demo";
|
|
574
|
+
|
|
575
|
+
const input = byId<HTMLInputElement>("find");
|
|
576
|
+
const result = byId("result");
|
|
577
|
+
const show = (): void => {
|
|
578
|
+
const parts = partsOf("Is 1+1=2? Yes.", input.value);
|
|
579
|
+
const found = parts.some((part) => part.hit);
|
|
580
|
+
result.replaceChildren(verdict(found, found ? "Found:" : "Not found:", `the text has "${input.value}".`), markedText(parts, "The text"));
|
|
581
|
+
};
|
|
582
|
+
input.addEventListener("input", show);
|
|
583
|
+
examples(byId("find-examples"), [["A question", "1+1=2?"], ["A word", "Yes"]], (value) => setField(input, value));
|
|
584
|
+
show();
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
The style reads the tokens of a site when they exist, for example `--surface`, `--ink`, `--muted` and `--rule` of `shell.css`. Without them, it uses its own colors, in light and in dark. The tokens `--sp-pass`, `--sp-pass-bg`, `--sp-fail`, `--sp-fail-bg` and `--sp-hit` set the colors of a verdict and of a mark.
|
|
588
|
+
|
|
546
589
|
## The measures of a site
|
|
547
590
|
|
|
548
591
|
The file `kpi.json` at the root of a site holds the measures of the project, in the format `kpi/1`. A reader outside the site takes the numbers from this file.
|
package/build/demo.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of a live demo on a page. The parts are a row of example buttons, the line of a verdict,
|
|
3
|
+
* a field that a script fills and a text with marks. This module imports no Node.js module, so a site
|
|
4
|
+
* can bundle it. Its style is in `@mark1russell7/site-pages/demo.css`.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { Child } from "./chrome.js";
|
|
9
|
+
/** An example of a demo: the label of its button and the value that a click gives. */
|
|
10
|
+
export type Example = readonly [label: string, value: string];
|
|
11
|
+
/**
|
|
12
|
+
* This function fills a row with one button for each example, and gives the buttons. A click on a
|
|
13
|
+
* button starts `pick` with the value of its example. When the value is not the label, the `title` of
|
|
14
|
+
* the button is the value, so a pointer shows the full value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function examples(row: HTMLElement, items: readonly Example[], pick: (value: string) => void): HTMLButtonElement[];
|
|
17
|
+
/**
|
|
18
|
+
* This function makes the line of a verdict: a mark, a title in bold and a reason. The mark is a check
|
|
19
|
+
* for a pass and a cross for a fail. Its label tells the same to a screen reader, so the color is not
|
|
20
|
+
* the only cue. The title has no punctuation of its own: give "Correct:" for a colon.
|
|
21
|
+
*/
|
|
22
|
+
export declare function verdict(pass: boolean, title: Child, ...reason: readonly Child[]): HTMLDivElement;
|
|
23
|
+
/**
|
|
24
|
+
* This function sets the value of a field and sends an `input` event that bubbles, as typing does.
|
|
25
|
+
* Thus an example button changes a field, and the demo of the field shows the new value.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setField(field: HTMLInputElement | HTMLTextAreaElement, value: string): void;
|
|
28
|
+
/** A part of a text. `markedText` puts a `mark` element on a part with `hit`. */
|
|
29
|
+
export interface TextPart {
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly hit: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This function divides a text into parts at ranges of code units, `[start, end)`. Each range gives a
|
|
35
|
+
* part with `hit`, and the text between the ranges gives parts with no `hit`. The function sorts the
|
|
36
|
+
* ranges, joins the ranges that overlap, and clamps each range to the text. Two ranges that touch stay
|
|
37
|
+
* two parts. An empty range gives no part.
|
|
38
|
+
*/
|
|
39
|
+
export declare function partsAt(text: string, ranges: readonly (readonly [start: number, end: number])[]): TextPart[];
|
|
40
|
+
/**
|
|
41
|
+
* This function divides a text into parts at each copy of `find`, from the start, with no overlap.
|
|
42
|
+
* Each copy gives a part with `hit`. An empty `find` gives one part with no `hit`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function partsOf(text: string, find: string): TextPart[];
|
|
45
|
+
/**
|
|
46
|
+
* This function shows a text in a `pre` box, with a `mark` element on each part with `hit`. The box is
|
|
47
|
+
* a group with the label, so a screen reader names it. A text with no parts shows "(empty)".
|
|
48
|
+
*/
|
|
49
|
+
export declare function markedText(parts: readonly TextPart[], label: string): HTMLPreElement;
|
|
50
|
+
//# sourceMappingURL=demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.d.ts","names":[],"sources":["../src/demo.ts"],"mappings":";;;;;;;;;YAUY,oBAAoB,eAAe;;;;;;wBAO/B,SAAS,KAAK,aAAa,gBAAgB,WAAW,OAAO,yBAAyB;;;;;;wBAetF,QAAQ,eAAe,OAAO,UAAU,iBAAiB,UAAU;;;;;wBAanE,SAAS,OAAO,mBAAmB,qBAAqB;;iBAMvD;WACN;WACA;;;;;;;;wBASK,QAAQ,cAAc,4BAA4B,eAAe,kBAAkB;;;;;wBA2BnF,QAAQ,cAAc,eAAe;;;;;wBAWrC,WAAW,gBAAgB,YAAY,gBAAgB"}
|
package/build/demo.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { h } from "./chrome.js";
|
|
2
|
+
// src/demo.ts
|
|
3
|
+
/**
|
|
4
|
+
* The parts of a live demo on a page. The parts are a row of example buttons, the line of a verdict,
|
|
5
|
+
* a field that a script fills and a text with marks. This module imports no Node.js module, so a site
|
|
6
|
+
* can bundle it. Its style is in `@mark1russell7/site-pages/demo.css`.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* This function fills a row with one button for each example, and gives the buttons. A click on a
|
|
12
|
+
* button starts `pick` with the value of its example. When the value is not the label, the `title` of
|
|
13
|
+
* the button is the value, so a pointer shows the full value.
|
|
14
|
+
*/
|
|
15
|
+
function examples(row, items, pick) {
|
|
16
|
+
const buttons = items.map(([label, value]) => {
|
|
17
|
+
const button = h("button", {
|
|
18
|
+
type: "button",
|
|
19
|
+
class: "sp-example",
|
|
20
|
+
title: value === label ? void 0 : value
|
|
21
|
+
}, label);
|
|
22
|
+
button.addEventListener("click", () => pick(value));
|
|
23
|
+
return button;
|
|
24
|
+
});
|
|
25
|
+
row.replaceChildren(...buttons);
|
|
26
|
+
return buttons;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* This function makes the line of a verdict: a mark, a title in bold and a reason. The mark is a check
|
|
30
|
+
* for a pass and a cross for a fail. Its label tells the same to a screen reader, so the color is not
|
|
31
|
+
* the only cue. The title has no punctuation of its own: give "Correct:" for a colon.
|
|
32
|
+
*/
|
|
33
|
+
function verdict(pass, title, ...reason) {
|
|
34
|
+
return h("div", { class: pass ? "sp-verdict sp-pass" : "sp-verdict sp-fail" }, h("span", {
|
|
35
|
+
class: "sp-mark",
|
|
36
|
+
role: "img",
|
|
37
|
+
"aria-label": pass ? "Pass" : "Fail"
|
|
38
|
+
}, pass ? "✓" : "✕"), h("div", {}, h("b", {}, title), reason.length > 0 ? " " : null, ...reason));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This function sets the value of a field and sends an `input` event that bubbles, as typing does.
|
|
42
|
+
* Thus an example button changes a field, and the demo of the field shows the new value.
|
|
43
|
+
*/
|
|
44
|
+
function setField(field, value) {
|
|
45
|
+
field.value = value;
|
|
46
|
+
field.dispatchEvent(new Event("input", { bubbles: true }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* This function divides a text into parts at ranges of code units, `[start, end)`. Each range gives a
|
|
50
|
+
* part with `hit`, and the text between the ranges gives parts with no `hit`. The function sorts the
|
|
51
|
+
* ranges, joins the ranges that overlap, and clamps each range to the text. Two ranges that touch stay
|
|
52
|
+
* two parts. An empty range gives no part.
|
|
53
|
+
*/
|
|
54
|
+
function partsAt(text, ranges) {
|
|
55
|
+
const clamp = (n) => Math.min(Math.max(Math.trunc(n), 0), text.length);
|
|
56
|
+
const sorted = ranges.map(([start, end]) => [clamp(start), clamp(end)]).filter(([start, end]) => end > start).sort((a, b) => a[0] - b[0]);
|
|
57
|
+
const parts = [];
|
|
58
|
+
let at = 0;
|
|
59
|
+
for (const [start, end] of sorted) {
|
|
60
|
+
if (end <= at) continue;
|
|
61
|
+
if (start < at) {
|
|
62
|
+
const last = parts[parts.length - 1];
|
|
63
|
+
parts[parts.length - 1] = {
|
|
64
|
+
text: last.text + text.slice(at, end),
|
|
65
|
+
hit: true
|
|
66
|
+
};
|
|
67
|
+
} else {
|
|
68
|
+
if (start > at) parts.push({
|
|
69
|
+
text: text.slice(at, start),
|
|
70
|
+
hit: false
|
|
71
|
+
});
|
|
72
|
+
parts.push({
|
|
73
|
+
text: text.slice(start, end),
|
|
74
|
+
hit: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
at = end;
|
|
78
|
+
}
|
|
79
|
+
if (at < text.length) parts.push({
|
|
80
|
+
text: text.slice(at),
|
|
81
|
+
hit: false
|
|
82
|
+
});
|
|
83
|
+
return parts;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* This function divides a text into parts at each copy of `find`, from the start, with no overlap.
|
|
87
|
+
* Each copy gives a part with `hit`. An empty `find` gives one part with no `hit`.
|
|
88
|
+
*/
|
|
89
|
+
function partsOf(text, find) {
|
|
90
|
+
if (find === "") return partsAt(text, []);
|
|
91
|
+
const ranges = [];
|
|
92
|
+
for (let at = text.indexOf(find); at >= 0; at = text.indexOf(find, at + find.length)) ranges.push([at, at + find.length]);
|
|
93
|
+
return partsAt(text, ranges);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* This function shows a text in a `pre` box, with a `mark` element on each part with `hit`. The box is
|
|
97
|
+
* a group with the label, so a screen reader names it. A text with no parts shows "(empty)".
|
|
98
|
+
*/
|
|
99
|
+
function markedText(parts, label) {
|
|
100
|
+
const nodes = parts.filter((part) => part.text !== "").map((part) => part.hit ? h("mark", {}, part.text) : part.text);
|
|
101
|
+
return h("pre", {
|
|
102
|
+
class: "sp-text",
|
|
103
|
+
role: "group",
|
|
104
|
+
"aria-label": label
|
|
105
|
+
}, nodes.length > 0 ? nodes : h("span", { class: "sp-empty" }, "(empty)"));
|
|
106
|
+
}
|
|
107
|
+
export { examples, markedText, partsAt, partsOf, setField, verdict };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","names":[],"sources":["../src/demo.ts"],"sourcesContent":["/**\n * The parts of a live demo on a page. The parts are a row of example buttons, the line of a verdict,\n * a field that a script fills and a text with marks. This module imports no Node.js module, so a site\n * can bundle it. Its style is in `@mark1russell7/site-pages/demo.css`.\n *\n * @packageDocumentation\n */\nimport { h, type Child } from \"./chrome.ts\";\n\n/** An example of a demo: the label of its button and the value that a click gives. */\nexport type Example = readonly [label: string, value: string];\n\n/**\n * This function fills a row with one button for each example, and gives the buttons. A click on a\n * button starts `pick` with the value of its example. When the value is not the label, the `title` of\n * the button is the value, so a pointer shows the full value.\n */\nexport function examples(row: HTMLElement, items: readonly Example[], pick: (value: string) => void): HTMLButtonElement[] {\n const buttons = items.map(([label, value]) => {\n const button = h(\"button\", { type: \"button\", class: \"sp-example\", title: value === label ? undefined : value }, label);\n button.addEventListener(\"click\", () => pick(value));\n return button;\n });\n row.replaceChildren(...buttons);\n return buttons;\n}\n\n/**\n * This function makes the line of a verdict: a mark, a title in bold and a reason. The mark is a check\n * for a pass and a cross for a fail. Its label tells the same to a screen reader, so the color is not\n * the only cue. The title has no punctuation of its own: give \"Correct:\" for a colon.\n */\nexport function verdict(pass: boolean, title: Child, ...reason: readonly Child[]): HTMLDivElement {\n return h(\n \"div\",\n { class: pass ? \"sp-verdict sp-pass\" : \"sp-verdict sp-fail\" },\n h(\"span\", { class: \"sp-mark\", role: \"img\", \"aria-label\": pass ? \"Pass\" : \"Fail\" }, pass ? \"✓\" : \"✕\"),\n h(\"div\", {}, h(\"b\", {}, title), reason.length > 0 ? \" \" : null, ...reason),\n );\n}\n\n/**\n * This function sets the value of a field and sends an `input` event that bubbles, as typing does.\n * Thus an example button changes a field, and the demo of the field shows the new value.\n */\nexport function setField(field: HTMLInputElement | HTMLTextAreaElement, value: string): void {\n field.value = value;\n field.dispatchEvent(new Event(\"input\", { bubbles: true }));\n}\n\n/** A part of a text. `markedText` puts a `mark` element on a part with `hit`. */\nexport interface TextPart {\n readonly text: string;\n readonly hit: boolean;\n}\n\n/**\n * This function divides a text into parts at ranges of code units, `[start, end)`. Each range gives a\n * part with `hit`, and the text between the ranges gives parts with no `hit`. The function sorts the\n * ranges, joins the ranges that overlap, and clamps each range to the text. Two ranges that touch stay\n * two parts. An empty range gives no part.\n */\nexport function partsAt(text: string, ranges: readonly (readonly [start: number, end: number])[]): TextPart[] {\n const clamp = (n: number): number => Math.min(Math.max(Math.trunc(n), 0), text.length);\n const sorted = ranges\n .map(([start, end]) => [clamp(start), clamp(end)] as const)\n .filter(([start, end]) => end > start)\n .sort((a, b) => a[0] - b[0]);\n const parts: TextPart[] = [];\n let at = 0;\n for (const [start, end] of sorted) {\n if (end <= at) continue;\n if (start < at) {\n const last = parts[parts.length - 1]!;\n parts[parts.length - 1] = { text: last.text + text.slice(at, end), hit: true };\n } else {\n if (start > at) parts.push({ text: text.slice(at, start), hit: false });\n parts.push({ text: text.slice(start, end), hit: true });\n }\n at = end;\n }\n if (at < text.length) parts.push({ text: text.slice(at), hit: false });\n return parts;\n}\n\n/**\n * This function divides a text into parts at each copy of `find`, from the start, with no overlap.\n * Each copy gives a part with `hit`. An empty `find` gives one part with no `hit`.\n */\nexport function partsOf(text: string, find: string): TextPart[] {\n if (find === \"\") return partsAt(text, []);\n const ranges: (readonly [number, number])[] = [];\n for (let at = text.indexOf(find); at >= 0; at = text.indexOf(find, at + find.length)) ranges.push([at, at + find.length]);\n return partsAt(text, ranges);\n}\n\n/**\n * This function shows a text in a `pre` box, with a `mark` element on each part with `hit`. The box is\n * a group with the label, so a screen reader names it. A text with no parts shows \"(empty)\".\n */\nexport function markedText(parts: readonly TextPart[], label: string): HTMLPreElement {\n const nodes = parts.filter((part) => part.text !== \"\").map((part) => (part.hit ? h(\"mark\", {}, part.text) : part.text));\n return h(\"pre\", { class: \"sp-text\", role: \"group\", \"aria-label\": label }, nodes.length > 0 ? nodes : h(\"span\", { class: \"sp-empty\" }, \"(empty)\"));\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,SAAS,KAAkB,OAA2B,MAAoD;CACxH,MAAM,UAAU,MAAM,KAAK,CAAC,OAAO,WAAW;EAC5C,MAAM,SAAS,EAAE,UAAU;GAAE,MAAM;GAAU,OAAO;GAAc,OAAO,UAAU,QAAQ,KAAA,IAAY;EAAM,GAAG,KAAK;EACrH,OAAO,iBAAiB,eAAe,KAAK,KAAK,CAAC;EAClD,OAAO;CACT,CAAC;CACD,IAAI,gBAAgB,GAAG,OAAO;CAC9B,OAAO;AACT;;;;;;AAOA,SAAgB,QAAQ,MAAe,OAAc,GAAG,QAA0C;CAChG,OAAO,EACL,OACA,EAAE,OAAO,OAAO,uBAAuB,qBAAqB,GAC5D,EAAE,QAAQ;EAAE,OAAO;EAAW,MAAM;EAAO,cAAc,OAAO,SAAS;CAAO,GAAG,OAAO,MAAM,GAAG,GACnG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,GAAG,OAAO,SAAS,IAAI,MAAM,MAAM,GAAG,MAAM,CAC3E;AACF;;;;;AAMA,SAAgB,SAAS,OAA+C,OAAqB;CAC3F,MAAM,QAAQ;CACd,MAAM,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC;AAC3D;;;;;;;AAcA,SAAgB,QAAQ,MAAc,QAAwE;CAC5G,MAAM,SAAS,MAAsB,KAAK,IAAI,KAAK,IAAI,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM;CACrF,MAAM,SAAS,OACZ,KAAK,CAAC,OAAO,SAAS,CAAC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,CAAU,CAAC,CAC1D,QAAQ,CAAC,OAAO,SAAS,MAAM,KAAK,CAAC,CACrC,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;CAC7B,MAAM,QAAoB,CAAC;CAC3B,IAAI,KAAK;CACT,KAAK,MAAM,CAAC,OAAO,QAAQ,QAAQ;EACjC,IAAI,OAAO,IAAI;EACf,IAAI,QAAQ,IAAI;GACd,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,MAAM,MAAM,SAAS,KAAK;IAAE,MAAM,KAAK,OAAO,KAAK,MAAM,IAAI,GAAG;IAAG,KAAK;GAAK;EAC/E,OAAO;GACL,IAAI,QAAQ,IAAI,MAAM,KAAK;IAAE,MAAM,KAAK,MAAM,IAAI,KAAK;IAAG,KAAK;GAAM,CAAC;GACtE,MAAM,KAAK;IAAE,MAAM,KAAK,MAAM,OAAO,GAAG;IAAG,KAAK;GAAK,CAAC;EACxD;EACA,KAAK;CACP;CACA,IAAI,KAAK,KAAK,QAAQ,MAAM,KAAK;EAAE,MAAM,KAAK,MAAM,EAAE;EAAG,KAAK;CAAM,CAAC;CACrE,OAAO;AACT;;;;;AAMA,SAAgB,QAAQ,MAAc,MAA0B;CAC9D,IAAI,SAAS,IAAI,OAAO,QAAQ,MAAM,CAAC,CAAC;CACxC,MAAM,SAAwC,CAAC;CAC/C,KAAK,IAAI,KAAK,KAAK,QAAQ,IAAI,GAAG,MAAM,GAAG,KAAK,KAAK,QAAQ,MAAM,KAAK,KAAK,MAAM,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,MAAM,CAAC;CACxH,OAAO,QAAQ,MAAM,MAAM;AAC7B;;;;;AAMA,SAAgB,WAAW,OAA4B,OAA+B;CACpF,MAAM,QAAQ,MAAM,QAAQ,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,KAAK,SAAU,KAAK,MAAM,EAAE,QAAQ,CAAC,GAAG,KAAK,IAAI,IAAI,KAAK,IAAK;CACtH,OAAO,EAAE,OAAO;EAAE,OAAO;EAAW,MAAM;EAAS,cAAc;CAAM,GAAG,MAAM,SAAS,IAAI,QAAQ,EAAE,QAAQ,EAAE,OAAO,WAAW,GAAG,SAAS,CAAC;AAClJ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/site-pages",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "A release timeline page and a live status page for the site of a GitHub repository: JSON data and standalone HTML, made at deploy time.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"github-pages",
|
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
"import": "./build/chrome.js",
|
|
38
38
|
"default": "./build/chrome.js"
|
|
39
39
|
},
|
|
40
|
+
"./demo": {
|
|
41
|
+
"types": "./build/demo.d.ts",
|
|
42
|
+
"import": "./build/demo.js",
|
|
43
|
+
"default": "./build/demo.js"
|
|
44
|
+
},
|
|
40
45
|
"./explorer": {
|
|
41
46
|
"types": "./build/explorer/index.d.ts",
|
|
42
47
|
"import": "./build/explorer/index.js",
|
|
@@ -50,6 +55,7 @@
|
|
|
50
55
|
"./scroll-cue.css": "./styles/scroll-cue.css",
|
|
51
56
|
"./shell.css": "./styles/shell.css",
|
|
52
57
|
"./explorer.css": "./styles/explorer.css",
|
|
58
|
+
"./demo.css": "./styles/demo.css",
|
|
53
59
|
"./package.json": "./package.json"
|
|
54
60
|
},
|
|
55
61
|
"bin": {
|
|
@@ -66,7 +72,7 @@
|
|
|
66
72
|
"node": ">=22"
|
|
67
73
|
},
|
|
68
74
|
"dependencies": {
|
|
69
|
-
"@mark1russell7/rigor-statistics": "^0.
|
|
75
|
+
"@mark1russell7/rigor-statistics": "^0.2.4"
|
|
70
76
|
},
|
|
71
77
|
"devDependencies": {
|
|
72
78
|
"@mark1russell7/cue": "^2.0.0",
|
package/styles/demo.css
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @mark1russell7/site-pages/demo.css: the style of the parts of a live demo (the entry ./demo).
|
|
3
|
+
*
|
|
4
|
+
* Use: import this file before the style sheet of the site, so the rules of the site come last.
|
|
5
|
+
* import "@mark1russell7/site-pages/demo.css";
|
|
6
|
+
*
|
|
7
|
+
* The parts read the tokens of a site when they exist: --card or --surface, --sunk, --sunken, --well or
|
|
8
|
+
* --panel, --fg or --ink, --muted or --quiet, --line or --rule, --accent, --focus or --link and --mono.
|
|
9
|
+
* Without them, they use the --sp-demo-base tokens. The colors of a pass, a fail and a mark are the
|
|
10
|
+
* tokens --sp-pass, --sp-pass-bg, --sp-fail, --sp-fail-bg and --sp-hit. Each base token and each of these
|
|
11
|
+
* tokens has a dark value. The two dark rules below keep the same values, as the rules of shell.css do.
|
|
12
|
+
*/
|
|
13
|
+
:root {
|
|
14
|
+
--sp-demo-base-surface: #ffffff;
|
|
15
|
+
--sp-demo-base-sunken: #f0f0ed;
|
|
16
|
+
--sp-demo-base-ink: #1c1c1a;
|
|
17
|
+
--sp-demo-base-muted: #5c5c57;
|
|
18
|
+
--sp-demo-base-rule: #d6d6d0;
|
|
19
|
+
--sp-demo-base-accent: #1f5fbf;
|
|
20
|
+
--sp-pass: #1d6b3a;
|
|
21
|
+
--sp-pass-bg: #e3f2e7;
|
|
22
|
+
--sp-fail: #a3271f;
|
|
23
|
+
--sp-fail-bg: #fbe6e3;
|
|
24
|
+
--sp-hit: #ffe28a;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (prefers-color-scheme: dark) {
|
|
28
|
+
:root:not([data-theme="light"]) {
|
|
29
|
+
--sp-demo-base-surface: #1b1b1a;
|
|
30
|
+
--sp-demo-base-sunken: #232321;
|
|
31
|
+
--sp-demo-base-ink: #ececea;
|
|
32
|
+
--sp-demo-base-muted: #a9a9a3;
|
|
33
|
+
--sp-demo-base-rule: #3b3b38;
|
|
34
|
+
--sp-demo-base-accent: #8ab8ff;
|
|
35
|
+
--sp-pass: #7fd49a;
|
|
36
|
+
--sp-pass-bg: #16301f;
|
|
37
|
+
--sp-fail: #ff9a8f;
|
|
38
|
+
--sp-fail-bg: #3a1a17;
|
|
39
|
+
--sp-hit: #6b5310;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:root[data-theme="dark"] {
|
|
44
|
+
--sp-demo-base-surface: #1b1b1a;
|
|
45
|
+
--sp-demo-base-sunken: #232321;
|
|
46
|
+
--sp-demo-base-ink: #ececea;
|
|
47
|
+
--sp-demo-base-muted: #a9a9a3;
|
|
48
|
+
--sp-demo-base-rule: #3b3b38;
|
|
49
|
+
--sp-demo-base-accent: #8ab8ff;
|
|
50
|
+
--sp-pass: #7fd49a;
|
|
51
|
+
--sp-pass-bg: #16301f;
|
|
52
|
+
--sp-fail: #ff9a8f;
|
|
53
|
+
--sp-fail-bg: #3a1a17;
|
|
54
|
+
--sp-hit: #6b5310;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* The tokens of the parts, read at each part, so the tokens of a site apply where the site sets them. */
|
|
58
|
+
.sp-demo,
|
|
59
|
+
.sp-field,
|
|
60
|
+
.sp-examples,
|
|
61
|
+
.sp-choices,
|
|
62
|
+
.sp-verdict,
|
|
63
|
+
.sp-cards,
|
|
64
|
+
.sp-card,
|
|
65
|
+
.sp-text {
|
|
66
|
+
--sp-demo-surface: var(--card, var(--surface, var(--sp-demo-base-surface)));
|
|
67
|
+
--sp-demo-sunken: var(--sunk, var(--sunken, var(--well, var(--panel, var(--sp-demo-base-sunken)))));
|
|
68
|
+
--sp-demo-ink: var(--fg, var(--ink, var(--sp-demo-base-ink)));
|
|
69
|
+
--sp-demo-muted: var(--muted, var(--quiet, var(--sp-demo-base-muted)));
|
|
70
|
+
--sp-demo-rule: var(--line, var(--rule, var(--sp-demo-base-rule)));
|
|
71
|
+
--sp-demo-accent: var(--accent, var(--focus, var(--link, var(--sp-demo-base-accent))));
|
|
72
|
+
--sp-demo-mono: var(--mono, ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* A demo: one section of a page with its controls and its result. */
|
|
76
|
+
.sp-demo {
|
|
77
|
+
margin: 2rem 0;
|
|
78
|
+
padding: 1rem;
|
|
79
|
+
border: 1px solid var(--sp-demo-rule);
|
|
80
|
+
border-radius: 0.75rem;
|
|
81
|
+
min-width: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sp-demo > :first-child {
|
|
85
|
+
margin-top: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* A field: a label above its input, its text box or its range. A taller field next to it does not move its input down. */
|
|
89
|
+
.sp-field {
|
|
90
|
+
display: grid;
|
|
91
|
+
align-content: start;
|
|
92
|
+
gap: 0.25rem;
|
|
93
|
+
margin: 0.75rem 0;
|
|
94
|
+
color: var(--sp-demo-muted);
|
|
95
|
+
font-size: 0.9rem;
|
|
96
|
+
min-width: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sp-field > span {
|
|
100
|
+
display: block;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sp-field b {
|
|
104
|
+
color: var(--sp-demo-ink);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sp-field :is(input:not([type="range"], [type="checkbox"], [type="radio"]), textarea, select) {
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
width: 100%;
|
|
110
|
+
min-height: 2.5rem;
|
|
111
|
+
padding: 0.5rem 0.625rem;
|
|
112
|
+
border: 1px solid var(--sp-demo-rule);
|
|
113
|
+
border-radius: 0.375rem;
|
|
114
|
+
background: var(--sp-demo-surface);
|
|
115
|
+
color: var(--sp-demo-ink);
|
|
116
|
+
font: 0.95rem/1.5 var(--sp-demo-mono);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.sp-field textarea {
|
|
120
|
+
resize: vertical;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.sp-field input[type="range"] {
|
|
124
|
+
width: 100%;
|
|
125
|
+
accent-color: var(--sp-demo-accent);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Two or three fields side by side, and one column on a phone. */
|
|
129
|
+
.sp-pair {
|
|
130
|
+
display: grid;
|
|
131
|
+
grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
|
|
132
|
+
gap: 0 1rem;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* A row of example buttons (examples), and a row of choices (a radio group with aria-checked). */
|
|
136
|
+
.sp-examples,
|
|
137
|
+
.sp-choices {
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-wrap: wrap;
|
|
140
|
+
gap: 0.375rem;
|
|
141
|
+
margin: 0.5rem 0 0.75rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.sp-examples > button,
|
|
145
|
+
.sp-choices > button {
|
|
146
|
+
min-height: 2rem;
|
|
147
|
+
padding: 0.25rem 0.75rem;
|
|
148
|
+
border: 1px solid var(--sp-demo-rule);
|
|
149
|
+
border-radius: 1rem;
|
|
150
|
+
background: var(--sp-demo-surface);
|
|
151
|
+
color: var(--sp-demo-ink);
|
|
152
|
+
font: inherit;
|
|
153
|
+
font-size: 0.875rem;
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.sp-examples > button:hover,
|
|
158
|
+
.sp-choices > button:hover {
|
|
159
|
+
border-color: var(--sp-demo-accent);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.sp-examples > button:focus-visible,
|
|
163
|
+
.sp-choices > button:focus-visible {
|
|
164
|
+
outline: 2px solid var(--sp-demo-accent);
|
|
165
|
+
outline-offset: 2px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.sp-examples > [aria-pressed="true"],
|
|
169
|
+
.sp-choices > [aria-checked="true"] {
|
|
170
|
+
border-color: var(--sp-demo-accent);
|
|
171
|
+
box-shadow: inset 0 0 0 1px var(--sp-demo-accent);
|
|
172
|
+
font-weight: 600;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* The line of a verdict (verdict): a mark, a title and a reason. */
|
|
176
|
+
.sp-verdict {
|
|
177
|
+
display: flex;
|
|
178
|
+
gap: 0.625rem;
|
|
179
|
+
align-items: flex-start;
|
|
180
|
+
margin: 0.5rem 0;
|
|
181
|
+
padding: 0.625rem 0.75rem;
|
|
182
|
+
border-radius: 0.5rem;
|
|
183
|
+
overflow-wrap: anywhere;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.sp-verdict.sp-pass {
|
|
187
|
+
background: var(--sp-pass-bg);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.sp-verdict.sp-fail {
|
|
191
|
+
background: var(--sp-fail-bg);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.sp-verdict > div {
|
|
195
|
+
min-width: 0;
|
|
196
|
+
color: var(--sp-demo-ink);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.sp-mark {
|
|
200
|
+
flex: none;
|
|
201
|
+
width: 1.5rem;
|
|
202
|
+
height: 1.5rem;
|
|
203
|
+
border-radius: 50%;
|
|
204
|
+
text-align: center;
|
|
205
|
+
line-height: 1.5rem;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.sp-pass > .sp-mark {
|
|
209
|
+
background: var(--sp-pass);
|
|
210
|
+
color: var(--sp-pass-bg);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.sp-fail > .sp-mark {
|
|
214
|
+
background: var(--sp-fail);
|
|
215
|
+
color: var(--sp-fail-bg);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Results side by side: one card for each version of a result. */
|
|
219
|
+
.sp-cards {
|
|
220
|
+
display: grid;
|
|
221
|
+
gap: 0.75rem;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.sp-card {
|
|
225
|
+
min-width: 0;
|
|
226
|
+
padding: 0.75rem;
|
|
227
|
+
border: 1px solid var(--sp-demo-rule);
|
|
228
|
+
border-radius: 0.5rem;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* A text in a box, with marks (markedText). */
|
|
232
|
+
.sp-text {
|
|
233
|
+
margin: 0.5rem 0 0;
|
|
234
|
+
padding: 0.75rem;
|
|
235
|
+
border-radius: 0.5rem;
|
|
236
|
+
background: var(--sp-demo-sunken);
|
|
237
|
+
color: var(--sp-demo-ink);
|
|
238
|
+
font: 0.875rem/1.5 var(--sp-demo-mono);
|
|
239
|
+
white-space: pre-wrap;
|
|
240
|
+
overflow-wrap: anywhere;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.sp-text mark {
|
|
244
|
+
border-radius: 0.2rem;
|
|
245
|
+
background: var(--sp-hit);
|
|
246
|
+
color: inherit;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.sp-empty {
|
|
250
|
+
color: var(--sp-demo-muted);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@media (max-width: 30rem) {
|
|
254
|
+
.sp-demo {
|
|
255
|
+
padding: 0.75rem;
|
|
256
|
+
}
|
|
257
|
+
}
|