ferst-core 0.15.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/README.md +13 -4
- package/bin/ferst-media.mjs +96 -0
- package/bin/ferst-modules.mjs +17 -2
- package/components/BlockRenderer.astro +131 -129
- package/components/Card.astro +53 -51
- package/components/MembersAccount.astro +370 -0
- package/components/PostCard.astro +138 -136
- package/components/SiteHeader.astro +32 -14
- package/components/blocks/Grid.astro +49 -48
- package/components/blocks/Heading.astro +4 -1
- package/components/islands/BookMonth.tsx +95 -0
- package/components/islands/MembersAccount.tsx +392 -0
- package/components/recipes/Banner.astro +146 -146
- package/components/recipes/Book.astro +1147 -926
- package/components/recipes/FeatureCards.astro +112 -118
- package/components/recipes/Gallery.astro +57 -59
- package/components/recipes/Hero.astro +112 -10
- package/components/recipes/LatestPosts.astro +295 -292
- package/components/recipes/Locations.astro +146 -143
- package/components/recipes/Marquee.astro +75 -75
- package/components/recipes/MediaCards.astro +213 -219
- package/components/recipes/MembersContent.astro +176 -0
- package/components/recipes/Pricing.astro +149 -150
- package/components/recipes/Stats.astro +150 -157
- package/components/recipes/Tiles.astro +342 -296
- package/content/blocks.ts +1091 -1024
- package/content/cookies.ts +14 -0
- package/content/imageSlots.mjs +542 -0
- package/content/recipe-questions.ts +81 -80
- package/content/schemas.ts +13 -11
- package/examples/recipes.ts +5 -0
- package/fonts/OFL.txt +1332 -287
- package/fonts/anton-latin-400-normal.woff2 +0 -0
- package/fonts/bangers-latin-400-normal.woff2 +0 -0
- package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
- package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
- package/fonts/fredoka-latin-400-normal.woff2 +0 -0
- package/fonts/fredoka-latin-600-normal.woff2 +0 -0
- package/fonts/fredoka-latin-700-normal.woff2 +0 -0
- package/fonts/knewave-latin-400-normal.woff2 +0 -0
- package/fonts/lora-latin-400-normal.woff2 +0 -0
- package/fonts/lora-latin-600-normal.woff2 +0 -0
- package/fonts/lora-latin-700-normal.woff2 +0 -0
- package/fonts/merriweather-latin-400-normal.woff2 +0 -0
- package/fonts/merriweather-latin-600-normal.woff2 +0 -0
- package/fonts/merriweather-latin-700-normal.woff2 +0 -0
- package/fonts/nunito-latin-400-normal.woff2 +0 -0
- package/fonts/nunito-latin-600-normal.woff2 +0 -0
- package/fonts/nunito-latin-700-normal.woff2 +0 -0
- package/fonts/oswald-latin-400-normal.woff2 +0 -0
- package/fonts/oswald-latin-600-normal.woff2 +0 -0
- package/fonts/oswald-latin-700-normal.woff2 +0 -0
- package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
- package/integration.mjs +319 -263
- package/layouts/Base.astro +8 -16
- package/lib/book.ts +416 -378
- package/lib/fonts.ts +130 -0
- package/lib/gridRows.ts +197 -0
- package/lib/image-fields.ts +140 -0
- package/lib/image-size.mjs +108 -73
- package/lib/image-sizes.ts +16 -0
- package/lib/logo-header.ts +46 -0
- package/lib/media-check.mjs +524 -0
- package/lib/members-account.ts +276 -0
- package/lib/members.ts +115 -0
- package/lib/theme-preview.ts +203 -140
- package/lib/themeTokens.ts +235 -220
- package/package.json +80 -71
- package/routes/account.astro +16 -0
- package/routes/cookie-policy.astro +28 -28
- package/styles/fonts.css +239 -76
- package/styles/theme.css +228 -160
- package/lib/gridColumns.ts +0 -22
|
@@ -13,6 +13,8 @@ import Button from './Button.astro';
|
|
|
13
13
|
import type { NavLink, NavGroup, LogoHeader } from '../content/schemas';
|
|
14
14
|
|
|
15
15
|
import { navWithoutCta } from '../lib/nav';
|
|
16
|
+
import { logoHeaderLayout } from '../lib/logo-header';
|
|
17
|
+
import { imageSizeOf } from '../lib/image-sizes';
|
|
16
18
|
interface Props {
|
|
17
19
|
path: string;
|
|
18
20
|
headerClass?: string;
|
|
@@ -20,22 +22,22 @@ interface Props {
|
|
|
20
22
|
primaryLogoDark?: string;
|
|
21
23
|
/** The logo's size and placement (logoSettings.header). Omitted: a standard logo in the bar. */
|
|
22
24
|
logoHeader?: Partial<LogoHeader>;
|
|
23
|
-
/** The logo image's own width and height, so its box keeps the image's shape before it loads. */
|
|
24
|
-
logoSize?: { width: number; height: number };
|
|
25
25
|
brandAlt: string;
|
|
26
26
|
primaryNav: NavLink[];
|
|
27
27
|
/** Optional dropdown / mega-menu group. Client-configured — the core ships none. */
|
|
28
28
|
dropdown?: NavGroup;
|
|
29
29
|
/** The call-to-action button (navbarSettings.cta); null hides it. */
|
|
30
30
|
cta?: { label: string; href: string } | null;
|
|
31
|
+
/** The members' account link (the site has the Ferst Members module): "Account" in the build,
|
|
32
|
+
* then "Sign in" or the member's first name, from a small script (lib/members). */
|
|
33
|
+
account?: boolean;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
const { path, headerClass, primaryLogoLight, primaryLogoDark, logoHeader = {},
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const logoRatio = logoSize && logoSize.width > 0 && logoSize.height > 0 ? +(logoSize.width / logoSize.height).toFixed(4) : undefined;
|
|
36
|
+
const { path, headerClass, primaryLogoLight, primaryLogoDark, logoHeader = {}, brandAlt, primaryNav, dropdown, cta = { label: 'Contact', href: '/contact/' }, account = false } = Astro.props;
|
|
37
|
+
// The logo's own size (read from the site's files at build), so its box keeps the image's
|
|
38
|
+
// shape before it loads; and the header's attributes for the logo's size and placement.
|
|
39
|
+
const logoSize = imageSizeOf(primaryLogoLight);
|
|
40
|
+
const logoLayout = logoHeaderLayout({ header: logoHeader, hasLogo: !!primaryLogoLight, size: logoSize });
|
|
39
41
|
// A menu link to the same place as the button would show it twice: the button wins.
|
|
40
42
|
const navLinks = navWithoutCta(primaryNav, cta);
|
|
41
43
|
const ctaActive = !!cta && cta.href.startsWith('/') && path.startsWith(cta.href.replace(/\/$/, '') || '/#');
|
|
@@ -71,11 +73,8 @@ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
|
|
|
71
73
|
-->
|
|
72
74
|
<header
|
|
73
75
|
class:list={['site-header', headerClass]}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
data-logo-hang={overhang && logoHeader.shrinkOnScroll === false ? '' : undefined}
|
|
77
|
-
data-logo-shadow={primaryLogoLight && logoHeader.shadow ? '' : undefined}
|
|
78
|
-
style={logoRatio ? `--logo-ratio: ${logoRatio}` : undefined}
|
|
76
|
+
{...logoLayout.attributes}
|
|
77
|
+
style={logoLayout.ratio ? `--logo-ratio: ${logoLayout.ratio}` : undefined}
|
|
79
78
|
transition:persist transition:name="site-header" transition:animate="none">
|
|
80
79
|
<a href="/" class="brand">
|
|
81
80
|
{primaryLogoLight ? (
|
|
@@ -152,6 +151,9 @@ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
|
|
|
152
151
|
</a>
|
|
153
152
|
);
|
|
154
153
|
})}
|
|
154
|
+
{account && (
|
|
155
|
+
<a href="/account" class:list={['nav-link', 'nav-account', { active: path.startsWith('/account') }]} data-members-account>Account</a>
|
|
156
|
+
)}
|
|
155
157
|
<div class="nav-mobile-theme">
|
|
156
158
|
{cta && (
|
|
157
159
|
<Button
|
|
@@ -375,7 +377,7 @@ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
|
|
|
375
377
|
}
|
|
376
378
|
/* A soft shadow, so a dark round badge stands apart from a dark header. */
|
|
377
379
|
.site-header[data-logo-shadow] .primary-logo {
|
|
378
|
-
filter: drop-shadow(
|
|
380
|
+
filter: drop-shadow(var(--shadow-logo));
|
|
379
381
|
}
|
|
380
382
|
@media (prefers-reduced-motion: reduce) {
|
|
381
383
|
.site-header[data-logo-placement='overhang'] .brand,
|
|
@@ -1036,6 +1038,22 @@ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
|
|
|
1036
1038
|
}
|
|
1037
1039
|
</style>
|
|
1038
1040
|
|
|
1041
|
+
<script>
|
|
1042
|
+
// The members' account link, on a site with Members: "Sign in", or the member's first name
|
|
1043
|
+
// (lib/members). Without the link it does nothing.
|
|
1044
|
+
import { MEMBERS_ME, accountLinkText, readMembersAnswer } from '../lib/members';
|
|
1045
|
+
const accountLink = document.querySelector<HTMLAnchorElement>('[data-members-account]');
|
|
1046
|
+
if (accountLink) {
|
|
1047
|
+
fetch(MEMBERS_ME, { credentials: 'same-origin', headers: { Accept: 'application/json' } })
|
|
1048
|
+
.then(readMembersAnswer)
|
|
1049
|
+
.then((answer) => {
|
|
1050
|
+
const text = accountLinkText(answer);
|
|
1051
|
+
if (text && accountLink.textContent !== text) accountLink.textContent = text;
|
|
1052
|
+
})
|
|
1053
|
+
.catch(() => { /* the build's "Account" stands */ });
|
|
1054
|
+
}
|
|
1055
|
+
</script>
|
|
1056
|
+
|
|
1039
1057
|
<script>
|
|
1040
1058
|
// ── Hamburger (mobile) ──
|
|
1041
1059
|
const toggle = document.querySelector('.nav-toggle') as HTMLButtonElement;
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
---
|
|
2
|
-
/** A layout container: places child blocks in a responsive N
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
---
|
|
2
|
+
/** A layout container: places child blocks in a responsive grid of up to N columns, its
|
|
3
|
+
* rows planned per screen width like every other grid (lib/gridRows): one to a row on
|
|
4
|
+
* phones, two on tablets, N on desktops, a shorter row filled or centred. Each child sits
|
|
5
|
+
* in a cell that carries its placement; the cell is a one-track grid itself, so the child
|
|
6
|
+
* fills it exactly as it filled the grid's track before. */
|
|
7
|
+
import BlockRenderer from '../BlockRenderer.astro';
|
|
8
|
+
import { planGrid } from '../../lib/gridRows';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
columns?: 2 | 3 | 4;
|
|
12
|
+
gap?: 'sm' | 'md' | 'lg';
|
|
13
|
+
blocks?: any[];
|
|
14
|
+
/** How the ragged last row lays out (lib/gridRows). */
|
|
15
|
+
lastRow?: 'auto' | 'fill' | 'center';
|
|
16
|
+
}
|
|
17
|
+
const { columns = 2, gap = 'md', blocks = [], lastRow = 'auto' } = Astro.props;
|
|
18
|
+
// Only the blocks that render take a cell.
|
|
19
|
+
const shown = blocks.filter((b) => b && b.enabled !== false);
|
|
20
|
+
const rows = planGrid(shown.length, { columns, item: 'grid', lastRow });
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<div class="b-grid ferst-rows" data-cols={rows.cols} data-gap={gap} style={rows.gridStyle}>
|
|
24
|
+
{shown.map((block, i) => (
|
|
25
|
+
<div class="b-grid__cell" style={rows.itemStyles[i]}>
|
|
26
|
+
<BlockRenderer blocks={[block]} />
|
|
27
|
+
</div>
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.b-grid {
|
|
33
|
+
display: grid;
|
|
34
|
+
}
|
|
35
|
+
.b-grid[data-gap='sm'] {
|
|
36
|
+
gap: 0.75rem;
|
|
37
|
+
}
|
|
38
|
+
.b-grid[data-gap='md'] {
|
|
39
|
+
gap: 1.5rem;
|
|
40
|
+
}
|
|
41
|
+
.b-grid[data-gap='lg'] {
|
|
42
|
+
gap: 3rem;
|
|
43
|
+
}
|
|
44
|
+
/* Rows come from lib/gridRows (the global .ferst-rows rules). */
|
|
45
|
+
.b-grid__cell {
|
|
46
|
+
display: grid;
|
|
47
|
+
min-width: 0;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -10,9 +10,12 @@ const { text, level = 2, align, gradient = false } = Astro.props;
|
|
|
10
10
|
const Tag = `h${level}` as unknown as keyof HTMLElementTagNameMap;
|
|
11
11
|
// A readable, page-unique anchor so any heading can be linked to (#mass-times).
|
|
12
12
|
const id = uniqueSlug(text, pageSlugs(Astro.locals));
|
|
13
|
+
// A recipe can draw the heading as something else (a hero's wordmark picture, described by
|
|
14
|
+
// `text`); the heading, its anchor and its level stay the same.
|
|
15
|
+
const drawn = Astro.slots.has('default') ? (await Astro.slots.render('default')).trim() : '';
|
|
13
16
|
---
|
|
14
17
|
|
|
15
|
-
<Tag class="b-heading" id={id} data-align={align} data-gradient={gradient ? 'true' : 'false'}>{text}</Tag>
|
|
18
|
+
<Tag class="b-heading" id={id} data-align={align} data-gradient={gradient ? 'true' : 'false'}>{drawn ? <Fragment set:html={drawn} /> : text}</Tag>
|
|
16
19
|
|
|
17
20
|
<style>
|
|
18
21
|
/* By default a heading INHERITS the page/section content alignment (the
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Book block's month (look: calendar; myai4-webdev #239): a React island (docs/BLOCK-ARCHITECTURE.md §8).
|
|
3
|
+
* A month grid from React Aria Components, the days with free times marked and named so to screen
|
|
4
|
+
* readers, earlier and later months by arrows or the keyboard. A view only: the block's own script reads
|
|
5
|
+
* the free times and runs the journey (hold, details, confirmation), as for its other looks.
|
|
6
|
+
*
|
|
7
|
+
* It talks to the block through the element the recipe places it in (`[data-book-month]`):
|
|
8
|
+
* - in: `host.bookMonth` (London dates: today, the last day bookings are taken, the month shown, its
|
|
9
|
+
* free days, the chosen day), and a `book:month-state` event whenever that changes;
|
|
10
|
+
* - out: `book:day` (a day chosen, 'YYYY-MM-DD') and `book:month` (another month shown, 'YYYY-MM').
|
|
11
|
+
* Dates are calendar dates (London's, worked out by the block), so a visitor's own time zone never
|
|
12
|
+
* moves a day. Styled wholly by the block's CSS from the site's tokens; nothing of its own.
|
|
13
|
+
*/
|
|
14
|
+
import { useContext, useEffect, useRef, useState } from 'react';
|
|
15
|
+
import { Button, Calendar, CalendarGrid, CalendarGridBody, CalendarGridHeader, CalendarHeaderCell, CalendarStateContext, Heading, I18nProvider } from 'react-aria-components';
|
|
16
|
+
import { useCalendarCell } from 'react-aria';
|
|
17
|
+
import { isSameMonth, parseDate, type CalendarDate } from '@internationalized/date';
|
|
18
|
+
|
|
19
|
+
export interface MonthState { today: string; max: string; month: string; free: string[]; value: string | null }
|
|
20
|
+
type Host = HTMLElement & { bookMonth?: MonthState };
|
|
21
|
+
|
|
22
|
+
/** One day: a button in the grid; a day with free times says so, one with none can't be chosen. */
|
|
23
|
+
function Day({ date, free, today }: { date: CalendarDate; free: Set<string>; today: string }) {
|
|
24
|
+
const state = useContext(CalendarStateContext)!;
|
|
25
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
26
|
+
const outside = !isSameMonth(date, state.visibleRange.start);
|
|
27
|
+
const { cellProps, buttonProps, isSelected, isFocused, formattedDate } = useCalendarCell({ date, isOutsideMonth: outside }, state, ref);
|
|
28
|
+
if (outside) return <td {...cellProps} />;
|
|
29
|
+
const day = date.toString();
|
|
30
|
+
const isFree = free.has(day);
|
|
31
|
+
const label = `${buttonProps['aria-label'] ?? day}${isFree ? ', times free' : ''}`;
|
|
32
|
+
const cls = ['b-book__cell', isFree && 'is-free', isSelected && 'is-selected', day === today && 'is-today', isFocused && 'is-focused'].filter(Boolean).join(' ');
|
|
33
|
+
return (
|
|
34
|
+
<td {...cellProps}>
|
|
35
|
+
<div {...buttonProps} aria-label={label} ref={ref} className={cls}>{formattedDate}</div>
|
|
36
|
+
</td>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function BookMonth() {
|
|
41
|
+
const root = useRef<HTMLDivElement>(null);
|
|
42
|
+
const [s, setS] = useState<MonthState | null>(null);
|
|
43
|
+
const [focus, setFocus] = useState<CalendarDate | null>(null);
|
|
44
|
+
const host = () => root.current?.closest<Host>('[data-book-month]') ?? null;
|
|
45
|
+
const tell = (name: string, detail: string) => host()?.dispatchEvent(new CustomEvent(name, { detail, bubbles: true }));
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const h = host();
|
|
49
|
+
if (!h) return;
|
|
50
|
+
const read = () => setS(h.bookMonth ? { ...h.bookMonth } : null);
|
|
51
|
+
read();
|
|
52
|
+
h.addEventListener('book:month-state', read);
|
|
53
|
+
return () => h.removeEventListener('book:month-state', read);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
// The block moved the month (a first month with nothing free looks on to the next): follow it.
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (s && (!focus || focus.toString().slice(0, 7) !== s.month)) setFocus(parseDate(s.value && s.value.startsWith(s.month) ? s.value : `${s.month}-01`));
|
|
59
|
+
}, [s?.month, s?.value]);
|
|
60
|
+
|
|
61
|
+
if (!s || !focus) return <div ref={root} className="b-book__month-wait" />;
|
|
62
|
+
const free = new Set(s.free);
|
|
63
|
+
return (
|
|
64
|
+
<div ref={root}>
|
|
65
|
+
<I18nProvider locale="en-GB">
|
|
66
|
+
<Calendar
|
|
67
|
+
className="b-book__calendar"
|
|
68
|
+
aria-label="Choose a day"
|
|
69
|
+
firstDayOfWeek="mon"
|
|
70
|
+
minValue={parseDate(s.today)}
|
|
71
|
+
maxValue={parseDate(s.max)}
|
|
72
|
+
value={s.value ? parseDate(s.value) : null}
|
|
73
|
+
onChange={(d) => tell('book:day', d.toString())}
|
|
74
|
+
focusedValue={focus}
|
|
75
|
+
onFocusChange={(d) => {
|
|
76
|
+
setFocus(d);
|
|
77
|
+
const m = d.toString().slice(0, 7);
|
|
78
|
+
if (m !== s.month) tell('book:month', m);
|
|
79
|
+
}}
|
|
80
|
+
isDateUnavailable={(d) => !free.has(d.toString())}
|
|
81
|
+
>
|
|
82
|
+
<header className="b-book__month-head">
|
|
83
|
+
<Button slot="previous" className="b-book__month-nav" aria-label="Earlier month"><span aria-hidden="true">‹</span></Button>
|
|
84
|
+
<Heading className="b-book__month-title" />
|
|
85
|
+
<Button slot="next" className="b-book__month-nav" aria-label="Later month"><span aria-hidden="true">›</span></Button>
|
|
86
|
+
</header>
|
|
87
|
+
<CalendarGrid className="b-book__grid" weekdayStyle="short">
|
|
88
|
+
<CalendarGridHeader>{(day) => <CalendarHeaderCell className="b-book__weekday">{day}</CalendarHeaderCell>}</CalendarGridHeader>
|
|
89
|
+
<CalendarGridBody>{(date) => <Day date={date} free={free} today={s.today} />}</CalendarGridBody>
|
|
90
|
+
</CalendarGrid>
|
|
91
|
+
</Calendar>
|
|
92
|
+
</I18nProvider>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|