ferst-core 0.7.0 → 0.7.2

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.
@@ -1,271 +1,285 @@
1
- ---
2
- /**
3
- * Tiles — a Level-2 recipe: a responsive grid of tiles in one of five looks,
4
- * chosen with `variant`:
5
- * outline — stroke only, no shadow (the "wireframe" look)
6
- * elevated — soft shadow, lifts on hover
7
- * filled — soft brand-tinted background
8
- * gradient — brand → derived accent-2 gradient, light text
9
- * image — full-bleed photo with a legibility scrim, light text
10
- *
11
- * Radius, stroke and elevation come from the GLOBAL surface tokens (--radius,
12
- * --card-border, --shadow-*), so tiles stay consistent with every other card and
13
- * a single knob restyles them all. A tile with `href` becomes one big link.
14
- * Composes the Icon primitive.
15
- */
16
- import Heading from '../blocks/Heading.astro';
17
- import Icon from '../Icon.astro';
18
- import { isIconKey } from '../../lib/icons';
19
-
20
- interface Tile {
21
- icon?: string;
22
- eyebrow?: string;
23
- title?: string;
24
- text?: string;
25
- href?: string;
26
- linkLabel?: string;
27
- image?: { src: string; alt?: string };
28
- }
29
- interface Props {
30
- title?: string;
31
- intro?: string;
32
- columns?: 2 | 3 | 4;
33
- variant?: 'outline' | 'elevated' | 'filled' | 'gradient' | 'image';
34
- spotlight?: boolean;
35
- tiles?: Tile[];
36
- }
37
- const { title, intro, columns = 3, variant = 'elevated', spotlight = false, tiles = [] } = Astro.props;
38
- // Never reserve more columns than there are tiles; `data-single` centres a lone one.
39
- const cols = Math.min(columns, Math.max(tiles.length, 1)) as 1 | 2 | 3 | 4;
40
- ---
41
-
42
- <section class="b-tiles">
43
- {(title || intro) && (
44
- <div class="b-tiles__head">
45
- {title && <Heading text={title} level={2} align="center" />}
46
- {intro && <p class="b-tiles__intro">{intro}</p>}
47
- </div>
48
- )}
49
- <div class="b-tiles__grid" data-cols={cols} data-single={tiles.length === 1 ? 'true' : undefined} data-variant={variant} data-spotlight={spotlight ? 'true' : 'false'}>
50
- {tiles.map((tile) => {
51
- const Tag = tile.href ? 'a' : 'div';
52
- const bg =
53
- variant === 'image' && tile.image
54
- ? `--tile-image: url('${tile.image.src}')`
55
- : undefined;
56
- // A picture tile: an image with no words — the picture itself is the tile (and
57
- // the button, when it links), named by its alt text.
58
- const plain = variant === 'image' && !!tile.image && !tile.title && !tile.text && !tile.eyebrow;
59
- return (
60
- <Tag
61
- class="b-tile"
62
- href={tile.href}
63
- style={bg}
64
- data-plain={plain ? 'true' : undefined}
65
- role={plain && !tile.href ? 'img' : undefined}
66
- aria-label={plain ? tile.image?.alt || undefined : undefined}
67
- >
68
- {tile.icon && isIconKey(tile.icon) && (
69
- <span class="b-tile__icon"><Icon name={tile.icon} size={26} /></span>
70
- )}
71
- {tile.eyebrow && <span class="b-tile__eyebrow">{tile.eyebrow}</span>}
72
- {tile.title && <h3 class="b-tile__title">{tile.title}</h3>}
73
- {tile.text && <p class="b-tile__text">{tile.text}</p>}
74
- {tile.href && !plain && <span class="b-tile__more" aria-hidden="true">{tile.linkLabel ?? 'Learn more'} &rarr;</span>}
75
- </Tag>
76
- );
77
- })}
78
- </div>
79
- </section>
80
-
81
- <style>
82
- .b-tiles {
83
- display: flex;
84
- flex-direction: column;
85
- gap: 2rem;
86
- max-width: 72rem;
87
- margin-inline: auto;
88
- padding-inline: 1rem;
89
- }
90
- .b-tiles__head {
91
- max-width: var(--max);
92
- margin-inline: auto;
93
- text-align: center;
94
- display: flex;
95
- flex-direction: column;
96
- gap: 0.75rem;
97
- }
98
- .b-tiles__intro {
99
- margin: 0;
100
- color: var(--muted);
101
- font-size: 1.0625rem;
102
- line-height: 1.6;
103
- }
104
- .b-tiles__grid {
105
- display: grid;
106
- grid-template-columns: 1fr;
107
- gap: 1.25rem;
108
- }
109
- /* A solitary tile is a centred feature, not a full-width slab. */
110
- .b-tiles__grid[data-single] { max-width: 26rem; margin-inline: auto; }
111
- @media (min-width: 48em) {
112
- .b-tiles__grid[data-cols='2'] { grid-template-columns: repeat(2, 1fr); }
113
- .b-tiles__grid[data-cols='3'] { grid-template-columns: repeat(3, 1fr); }
114
- .b-tiles__grid[data-cols='4'] { grid-template-columns: repeat(2, 1fr); }
115
- }
116
- @media (min-width: 64em) {
117
- .b-tiles__grid[data-cols='4'] { grid-template-columns: repeat(4, 1fr); }
118
- }
119
-
120
- /* Base tile — radius/stroke/shadow all from the global surface tokens. */
121
- .b-tile {
122
- position: relative;
123
- display: flex;
124
- flex-direction: column;
125
- gap: 0.5rem;
126
- padding: 1.5rem;
127
- border-radius: var(--radius);
128
- background: var(--bg-surface);
129
- color: var(--fg);
130
- text-decoration: none;
131
- overflow: hidden;
132
- isolation: isolate;
133
- transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
134
- }
135
-
136
- /* ── Variants ── */
137
- .b-tiles__grid[data-variant='outline'] .b-tile {
138
- border: var(--card-border);
139
- }
140
- .b-tiles__grid[data-variant='elevated'] .b-tile {
141
- box-shadow: var(--shadow-md);
142
- border: var(--card-border);
143
- }
144
- .b-tiles__grid[data-variant='filled'] .b-tile {
145
- background: var(--gold-light);
146
- }
147
- .b-tiles__grid[data-variant='gradient'] .b-tile {
148
- background: linear-gradient(135deg, var(--gold), var(--accent-2, var(--gold)));
149
- color: var(--text-light);
150
- }
151
- .b-tiles__grid[data-variant='image'] .b-tile {
152
- color: #fff;
153
- min-height: 15rem;
154
- justify-content: flex-end;
155
- background: var(--bg-section);
156
- }
157
- .b-tiles__grid[data-variant='image'] .b-tile::before {
158
- content: '';
159
- position: absolute;
160
- inset: 0;
161
- z-index: -1;
162
- background-image: linear-gradient(to top, rgba(10, 12, 20, 0.85), rgba(10, 12, 20, 0.15)), var(--tile-image);
163
- background-size: cover;
164
- background-position: center;
165
- }
166
- /* A picture tile shows the image as it is — no scrim, nothing over it. */
167
- .b-tiles__grid[data-variant='image'] .b-tile[data-plain]::before {
168
- background-image: var(--tile-image);
169
- }
170
- a.b-tile[data-plain]:focus-visible {
171
- outline: 3px solid var(--accent);
172
- outline-offset: 3px;
173
- }
174
-
175
- /* Hover: only tiles that link lift. */
176
- a.b-tile:hover {
177
- transform: translateY(-4px);
178
- }
179
- .b-tiles__grid[data-variant='elevated'] a.b-tile:hover {
180
- box-shadow: var(--shadow-lg);
181
- }
182
- .b-tiles__grid[data-variant='outline'] a.b-tile:hover {
183
- border-color: var(--gold);
184
- }
185
- a.b-tile:focus-visible {
186
- outline: 2px solid var(--gold);
187
- outline-offset: 2px;
188
- }
189
- @media (prefers-reduced-motion: reduce) {
190
- .b-tile { transition: none; }
191
- a.b-tile:hover { transform: none; }
192
- }
193
-
194
- .b-tile__icon {
195
- display: inline-flex;
196
- color: var(--gold);
197
- margin-bottom: 0.25rem;
198
- }
199
- .b-tiles__grid[data-variant='gradient'] .b-tile__icon,
200
- .b-tiles__grid[data-variant='image'] .b-tile__icon {
201
- color: currentColor;
202
- }
203
- .b-tile__eyebrow {
204
- font-size: 0.75rem;
205
- font-weight: 700;
206
- letter-spacing: 0.1em;
207
- text-transform: uppercase;
208
- color: var(--gold);
209
- }
210
- .b-tiles__grid[data-variant='gradient'] .b-tile__eyebrow,
211
- .b-tiles__grid[data-variant='image'] .b-tile__eyebrow {
212
- color: currentColor;
213
- opacity: 0.85;
214
- }
215
- .b-tile__title {
216
- margin: 0;
217
- font-size: 1.2rem;
218
- color: inherit;
219
- }
220
- .b-tile__text {
221
- margin: 0;
222
- color: var(--muted);
223
- line-height: 1.6;
224
- }
225
- .b-tiles__grid[data-variant='gradient'] .b-tile__text,
226
- .b-tiles__grid[data-variant='image'] .b-tile__text,
227
- .b-tiles__grid[data-variant='filled'] .b-tile__text {
228
- color: inherit;
229
- opacity: 0.92;
230
- }
231
- .b-tile__more {
232
- margin-top: auto;
233
- padding-top: 0.5rem;
234
- font-size: 0.85rem;
235
- font-weight: 600;
236
- color: var(--gold);
237
- }
238
- .b-tiles__grid[data-variant='gradient'] .b-tile__more,
239
- .b-tiles__grid[data-variant='image'] .b-tile__more {
240
- color: currentColor;
241
- }
242
-
243
- /* Spotlight — a soft glow that follows the pointer on hover (opt-in). The glow
244
- sits above the surface but below the content, so text stays crisp. */
245
- .b-tiles__grid[data-spotlight='true'] .b-tile > * { position: relative; z-index: 1; }
246
- .b-tiles__grid[data-spotlight='true'] .b-tile::after {
247
- content: '';
248
- position: absolute;
249
- inset: 0;
250
- z-index: 0;
251
- border-radius: inherit;
252
- background: radial-gradient(18rem 18rem at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--gold) 22%, transparent), transparent 60%);
253
- opacity: 0;
254
- transition: opacity 0.25s ease;
255
- pointer-events: none;
256
- }
257
- .b-tiles__grid[data-spotlight='true'] .b-tile:hover::after { opacity: 1; }
258
- </style>
259
-
260
- <script>
261
- // Spotlight: track the pointer over opt-in tiles and drive the glow position.
262
- if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
263
- document.querySelectorAll<HTMLElement>('.b-tiles__grid[data-spotlight="true"] .b-tile').forEach((tile) => {
264
- tile.addEventListener('pointermove', (e) => {
265
- const r = tile.getBoundingClientRect();
266
- tile.style.setProperty('--mx', `${((e.clientX - r.left) / r.width) * 100}%`);
267
- tile.style.setProperty('--my', `${((e.clientY - r.top) / r.height) * 100}%`);
268
- });
269
- });
270
- }
271
- </script>
1
+ ---
2
+ /**
3
+ * Tiles — a Level-2 recipe: a responsive grid of tiles in one of five looks,
4
+ * chosen with `variant`:
5
+ * outline — stroke only, no shadow (the "wireframe" look)
6
+ * elevated — soft shadow, lifts on hover
7
+ * filled — soft brand-tinted background
8
+ * gradient — brand → derived accent-2 gradient, light text
9
+ * image — full-bleed photo with a legibility scrim, light text
10
+ *
11
+ * Radius, stroke and elevation come from the GLOBAL surface tokens (--radius,
12
+ * --card-border, --shadow-*), so tiles stay consistent with every other card and
13
+ * a single knob restyles them all. A tile with `href` becomes one big link.
14
+ * Composes the Icon primitive.
15
+ */
16
+ import Heading from '../blocks/Heading.astro';
17
+ import Icon from '../Icon.astro';
18
+ import { isIconKey } from '../../lib/icons';
19
+
20
+ interface Tile {
21
+ icon?: string;
22
+ eyebrow?: string;
23
+ title?: string;
24
+ text?: string;
25
+ href?: string;
26
+ linkLabel?: string;
27
+ image?: { src: string; alt?: string };
28
+ }
29
+ interface Props {
30
+ title?: string;
31
+ intro?: string;
32
+ columns?: 2 | 3 | 4;
33
+ variant?: 'outline' | 'elevated' | 'filled' | 'gradient' | 'image';
34
+ spotlight?: boolean;
35
+ tiles?: Tile[];
36
+ }
37
+ const { title, intro, columns = 3, variant = 'elevated', spotlight = false, tiles = [] } = Astro.props;
38
+ // Never reserve more columns than there are tiles; `data-single` centres a lone one.
39
+ const cols = Math.min(columns, Math.max(tiles.length, 1)) as 1 | 2 | 3 | 4;
40
+ ---
41
+
42
+ <section class="b-tiles">
43
+ {(title || intro) && (
44
+ <div class="b-tiles__head">
45
+ {title && <Heading text={title} level={2} align="center" />}
46
+ {intro && <p class="b-tiles__intro">{intro}</p>}
47
+ </div>
48
+ )}
49
+ <div class="b-tiles__grid" data-cols={cols} data-single={tiles.length === 1 ? 'true' : undefined} data-variant={variant} data-spotlight={spotlight ? 'true' : 'false'}>
50
+ {tiles.map((tile) => {
51
+ const Tag = tile.href ? 'a' : 'div';
52
+ // A picture tile: an image with no words, shown WHOLE as a real <img> (posters,
53
+ // wide logos, badges must never be cropped), its alt naming the tile / link.
54
+ const plain = variant === 'image' && !!tile.image && !tile.title && !tile.text && !tile.eyebrow;
55
+ const bg =
56
+ variant === 'image' && tile.image && !plain
57
+ ? `--tile-image: url('${tile.image.src}')`
58
+ : undefined;
59
+ return (
60
+ <Tag
61
+ class="b-tile"
62
+ href={tile.href}
63
+ style={bg}
64
+ data-plain={plain ? 'true' : undefined}
65
+ >
66
+ {plain && <img class="b-tile__picture" src={tile.image!.src} alt={tile.image!.alt ?? ''} loading="lazy" decoding="async" />}
67
+ {tile.icon && isIconKey(tile.icon) && (
68
+ <span class="b-tile__icon"><Icon name={tile.icon} size={26} /></span>
69
+ )}
70
+ {tile.eyebrow && <span class="b-tile__eyebrow">{tile.eyebrow}</span>}
71
+ {tile.title && <h3 class="b-tile__title">{tile.title}</h3>}
72
+ {tile.text && <p class="b-tile__text">{tile.text}</p>}
73
+ {tile.href && !plain && <span class="b-tile__more" aria-hidden="true">{tile.linkLabel ?? 'Learn more'} &rarr;</span>}
74
+ </Tag>
75
+ );
76
+ })}
77
+ </div>
78
+ </section>
79
+
80
+ <style>
81
+ .b-tiles {
82
+ display: flex;
83
+ flex-direction: column;
84
+ gap: 2rem;
85
+ max-width: 72rem;
86
+ margin-inline: auto;
87
+ padding-inline: 1rem;
88
+ }
89
+ .b-tiles__head {
90
+ max-width: var(--max);
91
+ margin-inline: auto;
92
+ text-align: center;
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: 0.75rem;
96
+ }
97
+ .b-tiles__intro {
98
+ margin: 0;
99
+ color: var(--muted);
100
+ font-size: 1.0625rem;
101
+ line-height: 1.6;
102
+ }
103
+ .b-tiles__grid {
104
+ display: grid;
105
+ grid-template-columns: 1fr;
106
+ gap: 1.25rem;
107
+ }
108
+ /* A solitary tile is a centred feature, not a full-width slab. */
109
+ .b-tiles__grid[data-single] { max-width: 26rem; margin-inline: auto; }
110
+ @media (min-width: 48em) {
111
+ .b-tiles__grid[data-cols='2'] { grid-template-columns: repeat(2, 1fr); }
112
+ .b-tiles__grid[data-cols='3'] { grid-template-columns: repeat(3, 1fr); }
113
+ .b-tiles__grid[data-cols='4'] { grid-template-columns: repeat(2, 1fr); }
114
+ }
115
+ @media (min-width: 64em) {
116
+ .b-tiles__grid[data-cols='4'] { grid-template-columns: repeat(4, 1fr); }
117
+ }
118
+
119
+ /* Base tile — radius/stroke/shadow all from the global surface tokens. */
120
+ .b-tile {
121
+ position: relative;
122
+ display: flex;
123
+ flex-direction: column;
124
+ gap: 0.5rem;
125
+ padding: 1.5rem;
126
+ border-radius: var(--radius);
127
+ background: var(--bg-surface);
128
+ color: var(--fg);
129
+ text-decoration: none;
130
+ overflow: hidden;
131
+ isolation: isolate;
132
+ transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
133
+ }
134
+
135
+ /* ── Variants ── */
136
+ .b-tiles__grid[data-variant='outline'] .b-tile {
137
+ border: var(--card-border);
138
+ }
139
+ .b-tiles__grid[data-variant='elevated'] .b-tile {
140
+ box-shadow: var(--shadow-md);
141
+ border: var(--card-border);
142
+ }
143
+ .b-tiles__grid[data-variant='filled'] .b-tile {
144
+ background: var(--gold-light);
145
+ }
146
+ .b-tiles__grid[data-variant='gradient'] .b-tile {
147
+ background: linear-gradient(135deg, var(--gold), var(--accent-2, var(--gold)));
148
+ color: var(--text-light);
149
+ }
150
+ .b-tiles__grid[data-variant='image'] .b-tile {
151
+ color: #fff;
152
+ min-height: 15rem;
153
+ justify-content: flex-end;
154
+ background: var(--bg-section);
155
+ }
156
+ .b-tiles__grid[data-variant='image'] .b-tile::before {
157
+ content: '';
158
+ position: absolute;
159
+ inset: 0;
160
+ z-index: -1;
161
+ background-image: linear-gradient(to top, rgba(10, 12, 20, 0.85), rgba(10, 12, 20, 0.15)), var(--tile-image);
162
+ background-size: cover;
163
+ background-position: center;
164
+ }
165
+ /* A picture tile shows the whole image, whatever its shape: no scrim, no crop. */
166
+ .b-tiles__grid[data-variant='image'] .b-tile[data-plain] {
167
+ min-height: 0;
168
+ justify-content: center;
169
+ align-items: center;
170
+ padding: 0.75rem;
171
+ background: var(--bg-surface);
172
+ border: var(--card-border);
173
+ }
174
+ .b-tiles__grid[data-variant='image'] .b-tile[data-plain]::before {
175
+ content: none;
176
+ }
177
+ .b-tile__picture {
178
+ display: block;
179
+ width: 100%;
180
+ height: auto;
181
+ max-height: 18rem;
182
+ object-fit: contain;
183
+ }
184
+ a.b-tile[data-plain]:focus-visible {
185
+ outline: 3px solid var(--accent);
186
+ outline-offset: 3px;
187
+ }
188
+
189
+ /* Hover: only tiles that link lift. */
190
+ a.b-tile:hover {
191
+ transform: translateY(-4px);
192
+ }
193
+ .b-tiles__grid[data-variant='elevated'] a.b-tile:hover {
194
+ box-shadow: var(--shadow-lg);
195
+ }
196
+ .b-tiles__grid[data-variant='outline'] a.b-tile:hover {
197
+ border-color: var(--gold);
198
+ }
199
+ a.b-tile:focus-visible {
200
+ outline: 2px solid var(--gold);
201
+ outline-offset: 2px;
202
+ }
203
+ @media (prefers-reduced-motion: reduce) {
204
+ .b-tile { transition: none; }
205
+ a.b-tile:hover { transform: none; }
206
+ }
207
+
208
+ .b-tile__icon {
209
+ display: inline-flex;
210
+ color: var(--gold);
211
+ margin-bottom: 0.25rem;
212
+ }
213
+ .b-tiles__grid[data-variant='gradient'] .b-tile__icon,
214
+ .b-tiles__grid[data-variant='image'] .b-tile__icon {
215
+ color: currentColor;
216
+ }
217
+ .b-tile__eyebrow {
218
+ font-size: 0.75rem;
219
+ font-weight: 700;
220
+ letter-spacing: 0.1em;
221
+ text-transform: uppercase;
222
+ color: var(--gold);
223
+ }
224
+ .b-tiles__grid[data-variant='gradient'] .b-tile__eyebrow,
225
+ .b-tiles__grid[data-variant='image'] .b-tile__eyebrow {
226
+ color: currentColor;
227
+ opacity: 0.85;
228
+ }
229
+ .b-tile__title {
230
+ margin: 0;
231
+ font-size: 1.2rem;
232
+ color: inherit;
233
+ }
234
+ .b-tile__text {
235
+ margin: 0;
236
+ color: var(--muted);
237
+ line-height: 1.6;
238
+ }
239
+ .b-tiles__grid[data-variant='gradient'] .b-tile__text,
240
+ .b-tiles__grid[data-variant='image'] .b-tile__text,
241
+ .b-tiles__grid[data-variant='filled'] .b-tile__text {
242
+ color: inherit;
243
+ opacity: 0.92;
244
+ }
245
+ .b-tile__more {
246
+ margin-top: auto;
247
+ padding-top: 0.5rem;
248
+ font-size: 0.85rem;
249
+ font-weight: 600;
250
+ color: var(--gold);
251
+ }
252
+ .b-tiles__grid[data-variant='gradient'] .b-tile__more,
253
+ .b-tiles__grid[data-variant='image'] .b-tile__more {
254
+ color: currentColor;
255
+ }
256
+
257
+ /* Spotlight — a soft glow that follows the pointer on hover (opt-in). The glow
258
+ sits above the surface but below the content, so text stays crisp. */
259
+ .b-tiles__grid[data-spotlight='true'] .b-tile > * { position: relative; z-index: 1; }
260
+ .b-tiles__grid[data-spotlight='true'] .b-tile::after {
261
+ content: '';
262
+ position: absolute;
263
+ inset: 0;
264
+ z-index: 0;
265
+ border-radius: inherit;
266
+ background: radial-gradient(18rem 18rem at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--gold) 22%, transparent), transparent 60%);
267
+ opacity: 0;
268
+ transition: opacity 0.25s ease;
269
+ pointer-events: none;
270
+ }
271
+ .b-tiles__grid[data-spotlight='true'] .b-tile:hover::after { opacity: 1; }
272
+ </style>
273
+
274
+ <script>
275
+ // Spotlight: track the pointer over opt-in tiles and drive the glow position.
276
+ if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
277
+ document.querySelectorAll<HTMLElement>('.b-tiles__grid[data-spotlight="true"] .b-tile').forEach((tile) => {
278
+ tile.addEventListener('pointermove', (e) => {
279
+ const r = tile.getBoundingClientRect();
280
+ tile.style.setProperty('--mx', `${((e.clientX - r.left) / r.width) * 100}%`);
281
+ tile.style.setProperty('--my', `${((e.clientY - r.top) / r.height) * 100}%`);
282
+ });
283
+ });
284
+ }
285
+ </script>
package/content/blocks.ts CHANGED
@@ -115,7 +115,9 @@ export const heroBlock = z.object({
115
115
  cta: z.object({ label: z.string(), href: z.string() }).optional(),
116
116
  image: z.object({ src: z.string(), alt: z.string().default('') }).optional(),
117
117
  /** Background media for the `media` layout, in order of precedence: a looping
118
- * muted `video`, a slow crossfade through `images` (2+), or one `image`.
118
+ * muted `video` (a hosted file, or a YouTube / Vimeo link — embedded only after
119
+ * cookie consent, showing `poster` until then), a slow crossfade through `images`
120
+ * (2+), or one `image`.
119
121
  * `overlay` (0–100) is the darkening scrim so text stays legible; `poster` is
120
122
  * the video's still (and what reduced-motion visitors see). Moving backgrounds
121
123
  * get a pause button and stay still under prefers-reduced-motion. */