ferst-core 0.16.0 → 0.17.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/NOTICE +63 -31
- package/bin/ferst-modules.mjs +17 -2
- package/components/BlockRenderer.astro +131 -129
- package/components/MembersAccount.astro +370 -0
- package/components/SiteHeader.astro +23 -1
- package/components/islands/BookMonth.tsx +95 -0
- package/components/islands/MembersAccount.tsx +392 -0
- package/components/recipes/Book.astro +1147 -926
- package/components/recipes/MembersContent.astro +176 -0
- package/content/blocks.ts +25 -6
- package/content/cookies.ts +14 -0
- package/content/recipe-questions.ts +81 -80
- package/examples/recipes.ts +1 -0
- package/integration.mjs +319 -253
- package/layouts/Base.astro +1 -0
- package/lib/book.ts +416 -378
- package/lib/members-account.ts +276 -0
- package/lib/members.ts +115 -0
- package/package.json +80 -72
- package/routes/account.astro +16 -0
- package/routes/cookie-policy.astro +28 -28
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* MembersContent — a members' page from the Ferst Members module, written in the portal. The
|
|
4
|
+
* build renders only a placeholder (and the block's title, when it has one): what members read is
|
|
5
|
+
* never in the build. In the visitor's browser the block asks the site for the page
|
|
6
|
+
* (`/ferst-api/members/pages/<id>`, same-origin, the session cookie going with it), and the
|
|
7
|
+
* platform checks who is signed in. Then it shows the page, a sign-in prompt (401), "not included"
|
|
8
|
+
* (403) or "can't be shown" (anything else). On the author's own computer (`astro dev` /
|
|
9
|
+
* `astro preview`, no Pages Functions) it says sign-in works on the published site. lib/members
|
|
10
|
+
* holds the decisions.
|
|
11
|
+
*/
|
|
12
|
+
import Heading from '../blocks/Heading.astro';
|
|
13
|
+
import { MEMBERS_PAGE_TEXT, membersPageUrl } from '../../lib/members';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
page: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
}
|
|
19
|
+
const { page, title } = Astro.props;
|
|
20
|
+
const { align: blockAlign, headingAlign } = Astro.props as { align?: 'start' | 'center' | 'end'; headingAlign?: 'start' | 'center' | 'end' };
|
|
21
|
+
const headAlign = headingAlign ?? blockAlign;
|
|
22
|
+
const signIn = MEMBERS_PAGE_TEXT.signIn;
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<section class="b-members" data-members-page={membersPageUrl(page)} data-members-own-title={title ? undefined : ''} aria-busy="true">
|
|
26
|
+
<div class="b-members__head" data-recipe-head data-content-align={headAlign} hidden={!title}>
|
|
27
|
+
<Heading text={title ?? ''} level={2} />
|
|
28
|
+
</div>
|
|
29
|
+
<div class="b-members__skeleton" data-members-skeleton aria-hidden="true">
|
|
30
|
+
<span></span><span></span><span></span>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="b-members__body" data-members-body hidden></div>
|
|
33
|
+
<p class="b-members__notice" role="status" data-members-notice="sign-in" hidden>
|
|
34
|
+
{signIn.before} <a href="/account" data-members-sign-in>{signIn.link}</a> {signIn.after}
|
|
35
|
+
</p>
|
|
36
|
+
<p class="b-members__notice" role="status" data-members-notice="not-included" hidden>{MEMBERS_PAGE_TEXT.notIncluded}</p>
|
|
37
|
+
<p class="b-members__notice" role="status" data-members-notice="unavailable" hidden>{MEMBERS_PAGE_TEXT.unavailable}</p>
|
|
38
|
+
<p class="b-members__notice" role="status" data-members-notice="local" hidden>{MEMBERS_PAGE_TEXT.local}</p>
|
|
39
|
+
</section>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
import { isLocalHost, membersPageView, readMembersAnswer, signInHref, type MembersAnswer } from '../../lib/members';
|
|
43
|
+
|
|
44
|
+
async function ask(url: string): Promise<MembersAnswer | null> {
|
|
45
|
+
try {
|
|
46
|
+
const res = await fetch(url, { credentials: 'same-origin', headers: { Accept: 'application/json' } });
|
|
47
|
+
return await readMembersAnswer(res);
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function setUp(block: HTMLElement) {
|
|
54
|
+
const url = block.dataset.membersPage;
|
|
55
|
+
if (!url) return;
|
|
56
|
+
const view = membersPageView(await ask(url), import.meta.env.DEV || isLocalHost(location.hostname));
|
|
57
|
+
block.querySelector<HTMLElement>('[data-members-skeleton]')?.remove();
|
|
58
|
+
block.removeAttribute('aria-busy');
|
|
59
|
+
if (view.kind === 'page') {
|
|
60
|
+
// The page's own title, unless the block gives its own.
|
|
61
|
+
const head = block.querySelector<HTMLElement>('.b-members__head');
|
|
62
|
+
if (head && block.dataset.membersOwnTitle !== undefined && view.title) {
|
|
63
|
+
const heading = head.querySelector<HTMLElement>('.b-heading');
|
|
64
|
+
if (heading) heading.textContent = view.title;
|
|
65
|
+
head.hidden = false;
|
|
66
|
+
}
|
|
67
|
+
const body = block.querySelector<HTMLElement>('[data-members-body]');
|
|
68
|
+
if (body) {
|
|
69
|
+
// The platform renders the page's Markdown and allows only plain tags (no scripts, no styles).
|
|
70
|
+
body.innerHTML = view.html;
|
|
71
|
+
body.hidden = false;
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (view.kind === 'sign-in') {
|
|
76
|
+
const link = block.querySelector<HTMLAnchorElement>('[data-members-sign-in]');
|
|
77
|
+
if (link) link.href = signInHref(location.pathname + location.search);
|
|
78
|
+
}
|
|
79
|
+
const notice = block.querySelector<HTMLElement>(`[data-members-notice="${view.kind}"]`);
|
|
80
|
+
if (notice) notice.hidden = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
document.querySelectorAll<HTMLElement>('[data-members-page]').forEach((b) => { void setUp(b); });
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
.b-members {
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
gap: 1rem;
|
|
91
|
+
max-width: var(--max);
|
|
92
|
+
margin-inline: auto;
|
|
93
|
+
padding-inline: 1rem;
|
|
94
|
+
color: var(--fg);
|
|
95
|
+
}
|
|
96
|
+
.b-members__head[hidden],
|
|
97
|
+
.b-members__body[hidden],
|
|
98
|
+
.b-members__notice[hidden] {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* The placeholder while the page loads: three quiet bars, still under reduced motion. */
|
|
103
|
+
.b-members__skeleton {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
gap: 0.75rem;
|
|
107
|
+
}
|
|
108
|
+
.b-members__skeleton span {
|
|
109
|
+
display: block;
|
|
110
|
+
height: 1rem;
|
|
111
|
+
border-radius: var(--radius-sm);
|
|
112
|
+
background: var(--bg-section);
|
|
113
|
+
animation: b-members-pulse 1.6s ease-in-out infinite;
|
|
114
|
+
}
|
|
115
|
+
.b-members__skeleton span:nth-child(2) { width: 92%; }
|
|
116
|
+
.b-members__skeleton span:nth-child(3) { width: 64%; }
|
|
117
|
+
@keyframes b-members-pulse {
|
|
118
|
+
50% { opacity: 0.55; }
|
|
119
|
+
}
|
|
120
|
+
@media (prefers-reduced-motion: reduce) {
|
|
121
|
+
.b-members__skeleton span { animation: none; }
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* The page itself: plain Markdown from the portal, read like a Prose block. */
|
|
125
|
+
.b-members__body :global(:is(p, ul, ol, blockquote, pre, table)) {
|
|
126
|
+
margin: 0 0 1rem;
|
|
127
|
+
line-height: 1.7;
|
|
128
|
+
}
|
|
129
|
+
.b-members__body :global(:is(ul, ol)) {
|
|
130
|
+
padding-inline-start: 1.4em;
|
|
131
|
+
}
|
|
132
|
+
.b-members__body :global(li + li) {
|
|
133
|
+
margin-top: 0.25rem;
|
|
134
|
+
}
|
|
135
|
+
.b-members__body :global(:is(h1, h2, h3, h4, h5, h6)) {
|
|
136
|
+
margin: 1.5rem 0 0.75rem;
|
|
137
|
+
line-height: 1.25;
|
|
138
|
+
color: var(--fg);
|
|
139
|
+
}
|
|
140
|
+
.b-members__body :global(a) {
|
|
141
|
+
color: var(--accent);
|
|
142
|
+
text-decoration: underline;
|
|
143
|
+
text-underline-offset: 0.15em;
|
|
144
|
+
}
|
|
145
|
+
.b-members__body :global(img) {
|
|
146
|
+
max-width: 100%;
|
|
147
|
+
height: auto;
|
|
148
|
+
border-radius: var(--radius-sm);
|
|
149
|
+
}
|
|
150
|
+
.b-members__body :global(blockquote) {
|
|
151
|
+
padding-inline-start: 1rem;
|
|
152
|
+
border-inline-start: 3px solid var(--border);
|
|
153
|
+
color: var(--muted);
|
|
154
|
+
}
|
|
155
|
+
.b-members__body > :global(:first-child) {
|
|
156
|
+
margin-top: 0;
|
|
157
|
+
}
|
|
158
|
+
.b-members__body > :global(:last-child) {
|
|
159
|
+
margin-bottom: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.b-members__notice {
|
|
163
|
+
margin: 0;
|
|
164
|
+
padding: 0.85rem 1rem;
|
|
165
|
+
border: 1px solid var(--border);
|
|
166
|
+
border-radius: var(--radius-sm);
|
|
167
|
+
background: var(--bg-section);
|
|
168
|
+
line-height: 1.5;
|
|
169
|
+
}
|
|
170
|
+
.b-members__notice a {
|
|
171
|
+
color: var(--accent);
|
|
172
|
+
font-weight: 600;
|
|
173
|
+
text-decoration: underline;
|
|
174
|
+
text-underline-offset: 0.15em;
|
|
175
|
+
}
|
|
176
|
+
</style>
|
package/content/blocks.ts
CHANGED
|
@@ -310,8 +310,10 @@ export const bookBlock = z.object({
|
|
|
310
310
|
/** One event of it (e.g. `eve_…`, the Christmas concert): only that event's dates. Left out: all of them. */
|
|
311
311
|
event: z.string().min(1).optional(),
|
|
312
312
|
/** `button`: "Book now" for one date of a class or an event, with only the booker's details left
|
|
313
|
-
* (the maintainer, 2026-11-24). Its next date with places, or `date`. Left out: the calendar or list.
|
|
314
|
-
|
|
313
|
+
* (the maintainer, 2026-11-24). Its next date with places, or `date`. Left out: the calendar or list.
|
|
314
|
+
* `calendar` (myai4-webdev #239, a trial): an offer booked by time shows a month with the days that
|
|
315
|
+
* have free times marked, and the chosen day's times beside it (under it on a phone). */
|
|
316
|
+
look: z.enum(['button', 'calendar']).optional(),
|
|
315
317
|
/** With `look: button`: one date of a repeating event ('YYYY-MM-DDTHH:MM', London). Left out: the next with places. */
|
|
316
318
|
date: z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/).optional(),
|
|
317
319
|
/** A list of dates across chosen classes and events, in place of `service` (the maintainer, 2026-11-24:
|
|
@@ -328,6 +330,20 @@ export const bookBlock = z.object({
|
|
|
328
330
|
buttonLabel: z.string().max(40).optional(),
|
|
329
331
|
});
|
|
330
332
|
|
|
333
|
+
/** A members' page from the Ferst Members module, written in the portal: only signed-in members
|
|
334
|
+
* of the organisation read it. The build renders a placeholder (and the title, when given); the
|
|
335
|
+
* visitor's browser asks the site for the page (`/ferst-api/members/pages/<id>`), and the platform
|
|
336
|
+
* checks who is signed in. Nothing members-only is ever in the build or the repo (lib/members).
|
|
337
|
+
* List a site's members' pages with `npx ferst-modules`. */
|
|
338
|
+
export const membersContentBlock = z.object({
|
|
339
|
+
type: z.literal('membersContent'),
|
|
340
|
+
enabled: z.boolean().default(true),
|
|
341
|
+
/** The page's id in the portal (e.g. `mpg_3f2a…`). */
|
|
342
|
+
page: z.string().regex(/^mpg_[0-9a-f]{24}$/, 'a members’ page id from the portal, like mpg_ and 24 letters and digits'),
|
|
343
|
+
/** Shown while the page loads and to visitors who can't read it. Left out: the page's own title, once it loads. */
|
|
344
|
+
title: z.string().optional(),
|
|
345
|
+
});
|
|
346
|
+
|
|
331
347
|
/** A contact form recipe. `fields` is generic (any labelled input list) so the
|
|
332
348
|
* same recipe serves a contact page, an enquiry form, a sign-up, etc. `action`
|
|
333
349
|
* is optional: the core ships no backend, so with none it renders a standard
|
|
@@ -830,6 +846,7 @@ export type RecipeBlock =
|
|
|
830
846
|
| z.infer<typeof formBlock>
|
|
831
847
|
| z.infer<typeof payBlock>
|
|
832
848
|
| z.infer<typeof bookBlock>
|
|
849
|
+
| z.infer<typeof membersContentBlock>
|
|
833
850
|
| z.infer<typeof accordionBlock>
|
|
834
851
|
| z.infer<typeof tilesBlock>
|
|
835
852
|
| z.infer<typeof bannerBlock>
|
|
@@ -976,6 +993,7 @@ export const blockSchema = z.discriminatedUnion(
|
|
|
976
993
|
formBlock,
|
|
977
994
|
payBlock,
|
|
978
995
|
bookBlock,
|
|
996
|
+
membersContentBlock,
|
|
979
997
|
accordionBlock,
|
|
980
998
|
tilesBlock,
|
|
981
999
|
bannerBlock,
|
|
@@ -1066,7 +1084,8 @@ export const blockTypes = (
|
|
|
1066
1084
|
blockSchema as unknown as { options: ReadonlyArray<{ shape: { type: { value: BlockType } } }> }
|
|
1067
1085
|
).options.map((o) => o.shape.type.value);
|
|
1068
1086
|
|
|
1069
|
-
/** Blocks whose content comes from the Ferst platform
|
|
1070
|
-
* The public showcase can't render them without the
|
|
1071
|
-
* look through their local twin instead (`form` renders with the
|
|
1072
|
-
|
|
1087
|
+
/** Blocks whose content comes from the Ferst platform (a form, an item to pay for, an offer to book: at build
|
|
1088
|
+
* time; a members' page: in the visitor's browser). The public showcase can't render them without the
|
|
1089
|
+
* platform, so its galleries show the look through their local twin instead (`form` renders with the
|
|
1090
|
+
* contactForm recipe). */
|
|
1091
|
+
export const platformBlockTypes: readonly BlockType[] = ['form', 'pay', 'book', 'membersContent'];
|
package/content/cookies.ts
CHANGED
|
@@ -90,6 +90,15 @@ const NECESSARY: readonly CookieUse[] = [
|
|
|
90
90
|
},
|
|
91
91
|
];
|
|
92
92
|
|
|
93
|
+
/** The members' sign-in (the Ferst Members module): on a site where members sign in. */
|
|
94
|
+
const MEMBERS_SESSION: CookieUse = {
|
|
95
|
+
id: 'members-session',
|
|
96
|
+
category: 'necessary',
|
|
97
|
+
name: 'Members’ sign-in',
|
|
98
|
+
purpose: 'Keeps you signed in to your account on this site after you sign in with a code sent to your email. Set only when you sign in, and removed when you sign out.',
|
|
99
|
+
storage: 'A cookie set by this site (__Host-ferst_member), kept for 30 days from your last visit. Only this site reads it; it is never shared.',
|
|
100
|
+
};
|
|
101
|
+
|
|
93
102
|
/** Third-party embeds — listed only when a site actually uses them. */
|
|
94
103
|
const ADDITIONAL: readonly AdditionalUse[] = [
|
|
95
104
|
{
|
|
@@ -157,6 +166,9 @@ export interface CookieScanInput {
|
|
|
157
166
|
blockTypes?: Iterable<string>;
|
|
158
167
|
/** True when the site has a Google Calendar configured (dedicated calendar page). */
|
|
159
168
|
calendarConfigured?: boolean;
|
|
169
|
+
/** True when members sign in on the site (the Ferst Members module): its sign-in cookie is listed.
|
|
170
|
+
* A members' page block on the site lists it too. */
|
|
171
|
+
members?: boolean;
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
export interface CookiePolicyModel {
|
|
@@ -186,6 +198,8 @@ const BY_TYPE: Record<string, string[]> = {
|
|
|
186
198
|
/** Report the cookie uses actually active on a site, grouped by category. */
|
|
187
199
|
export function scanCookieUses(input: CookieScanInput): CookiePolicyModel {
|
|
188
200
|
const necessary = NECESSARY.map((u) => ({ ...u }));
|
|
201
|
+
const signsIn = input.members === true || (input.blocks ? allBlocks(input.blocks).some((b) => b.type === 'membersContent') : false);
|
|
202
|
+
if (signsIn) necessary.push({ ...MEMBERS_SESSION });
|
|
189
203
|
if (!input.blocks && input.blockTypes) {
|
|
190
204
|
const types = new Set(input.blockTypes);
|
|
191
205
|
const additional = ADDITIONAL.filter(
|
|
@@ -1,80 +1,81 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Setup questions, kept with the recipes. When a client sets up a page from a design, each
|
|
3
|
-
* section of the design asks one free-flowing question; the answer is a paragraph in the client's
|
|
4
|
-
* own words, from which the section is filled. Deliberately not a field-by-field form: the
|
|
5
|
-
* recipe decides how the words are laid out, so the client only has to say what they mean.
|
|
6
|
-
*
|
|
7
|
-
* - `ask`: the question, a hint, and a plain name for the section.
|
|
8
|
-
* - `note`: the section fills itself (from the platform or the site), so nothing is asked.
|
|
9
|
-
* - `null`: spacing and layout pieces, which have no content of their own (containers are
|
|
10
|
-
* walked into by the caller).
|
|
11
|
-
*
|
|
12
|
-
* Generic wording only. How questions are ordered and combined into a request lives with the
|
|
13
|
-
* platform.
|
|
14
|
-
*/
|
|
15
|
-
export type RecipeQuestion =
|
|
16
|
-
| { kind: 'ask'; label: string; question: string; hint: string }
|
|
17
|
-
| { kind: 'note'; label: string; note: string };
|
|
18
|
-
|
|
19
|
-
const ask = (label: string, question: string, hint: string): RecipeQuestion => ({ kind: 'ask', label, question, hint });
|
|
20
|
-
const note = (label: string, text: string): RecipeQuestion => ({ kind: 'note', label, note: text });
|
|
21
|
-
|
|
22
|
-
const QUESTIONS: Record<string, RecipeQuestion | null> = {
|
|
23
|
-
// Recipes
|
|
24
|
-
hero: ask('Opening banner', 'What should the first thing visitors see say?', 'Your main message in your own words, a supporting line, and where the main button should take people.'),
|
|
25
|
-
featureCards: ask('Highlights', 'What are the main things you want to highlight here?', 'Describe each one in a sentence or two, and say where each should lead if people want more.'),
|
|
26
|
-
cta: ask('Call to action', 'What do you most want visitors to do next?', 'For example: book, call, visit, sign up. Say it the way you would to a customer.'),
|
|
27
|
-
faq: ask('Questions and answers', 'What do people often ask you, and how do you answer?', 'Write each question with your usual answer. As many as you like.'),
|
|
28
|
-
gallery: ask('Photo gallery', 'What should these photos show?', 'Describe the pictures you have or want: your work, your place, your people. You can upload them in the content editor.'),
|
|
29
|
-
testimonial: ask('What people say', 'What have customers said about you?', 'Paste a kind word or review, with the person’s name or initials if they’re happy to be named.'),
|
|
30
|
-
contactForm: ask('Contact form', 'What should people be able to ask you through this form?', 'Who answers, what you need to know from them, and how soon they can expect a reply.'),
|
|
31
|
-
form: note('Form', 'This shows one of your organisation’s forms. Choose or create it in the portal under Forms.'),
|
|
32
|
-
pay: note('Payment', 'This takes a payment for one of the things your sites take payment for. Set what it’s for and its price in the portal, under Payments.'),
|
|
33
|
-
book: note('Booking', 'This lets visitors book a time for one of your offers. Set the offer, who gives it and their opening hours in the portal, under Events and bookings.'),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Setup questions, kept with the recipes. When a client sets up a page from a design, each
|
|
3
|
+
* section of the design asks one free-flowing question; the answer is a paragraph in the client's
|
|
4
|
+
* own words, from which the section is filled. Deliberately not a field-by-field form: the
|
|
5
|
+
* recipe decides how the words are laid out, so the client only has to say what they mean.
|
|
6
|
+
*
|
|
7
|
+
* - `ask`: the question, a hint, and a plain name for the section.
|
|
8
|
+
* - `note`: the section fills itself (from the platform or the site), so nothing is asked.
|
|
9
|
+
* - `null`: spacing and layout pieces, which have no content of their own (containers are
|
|
10
|
+
* walked into by the caller).
|
|
11
|
+
*
|
|
12
|
+
* Generic wording only. How questions are ordered and combined into a request lives with the
|
|
13
|
+
* platform.
|
|
14
|
+
*/
|
|
15
|
+
export type RecipeQuestion =
|
|
16
|
+
| { kind: 'ask'; label: string; question: string; hint: string }
|
|
17
|
+
| { kind: 'note'; label: string; note: string };
|
|
18
|
+
|
|
19
|
+
const ask = (label: string, question: string, hint: string): RecipeQuestion => ({ kind: 'ask', label, question, hint });
|
|
20
|
+
const note = (label: string, text: string): RecipeQuestion => ({ kind: 'note', label, note: text });
|
|
21
|
+
|
|
22
|
+
const QUESTIONS: Record<string, RecipeQuestion | null> = {
|
|
23
|
+
// Recipes
|
|
24
|
+
hero: ask('Opening banner', 'What should the first thing visitors see say?', 'Your main message in your own words, a supporting line, and where the main button should take people.'),
|
|
25
|
+
featureCards: ask('Highlights', 'What are the main things you want to highlight here?', 'Describe each one in a sentence or two, and say where each should lead if people want more.'),
|
|
26
|
+
cta: ask('Call to action', 'What do you most want visitors to do next?', 'For example: book, call, visit, sign up. Say it the way you would to a customer.'),
|
|
27
|
+
faq: ask('Questions and answers', 'What do people often ask you, and how do you answer?', 'Write each question with your usual answer. As many as you like.'),
|
|
28
|
+
gallery: ask('Photo gallery', 'What should these photos show?', 'Describe the pictures you have or want: your work, your place, your people. You can upload them in the content editor.'),
|
|
29
|
+
testimonial: ask('What people say', 'What have customers said about you?', 'Paste a kind word or review, with the person’s name or initials if they’re happy to be named.'),
|
|
30
|
+
contactForm: ask('Contact form', 'What should people be able to ask you through this form?', 'Who answers, what you need to know from them, and how soon they can expect a reply.'),
|
|
31
|
+
form: note('Form', 'This shows one of your organisation’s forms. Choose or create it in the portal under Forms.'),
|
|
32
|
+
pay: note('Payment', 'This takes a payment for one of the things your sites take payment for. Set what it’s for and its price in the portal, under Payments.'),
|
|
33
|
+
book: note('Booking', 'This lets visitors book a time for one of your offers. Set the offer, who gives it and their opening hours in the portal, under Events and bookings.'),
|
|
34
|
+
membersContent: note('Members’ page', 'This shows one of your members’ pages to members who are signed in. Write it, and choose the sites it’s shown on, in the portal under Members.'),
|
|
35
|
+
accordion: ask('Expandable sections', 'What information should people be able to open up and read here?', 'Give each topic a short heading and the detail that goes under it.'),
|
|
36
|
+
tiles: ask('Quick links', 'Where do visitors most often want to go from here?', 'List the places or tasks, a few words each, for example: opening times, book now, prices.'),
|
|
37
|
+
banner: ask('Banner', 'What message deserves a bold band across the page?', 'A short statement or invitation, and where it should lead if anywhere.'),
|
|
38
|
+
stats: ask('Key numbers', 'Which numbers say something good about you?', 'Years running, people helped, places served: the number and what it means.'),
|
|
39
|
+
steps: ask('How it works', 'What are the steps someone goes through with you?', 'From first contact to finished, in your own words, in order.'),
|
|
40
|
+
pricing: ask('Prices', 'What do you charge, and what does each option include?', 'List each option with its price and what someone gets. Say if prices start “from”.'),
|
|
41
|
+
logos: ask('Logos', 'Whose logos should appear here?', 'Partners, accreditations or clients you are proud to show. You can upload the images in the content editor.'),
|
|
42
|
+
tabs: ask('Tabbed information', 'What information would people like to switch between here?', 'Name each topic and what it should say.'),
|
|
43
|
+
announcement: ask('Announcement', 'Is there a short announcement visitors should see?', 'One or two sentences: news, a change to times, an offer. Leave it blank if not.'),
|
|
44
|
+
bento: ask('Feature panels', 'What would you show off in a set of feature panels?', 'Your strongest points, products or moments, a sentence or two each.'),
|
|
45
|
+
marquee: ask('Scrolling line', 'What short words or phrases should scroll across here?', 'Things you offer, places you serve, or values, a few words each.'),
|
|
46
|
+
latestPosts: note('Latest posts', 'This shows your newest posts automatically. Write posts in the content editor.'),
|
|
47
|
+
mapEmbed: ask('Map', 'Where should the map show?', 'The address or place name, and anything about finding you or parking.'),
|
|
48
|
+
table: ask('Table', 'What information belongs in a table here?', 'Describe the rows and columns, or paste the details as you have them.'),
|
|
49
|
+
notice: ask('Notice', 'What notice should stand out on this page?', 'An important point people must not miss, in a sentence or two.'),
|
|
50
|
+
mediaCards: ask('Picture cards', 'What should each picture card show and say?', 'For each one: what the picture is, a short title and a line of text.'),
|
|
51
|
+
contactCard: ask('Contact details', 'How would you like people to reach you?', 'Phone, email, address and opening hours, as you want them shown.'),
|
|
52
|
+
locations: ask('Locations', 'Which places should be listed?', 'Each place with its address and anything visitors should know.'),
|
|
53
|
+
video: ask('Video', 'Which video should play here, and what is it about?', 'A link to the video (for example YouTube) and a line about it.'),
|
|
54
|
+
documents: ask('Documents', 'Which documents should people be able to open or download?', 'List each with a short description. You can upload the files in the content editor.'),
|
|
55
|
+
linkRow: ask('Links', 'Which links should sit together here?', 'Each link’s words and where it goes.'),
|
|
56
|
+
document: ask('Document', 'Which document should be shown here?', 'What it is and who it is for. You can upload the file in the content editor.'),
|
|
57
|
+
timetable: ask('Timetable', 'What happens when?', 'The days and times, and what is on at each. Say if it changes through the year.'),
|
|
58
|
+
contacts: ask('People to contact', 'Who should people contact, and about what?', 'Each person or role, what they help with, and how to reach them.'),
|
|
59
|
+
mediaText: ask('Picture with text', 'What should this picture and its words tell people?', 'Describe the picture and write the words that go beside it.'),
|
|
60
|
+
// Leaves and primitives
|
|
61
|
+
heading: ask('Heading', 'What should this heading say?', 'A few words that introduce what comes next.'),
|
|
62
|
+
prose: ask('Text', 'What should this text say?', 'Write it as you would explain it to a visitor. The more you give, the better the result.'),
|
|
63
|
+
image: ask('Picture', 'What should this picture show?', 'Describe it, or say which of your photos to use. You can upload it in the content editor.'),
|
|
64
|
+
button: ask('Button', 'What should this button say, and where should it take people?', 'A few words for the button and the page or address it opens.'),
|
|
65
|
+
quote: ask('Quote', 'What quote belongs here, and who said it?', 'The words and the person, if they are happy to be named.'),
|
|
66
|
+
list: ask('List', 'What should this list contain?', 'One item per line, in the order you want them.'),
|
|
67
|
+
stat: ask('Number', 'Which number should stand out here, and what does it mean?', 'The figure and a few words about it.'),
|
|
68
|
+
badge: ask('Label', 'What short label belongs here?', 'One to three words, for example: New, Open now, Since 1998.'),
|
|
69
|
+
divider: null,
|
|
70
|
+
spacer: null,
|
|
71
|
+
section: null,
|
|
72
|
+
grid: null,
|
|
73
|
+
stack: null,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const GENERAL = ask('Section', 'What should this section say?', 'Describe what it is for and the words you want in it.');
|
|
77
|
+
|
|
78
|
+
/** The setup question for a block type; `null` for spacing and layout pieces. */
|
|
79
|
+
export function recipeQuestion(type: string): RecipeQuestion | null {
|
|
80
|
+
return type in QUESTIONS ? QUESTIONS[type] : GENERAL;
|
|
81
|
+
}
|
package/examples/recipes.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const recipes: GalleryEntry[] = [
|
|
|
14
14
|
{ type: 'gallery', description: 'A responsive grid of images with optional captions.', block: { type: 'gallery', columns: 3, images: [{ src: '/placeholder.svg', alt: 'One', caption: 'One' }, { src: '/placeholder.svg', alt: 'Two', caption: 'Two' }, { src: '/placeholder.svg', alt: 'Three', caption: 'Three' }] } },
|
|
15
15
|
{ type: 'testimonial', description: 'A centred quotation with author, role and an optional avatar.', block: { type: 'testimonial', quote: 'The showcase made the whole model click in a minute.', author: 'A. Client', role: 'Parish administrator' } },
|
|
16
16
|
{ type: 'contactForm', description: 'An accessible contact form in a centred column — labelled fields, a submit and an optional note. Fields are generic, so it also serves enquiry / sign-up forms.', block: { type: 'contactForm', title: 'Send us a message', intro: 'We usually reply within a day.', note: 'Demo form — the showcase has no backend; a real client points its action at their own endpoint.' } },
|
|
17
|
+
{ type: 'membersContent', description: 'A members’ page from the Members module, written in the portal and read only by the organisation’s signed-in members. The build holds a placeholder, never the words: the visitor’s browser asks the site (`/ferst-api/members/pages/<id>`) and the platform decides. Signed out, it offers “Sign in”; someone whose membership doesn’t include it is told so. The showcase has no members service, so here it says it can’t be shown (on your own computer: that sign-in works on the published site).', block: { type: 'membersContent', page: 'mpg_000000000000000000000000', title: 'For members' } },
|
|
17
18
|
{ type: 'accordion', description: 'Generic expand/collapse rows (title + body) — native, accessible, no JavaScript. FAQ’s domain-free sibling.', block: { type: 'accordion', title: 'How it works', items: [{ heading: 'Composable', body: 'Pages are ordered blocks stored as JSON.' }, { heading: 'Consistent', body: 'Recipes lock a good layout so quality can’t drift.' }] } },
|
|
18
19
|
{ type: 'tiles', description: 'A card grid with five looks — here “elevated” (soft shadow, lifts on hover) with the optional pointer-following spotlight. Radius / stroke / elevation come from the global surface tokens.', block: { type: 'tiles', variant: 'elevated', columns: 3, spotlight: true, tiles: [{ icon: 'sparkle', eyebrow: 'Level 1', title: 'Primitives', text: 'The raw ingredients.', href: '#' }, { icon: 'book-open', eyebrow: 'Level 2', title: 'Recipes', text: 'Curated compositions.', href: '#' }, { icon: 'shield', eyebrow: 'Level 3', title: 'Templates', text: 'Whole pages.', href: '#' }] } },
|
|
19
20
|
{ type: 'tiles', description: 'The “gradient” variant — brand → a derived accent-2 (an OKLCH hue-shift of your one brand colour), light text.', block: { type: 'tiles', variant: 'gradient', columns: 3, tiles: [{ icon: 'flame', title: 'Vibrant', text: 'One brand colour, a harmonious gradient.' }, { icon: 'sparkle', title: 'Derived', text: 'Accent-2 is computed, not configured.' }, { icon: 'heart', title: 'On-brand', text: 'Always harmonises with your hue.' }] } },
|