ferst-core 0.6.2 → 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,252 +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
- image?: { src: string; alt?: string };
27
- }
28
- interface Props {
29
- title?: string;
30
- intro?: string;
31
- columns?: 2 | 3 | 4;
32
- variant?: 'outline' | 'elevated' | 'filled' | 'gradient' | 'image';
33
- spotlight?: boolean;
34
- tiles?: Tile[];
35
- }
36
- const { title, intro, columns = 3, variant = 'elevated', spotlight = false, tiles = [] } = Astro.props;
37
- // Never reserve more columns than there are tiles; `data-single` centres a lone one.
38
- const cols = Math.min(columns, Math.max(tiles.length, 1)) as 1 | 2 | 3 | 4;
39
- ---
40
-
41
- <section class="b-tiles">
42
- {(title || intro) && (
43
- <div class="b-tiles__head">
44
- {title && <Heading text={title} level={2} align="center" />}
45
- {intro && <p class="b-tiles__intro">{intro}</p>}
46
- </div>
47
- )}
48
- <div class="b-tiles__grid" data-cols={cols} data-single={tiles.length === 1 ? 'true' : undefined} data-variant={variant} data-spotlight={spotlight ? 'true' : 'false'}>
49
- {tiles.map((tile) => {
50
- const Tag = tile.href ? 'a' : 'div';
51
- const bg =
52
- variant === 'image' && tile.image
53
- ? `--tile-image: url('${tile.image.src}')`
54
- : undefined;
55
- return (
56
- <Tag class="b-tile" href={tile.href} style={bg}>
57
- {tile.icon && isIconKey(tile.icon) && (
58
- <span class="b-tile__icon"><Icon name={tile.icon} size={26} /></span>
59
- )}
60
- {tile.eyebrow && <span class="b-tile__eyebrow">{tile.eyebrow}</span>}
61
- <h3 class="b-tile__title">{tile.title}</h3>
62
- {tile.text && <p class="b-tile__text">{tile.text}</p>}
63
- {tile.href && <span class="b-tile__more" aria-hidden="true">Learn more &rarr;</span>}
64
- </Tag>
65
- );
66
- })}
67
- </div>
68
- </section>
69
-
70
- <style>
71
- .b-tiles {
72
- display: flex;
73
- flex-direction: column;
74
- gap: 2rem;
75
- max-width: 72rem;
76
- margin-inline: auto;
77
- padding-inline: 1rem;
78
- }
79
- .b-tiles__head {
80
- max-width: var(--max);
81
- margin-inline: auto;
82
- text-align: center;
83
- display: flex;
84
- flex-direction: column;
85
- gap: 0.75rem;
86
- }
87
- .b-tiles__intro {
88
- margin: 0;
89
- color: var(--muted);
90
- font-size: 1.0625rem;
91
- line-height: 1.6;
92
- }
93
- .b-tiles__grid {
94
- display: grid;
95
- grid-template-columns: 1fr;
96
- gap: 1.25rem;
97
- }
98
- /* A solitary tile is a centred feature, not a full-width slab. */
99
- .b-tiles__grid[data-single] { max-width: 26rem; margin-inline: auto; }
100
- @media (min-width: 48em) {
101
- .b-tiles__grid[data-cols='2'] { grid-template-columns: repeat(2, 1fr); }
102
- .b-tiles__grid[data-cols='3'] { grid-template-columns: repeat(3, 1fr); }
103
- .b-tiles__grid[data-cols='4'] { grid-template-columns: repeat(2, 1fr); }
104
- }
105
- @media (min-width: 64em) {
106
- .b-tiles__grid[data-cols='4'] { grid-template-columns: repeat(4, 1fr); }
107
- }
108
-
109
- /* Base tile — radius/stroke/shadow all from the global surface tokens. */
110
- .b-tile {
111
- position: relative;
112
- display: flex;
113
- flex-direction: column;
114
- gap: 0.5rem;
115
- padding: 1.5rem;
116
- border-radius: var(--radius);
117
- background: var(--bg-surface);
118
- color: var(--fg);
119
- text-decoration: none;
120
- overflow: hidden;
121
- isolation: isolate;
122
- transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
123
- }
124
-
125
- /* ── Variants ── */
126
- .b-tiles__grid[data-variant='outline'] .b-tile {
127
- border: var(--card-border);
128
- }
129
- .b-tiles__grid[data-variant='elevated'] .b-tile {
130
- box-shadow: var(--shadow-md);
131
- border: var(--card-border);
132
- }
133
- .b-tiles__grid[data-variant='filled'] .b-tile {
134
- background: var(--gold-light);
135
- }
136
- .b-tiles__grid[data-variant='gradient'] .b-tile {
137
- background: linear-gradient(135deg, var(--gold), var(--accent-2, var(--gold)));
138
- color: var(--text-light);
139
- }
140
- .b-tiles__grid[data-variant='image'] .b-tile {
141
- color: #fff;
142
- min-height: 15rem;
143
- justify-content: flex-end;
144
- background: var(--bg-section);
145
- }
146
- .b-tiles__grid[data-variant='image'] .b-tile::before {
147
- content: '';
148
- position: absolute;
149
- inset: 0;
150
- z-index: -1;
151
- background-image: linear-gradient(to top, rgba(10, 12, 20, 0.85), rgba(10, 12, 20, 0.15)), var(--tile-image);
152
- background-size: cover;
153
- background-position: center;
154
- }
155
-
156
- /* Hover: only tiles that link lift. */
157
- a.b-tile:hover {
158
- transform: translateY(-4px);
159
- }
160
- .b-tiles__grid[data-variant='elevated'] a.b-tile:hover {
161
- box-shadow: var(--shadow-lg);
162
- }
163
- .b-tiles__grid[data-variant='outline'] a.b-tile:hover {
164
- border-color: var(--gold);
165
- }
166
- a.b-tile:focus-visible {
167
- outline: 2px solid var(--gold);
168
- outline-offset: 2px;
169
- }
170
- @media (prefers-reduced-motion: reduce) {
171
- .b-tile { transition: none; }
172
- a.b-tile:hover { transform: none; }
173
- }
174
-
175
- .b-tile__icon {
176
- display: inline-flex;
177
- color: var(--gold);
178
- margin-bottom: 0.25rem;
179
- }
180
- .b-tiles__grid[data-variant='gradient'] .b-tile__icon,
181
- .b-tiles__grid[data-variant='image'] .b-tile__icon {
182
- color: currentColor;
183
- }
184
- .b-tile__eyebrow {
185
- font-size: 0.75rem;
186
- font-weight: 700;
187
- letter-spacing: 0.1em;
188
- text-transform: uppercase;
189
- color: var(--gold);
190
- }
191
- .b-tiles__grid[data-variant='gradient'] .b-tile__eyebrow,
192
- .b-tiles__grid[data-variant='image'] .b-tile__eyebrow {
193
- color: currentColor;
194
- opacity: 0.85;
195
- }
196
- .b-tile__title {
197
- margin: 0;
198
- font-size: 1.2rem;
199
- color: inherit;
200
- }
201
- .b-tile__text {
202
- margin: 0;
203
- color: var(--muted);
204
- line-height: 1.6;
205
- }
206
- .b-tiles__grid[data-variant='gradient'] .b-tile__text,
207
- .b-tiles__grid[data-variant='image'] .b-tile__text,
208
- .b-tiles__grid[data-variant='filled'] .b-tile__text {
209
- color: inherit;
210
- opacity: 0.92;
211
- }
212
- .b-tile__more {
213
- margin-top: auto;
214
- padding-top: 0.5rem;
215
- font-size: 0.85rem;
216
- font-weight: 600;
217
- color: var(--gold);
218
- }
219
- .b-tiles__grid[data-variant='gradient'] .b-tile__more,
220
- .b-tiles__grid[data-variant='image'] .b-tile__more {
221
- color: currentColor;
222
- }
223
-
224
- /* Spotlight — a soft glow that follows the pointer on hover (opt-in). The glow
225
- sits above the surface but below the content, so text stays crisp. */
226
- .b-tiles__grid[data-spotlight='true'] .b-tile > * { position: relative; z-index: 1; }
227
- .b-tiles__grid[data-spotlight='true'] .b-tile::after {
228
- content: '';
229
- position: absolute;
230
- inset: 0;
231
- z-index: 0;
232
- border-radius: inherit;
233
- background: radial-gradient(18rem 18rem at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--gold) 22%, transparent), transparent 60%);
234
- opacity: 0;
235
- transition: opacity 0.25s ease;
236
- pointer-events: none;
237
- }
238
- .b-tiles__grid[data-spotlight='true'] .b-tile:hover::after { opacity: 1; }
239
- </style>
240
-
241
- <script>
242
- // Spotlight: track the pointer over opt-in tiles and drive the glow position.
243
- if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
244
- document.querySelectorAll<HTMLElement>('.b-tiles__grid[data-spotlight="true"] .b-tile').forEach((tile) => {
245
- tile.addEventListener('pointermove', (e) => {
246
- const r = tile.getBoundingClientRect();
247
- tile.style.setProperty('--mx', `${((e.clientX - r.left) / r.width) * 100}%`);
248
- tile.style.setProperty('--my', `${((e.clientY - r.top) / r.height) * 100}%`);
249
- });
250
- });
251
- }
252
- </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>