@mccaskie-labs/workbench-site 0.0.0-stage → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +36 -2
- package/dist/builder.d.ts +73 -0
- package/dist/builder.js +769 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +126 -0
- package/dist/frames.d.ts +91 -0
- package/dist/frames.js +63 -0
- package/dist/html.d.ts +6 -0
- package/dist/html.js +24 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/recipe.d.ts +204 -0
- package/dist/recipe.js +151 -0
- package/dist/recipes/admin.d.ts +3 -0
- package/dist/recipes/admin.js +194 -0
- package/dist/recipes/enquiries-kit.d.ts +55 -0
- package/dist/recipes/enquiries-kit.js +235 -0
- package/dist/recipes/every-site.d.ts +3 -0
- package/dist/recipes/every-site.js +166 -0
- package/dist/recipes/index.d.ts +2 -0
- package/dist/recipes/index.js +7 -0
- package/dist/recipes/members.d.ts +3 -0
- package/dist/recipes/members.js +37 -0
- package/dist/samples.d.ts +18 -0
- package/dist/samples.js +69 -0
- package/dist/sections.d.ts +142 -0
- package/dist/sections.js +116 -0
- package/dist/styles.d.ts +33 -0
- package/dist/styles.js +153 -0
- package/package.json +52 -4
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// What Contact's enquiry form and the Enquiries admin list need besides their
|
|
2
|
+
// page files (docs/site-planner.md §5, §6): the form's answers file, the
|
|
3
|
+
// table, and the code their sections call. The builder writes each once,
|
|
4
|
+
// when the Enquiries page is added (Contact needs it, so no enquiry is taken
|
|
5
|
+
// before there is somewhere to read it); from then on they're the project's.
|
|
6
|
+
/** workbench/forms/enquiry.json: the form, as Claude would write it from the forms questions. `npm run forms` builds it. */
|
|
7
|
+
export const ENQUIRY_ANSWERS = {
|
|
8
|
+
format: 1,
|
|
9
|
+
status: "done",
|
|
10
|
+
form: "enquiry",
|
|
11
|
+
title: "Contact enquiry form",
|
|
12
|
+
fields: [
|
|
13
|
+
{ name: "name", label: "Your name", kind: "text", required: true, max: 100, width: "l", limit_status: "proposed", reason: "Workbench default, not yet confirmed", column: "site_enquiries.name" },
|
|
14
|
+
{ name: "email", label: "Your email", kind: "email", required: true, width: "l", limit_status: "proposed", reason: "Workbench default, not yet confirmed", column: "site_enquiries.email" },
|
|
15
|
+
{ name: "phone", label: "Your phone (if you'd like a call)", kind: "phone" },
|
|
16
|
+
{ name: "message", label: "Your message", kind: "long_text", required: true, max: 2000, limit_status: "proposed", reason: "Workbench default, not yet confirmed", column: "site_enquiries.message" },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The table, as a Workbench tool's own migration (`<stamp>_workbench_site_enquiries`):
|
|
21
|
+
* a new table and its policies only, so Control applies it to staging with no
|
|
22
|
+
* approval. Anyone may add an enquiry (the Worker checks the form and
|
|
23
|
+
* Turnstile first); only the site's admins read or delete them, as
|
|
24
|
+
* themselves, so the project needs no secret key. An enquiry can't be dated
|
|
25
|
+
* by the sender: received_at is the database's own time.
|
|
26
|
+
*/
|
|
27
|
+
export const ENQUIRY_MIGRATION = {
|
|
28
|
+
name: "workbench_site_enquiries",
|
|
29
|
+
up: `-- workbench-site: Contact's enquiries and the Enquiries admin list (docs/site-planner.md §5).
|
|
30
|
+
-- A new table and its policies only. Applied through Workbench Control: sb_migration_apply.
|
|
31
|
+
|
|
32
|
+
set lock_timeout = '5s';
|
|
33
|
+
|
|
34
|
+
create table public.site_enquiries (
|
|
35
|
+
id uuid primary key default gen_random_uuid(),
|
|
36
|
+
name varchar(100) not null,
|
|
37
|
+
email varchar(254) not null,
|
|
38
|
+
phone varchar(16),
|
|
39
|
+
message varchar(2000) not null,
|
|
40
|
+
received_at timestamptz not null default now()
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
create index site_enquiries_received on public.site_enquiries (received_at desc);
|
|
44
|
+
|
|
45
|
+
alter table public.site_enquiries enable row level security;
|
|
46
|
+
|
|
47
|
+
-- Anyone sends one, dated now: the sender can't set the time.
|
|
48
|
+
create policy "anyone sends an enquiry" on public.site_enquiries
|
|
49
|
+
for insert to anon, authenticated
|
|
50
|
+
with check (received_at between now() - interval '1 minute' and now() + interval '1 minute');
|
|
51
|
+
|
|
52
|
+
create policy "admins read enquiries" on public.site_enquiries
|
|
53
|
+
for select to authenticated using (exists (select 1 from public.app_admins a where a.user_id = (select auth.uid())));
|
|
54
|
+
|
|
55
|
+
create policy "admins delete enquiries" on public.site_enquiries
|
|
56
|
+
for delete to authenticated using (exists (select 1 from public.app_admins a where a.user_id = (select auth.uid())));
|
|
57
|
+
|
|
58
|
+
comment on table public.site_enquiries is 'Enquiries from the Contact page, read by the site''s admins at /admin/enquiries (workbench-site).';
|
|
59
|
+
`,
|
|
60
|
+
down: `drop table public.site_enquiries;
|
|
61
|
+
`,
|
|
62
|
+
};
|
|
63
|
+
/** src/pages/enquiry-store.ts: written once, then the project's. */
|
|
64
|
+
export const ENQUIRY_STORE = `// The site's enquiries: Contact's form and the Enquiries admin list. Written by
|
|
65
|
+
// @mccaskie-labs/workbench-site once; it's the project's to change.
|
|
66
|
+
//
|
|
67
|
+
// - The form is workbench/forms/enquiry.json (\`npm run forms\` builds it); its
|
|
68
|
+
// numbers are in the limits register and match site_enquiries' columns.
|
|
69
|
+
// - The table is site_enquiries (supabase/migrations/*_workbench_site_enquiries.sql).
|
|
70
|
+
// Anyone may add a row and only the site's admins read or delete them, as
|
|
71
|
+
// themselves (RLS), so the project needs no secret key.
|
|
72
|
+
// - The page checks the form and Turnstile before it stores an enquiry. The
|
|
73
|
+
// table also takes rows sent straight to the database with the publishable
|
|
74
|
+
// key, which skip both: each is capped in length, and admins delete what
|
|
75
|
+
// they don't want. To close that, add SUPABASE_SECRET_KEY (two-step), send
|
|
76
|
+
// with the service client, and drop the insert policy.
|
|
77
|
+
|
|
78
|
+
import { readForm, validate, type Result } from "@mccaskie-labs/workbench-forms";
|
|
79
|
+
import { FORMS_SCRIPT } from "@mccaskie-labs/workbench-forms/browser";
|
|
80
|
+
import { boundsFor } from "@mccaskie-labs/workbench-forms/limits";
|
|
81
|
+
import { formatDateTime } from "@mccaskie-labs/workbench-country";
|
|
82
|
+
import { enquiryList, formSection, type Enquiry } from "@mccaskie-labs/workbench-site";
|
|
83
|
+
import { sameOrigin } from "@mccaskie-labs/workbench-supabase";
|
|
84
|
+
import { escape, FORM_SCRIPT } from "@mccaskie-labs/workbench-ui";
|
|
85
|
+
import { appConfig } from "../config.ts";
|
|
86
|
+
import { FORMS, formContext } from "../forms/index.ts";
|
|
87
|
+
import { formHtml } from "../forms/page.ts";
|
|
88
|
+
import { READERS } from "../lib/country.ts";
|
|
89
|
+
import { dbAs } from "../lib/db.ts";
|
|
90
|
+
import { TURNSTILE_ACTION, TURNSTILE_ORIGIN, turnstileSetup, verifyTurnstile } from "../lib/turnstile.ts";
|
|
91
|
+
import { LIMITS } from "../limits.ts";
|
|
92
|
+
import type { PageContext, SitePage } from "./site.ts";
|
|
93
|
+
|
|
94
|
+
/** The form's state after a submit that didn't go through. */
|
|
95
|
+
export interface EnquiryState {
|
|
96
|
+
result?: Result;
|
|
97
|
+
input?: Record<string, unknown>;
|
|
98
|
+
/** It couldn't be sent: the check or the database is down. */
|
|
99
|
+
problem?: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const SENT = "sent";
|
|
103
|
+
/** At most this many shown, newest first. */
|
|
104
|
+
const SHOWN = 200;
|
|
105
|
+
|
|
106
|
+
function enquiryForm() {
|
|
107
|
+
const form = FORMS.find((f) => f.name === "enquiry");
|
|
108
|
+
if (!form) throw new Error("There's no enquiry form: run npm run forms (workbench/forms/enquiry.json)");
|
|
109
|
+
return form;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The table, as the Worker reaches it. Tests replace these. */
|
|
113
|
+
export const enquiryStore = {
|
|
114
|
+
/** Adds one enquiry as anyone (the publishable key). False when the database didn't take it. */
|
|
115
|
+
async send(env: object, values: { name: string; email: string; phone: string | null; message: string }): Promise<boolean> {
|
|
116
|
+
const c = appConfig(env);
|
|
117
|
+
try {
|
|
118
|
+
const res = await fetch(\`\${c.SUPABASE_URL}/rest/v1/site_enquiries\`, {
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: { apikey: c.SUPABASE_PUBLISHABLE_KEY, "content-type": "application/json", prefer: "return=minimal" },
|
|
121
|
+
body: JSON.stringify(values),
|
|
122
|
+
signal: AbortSignal.timeout(10_000),
|
|
123
|
+
});
|
|
124
|
+
if (!res.ok) console.warn(JSON.stringify({ event: "site_enquiry_failed", status: res.status }));
|
|
125
|
+
return res.ok;
|
|
126
|
+
} catch {
|
|
127
|
+
console.warn(JSON.stringify({ event: "site_enquiry_failed", status: 0 }));
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
/** The newest enquiries, as the signed-in admin. Null when they can't be read. */
|
|
132
|
+
async list(env: object, accessToken: string): Promise<{ id: string; name: string; email: string; phone: string | null; message: string; received_at: string }[] | null> {
|
|
133
|
+
const { data, error } = await dbAs(env, accessToken).from("site_enquiries").select("id, name, email, phone, message, received_at").order("received_at", { ascending: false }).limit(SHOWN);
|
|
134
|
+
if (error) {
|
|
135
|
+
console.warn(JSON.stringify({ event: "site_enquiries_read_failed" }));
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return data;
|
|
139
|
+
},
|
|
140
|
+
/** Deletes one, as the signed-in admin. */
|
|
141
|
+
async remove(env: object, accessToken: string, id: string): Promise<boolean> {
|
|
142
|
+
const { error } = await dbAs(env, accessToken).from("site_enquiries").delete().eq("id", id);
|
|
143
|
+
return !error;
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export interface EnquiryWords {
|
|
148
|
+
heading: string;
|
|
149
|
+
intro?: string;
|
|
150
|
+
/** The submit button's key: renderForm looks it up. */
|
|
151
|
+
send: string;
|
|
152
|
+
/** The thank-you. */
|
|
153
|
+
sent: string;
|
|
154
|
+
/** When the check or the database is down. */
|
|
155
|
+
unavailable: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Contact's enquiry form, or its thank-you once sent. */
|
|
159
|
+
export function enquirySection(request: Request, env: object, ctx: PageContext, w: EnquiryWords): string {
|
|
160
|
+
if (new URL(request.url).searchParams.get(SENT) === "1") return formSection({ id: "enquiry", heading: w.heading, done: w.sent });
|
|
161
|
+
const state = (ctx.form ?? {}) as EnquiryState;
|
|
162
|
+
const path = new URL(request.url).pathname;
|
|
163
|
+
let html = formHtml(enquiryForm(), request, env, { action: \`\${path}#enquiry\`, submit: w.send, ...(state.result ? { result: state.result } : {}), ...(state.input ? { input: state.input } : {}) });
|
|
164
|
+
const bot = turnstileSetup(env);
|
|
165
|
+
if (bot.state === "on") {
|
|
166
|
+
// Inside the form, so its token is sent with it; shown only when Cloudflare needs the person to click.
|
|
167
|
+
const widget = \`<div class="cf-turnstile" data-sitekey="\${escape(bot.siteKey)}" data-action="\${TURNSTILE_ACTION}" data-appearance="interaction-only" data-theme="auto"></div>\`;
|
|
168
|
+
const at = html.lastIndexOf("</form>");
|
|
169
|
+
if (at !== -1) html = html.slice(0, at) + widget + html.slice(at);
|
|
170
|
+
html += \`<script src="\${TURNSTILE_ORIGIN}/turnstile/v0/api.js" async defer></script>\`;
|
|
171
|
+
}
|
|
172
|
+
html += \`<script>\${FORMS_SCRIPT}</script><script>\${FORM_SCRIPT}</script>\`;
|
|
173
|
+
return formSection({ id: "enquiry", heading: w.heading, ...(w.intro ? { intro: w.intro } : {}), form: html, ...(state.problem ? { problem: w.unavailable } : {}) });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Contact's POST: checks the form and Turnstile, stores it, and sends the person back to the thank-you. */
|
|
177
|
+
export async function takeEnquiry(request: Request, env: Env, ctx: PageContext, page: SitePage): Promise<Response> {
|
|
178
|
+
if (!sameOrigin(request)) return new Response("Forbidden\\n", { status: 403 });
|
|
179
|
+
const again = async (status: number, form: EnquiryState) => {
|
|
180
|
+
const res = await page.render(request, env, { ...ctx, form });
|
|
181
|
+
return new Response(res.body, { status, headers: res.headers });
|
|
182
|
+
};
|
|
183
|
+
let data: FormData;
|
|
184
|
+
try {
|
|
185
|
+
data = await request.formData();
|
|
186
|
+
} catch {
|
|
187
|
+
return again(400, {});
|
|
188
|
+
}
|
|
189
|
+
const form = enquiryForm();
|
|
190
|
+
const input = readForm(form, data);
|
|
191
|
+
const result = validate(form, input, { ...formContext(), bounds: boundsFor(LIMITS, form) });
|
|
192
|
+
if (!result.ok) return again(422, { result, input });
|
|
193
|
+
const bot = turnstileSetup(env);
|
|
194
|
+
if (bot.state === "missing") return again(503, { input, problem: true });
|
|
195
|
+
if (bot.state === "on" && !(await verifyTurnstile(bot.secret, data.get("cf-turnstile-response"), request, bot.strict)).ok) return again(400, { input, problem: true });
|
|
196
|
+
const v = result.values as Record<string, unknown>;
|
|
197
|
+
const sent = await enquiryStore.send(env, { name: String(v.name), email: String(v.email), phone: typeof v.phone === "string" ? v.phone : null, message: String(v.message) });
|
|
198
|
+
if (!sent) return again(503, { input, problem: true });
|
|
199
|
+
const back = new URL(request.url);
|
|
200
|
+
back.search = \`?\${SENT}=1\`;
|
|
201
|
+
back.hash = "enquiry";
|
|
202
|
+
return new Response(null, { status: 303, headers: { location: \`\${back.pathname}\${back.search}\${back.hash}\` } });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The enquiries for the admin list, in the readers' time zone. Null when they can't be read. */
|
|
206
|
+
export async function listEnquiries(env: object, ctx: PageContext): Promise<Enquiry[] | null> {
|
|
207
|
+
if (!ctx.accessToken) return null;
|
|
208
|
+
const rows = await enquiryStore.list(env, ctx.accessToken);
|
|
209
|
+
return rows && rows.map((r) => ({ id: r.id, name: r.name, email: r.email, phone: r.phone, message: r.message, received: formatDateTime(r.received_at, { pack: READERS }) }));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface EnquiryListWords {
|
|
213
|
+
heading?: string;
|
|
214
|
+
empty: string;
|
|
215
|
+
unavailable: string;
|
|
216
|
+
remove: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The Enquiries admin list. */
|
|
220
|
+
export function enquiriesSection(request: Request, enquiries: Enquiry[] | null, w: EnquiryListWords): string {
|
|
221
|
+
return enquiryList({ ...w, enquiries, removeAction: new URL(request.url).pathname });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The Enquiries page's POST: deletes one, as the admin, and shows the list again. */
|
|
225
|
+
export async function removeEnquiry(request: Request, env: object, ctx: PageContext): Promise<Response> {
|
|
226
|
+
let id: unknown = null;
|
|
227
|
+
try {
|
|
228
|
+
id = (await request.formData()).get("remove");
|
|
229
|
+
} catch {
|
|
230
|
+
// Nothing to delete: shown the list again.
|
|
231
|
+
}
|
|
232
|
+
if (ctx.accessToken && typeof id === "string" && /^[0-9a-f-]{36}$/.test(id)) await enquiryStore.remove(env, ctx.accessToken, id);
|
|
233
|
+
return new Response(null, { status: 303, headers: { location: new URL(request.url).pathname } });
|
|
234
|
+
}
|
|
235
|
+
`;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The "Every site" recipes (docs/site-planner.md §5): the pages most sites
|
|
2
|
+
// have. Privacy and Terms join them with their written clauses per country
|
|
3
|
+
// (site planner step 4). Contact's enquiry form needs the Enquiries admin
|
|
4
|
+
// list, so no enquiry is taken before there is somewhere to read it. Words in [square brackets] are the owner's to fill in: Workbench
|
|
5
|
+
// never makes up a price, an address, an opening hour or a person.
|
|
6
|
+
const home = {
|
|
7
|
+
id: "home",
|
|
8
|
+
version: 1,
|
|
9
|
+
title: "Home",
|
|
10
|
+
does: "The first page people see: what you do, who for, and how to get in touch.",
|
|
11
|
+
group: "every-site",
|
|
12
|
+
area: "public",
|
|
13
|
+
path: "/",
|
|
14
|
+
frames: ["landing", "column"],
|
|
15
|
+
tools: [],
|
|
16
|
+
needs: [],
|
|
17
|
+
menu: { label: "page.home.menu", header: 0 },
|
|
18
|
+
pageTitle: "page.home.title",
|
|
19
|
+
sections: [
|
|
20
|
+
{ kind: "hero", heading: "page.home.hero.heading", lead: "page.home.hero.lead", action: { label: "page.home.hero.action", to: "contact" } },
|
|
21
|
+
{
|
|
22
|
+
kind: "list",
|
|
23
|
+
heading: "page.home.points.heading",
|
|
24
|
+
items: [
|
|
25
|
+
{ title: "page.home.points.first.title", body: "page.home.points.first.body" },
|
|
26
|
+
{ title: "page.home.points.second.title", body: "page.home.points.second.body" },
|
|
27
|
+
{ title: "page.home.points.third.title", body: "page.home.points.third.body" },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{ kind: "text", heading: "page.home.intro.heading", body: "page.home.intro.body" },
|
|
31
|
+
{ kind: "call", heading: "page.home.call.heading", body: "page.home.call.body", action: { label: "page.home.call.action", to: "contact" } },
|
|
32
|
+
],
|
|
33
|
+
words: {
|
|
34
|
+
"page.home.menu": "Home",
|
|
35
|
+
"page.home.title": "Home",
|
|
36
|
+
"page.home.hero.heading": "[What you do, in a few words]",
|
|
37
|
+
"page.home.hero.lead": "[One or two sentences on who you help and how.]",
|
|
38
|
+
"page.home.hero.action": "Get in touch",
|
|
39
|
+
"page.home.points.heading": "Why people choose us",
|
|
40
|
+
"page.home.points.first.title": "[First reason]",
|
|
41
|
+
"page.home.points.first.body": "[A sentence about it.]",
|
|
42
|
+
"page.home.points.second.title": "[Second reason]",
|
|
43
|
+
"page.home.points.second.body": "[A sentence about it.]",
|
|
44
|
+
"page.home.points.third.title": "[Third reason]",
|
|
45
|
+
"page.home.points.third.body": "[A sentence about it.]",
|
|
46
|
+
"page.home.intro.heading": "[A short heading about your business]",
|
|
47
|
+
"page.home.intro.body": "[A paragraph or two about your business: what you offer, where, and what makes it yours.]",
|
|
48
|
+
"page.home.call.heading": "Ready to talk?",
|
|
49
|
+
"page.home.call.body": "Send us a message and we'll get back to you.",
|
|
50
|
+
"page.home.call.action": "Contact us",
|
|
51
|
+
},
|
|
52
|
+
suggest: { types: [], signals: ["every site"] },
|
|
53
|
+
};
|
|
54
|
+
const about = {
|
|
55
|
+
id: "about",
|
|
56
|
+
version: 1,
|
|
57
|
+
title: "About",
|
|
58
|
+
does: "Your story: who you are, why you started and what you care about.",
|
|
59
|
+
group: "every-site",
|
|
60
|
+
area: "public",
|
|
61
|
+
path: "/about",
|
|
62
|
+
frames: ["column", "landing"],
|
|
63
|
+
tools: [],
|
|
64
|
+
needs: [],
|
|
65
|
+
menu: { label: "page.about.menu", header: 10 },
|
|
66
|
+
pageTitle: "page.about.title",
|
|
67
|
+
sections: [
|
|
68
|
+
{ kind: "hero", heading: "page.about.hero.heading", lead: "page.about.hero.lead" },
|
|
69
|
+
{ kind: "text", heading: "page.about.story.heading", body: "page.about.story.body" },
|
|
70
|
+
{ kind: "text", heading: "page.about.values.heading", body: "page.about.values.body" },
|
|
71
|
+
{ kind: "call", heading: "page.about.call.heading", action: { label: "page.about.call.action", to: "contact" } },
|
|
72
|
+
],
|
|
73
|
+
words: {
|
|
74
|
+
"page.about.menu": "About",
|
|
75
|
+
"page.about.title": "About us",
|
|
76
|
+
"page.about.hero.heading": "About us",
|
|
77
|
+
"page.about.hero.lead": "[A sentence on who you are.]",
|
|
78
|
+
"page.about.story.heading": "Our story",
|
|
79
|
+
"page.about.story.body": "[How the business started, and why.]\n\n[Where it is now, and who is part of it.]",
|
|
80
|
+
"page.about.values.heading": "What we care about",
|
|
81
|
+
"page.about.values.body": "[What matters to you in how you work.]",
|
|
82
|
+
"page.about.call.heading": "Want to know more?",
|
|
83
|
+
"page.about.call.action": "Get in touch",
|
|
84
|
+
},
|
|
85
|
+
suggest: { types: [], signals: ["every site"] },
|
|
86
|
+
};
|
|
87
|
+
const contact = {
|
|
88
|
+
id: "contact",
|
|
89
|
+
version: 2,
|
|
90
|
+
title: "Contact",
|
|
91
|
+
does: "How to reach you: email, phone, where you are and when you're open, and a form to send you a message.",
|
|
92
|
+
group: "every-site",
|
|
93
|
+
area: "public",
|
|
94
|
+
path: "/contact",
|
|
95
|
+
frames: ["two-columns", "column"],
|
|
96
|
+
tools: [],
|
|
97
|
+
needs: ["enquiries"],
|
|
98
|
+
menu: { label: "page.contact.menu", header: 90, footer: 10 },
|
|
99
|
+
pageTitle: "page.contact.title",
|
|
100
|
+
sections: [
|
|
101
|
+
{ kind: "hero", heading: "page.contact.hero.heading", lead: "page.contact.hero.lead" },
|
|
102
|
+
{
|
|
103
|
+
kind: "details",
|
|
104
|
+
heading: "page.contact.reach.heading",
|
|
105
|
+
rows: [
|
|
106
|
+
{ label: "page.contact.reach.email.label", value: "page.contact.reach.email.value" },
|
|
107
|
+
{ label: "page.contact.reach.phone.label", value: "page.contact.reach.phone.value" },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
kind: "details",
|
|
112
|
+
heading: "page.contact.visit.heading",
|
|
113
|
+
rows: [
|
|
114
|
+
{ label: "page.contact.visit.address.label", value: "page.contact.visit.address.value" },
|
|
115
|
+
{ label: "page.contact.visit.hours.label", value: "page.contact.visit.hours.value" },
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{ kind: "enquiry-form", heading: "page.contact.form.heading", intro: "page.contact.form.intro", send: "page.contact.form.send", sent: "page.contact.form.sent", unavailable: "page.contact.form.unavailable" },
|
|
119
|
+
],
|
|
120
|
+
words: {
|
|
121
|
+
"page.contact.menu": "Contact",
|
|
122
|
+
"page.contact.title": "Contact us",
|
|
123
|
+
"page.contact.hero.heading": "Contact us",
|
|
124
|
+
"page.contact.hero.lead": "We'd love to hear from you.",
|
|
125
|
+
"page.contact.reach.heading": "Get in touch",
|
|
126
|
+
"page.contact.reach.email.label": "Email",
|
|
127
|
+
"page.contact.reach.email.value": "[Your email address]",
|
|
128
|
+
"page.contact.reach.phone.label": "Phone",
|
|
129
|
+
"page.contact.reach.phone.value": "[Your phone number]",
|
|
130
|
+
"page.contact.visit.heading": "Find us",
|
|
131
|
+
"page.contact.visit.address.label": "Address",
|
|
132
|
+
"page.contact.visit.address.value": "[Your address, or the area you cover]",
|
|
133
|
+
"page.contact.visit.hours.label": "Opening hours",
|
|
134
|
+
"page.contact.visit.hours.value": "[Your opening hours]",
|
|
135
|
+
"page.contact.form.heading": "Send us a message",
|
|
136
|
+
"page.contact.form.intro": "We'll reply by email, usually within a business day.",
|
|
137
|
+
"page.contact.form.send": "Send message",
|
|
138
|
+
"page.contact.form.sent": "Thanks, your message is on its way. We'll be in touch soon.",
|
|
139
|
+
"page.contact.form.unavailable": "Your message couldn't be sent just now. Please try again in a minute, or email us instead.",
|
|
140
|
+
},
|
|
141
|
+
suggest: { types: [], signals: ["every site"] },
|
|
142
|
+
};
|
|
143
|
+
const notFound = {
|
|
144
|
+
id: "not-found",
|
|
145
|
+
version: 1,
|
|
146
|
+
title: "Not found",
|
|
147
|
+
does: "What people see when an address on your site doesn't exist, with a way back.",
|
|
148
|
+
group: "every-site",
|
|
149
|
+
area: "public",
|
|
150
|
+
path: null,
|
|
151
|
+
status: 404,
|
|
152
|
+
frames: ["column"],
|
|
153
|
+
tools: [],
|
|
154
|
+
needs: [],
|
|
155
|
+
pageTitle: "page.not_found.title",
|
|
156
|
+
sections: [{ kind: "hero", heading: "page.not_found.hero.heading", lead: "page.not_found.hero.lead", action: { label: "page.not_found.hero.action", to: "/" } }],
|
|
157
|
+
words: {
|
|
158
|
+
"page.not_found.title": "Page not found",
|
|
159
|
+
"page.not_found.hero.heading": "We can't find that page",
|
|
160
|
+
"page.not_found.hero.lead": "The address may be mistyped, or the page may have moved.",
|
|
161
|
+
"page.not_found.hero.action": "Go to the home page",
|
|
162
|
+
},
|
|
163
|
+
suggest: { types: [], signals: ["every site"] },
|
|
164
|
+
};
|
|
165
|
+
/** The "Every site" group, in the order they're offered. */
|
|
166
|
+
export const EVERY_SITE = [home, about, contact, notFound];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The recipe catalogue: every page Workbench knows how to build
|
|
2
|
+
// (docs/site-planner.md §5). The business recipes join it in later steps; each tool's own pages will live in that tool's package and
|
|
3
|
+
// be gathered here.
|
|
4
|
+
import { ADMIN } from "./admin.js";
|
|
5
|
+
import { EVERY_SITE } from "./every-site.js";
|
|
6
|
+
import { MEMBERS } from "./members.js";
|
|
7
|
+
export const RECIPES = [...EVERY_SITE, ...MEMBERS, ...ADMIN];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The "Members" recipes (docs/site-planner.md §5): pages for the app's own
|
|
2
|
+
// signed-in users. Sign in itself is the template's (/sign-in). Your
|
|
3
|
+
// bookings and Your orders come with their tools' recipes (step 6).
|
|
4
|
+
const account = {
|
|
5
|
+
id: "account",
|
|
6
|
+
version: 1,
|
|
7
|
+
title: "Your account",
|
|
8
|
+
does: "Where a signed-in customer sees who they're signed in as and signs out.",
|
|
9
|
+
group: "members",
|
|
10
|
+
area: "members",
|
|
11
|
+
path: "/account",
|
|
12
|
+
frames: ["column"],
|
|
13
|
+
tools: ["sign-in"],
|
|
14
|
+
needs: [],
|
|
15
|
+
menu: { label: "page.account.menu", header: 95 },
|
|
16
|
+
pageTitle: "page.account.title",
|
|
17
|
+
sections: [
|
|
18
|
+
{ kind: "hero", heading: "page.account.hero.heading", lead: "page.account.hero.lead" },
|
|
19
|
+
{ kind: "account", heading: "page.account.you.heading", signedIn: "page.account.you.signed_in", signOut: "page.account.you.sign_out" },
|
|
20
|
+
{ kind: "call", heading: "page.account.call.heading", body: "page.account.call.body", action: { label: "page.account.call.action", to: "contact" } },
|
|
21
|
+
],
|
|
22
|
+
words: {
|
|
23
|
+
"page.account.menu": "Your account",
|
|
24
|
+
"page.account.title": "Your account",
|
|
25
|
+
"page.account.hero.heading": "Your account",
|
|
26
|
+
"page.account.hero.lead": "Your details, in one place.",
|
|
27
|
+
"page.account.you.heading": "You",
|
|
28
|
+
"page.account.you.signed_in": "Signed in as {email}.",
|
|
29
|
+
"page.account.you.sign_out": "Sign out",
|
|
30
|
+
"page.account.call.heading": "Need a hand?",
|
|
31
|
+
"page.account.call.body": "Get in touch and we'll sort it out.",
|
|
32
|
+
"page.account.call.action": "Contact us",
|
|
33
|
+
},
|
|
34
|
+
suggest: { types: [], signals: ["customers sign in", "members", "bookings", "orders"] },
|
|
35
|
+
};
|
|
36
|
+
/** The "Members" group, in the order they're offered. */
|
|
37
|
+
export const MEMBERS = [account];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One sample: a part of the tool, or one of its layouts. */
|
|
2
|
+
interface ToolSample {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
layout?: string;
|
|
6
|
+
html: () => string;
|
|
7
|
+
}
|
|
8
|
+
/** Every sample of one tool (workbench-ui's ToolSamples). */
|
|
9
|
+
export interface ToolSamples {
|
|
10
|
+
format: 1;
|
|
11
|
+
package: string;
|
|
12
|
+
title: string;
|
|
13
|
+
prefix: string;
|
|
14
|
+
samples: readonly ToolSample[];
|
|
15
|
+
}
|
|
16
|
+
/** Every sample of the site tool. */
|
|
17
|
+
export declare const SITE_SAMPLES: ToolSamples;
|
|
18
|
+
export {};
|
package/dist/samples.js
ADDED
|
@@ -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
|
+
};
|