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
|
@@ -1,150 +1,149 @@
|
|
|
1
|
-
---
|
|
2
|
-
/** Pricing — a Level-2 recipe: a row of plan cards (name, price, period,
|
|
3
|
-
* feature list, CTA). One plan may be `featured`. Composes Heading + Button +
|
|
4
|
-
* the check icon. Token-driven, so it recolours + restyles with the theme. */
|
|
5
|
-
import Heading from '../blocks/Heading.astro';
|
|
6
|
-
import Button from '../Button.astro';
|
|
7
|
-
import Icon from '../Icon.astro';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
display:
|
|
83
|
-
|
|
84
|
-
gap:
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
font-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
font-
|
|
122
|
-
font-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
.b-
|
|
127
|
-
|
|
128
|
-
font-
|
|
129
|
-
font-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
.b-
|
|
135
|
-
.b-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
.b-
|
|
147
|
-
.b-
|
|
148
|
-
.b-pricing__cta
|
|
149
|
-
|
|
150
|
-
</style>
|
|
1
|
+
---
|
|
2
|
+
/** Pricing — a Level-2 recipe: a row of plan cards (name, price, period,
|
|
3
|
+
* feature list, CTA). One plan may be `featured`. Composes Heading + Button +
|
|
4
|
+
* the check icon. Token-driven, so it recolours + restyles with the theme. */
|
|
5
|
+
import Heading from '../blocks/Heading.astro';
|
|
6
|
+
import Button from '../Button.astro';
|
|
7
|
+
import Icon from '../Icon.astro';
|
|
8
|
+
import { planGrid } from '../../lib/gridRows';
|
|
9
|
+
|
|
10
|
+
interface Plan {
|
|
11
|
+
name: string;
|
|
12
|
+
price: string;
|
|
13
|
+
period?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
features?: string[];
|
|
16
|
+
cta?: { label: string; href: string };
|
|
17
|
+
featured?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface Props {
|
|
20
|
+
title?: string;
|
|
21
|
+
intro?: string;
|
|
22
|
+
plans?: Plan[];
|
|
23
|
+
/** How the ragged last row lays out (lib/gridRows). */
|
|
24
|
+
lastRow?: 'auto' | 'fill' | 'center';
|
|
25
|
+
}
|
|
26
|
+
const { title, intro, plans = [], lastRow = 'auto' } = Astro.props;
|
|
27
|
+
// Alignment overrides (BlockLayout): the title + intro default to centred; the block's
|
|
28
|
+
// own `align`, or `headingAlign` for the title alone, overrides it from the page data.
|
|
29
|
+
const { align: blockAlign, headingAlign } = Astro.props as { align?: 'start' | 'center' | 'end'; headingAlign?: 'start' | 'center' | 'end' };
|
|
30
|
+
const headAlign = headingAlign ?? blockAlign ?? 'center';
|
|
31
|
+
// Rows planned per screen (lib/gridRows): up to four plans to a row on desktops.
|
|
32
|
+
const rows = planGrid(plans.length, { columns: 4, item: 'pricing', lastRow });
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
<section class="b-pricing">
|
|
36
|
+
{(title || intro) && (
|
|
37
|
+
<div class="b-pricing__head" data-recipe-head data-content-align={headAlign}>
|
|
38
|
+
{title && <Heading text={title} level={2} />}
|
|
39
|
+
{intro && <p class="b-pricing__intro">{intro}</p>}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
<div class="b-pricing__grid ferst-rows" data-count={plans.length} data-cols={rows.cols} style={rows.gridStyle}>
|
|
43
|
+
{plans.map((plan, i) => (
|
|
44
|
+
<div class="b-pricing__plan ferst-tile" data-featured={plan.featured ? 'true' : 'false'} style={rows.itemStyles[i]}>
|
|
45
|
+
{plan.featured && <span class="b-pricing__badge">Most popular</span>}
|
|
46
|
+
<p class="b-pricing__name">{plan.name}</p>
|
|
47
|
+
<p class="b-pricing__price">
|
|
48
|
+
<span class="b-pricing__amount">{plan.price}</span>
|
|
49
|
+
{plan.period && <span class="b-pricing__period">{plan.period}</span>}
|
|
50
|
+
</p>
|
|
51
|
+
{plan.description && <p class="b-pricing__desc">{plan.description}</p>}
|
|
52
|
+
{plan.features && plan.features.length > 0 && (
|
|
53
|
+
<ul class="b-pricing__features">
|
|
54
|
+
{plan.features.map((f) => (
|
|
55
|
+
<li><span class="b-pricing__check" aria-hidden="true"><Icon name="check" size={16} /></span>{f}</li>
|
|
56
|
+
))}
|
|
57
|
+
</ul>
|
|
58
|
+
)}
|
|
59
|
+
{plan.cta && (
|
|
60
|
+
<div class="b-pricing__cta">
|
|
61
|
+
<Button href={plan.cta.href} variant={plan.featured ? 'cta' : 'secondary'}>{plan.cta.label}</Button>
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
))}
|
|
66
|
+
</div>
|
|
67
|
+
</section>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.b-pricing {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
gap: 2rem;
|
|
74
|
+
width: 100%; /* the full content width, whatever its items hold (lib/gridRows) */
|
|
75
|
+
max-width: 72rem;
|
|
76
|
+
margin-inline: auto;
|
|
77
|
+
padding-inline: 1rem;
|
|
78
|
+
}
|
|
79
|
+
.b-pricing__head {
|
|
80
|
+
max-width: var(--max);
|
|
81
|
+
margin-inline: auto;
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
gap: 0.75rem;
|
|
85
|
+
}
|
|
86
|
+
.b-pricing__intro { margin: 0; color: var(--muted); line-height: 1.6; }
|
|
87
|
+
.b-pricing__grid {
|
|
88
|
+
display: grid;
|
|
89
|
+
gap: 1.5rem;
|
|
90
|
+
align-items: start;
|
|
91
|
+
}
|
|
92
|
+
/* Rows come from lib/gridRows (the global .ferst-rows rules): even rows where the
|
|
93
|
+
count allows by using fewer columns, else full rows and a tidied last row. */
|
|
94
|
+
.b-pricing__plan {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: 0.75rem;
|
|
98
|
+
padding: 1.75rem;
|
|
99
|
+
/* surface (bg/border/radius/shadow) comes from .ferst-tile; the featured
|
|
100
|
+
variant below overrides border-colour + shadow at higher specificity. */
|
|
101
|
+
}
|
|
102
|
+
.b-pricing__plan[data-featured='true'] {
|
|
103
|
+
border-color: var(--gold);
|
|
104
|
+
box-shadow: var(--shadow-lg);
|
|
105
|
+
position: relative;
|
|
106
|
+
}
|
|
107
|
+
.b-pricing__badge {
|
|
108
|
+
align-self: var(--content-self, flex-start);
|
|
109
|
+
font-size: 0.7rem;
|
|
110
|
+
font-weight: 700;
|
|
111
|
+
letter-spacing: 0.08em;
|
|
112
|
+
text-transform: uppercase;
|
|
113
|
+
color: var(--on-brand);
|
|
114
|
+
background: var(--gold);
|
|
115
|
+
padding: 0.2rem 0.6rem;
|
|
116
|
+
border-radius: var(--radius-pill);
|
|
117
|
+
}
|
|
118
|
+
.b-pricing__name {
|
|
119
|
+
margin: 0;
|
|
120
|
+
font-family: var(--font-heading);
|
|
121
|
+
font-weight: 600;
|
|
122
|
+
font-size: 1.1rem;
|
|
123
|
+
color: var(--fg);
|
|
124
|
+
}
|
|
125
|
+
.b-pricing__price { margin: 0; display: flex; align-items: baseline; gap: 0.35rem; }
|
|
126
|
+
.b-pricing__amount {
|
|
127
|
+
font-family: var(--font-heading);
|
|
128
|
+
font-weight: 700;
|
|
129
|
+
font-size: clamp(2rem, 1.6rem + 1.4vw, 2.6rem);
|
|
130
|
+
line-height: 1;
|
|
131
|
+
color: var(--fg);
|
|
132
|
+
}
|
|
133
|
+
.b-pricing__period { color: var(--muted); font-size: 0.9rem; }
|
|
134
|
+
.b-pricing__desc { margin: 0; color: var(--muted); line-height: 1.5; }
|
|
135
|
+
.b-pricing__features {
|
|
136
|
+
list-style: none;
|
|
137
|
+
margin: 0.5rem 0;
|
|
138
|
+
padding: 0;
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
gap: 0.5rem;
|
|
142
|
+
color: var(--muted);
|
|
143
|
+
line-height: 1.5;
|
|
144
|
+
}
|
|
145
|
+
.b-pricing__features li { display: flex; gap: 0.5rem; align-items: flex-start; }
|
|
146
|
+
.b-pricing__check { color: var(--gold); display: inline-flex; margin-top: 0.1rem; flex-shrink: 0; }
|
|
147
|
+
.b-pricing__cta { margin-top: auto; padding-top: 0.5rem; }
|
|
148
|
+
.b-pricing__cta :global(.btn) { width: 100%; }
|
|
149
|
+
</style>
|
|
@@ -1,157 +1,150 @@
|
|
|
1
|
-
---
|
|
2
|
-
/** Stats — a Level-2 recipe: a band of headline numbers over an optional
|
|
3
|
-
* heading/intro. Composes the Heading primitive; numbers use the brand accent.
|
|
4
|
-
*
|
|
5
|
-
* Self-composing: the grid never reserves more columns than there are stats, so
|
|
6
|
-
* a single item centres as a feature instead of stranding an empty half-band
|
|
7
|
-
* (the "£10 pinned to one side" bug); each stat is a token-driven tile (radius/
|
|
8
|
-
* surface/stroke/shadow knobs, like every Card), so it reads as a designed unit
|
|
9
|
-
* at any count and in either theme. Labels are width-capped so a long caption
|
|
10
|
-
* wraps to a tidy block rather than a full-width line. */
|
|
11
|
-
import Heading from '../blocks/Heading.astro';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
interface Item { value: string; label: string; description?: string }
|
|
15
|
-
interface Props {
|
|
16
|
-
title?: string;
|
|
17
|
-
intro?: string;
|
|
18
|
-
background?: 'none' | 'muted' | 'accent';
|
|
19
|
-
columns?: 2 | 3 | 4;
|
|
20
|
-
items?: Item[];
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
</
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.b-stats
|
|
56
|
-
.b-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
.b-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const io = new IntersectionObserver(
|
|
152
|
-
(entries) => entries.forEach((e) => { if (e.isIntersecting) { run(e.target as HTMLElement); io.unobserve(e.target); } }),
|
|
153
|
-
{ threshold: 0.4 }
|
|
154
|
-
);
|
|
155
|
-
values.forEach((v) => io.observe(v));
|
|
156
|
-
}
|
|
157
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
/** Stats — a Level-2 recipe: a band of headline numbers over an optional
|
|
3
|
+
* heading/intro. Composes the Heading primitive; numbers use the brand accent.
|
|
4
|
+
*
|
|
5
|
+
* Self-composing: the grid never reserves more columns than there are stats, so
|
|
6
|
+
* a single item centres as a feature instead of stranding an empty half-band
|
|
7
|
+
* (the "£10 pinned to one side" bug); each stat is a token-driven tile (radius/
|
|
8
|
+
* surface/stroke/shadow knobs, like every Card), so it reads as a designed unit
|
|
9
|
+
* at any count and in either theme. Labels are width-capped so a long caption
|
|
10
|
+
* wraps to a tidy block rather than a full-width line. */
|
|
11
|
+
import Heading from '../blocks/Heading.astro';
|
|
12
|
+
import { planGrid } from '../../lib/gridRows';
|
|
13
|
+
|
|
14
|
+
interface Item { value: string; label: string; description?: string }
|
|
15
|
+
interface Props {
|
|
16
|
+
title?: string;
|
|
17
|
+
intro?: string;
|
|
18
|
+
background?: 'none' | 'muted' | 'accent';
|
|
19
|
+
columns?: 2 | 3 | 4;
|
|
20
|
+
items?: Item[];
|
|
21
|
+
/** How the ragged last row lays out (lib/gridRows). */
|
|
22
|
+
lastRow?: 'auto' | 'fill' | 'center';
|
|
23
|
+
}
|
|
24
|
+
const { title, intro, background = 'muted', columns = 3, items = [], lastRow = 'auto' } = Astro.props;
|
|
25
|
+
// Alignment overrides (BlockLayout): the title + intro default to centred; the block's
|
|
26
|
+
// own `align`, or `headingAlign` for the title alone, overrides it from the page data.
|
|
27
|
+
const { align: blockAlign, headingAlign } = Astro.props as { align?: 'start' | 'center' | 'end'; headingAlign?: 'start' | 'center' | 'end' };
|
|
28
|
+
const headAlign = headingAlign ?? blockAlign ?? 'center';
|
|
29
|
+
// Rows planned per screen (lib/gridRows). Numbers are small items, so tablets fit three;
|
|
30
|
+
// a lone one is centred (`data-cols="1"`).
|
|
31
|
+
const plan = planGrid(items.length, { columns, item: 'stats', lastRow });
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<section class="b-stats" data-bg={background}>
|
|
35
|
+
<div class="b-stats__inner">
|
|
36
|
+
{(title || intro) && (
|
|
37
|
+
<div class="b-stats__head" data-recipe-head data-content-align={headAlign}>
|
|
38
|
+
{title && <Heading text={title} level={2} />}
|
|
39
|
+
{intro && <p class="b-stats__intro">{intro}</p>}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
<div class="b-stats__grid ferst-rows" data-cols={plan.cols} style={plan.gridStyle}>
|
|
43
|
+
{items.map((item, i) => (
|
|
44
|
+
<div class="b-stats__item ferst-tile" style={plan.itemStyles[i]}>
|
|
45
|
+
<span class="b-stats__value">{item.value}</span>
|
|
46
|
+
{item.label && <span class="b-stats__label">{item.label}</span>}
|
|
47
|
+
{item.description && <span class="b-stats__desc">{item.description}</span>}
|
|
48
|
+
</div>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</section>
|
|
53
|
+
|
|
54
|
+
<style>
|
|
55
|
+
.b-stats { padding-block: clamp(2.5rem, 6vw, 4rem); }
|
|
56
|
+
.b-stats[data-bg='muted'] { background: var(--bg-section); }
|
|
57
|
+
.b-stats[data-bg='accent'] { background: var(--gold-light); }
|
|
58
|
+
.b-stats__inner {
|
|
59
|
+
max-width: 72rem;
|
|
60
|
+
margin-inline: auto;
|
|
61
|
+
padding-inline: 1rem;
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
gap: 2rem;
|
|
65
|
+
}
|
|
66
|
+
.b-stats__head {
|
|
67
|
+
max-width: var(--max);
|
|
68
|
+
margin-inline: auto;
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
gap: 0.75rem;
|
|
72
|
+
}
|
|
73
|
+
.b-stats__intro { margin: 0; color: var(--muted); line-height: 1.6; }
|
|
74
|
+
.b-stats__grid {
|
|
75
|
+
display: grid;
|
|
76
|
+
gap: 1.25rem;
|
|
77
|
+
width: 100%;
|
|
78
|
+
margin-inline: auto;
|
|
79
|
+
}
|
|
80
|
+
/* Rows come from lib/gridRows (the global .ferst-rows rules): even rows where the
|
|
81
|
+
count allows by using fewer columns, else full rows and a tidied last row. */
|
|
82
|
+
/* A lone stat is a centred feature, not a full-width slab. */
|
|
83
|
+
.b-stats__grid[data-cols='1'] { max-width: 30rem; }
|
|
84
|
+
/* Token-driven tile: the same radius / surface / stroke / shadow knobs as every
|
|
85
|
+
Card, so it stays consistent and theme-correct. On the muted band the tile's
|
|
86
|
+
--bg-surface sits a step above --bg-section, giving depth in both themes. */
|
|
87
|
+
.b-stats__item {
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
align-items: center;
|
|
91
|
+
text-align: center;
|
|
92
|
+
gap: 0.5rem;
|
|
93
|
+
padding: clamp(1.5rem, 3vw, 2.25rem) clamp(1.25rem, 3vw, 1.75rem);
|
|
94
|
+
/* surface (bg/border/radius/shadow) comes from .ferst-tile */
|
|
95
|
+
}
|
|
96
|
+
.b-stats__value {
|
|
97
|
+
font-family: var(--font-heading);
|
|
98
|
+
font-weight: 700;
|
|
99
|
+
font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.25rem);
|
|
100
|
+
line-height: 1;
|
|
101
|
+
color: var(--gold);
|
|
102
|
+
}
|
|
103
|
+
.b-stats__label { font-weight: 600; color: var(--fg); line-height: 1.4; max-width: 30ch; }
|
|
104
|
+
.b-stats__desc { font-size: 0.875rem; color: var(--muted); line-height: 1.5; max-width: 32ch; }
|
|
105
|
+
/* One key figure: centred, not stranded at the start of a wide row. */
|
|
106
|
+
.b-stats__grid[data-cols='1'] {
|
|
107
|
+
max-width: 28rem;
|
|
108
|
+
margin-inline: auto;
|
|
109
|
+
text-align: center;
|
|
110
|
+
justify-items: center;
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
113
|
+
|
|
114
|
+
<script>
|
|
115
|
+
// Count-up: numbers tick from 0 to their value when they scroll into view.
|
|
116
|
+
// Progressive — the final value is server-rendered, so with no JS (or under
|
|
117
|
+
// reduced-motion) it just shows the number. Non-numeric values (One, Any…) are
|
|
118
|
+
// left untouched; a leading sign / trailing suffix (+, %, " day") is preserved.
|
|
119
|
+
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
120
|
+
const values = document.querySelectorAll<HTMLElement>('.b-stats__value');
|
|
121
|
+
if (!reduce && 'IntersectionObserver' in window && values.length) {
|
|
122
|
+
const parse = (t: string) => {
|
|
123
|
+
const m = t.match(/^(\D*)(\d[\d,]*(?:\.\d+)?)(.*)$/);
|
|
124
|
+
if (!m) return null;
|
|
125
|
+
const decimals = (m[2].split('.')[1] || '').length;
|
|
126
|
+
return { pre: m[1], num: parseFloat(m[2].replace(/,/g, '')), suf: m[3], decimals };
|
|
127
|
+
};
|
|
128
|
+
const fmt = (n: number, d: number) => (d > 0 ? n.toFixed(d) : Math.round(n).toLocaleString());
|
|
129
|
+
const run = (el: HTMLElement) => {
|
|
130
|
+
const final = (el.textContent || '').trim();
|
|
131
|
+
const p = parse(final);
|
|
132
|
+
if (!p) return;
|
|
133
|
+
const dur = 1100;
|
|
134
|
+
const t0 = performance.now();
|
|
135
|
+
const tick = (now: number) => {
|
|
136
|
+
const t = Math.min(1, (now - t0) / dur);
|
|
137
|
+
const eased = 1 - Math.pow(1 - t, 3);
|
|
138
|
+
el.textContent = p.pre + fmt(p.num * eased, p.decimals) + p.suf;
|
|
139
|
+
if (t < 1) requestAnimationFrame(tick);
|
|
140
|
+
else el.textContent = final;
|
|
141
|
+
};
|
|
142
|
+
requestAnimationFrame(tick);
|
|
143
|
+
};
|
|
144
|
+
const io = new IntersectionObserver(
|
|
145
|
+
(entries) => entries.forEach((e) => { if (e.isIntersecting) { run(e.target as HTMLElement); io.unobserve(e.target); } }),
|
|
146
|
+
{ threshold: 0.4 }
|
|
147
|
+
);
|
|
148
|
+
values.forEach((v) => io.observe(v));
|
|
149
|
+
}
|
|
150
|
+
</script>
|