@mccaskie-labs/workbench-site 0.0.0-stage → 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,69 @@
1
+ // The site tool's samples (docs/look-studio.md §5.1): a page in each frame,
2
+ // header and footer, and every section, with made-up words, for the project's
3
+ // style guide, the look previewer and the visual check. Drawn by the tool's
4
+ // own frame() and sections; the style guide shows what is inside the page's
5
+ // body.
6
+ import { FOOTERS, frame, FRAMES, HEADERS } from "./frames.js";
7
+ import { account, callToAction, designSwitch, details, enquiryList, formSection, hero, list, picture, text } from "./sections.js";
8
+ import { SITE_STYLES } from "./styles.js";
9
+ const PHOTO = { src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 90"><rect width="160" height="90" fill="#6b8f71"/></svg>')}`, alt: "The studio in morning light" };
10
+ const MENU = [
11
+ { label: "Classes", href: "/classes" },
12
+ { label: "Prices", href: "/prices" },
13
+ { label: "Contact", href: "/contact" },
14
+ ];
15
+ const SECTIONS = [
16
+ hero({ heading: "Slow, kind yoga in Newtown", lead: "Small classes, warm rooms and teachers who know your name.", action: { label: "See the timetable", href: "/classes" }, arrangement: "beside-picture", picture: PHOTO }),
17
+ text({ heading: "About the studio", body: "We opened in 2019 with one room and six mats.\n\nNow there are two rooms and a garden." }),
18
+ list({ heading: "Classes", items: [{ title: "Sunday slow flow", body: "An hour to unwind.", href: "/classes/slow-flow" }, { title: "Beginners' course", body: "Six weeks, from the start." }] }),
19
+ ];
20
+ /** The page's own HTML: what is inside its <body>. */
21
+ const body = (doc) => doc.slice(doc.indexOf(">", doc.indexOf("<body")) + 1, doc.lastIndexOf("</body>"));
22
+ const page = (name, header, footer, env) => body(frame({
23
+ frame: name,
24
+ title: "Home",
25
+ site: "Saltbush Yoga",
26
+ sections: SECTIONS,
27
+ layout: { header, footer },
28
+ headerAction: { label: "Book a class", href: "/book" },
29
+ menu: MENU,
30
+ footer: [{ label: "Privacy", href: "/privacy" }],
31
+ footerNote: "© 2026 Saltbush Yoga",
32
+ current: "/classes",
33
+ stylesheets: [],
34
+ ...(env ? { env } : {}),
35
+ }));
36
+ /** Every sample of the site tool. */
37
+ export const SITE_SAMPLES = {
38
+ format: 1,
39
+ package: SITE_STYLES.package,
40
+ title: "Site pages",
41
+ prefix: SITE_STYLES.prefix,
42
+ samples: [
43
+ ...FRAMES.map((f, i) => ({ id: `frame-${f}`, title: `A page in the ${f.replace("-", " ")} frame`, html: () => page(f, HEADERS[i % HEADERS.length], FOOTERS[i % FOOTERS.length], i === 0 ? "staging" : undefined) })),
44
+ { id: "hero-over", title: "A hero over its picture", html: () => hero({ heading: "Find your calm", arrangement: "over-picture", picture: PHOTO, action: { label: "Book", href: "/book" } }) },
45
+ { id: "picture", title: "A picture with its caption", html: () => picture({ ...PHOTO, caption: "The garden room" }) },
46
+ { id: "design-switch", title: "Design mode's switch", html: () => designSwitch({ on: false, live: false, words: { on: "Design mode is on in this browser.", off: "Try looks and layouts on your own pages. Only you see them until you keep them.", turnOn: "Turn on design mode", turnOff: "Turn it off", live: "Design mode is on your test site." } }) },
47
+ { id: "call", title: "A call to action", html: () => callToAction({ heading: "Your first class is free", body: "Come and try any class this month.", action: { label: "Book your free class", href: "/book" } }) },
48
+ { id: "details", title: "Contact details", html: () => details({ heading: "Find us", rows: [{ label: "Address", value: "12 Wattle Street\nNewtown NSW 2042" }, { label: "Email", value: "hello@saltbush.example" }, { label: "Phone", value: "02 9000 0000" }] }) },
49
+ {
50
+ id: "form",
51
+ title: "A form section, with a problem and once sent",
52
+ html: () => formSection({ heading: "Ask us anything", intro: "We reply within a day.", problem: "Please add your email.", form: '<form method="post"><p><label>Email <input type="email" name="email"></label></p></form>' }) +
53
+ formSection({ heading: "Ask us anything", done: "Thanks, we'll be in touch soon." }),
54
+ },
55
+ { id: "account", title: "The member's account", html: () => account({ heading: "Your account", signedIn: "Signed in as maria@example.com", signOut: "Sign out" }) },
56
+ {
57
+ id: "enquiries",
58
+ title: "The owner's enquiries",
59
+ html: () => enquiryList({
60
+ heading: "Enquiries",
61
+ enquiries: [{ id: "e1", name: "Maria Santos", email: "maria@example.com", phone: "0400 000 000", message: "Do you have a class for six on a Saturday?", received: "24 Nov 2026" }],
62
+ empty: "No enquiries yet.",
63
+ unavailable: "Enquiries can't be shown right now.",
64
+ remove: "Remove",
65
+ removeAction: "/admin/enquiries",
66
+ }),
67
+ },
68
+ ],
69
+ };
@@ -0,0 +1,142 @@
1
+ /** A link drawn as a button. `href` is a path on this site, https, mailto or tel. */
2
+ export interface Action {
3
+ label: string;
4
+ href: string;
5
+ }
6
+ /** A picture from the project's own storage or public/ folder. */
7
+ export interface Picture {
8
+ src: string;
9
+ /** What the picture shows, for people who can't see it. Empty only for a picture that is decoration. */
10
+ alt: string;
11
+ }
12
+ /** How a hero is laid out: words alone, words over a picture, or words beside one. */
13
+ export declare const HERO_ARRANGEMENTS: readonly ["plain", "over-picture", "beside-picture"];
14
+ export type HeroArrangement = (typeof HERO_ARRANGEMENTS)[number];
15
+ export interface HeroOptions {
16
+ heading: string;
17
+ lead?: string;
18
+ action?: Action;
19
+ /** Defaults to "plain". The two picture arrangements need `picture`, and fall back to plain without one. */
20
+ arrangement?: HeroArrangement;
21
+ picture?: Picture;
22
+ }
23
+ /** The top of a page: its big heading, a line or two under it and one button. The page's only h1. */
24
+ export declare function hero(o: HeroOptions): string;
25
+ export interface TextOptions {
26
+ heading?: string;
27
+ /** Plain words; a blank line starts a new paragraph. */
28
+ body: string;
29
+ }
30
+ /** A heading and paragraphs. */
31
+ export declare function text(o: TextOptions): string;
32
+ export interface ListItem {
33
+ title: string;
34
+ body?: string;
35
+ /** Makes the title a link: a path on this site, https, mailto or tel. */
36
+ href?: string;
37
+ }
38
+ export interface ListOptions {
39
+ heading?: string;
40
+ items: readonly ListItem[];
41
+ }
42
+ /** A few short points side by side: what you offer, why people choose you. */
43
+ export declare function list(o: ListOptions): string;
44
+ export interface PictureOptions extends Picture {
45
+ caption?: string;
46
+ }
47
+ /** One picture, with a line under it. */
48
+ export declare function picture(o: PictureOptions): string;
49
+ export interface CallToActionOptions {
50
+ heading: string;
51
+ body?: string;
52
+ action: Action;
53
+ }
54
+ /** A band near the end of a page that asks the visitor to do one thing. */
55
+ export declare function callToAction(o: CallToActionOptions): string;
56
+ export interface DetailRow {
57
+ label: string;
58
+ value: string;
59
+ }
60
+ export interface DetailsOptions {
61
+ heading?: string;
62
+ rows: readonly DetailRow[];
63
+ }
64
+ /** Labelled facts: how to reach you, where you are, when you're open. */
65
+ export declare function details(o: DetailsOptions): string;
66
+ export interface AccountOptions {
67
+ heading?: string;
68
+ /** Who is signed in, such as "Signed in as sam@example.com." */
69
+ signedIn: string;
70
+ /** The sign-out button's words. */
71
+ signOut: string;
72
+ /** Where the button posts. Defaults to the template's /auth/sign-out. */
73
+ signOutAction?: string;
74
+ }
75
+ /** Who is signed in, and a button to sign out. */
76
+ export declare function account(o: AccountOptions): string;
77
+ export interface FormSectionOptions {
78
+ heading?: string;
79
+ intro?: string;
80
+ /** The form, drawn by workbench-forms (the project's formHtml). Trusted HTML. */
81
+ form?: string;
82
+ /** In place of the form once it's sent: the thank-you. */
83
+ done?: string;
84
+ /** Why the form can't be sent right now, shown above it. */
85
+ problem?: string;
86
+ /** The section's id, for a link straight to it (#enquiry). */
87
+ id?: string;
88
+ }
89
+ /** A form on a public page, such as Contact's enquiry form: its heading, a line on what it's for, and the form, or the thank-you once it's sent. */
90
+ export declare function formSection(o: FormSectionOptions): string;
91
+ /** One enquiry, as the Enquiries admin list shows it. */
92
+ export interface Enquiry {
93
+ id: string;
94
+ name: string;
95
+ email: string;
96
+ phone: string | null;
97
+ message: string;
98
+ /** When it came, already in the reader's words and time zone. */
99
+ received: string;
100
+ }
101
+ export interface EnquiryListOptions {
102
+ heading?: string;
103
+ /** Newest first. Null when they couldn't be read. */
104
+ enquiries: readonly Enquiry[] | null;
105
+ /** Shown when there are none yet. */
106
+ empty: string;
107
+ /** Shown when they couldn't be read. */
108
+ unavailable: string;
109
+ /** The delete button's words. */
110
+ remove: string;
111
+ /** Where the delete button posts (the page's own address); it sends `remove` with the enquiry's id. */
112
+ removeAction: string;
113
+ }
114
+ /** The site's enquiries, newest first, each with a way to reply and a delete button. */
115
+ export declare function enquiryList(o: EnquiryListOptions): string;
116
+ /** The cookie that turns design mode on in this browser (docs/look-studio.md §8): the site helper reads it, the design script clears it. */
117
+ export declare const DESIGN_COOKIE = "wb-design";
118
+ /** True when this request comes from a browser with design mode on. */
119
+ export declare function designModeOn(request: Request): boolean;
120
+ export interface DesignSwitchOptions {
121
+ /** Design mode is on in this browser now. */
122
+ on: boolean;
123
+ /** The live site: design mode is for the test site only. */
124
+ live: boolean;
125
+ words: {
126
+ on: string;
127
+ off: string;
128
+ turnOn: string;
129
+ turnOff: string;
130
+ live: string;
131
+ };
132
+ /** Where the switch posts; the page's own address by default. */
133
+ action?: string;
134
+ }
135
+ /** Design mode's switch, on its admin page: on in this browser, or off, and never on the live site. */
136
+ export declare function designSwitch(o: DesignSwitchOptions): string;
137
+ /**
138
+ * The switch's POST, behind the admin check: design=on sets the cookie for
139
+ * eight hours and opens the home page in design mode; design=off clears it
140
+ * and comes back. Refused on the live site.
141
+ */
142
+ export declare function designModePost(request: Request, live: boolean): Promise<Response>;
@@ -0,0 +1,116 @@
1
+ // Page sections: the parts a site page is made of, in order (docs/site-planner.md
2
+ // §5, §8). Each takes the finished words (plain text, already looked up in the
3
+ // project's strings catalogue) and returns HTML with wb-site-* classes, so the
4
+ // project restyles it from its own project.css. Tools draw their own sections
5
+ // (the free times, the order form) from their own packages; these are the
6
+ // general ones every site uses.
7
+ import { escape, paragraphs, safeHref } from "./html.js";
8
+ /** How a hero is laid out: words alone, words over a picture, or words beside one. */
9
+ export const HERO_ARRANGEMENTS = ["plain", "over-picture", "beside-picture"];
10
+ const action = (a, quiet = false) => a ? `<p class="wb-site-actions"><a class="wb-site-button${quiet ? " wb-site-button-quiet" : ""}" href="${escape(safeHref(a.href))}">${escape(a.label)}</a></p>` : "";
11
+ const img = (p) => `<img class="wb-site-image" src="${escape(safeHref(p.src))}" alt="${escape(p.alt)}" loading="lazy">`;
12
+ const heading = (text, level = 2) => (text ? `<h${level} class="wb-site-heading">${escape(text)}</h${level}>` : "");
13
+ /** The top of a page: its big heading, a line or two under it and one button. The page's only h1. */
14
+ export function hero(o) {
15
+ const arrangement = o.picture ? (o.arrangement ?? "plain") : "plain";
16
+ const words = `<div class="wb-site-hero-words"><h1 class="wb-site-hero-heading">${escape(o.heading)}</h1>${o.lead ? paragraphs(o.lead, "wb-site-lead") : ""}${action(o.action)}</div>`;
17
+ const picture = arrangement !== "plain" && o.picture ? `<div class="wb-site-hero-picture">${img(o.picture)}</div>` : "";
18
+ return `<section class="wb-site-section wb-site-hero" data-arrangement="${arrangement}">${picture}${words}</section>`;
19
+ }
20
+ /** A heading and paragraphs. */
21
+ export function text(o) {
22
+ return `<section class="wb-site-section wb-site-text">${heading(o.heading)}${paragraphs(o.body, "wb-site-paragraph")}</section>`;
23
+ }
24
+ /** A few short points side by side: what you offer, why people choose you. */
25
+ export function list(o) {
26
+ const items = o.items
27
+ .map((i) => {
28
+ const title = i.href ? `<h3 class="wb-site-heading"><a class="wb-site-link" href="${escape(safeHref(i.href))}">${escape(i.title)}</a></h3>` : heading(i.title, 3);
29
+ return `<li class="wb-site-item">${title}${i.body ? paragraphs(i.body, "wb-site-paragraph") : ""}</li>`;
30
+ })
31
+ .join("");
32
+ return `<section class="wb-site-section wb-site-list">${heading(o.heading)}<ul class="wb-site-items">${items}</ul></section>`;
33
+ }
34
+ /** One picture, with a line under it. */
35
+ export function picture(o) {
36
+ const caption = o.caption ? `<figcaption class="wb-site-caption">${escape(o.caption)}</figcaption>` : "";
37
+ return `<section class="wb-site-section wb-site-picture"><figure class="wb-site-figure">${img(o)}${caption}</figure></section>`;
38
+ }
39
+ /** A band near the end of a page that asks the visitor to do one thing. */
40
+ export function callToAction(o) {
41
+ return `<section class="wb-site-section wb-site-call">${heading(o.heading)}${o.body ? paragraphs(o.body, "wb-site-paragraph") : ""}${action(o.action)}</section>`;
42
+ }
43
+ /** A value that is an email address or a phone number becomes a link; a [fill-in] never does. */
44
+ function detailValue(value) {
45
+ const v = value.trim();
46
+ if (/^\[.*\]$/s.test(v))
47
+ return escape(v);
48
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v))
49
+ return `<a class="wb-site-link" href="mailto:${escape(v)}">${escape(v)}</a>`;
50
+ if (/^\+?[\d\s()-]{6,}$/.test(v))
51
+ return `<a class="wb-site-link" href="tel:${escape(v.replace(/[^\d+]/g, ""))}">${escape(v)}</a>`;
52
+ return escape(v).replace(/\n/g, "<br>");
53
+ }
54
+ /** Labelled facts: how to reach you, where you are, when you're open. */
55
+ export function details(o) {
56
+ const rows = o.rows.map((r) => `<div class="wb-site-detail"><dt class="wb-site-detail-label">${escape(r.label)}</dt><dd class="wb-site-detail-value">${detailValue(r.value)}</dd></div>`).join("");
57
+ return `<section class="wb-site-section wb-site-details">${heading(o.heading)}<dl class="wb-site-detail-list">${rows}</dl></section>`;
58
+ }
59
+ /** Who is signed in, and a button to sign out. */
60
+ export function account(o) {
61
+ const form = `<form class="wb-site-form" method="post" action="${escape(safeHref(o.signOutAction ?? "/auth/sign-out"))}"><button class="wb-site-button" type="submit">${escape(o.signOut)}</button></form>`;
62
+ return `<section class="wb-site-section wb-site-account">${heading(o.heading)}<p class="wb-site-paragraph">${escape(o.signedIn)}</p>${form}</section>`;
63
+ }
64
+ /** A form on a public page, such as Contact's enquiry form: its heading, a line on what it's for, and the form, or the thank-you once it's sent. */
65
+ export function formSection(o) {
66
+ const id = o.id ? ` id="${escape(o.id)}"` : "";
67
+ const intro = o.intro && !o.done ? paragraphs(o.intro, "wb-site-paragraph") : "";
68
+ const problem = o.problem ? `<p class="wb-site-problem" role="alert">${escape(o.problem)}</p>` : "";
69
+ const body = o.done ? `<p class="wb-site-done" role="status">${escape(o.done)}</p>` : (o.form ?? "");
70
+ return `<section class="wb-site-section wb-site-form-section"${id}>${heading(o.heading)}${intro}${problem}${body}</section>`;
71
+ }
72
+ /** The site's enquiries, newest first, each with a way to reply and a delete button. */
73
+ export function enquiryList(o) {
74
+ const rows = o.enquiries;
75
+ const body = rows === null
76
+ ? `<p class="wb-site-problem" role="alert">${escape(o.unavailable)}</p>`
77
+ : rows.length === 0
78
+ ? `<p class="wb-site-paragraph">${escape(o.empty)}</p>`
79
+ : `<ul class="wb-site-enquiries">${rows
80
+ .map((e) => {
81
+ const reach = [`<a class="wb-site-link" href="${escape(safeHref(`mailto:${e.email}`))}">${escape(e.email)}</a>`, ...(e.phone ? [`<a class="wb-site-link" href="${escape(safeHref(`tel:${e.phone}`))}">${escape(e.phone)}</a>`] : [])].join(" · ");
82
+ const remove = `<form class="wb-site-form" method="post" action="${escape(safeHref(o.removeAction))}"><input type="hidden" name="remove" value="${escape(e.id)}"><button class="wb-site-button wb-site-button-quiet" type="submit">${escape(o.remove)}</button></form>`;
83
+ return `<li class="wb-site-enquiry"><h3 class="wb-site-heading">${escape(e.name)}</h3><p class="wb-site-enquiry-meta">${escape(e.received)} · ${reach}</p>${paragraphs(e.message, "wb-site-paragraph")}${remove}</li>`;
84
+ })
85
+ .join("")}</ul>`;
86
+ return `<section class="wb-site-section wb-site-enquiry-list">${heading(o.heading)}${body}</section>`;
87
+ }
88
+ /** The cookie that turns design mode on in this browser (docs/look-studio.md §8): the site helper reads it, the design script clears it. */
89
+ export const DESIGN_COOKIE = "wb-design";
90
+ /** True when this request comes from a browser with design mode on. */
91
+ export function designModeOn(request) {
92
+ return new RegExp(`(?:^|;\\s*)${DESIGN_COOKIE}=on(?:;|$)`).test(request.headers.get("cookie") ?? "");
93
+ }
94
+ /** Design mode's switch, on its admin page: on in this browser, or off, and never on the live site. */
95
+ export function designSwitch(o) {
96
+ if (o.live)
97
+ return `<section class="wb-site-section wb-site-design-switch"><p class="wb-site-paragraph">${escape(o.words.live)}</p></section>`;
98
+ const button = `<form class="wb-site-form" method="post"${o.action ? ` action="${escape(safeHref(o.action))}"` : ""}><input type="hidden" name="design" value="${o.on ? "off" : "on"}"><button class="wb-site-button${o.on ? " wb-site-button-quiet" : ""}" type="submit">${escape(o.on ? o.words.turnOff : o.words.turnOn)}</button></form>`;
99
+ return `<section class="wb-site-section wb-site-design-switch"><p class="wb-site-paragraph">${escape(o.on ? o.words.on : o.words.off)}</p>${button}</section>`;
100
+ }
101
+ /**
102
+ * The switch's POST, behind the admin check: design=on sets the cookie for
103
+ * eight hours and opens the home page in design mode; design=off clears it
104
+ * and comes back. Refused on the live site.
105
+ */
106
+ export async function designModePost(request, live) {
107
+ if (live)
108
+ return new Response("Design mode is for the test site only.\n", { status: 403, headers: { "content-type": "text/plain; charset=utf-8" } });
109
+ const form = await request.formData().catch(() => null);
110
+ const on = form?.get("design") === "on";
111
+ const back = new URL(request.url).pathname;
112
+ return new Response(null, {
113
+ status: 303,
114
+ headers: { location: on ? "/" : back, "set-cookie": `${DESIGN_COOKIE}=${on ? "on" : ""}; Path=/; Secure; SameSite=Lax; Max-Age=${on ? 8 * 3600 : 0}`, "cache-control": "no-store" },
115
+ });
116
+ }
@@ -0,0 +1,33 @@
1
+ /** One CSS custom property the rules read, with its default. */
2
+ interface StyleVariable {
3
+ name: string;
4
+ value: string;
5
+ about: string;
6
+ }
7
+ /** A rule for a class in another state, or for an element inside it. */
8
+ interface StyleState {
9
+ selector: string;
10
+ about: string;
11
+ css: string;
12
+ }
13
+ /** One class the tool puts on an element, with its default rule. */
14
+ interface StyleClass {
15
+ name: string;
16
+ element: string;
17
+ about: string;
18
+ css: string;
19
+ states?: readonly StyleState[];
20
+ }
21
+ /** Every class and variable the tool draws with. */
22
+ export interface ToolStyles {
23
+ format: 1;
24
+ tool: string;
25
+ package: string;
26
+ title: string;
27
+ prefix: string;
28
+ variables: readonly StyleVariable[];
29
+ classes: readonly StyleClass[];
30
+ }
31
+ /** The style hooks of the site's frames and sections. */
32
+ export declare const SITE_STYLES: ToolStyles;
33
+ export {};
package/dist/styles.js ADDED
@@ -0,0 +1,153 @@
1
+ // The look the site's page frames and sections start with
2
+ // (docs/capabilities-manifest.md §10, docs/theming.md). Every element they
3
+ // draw carries one of these classes, and every class has a default rule here.
4
+ // Each colour, font, corner and space variable defaults to the project's
5
+ // shared theme token (--wb-accent and the rest, workbench-ui's theme layer),
6
+ // with Clean light's value as the fallback, so a site takes the project's
7
+ // look with nothing set. `npx workbench-ui styles` writes these into the
8
+ // project's public/styles/workbench.css; the project restyles them in its own
9
+ // project.css by the same names. The names are public: renaming one is a
10
+ // breaking change.
11
+ const v = (name) => `var(--wb-site-${name})`;
12
+ const focus = { selector: ":focus-visible", about: "Has focus", css: `outline:2px solid ${v("focus")};outline-offset:2px` };
13
+ /** The style hooks of the site's frames and sections. */
14
+ export const SITE_STYLES = {
15
+ format: 1,
16
+ tool: "site",
17
+ package: "@mccaskie-labs/workbench-site",
18
+ title: "Site pages: frames and sections",
19
+ prefix: "wb-site-",
20
+ variables: [
21
+ { name: "--wb-site-background", value: "var(--wb-background, #ffffff)", about: "Page background (the theme's background)" },
22
+ { name: "--wb-site-surface", value: "var(--wb-surface, #f6f7f9)", about: "Background of bands and cards (the theme's surface)" },
23
+ { name: "--wb-site-text", value: "var(--wb-text, #1f2937)", about: "Text (the theme's text)" },
24
+ { name: "--wb-site-muted", value: "var(--wb-muted, #5b6472)", about: "Quieter text: the lead, captions, labels, the footer (the theme's muted)" },
25
+ { name: "--wb-site-line", value: "var(--wb-line, #e2e5ea)", about: "Lines between header, sections and footer (the theme's line)" },
26
+ { name: "--wb-site-accent", value: "var(--wb-accent, #2563eb)", about: "Buttons and links (the theme's accent)" },
27
+ { name: "--wb-site-accent-hover", value: "var(--wb-accent-hover, #1d4ed8)", about: "A button under the pointer (the theme's accent-hover)" },
28
+ { name: "--wb-site-on-accent", value: "var(--wb-on-accent, #ffffff)", about: "Text on a button (the theme's on-accent)" },
29
+ { name: "--wb-site-focus", value: "var(--wb-focus, #2563eb)", about: "The ring round whatever has focus (the theme's focus)" },
30
+ { name: "--wb-site-danger", value: "var(--wb-danger, #b91c1c)", about: "A form that can't be sent, a list that can't be read (the theme's danger)" },
31
+ { name: "--wb-site-success", value: "var(--wb-success, #15803d)", about: "A form sent (the theme's success)" },
32
+ { name: "--wb-site-font", value: "var(--wb-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif)", about: "Body text font (the theme's font)" },
33
+ { name: "--wb-site-font-heading", value: "var(--wb-font-heading, var(--wb-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif))", about: "Headings font (the theme's heading font)" },
34
+ { name: "--wb-site-radius", value: "var(--wb-radius, 8px)", about: "Corners of buttons, pictures and cards (the theme's radius)" },
35
+ { name: "--wb-site-space", value: "var(--wb-space, 1rem)", about: "The basic gap; sections and the header use multiples of it (the theme's space)" },
36
+ { name: "--wb-site-width", value: "var(--wb-page-width, 72rem)", about: "The widest the header, footer and landing sections get (the theme's page width, from the site layout)" },
37
+ { name: "--wb-site-reading", value: "42rem", about: "The width of a column frame, kept short enough to read" },
38
+ { name: "--wb-site-section-space", value: "var(--wb-section-space, 2.5rem)", about: "The space above and below each section (the theme's section spacing, from the site layout)" },
39
+ ],
40
+ classes: [
41
+ { name: "wb-site", element: "html", about: "A site page drawn by a frame", css: `background:${v("background")};color:${v("text")}` },
42
+ { name: "wb-site-body", element: "body", about: "The page", css: `margin:0;min-height:100vh;display:flex;flex-direction:column;font-family:${v("font")};line-height:1.6;background:${v("background")};color:${v("text")}` },
43
+ {
44
+ name: "wb-site-header",
45
+ element: "header",
46
+ about: "The site's header (data-header: menu-right, centred, menu-centre)",
47
+ css: `border-bottom:1px solid ${v("line")}`,
48
+ states: [
49
+ { selector: "[data-header=\"centred\"] .wb-site-header-row", about: "Centred header: the name over the menu", css: "flex-direction:column;justify-content:center;text-align:center" },
50
+ { selector: "[data-header=\"centred\"] .wb-site-menu", about: "Centred header: the menu under the name", css: "margin-left:0;justify-content:center" },
51
+ { selector: "[data-header=\"menu-centre\"] .wb-site-menu", about: "Menu-centre header: the menu in the middle, the button on the right", css: "margin:0 auto;justify-content:center" },
52
+ ],
53
+ },
54
+ { name: "wb-site-header-row", element: "div", about: "The header's line: name, environment tag, menu, button", css: `box-sizing:border-box;max-width:${v("width")};margin:0 auto;padding:calc(${v("space")} * .75) ${v("space")};display:flex;flex-wrap:wrap;align-items:center;gap:${v("space")}` },
55
+ { name: "wb-site-name", element: "a", about: "The business's name, linking home", css: `font-family:${v("font-heading")};font-weight:700;font-size:1.15rem;color:${v("text")};text-decoration:none`, states: [focus] },
56
+ { name: "wb-site-env", element: "span", about: "The environment tag (staging, development), never shown in production", css: `padding:.1rem .5rem;border-radius:999px;font-size:.75rem;font-weight:600;background:#fde68a;color:#78350f` },
57
+ { name: "wb-site-menu", element: "nav", about: "The header's menu", css: `margin-left:auto;display:flex;flex-wrap:wrap;gap:calc(${v("space")} * .25) ${v("space")}` },
58
+ {
59
+ name: "wb-site-menu-link",
60
+ element: "a",
61
+ about: "A menu link",
62
+ css: `color:${v("text")};text-decoration:none;padding:.25rem 0`,
63
+ states: [
64
+ { selector: ":hover", about: "Under the pointer", css: `color:${v("accent")}` },
65
+ { selector: "[aria-current=\"page\"]", about: "The page you're on", css: `color:${v("accent")};font-weight:600` },
66
+ focus,
67
+ ],
68
+ },
69
+ {
70
+ name: "wb-site-main",
71
+ element: "main",
72
+ about: "The page's sections, laid out by its frame (data-frame)",
73
+ css: `flex:1;box-sizing:border-box;width:100%;margin:0 auto;padding:0 ${v("space")}`,
74
+ states: [
75
+ { selector: "[data-frame=\"landing\"]", about: "Landing frame: full width", css: `max-width:${v("width")}` },
76
+ { selector: "[data-frame=\"column\"]", about: "Column frame: one reading-width column", css: `max-width:${v("reading")}` },
77
+ { selector: "[data-frame=\"two-columns\"]", about: "Two-columns frame: the first section across the top, the rest beside each other", css: `max-width:${v("width")}` },
78
+ ],
79
+ },
80
+ { name: "wb-site-columns", element: "div", about: "The two columns of a two-columns frame (one column on a narrow screen)", css: `display:grid;grid-template-columns:repeat(auto-fit, minmax(min(100%, 20rem), 1fr));gap:0 calc(${v("space")} * 2)` },
81
+ { name: "wb-site-section", element: "section", about: "Any section", css: `padding:${v("section-space")} 0` },
82
+ {
83
+ name: "wb-site-hero",
84
+ element: "section",
85
+ about: "The top of a page: big heading, lead and button (data-arrangement: plain, over-picture, beside-picture)",
86
+ css: `padding:calc(${v("space")} * 4) 0 calc(${v("space")} * 3)`,
87
+ states: [
88
+ { selector: "[data-arrangement=\"beside-picture\"]", about: "Words beside a picture (stacked on a narrow screen)", css: `display:grid;grid-template-columns:repeat(auto-fit, minmax(min(100%, 18rem), 1fr));gap:calc(${v("space")} * 2);align-items:center` },
89
+ { selector: "[data-arrangement=\"over-picture\"]", about: "Words over a picture", css: `position:relative;display:grid;min-height:24rem;align-items:end;overflow:hidden;border-radius:${v("radius")}` },
90
+ { selector: "[data-arrangement=\"over-picture\"] .wb-site-hero-picture", about: "The picture behind the words", css: `position:absolute;inset:0` },
91
+ { selector: "[data-arrangement=\"over-picture\"] .wb-site-image", about: "The picture filling the hero", css: `height:100%;object-fit:cover;border-radius:0` },
92
+ { selector: "[data-arrangement=\"over-picture\"] .wb-site-hero-words", about: "The words on a panel over the picture", css: `margin:${v("space")};padding:calc(${v("space")} * 1.5);border-radius:${v("radius")};background:${v("background")}` },
93
+ ],
94
+ },
95
+ { name: "wb-site-hero-words", element: "div", about: "The hero's words", css: `position:relative;max-width:40rem` },
96
+ { name: "wb-site-hero-heading", element: "h1", about: "The page's heading", css: `margin:0 0 calc(${v("space")} * .75);font-family:${v("font-heading")};font-size:clamp(2rem, 5vw, 3rem);line-height:1.15` },
97
+ { name: "wb-site-hero-picture", element: "div", about: "The hero's picture", css: `min-width:0` },
98
+ { name: "wb-site-lead", element: "p", about: "The line or two under the page's heading", css: `margin:0 0 ${v("space")};font-size:1.2rem;color:${v("muted")}` },
99
+ { name: "wb-site-actions", element: "p", about: "Where a section's button sits", css: `margin:calc(${v("space")} * 1.5) 0 0` },
100
+ {
101
+ name: "wb-site-button",
102
+ element: "a, button",
103
+ about: "A link or form button drawn as a button",
104
+ css: `display:inline-flex;align-items:center;min-height:2.75rem;padding:0 1.25rem;border:0;border-radius:${v("radius")};background:${v("accent")};color:${v("on-accent")};font:inherit;font-weight:600;text-decoration:none;cursor:pointer`,
105
+ states: [{ selector: ":hover", about: "Under the pointer", css: `background:${v("accent-hover")}` }, focus],
106
+ },
107
+ { name: "wb-site-button-quiet", element: "a, button", about: "A second, quieter button", css: `background:transparent;color:${v("accent")};box-shadow:inset 0 0 0 1px ${v("accent")}` },
108
+ { name: "wb-site-header-action", element: "a", about: "The header's one button, such as Book now", css: `min-height:2.25rem;padding:0 1rem` },
109
+ { name: "wb-site-image", element: "img", about: "A picture", css: `display:block;width:100%;height:auto;border-radius:${v("radius")}` },
110
+ { name: "wb-site-heading", element: "h2, h3", about: "A section's or an item's heading", css: `margin:0 0 calc(${v("space")} * .5);font-family:${v("font-heading")};line-height:1.25` },
111
+ { name: "wb-site-text", element: "section", about: "A heading and paragraphs", css: `max-width:${v("reading")}` },
112
+ { name: "wb-site-paragraph", element: "p", about: "A paragraph", css: `margin:0 0 ${v("space")}` },
113
+ { name: "wb-site-list", element: "section", about: "A few short points side by side", css: `border-top:1px solid ${v("line")}` },
114
+ { name: "wb-site-items", element: "ul", about: "The points (one column on a narrow screen)", css: `list-style:none;margin:${v("space")} 0 0;padding:0;display:grid;grid-template-columns:repeat(auto-fit, minmax(min(100%, 15rem), 1fr));gap:calc(${v("space")} * 1.5)` },
115
+ { name: "wb-site-item", element: "li", about: "One point", css: `padding:${v("space")};border-radius:${v("radius")};background:${v("surface")}` },
116
+ { name: "wb-site-picture", element: "section", about: "One picture", css: `padding:${v("space")} 0` },
117
+ { name: "wb-site-figure", element: "figure", about: "The picture and its caption", css: `margin:0` },
118
+ { name: "wb-site-caption", element: "figcaption", about: "The line under a picture", css: `margin-top:calc(${v("space")} * .5);font-size:.9rem;color:${v("muted")}` },
119
+ { name: "wb-site-call", element: "section", about: "A band that asks the visitor to do one thing", css: `margin:calc(${v("space")} * 2) 0;padding:calc(${v("space")} * 2);border-radius:${v("radius")};background:${v("surface")};text-align:center` },
120
+ { name: "wb-site-account", element: "section", about: "Who is signed in, and the sign-out button", css: `max-width:${v("reading")}` },
121
+ { name: "wb-site-design-switch", element: "section", about: "Design mode's switch on its admin page", css: `max-width:${v("reading")}` },
122
+ { name: "wb-site-form", element: "form", about: "A form inside a section", css: `margin:${v("space")} 0 0` },
123
+ { name: "wb-site-form-section", element: "section", about: "A form on a page, such as Contact's enquiry form", css: `max-width:${v("reading")}` },
124
+ { name: "wb-site-problem", element: "p", about: "Why a form can't be sent, or a list read, right now", css: `margin:${v("space")} 0;padding:calc(${v("space")} * .75);border-left:4px solid ${v("danger")};background:${v("surface")};color:${v("text")}` },
125
+ { name: "wb-site-done", element: "p", about: "The thank-you once a form is sent", css: `margin:${v("space")} 0;padding:calc(${v("space")} * .75);border-left:4px solid ${v("success")};background:${v("surface")};color:${v("text")}` },
126
+ { name: "wb-site-enquiry-list", element: "section", about: "The Enquiries admin list", css: `max-width:${v("reading")}` },
127
+ { name: "wb-site-enquiries", element: "ul", about: "The enquiries, newest first", css: `list-style:none;margin:0;padding:0;display:grid;gap:${v("space")}` },
128
+ { name: "wb-site-enquiry", element: "li", about: "One enquiry", css: `padding:${v("space")};border:1px solid ${v("line")};border-radius:${v("radius")};background:${v("background")}` },
129
+ { name: "wb-site-enquiry-meta", element: "p", about: "When it came and how to reply", css: `margin:0;font-size:.9rem;color:${v("muted")}` },
130
+ { name: "wb-site-details", element: "section", about: "Labelled facts: how to reach you, where, when", css: `max-width:${v("reading")}` },
131
+ { name: "wb-site-detail-list", element: "dl", about: "The facts", css: `margin:0;display:grid;gap:${v("space")}` },
132
+ { name: "wb-site-detail", element: "div", about: "One fact", css: `display:grid;gap:.15rem` },
133
+ { name: "wb-site-detail-label", element: "dt", about: "What the fact is", css: `font-size:.85rem;font-weight:600;color:${v("muted")}` },
134
+ { name: "wb-site-detail-value", element: "dd", about: "The fact", css: `margin:0` },
135
+ { name: "wb-site-link", element: "a", about: "A link inside a section", css: `color:${v("accent")}`, states: [focus] },
136
+ {
137
+ name: "wb-site-footer",
138
+ element: "footer",
139
+ about: "The site's footer (data-footer: line, columns, centred)",
140
+ css: `box-sizing:border-box;width:100%;max-width:${v("width")};margin:0 auto;padding:calc(${v("space")} * 2) ${v("space")};border-top:1px solid ${v("line")};font-size:.9rem;color:${v("muted")}`,
141
+ states: [
142
+ { selector: "[data-footer=\"columns\"]", about: "Columns footer: the links and the note side by side (stacked on a narrow screen)", css: `display:grid;grid-template-columns:repeat(auto-fit, minmax(min(100%, 14rem), 1fr));gap:${v("space")} calc(${v("space")} * 2);align-items:start` },
143
+ { selector: "[data-footer=\"columns\"] .wb-site-footer-links", about: "Columns footer: the links one under another", css: "flex-direction:column;gap:.35rem" },
144
+ { selector: "[data-footer=\"columns\"] .wb-site-footer-note", about: "Columns footer: the note in its own column", css: "margin:0" },
145
+ { selector: "[data-footer=\"centred\"]", about: "Centred footer", css: "text-align:center" },
146
+ { selector: "[data-footer=\"centred\"] .wb-site-footer-links", about: "Centred footer: the links centred", css: "justify-content:center" },
147
+ ],
148
+ },
149
+ { name: "wb-site-footer-links", element: "nav", about: "The footer's links", css: `display:flex;flex-wrap:wrap;gap:${v("space")}` },
150
+ { name: "wb-site-footer-link", element: "a", about: "A footer link", css: `color:${v("muted")}`, states: [{ selector: ":hover", about: "Under the pointer", css: `color:${v("text")}` }, focus] },
151
+ { name: "wb-site-footer-note", element: "p", about: "A line in the footer", css: `margin:${v("space")} 0 0` },
152
+ ],
153
+ };
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-site",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.10.0",
4
+ "description": "A Workbench project's standard pages: page recipes, the builder that turns them into thin page files calling Workbench's tools, and the page frames and sections they are drawn with (wb-site-*, restylable, on the project's theme tokens).",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mccaskie-labs/workbench.git",
10
+ "directory": "packages/site"
11
+ },
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./styles": {
22
+ "types": "./dist/styles.d.ts",
23
+ "default": "./dist/styles.js"
24
+ },
25
+ "./samples": {
26
+ "types": "./dist/samples.d.ts",
27
+ "default": "./dist/samples.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "bin": {
32
+ "workbench-site": "./dist/cli.js"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "CHANGELOG.md"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p test/tsconfig.json --noEmit",
44
+ "test": "vitest run",
45
+ "test:store": "vitest run --config vitest.db.config.ts",
46
+ "build": "node scripts/build.mjs",
47
+ "prepack": "node scripts/build.mjs"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "24.19.2",
51
+ "postgres": "4.1.0",
52
+ "vitest": "^5.1.0"
53
+ }
54
+ }