ferst-core 0.15.0 → 0.16.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/README.md +13 -4
- package/bin/ferst-media.mjs +96 -0
- package/components/Card.astro +53 -51
- package/components/PostCard.astro +138 -136
- package/components/SiteHeader.astro +10 -14
- package/components/blocks/Grid.astro +49 -48
- package/components/blocks/Heading.astro +4 -1
- package/components/recipes/Banner.astro +146 -146
- 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/Pricing.astro +149 -150
- package/components/recipes/Stats.astro +150 -157
- package/components/recipes/Tiles.astro +342 -296
- package/content/blocks.ts +1072 -1024
- package/content/imageSlots.mjs +542 -0
- package/content/schemas.ts +13 -11
- package/examples/recipes.ts +4 -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 +4 -14
- package/layouts/Base.astro +7 -16
- 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/theme-preview.ts +203 -140
- package/lib/themeTokens.ts +235 -220
- package/package.json +3 -2
- package/styles/fonts.css +239 -76
- package/styles/theme.css +228 -160
- package/lib/gridColumns.ts +0 -22
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
---
|
|
2
|
-
/** Gallery — a Level-2 recipe: a responsive grid of images with optional
|
|
3
|
-
* captions. (Distinct from the `grid` layout primitive, which holds arbitrary
|
|
4
|
-
* child blocks; this one is image-specific.) */
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
</style>
|
|
1
|
+
---
|
|
2
|
+
/** Gallery — a Level-2 recipe: a responsive grid of images with optional
|
|
3
|
+
* captions. (Distinct from the `grid` layout primitive, which holds arbitrary
|
|
4
|
+
* child blocks; this one is image-specific.) */
|
|
5
|
+
import { planGrid } from '../../lib/gridRows';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
columns?: 2 | 3 | 4;
|
|
9
|
+
images?: { src: string; alt?: string; caption?: string }[];
|
|
10
|
+
/** How the ragged last row lays out (lib/gridRows). */
|
|
11
|
+
lastRow?: 'auto' | 'fill' | 'center';
|
|
12
|
+
}
|
|
13
|
+
const { columns = 3, images = [], lastRow = 'auto' } = Astro.props;
|
|
14
|
+
// Rows planned per screen (lib/gridRows); `data-single` centres a lone image.
|
|
15
|
+
const rows = planGrid(images.length, { columns, item: 'gallery', lastRow });
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div class="b-gallery ferst-rows" data-cols={rows.cols} data-single={images.length === 1 ? 'true' : undefined} style={rows.gridStyle}>
|
|
19
|
+
{images.map((img, i) => (
|
|
20
|
+
<figure class="b-gallery__item" style={rows.itemStyles[i]}>
|
|
21
|
+
<img src={img.src} alt={img.alt ?? ''} loading="lazy" decoding="async" />
|
|
22
|
+
{img.caption && <figcaption>{img.caption}</figcaption>}
|
|
23
|
+
</figure>
|
|
24
|
+
))}
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.b-gallery {
|
|
29
|
+
display: grid;
|
|
30
|
+
gap: 1rem;
|
|
31
|
+
width: 100%; /* the full content width, whatever its items hold (lib/gridRows) */
|
|
32
|
+
max-width: 72rem;
|
|
33
|
+
margin-inline: auto;
|
|
34
|
+
padding-inline: 1rem;
|
|
35
|
+
}
|
|
36
|
+
/* A solitary image is a centred feature, not a full-bleed slab. */
|
|
37
|
+
.b-gallery[data-single] { max-width: 34rem; }
|
|
38
|
+
/* Rows come from lib/gridRows (the global .ferst-rows rules): even rows where the
|
|
39
|
+
count allows by using fewer columns, else full rows and a tidied last row. */
|
|
40
|
+
.b-gallery__item {
|
|
41
|
+
margin: 0;
|
|
42
|
+
}
|
|
43
|
+
.b-gallery__item img {
|
|
44
|
+
display: block;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: auto;
|
|
47
|
+
aspect-ratio: 4 / 3;
|
|
48
|
+
object-fit: cover;
|
|
49
|
+
border-radius: 6px;
|
|
50
|
+
}
|
|
51
|
+
.b-gallery__item figcaption {
|
|
52
|
+
margin-top: 0.4rem;
|
|
53
|
+
color: var(--muted);
|
|
54
|
+
font-size: 0.875rem;
|
|
55
|
+
text-align: center;
|
|
56
|
+
}
|
|
57
|
+
</style>
|
|
@@ -14,14 +14,17 @@
|
|
|
14
14
|
import Heading from '../blocks/Heading.astro';
|
|
15
15
|
import Button from '../Button.astro';
|
|
16
16
|
import { backgroundEmbed, videoEmbed } from '../../lib/video';
|
|
17
|
+
import { imageSizeOf } from '../../lib/image-sizes';
|
|
17
18
|
|
|
18
19
|
interface Props {
|
|
19
20
|
eyebrow?: string;
|
|
20
21
|
title: string;
|
|
22
|
+
titleImage?: { src: string; width?: 'small' | 'medium' | 'large'; shadow?: boolean };
|
|
23
|
+
titleHidden?: boolean;
|
|
21
24
|
subtitle?: string;
|
|
22
25
|
cta?: { label: string; href: string };
|
|
23
26
|
image?: { src: string; alt?: string };
|
|
24
|
-
media?: { image?: string; images?: string[]; video?: string; poster?: string; overlay?: number; link?: string; linkLabel?: string };
|
|
27
|
+
media?: { image?: string; images?: string[]; video?: string; poster?: string; overlay?: number; link?: string; linkLabel?: string; fit?: 'cover' | 'contain' };
|
|
25
28
|
layout?: 'centered' | 'split' | 'media';
|
|
26
29
|
size?: 'compact' | 'standard' | 'tall' | 'screen';
|
|
27
30
|
parallax?: boolean;
|
|
@@ -29,7 +32,7 @@ interface Props {
|
|
|
29
32
|
fullBleed?: boolean;
|
|
30
33
|
focus?: string;
|
|
31
34
|
}
|
|
32
|
-
const { eyebrow, title, subtitle, cta, image, media, layout = 'centered', size = 'standard', parallax = false, background = 'none', fullBleed = false, focus } = Astro.props;
|
|
35
|
+
const { eyebrow, title, titleImage, titleHidden = false, subtitle, cta, image, media, layout = 'centered', size = 'standard', parallax = false, background = 'none', fullBleed = false, focus } = Astro.props;
|
|
33
36
|
// A YouTube / Vimeo link plays as an embedded background (after consent); anything else
|
|
34
37
|
// in `video` is a file for a native <video>.
|
|
35
38
|
const embed = media?.video ? backgroundEmbed(media.video) : null;
|
|
@@ -50,6 +53,22 @@ const stillSrc = embed ? media?.poster ?? still : !media?.video && !slides.lengt
|
|
|
50
53
|
// found late (never by the preload scanner), so the hero sat grey until it arrived, and
|
|
51
54
|
// some browsers kept it grey. A real image, loaded first, is found early and painted.
|
|
52
55
|
const heroImg = isMedia && stillSrc ? stillSrc : undefined;
|
|
56
|
+
// The title as a picture (a wordmark): drawn inside the h1, described by the title, with its
|
|
57
|
+
// own width and height when the build read them, so its box keeps the picture's shape.
|
|
58
|
+
const titleImageSize = imageSizeOf(titleImage?.src);
|
|
59
|
+
const titleAlt = title.replace(/\s+/g, ' ').trim();
|
|
60
|
+
// A title hidden from view stays the h1 (titleHidden). A title picture is already the
|
|
61
|
+
// visible title, so it stays shown.
|
|
62
|
+
const hideTitle = titleHidden && !titleImage;
|
|
63
|
+
// A picture shown whole (media.fit "contain"), e.g. a designed poster: the band takes the
|
|
64
|
+
// picture's own shape (when the build read it), with no scrim or drift, and the words sit
|
|
65
|
+
// below it. A video always covers.
|
|
66
|
+
const contain = Boolean(isMedia && media?.fit === 'contain' && !media.video);
|
|
67
|
+
const posterSize = contain ? imageSizeOf(heroImg ?? slides[0]) : undefined;
|
|
68
|
+
const wordsBelow = Boolean(eyebrow || subtitle || cta || !hideTitle);
|
|
69
|
+
const heroStyle = isMedia
|
|
70
|
+
? `--hero-overlay: ${overlay}${focus ? `; --hero-focus: ${focus}` : ''}${posterSize ? `; --hero-ratio: ${posterSize.width} / ${posterSize.height}` : ''}`
|
|
71
|
+
: undefined;
|
|
53
72
|
---
|
|
54
73
|
|
|
55
74
|
<section
|
|
@@ -59,13 +78,15 @@ const heroImg = isMedia && stillSrc ? stillSrc : undefined;
|
|
|
59
78
|
data-bg={isMesh ? 'mesh' : undefined}
|
|
60
79
|
data-motion={motion}
|
|
61
80
|
data-linked={bgLink ? 'true' : undefined}
|
|
62
|
-
data-parallax={isMedia && parallax ? 'true' : undefined}
|
|
81
|
+
data-parallax={isMedia && parallax && !contain ? 'true' : undefined}
|
|
63
82
|
data-full-bleed={isMedia && fullBleed ? 'true' : undefined}
|
|
64
|
-
|
|
83
|
+
data-fit={contain ? 'contain' : undefined}
|
|
84
|
+
data-title-hidden={hideTitle ? '' : undefined}
|
|
85
|
+
style={heroStyle}
|
|
65
86
|
>
|
|
66
87
|
{isMedia && (
|
|
67
88
|
<div class="b-hero__bg" aria-hidden="true">
|
|
68
|
-
{heroImg && <img class="b-hero__img" src={heroImg} alt="" loading="eager" fetchpriority="high" decoding="async" />}
|
|
89
|
+
{heroImg && <img class="b-hero__img" src={heroImg} alt="" width={posterSize?.width} height={posterSize?.height} loading="eager" fetchpriority="high" decoding="async" />}
|
|
69
90
|
{embed && <div class="b-hero__embed" data-embed-url={embed.embedUrl} data-provider={embed.provider}></div>}
|
|
70
91
|
{media?.video && !embed ? (
|
|
71
92
|
<video aria-hidden="true" tabindex="-1" autoplay muted loop playsinline poster={media.poster} preload="metadata">
|
|
@@ -73,16 +94,31 @@ const heroImg = isMedia && stillSrc ? stillSrc : undefined;
|
|
|
73
94
|
</video>
|
|
74
95
|
) : null}
|
|
75
96
|
{slides.map((src, i) => (
|
|
76
|
-
<img class:list={['b-hero__slide', { 'is-on': i === 0 }]} src={src} alt="" loading={i === 0 ? 'eager' : 'lazy'} fetchpriority={i === 0 ? 'high' : undefined} decoding="async" />
|
|
97
|
+
<img class:list={['b-hero__slide', { 'is-on': i === 0 }]} src={src} alt="" width={i === 0 ? posterSize?.width : undefined} height={i === 0 ? posterSize?.height : undefined} loading={i === 0 ? 'eager' : 'lazy'} fetchpriority={i === 0 ? 'high' : undefined} decoding="async" />
|
|
77
98
|
))}
|
|
78
|
-
<span class="b-hero__scrim"></span>
|
|
99
|
+
{!contain && <span class="b-hero__scrim"></span>}
|
|
79
100
|
</div>
|
|
80
101
|
)}
|
|
81
102
|
{bgLink && <a class="b-hero__bglink" href={bgLink} target="_blank" rel="noopener" tabindex="-1" aria-hidden="true"></a>}
|
|
82
103
|
{isMesh && <div class="b-hero__mesh" aria-hidden="true"></div>}
|
|
83
|
-
<div class="b-hero__text">
|
|
104
|
+
<div class="b-hero__text" data-display-title data-words={contain && !wordsBelow ? 'none' : undefined}>
|
|
84
105
|
{eyebrow && <p class="b-hero__eyebrow">{eyebrow}</p>}
|
|
85
|
-
<Heading text={title} level={1} align={layout === 'split' ? 'start' : 'center'}
|
|
106
|
+
<Heading text={title} level={1} align={layout === 'split' ? 'start' : 'center'}>
|
|
107
|
+
{titleImage && (
|
|
108
|
+
<img
|
|
109
|
+
class="b-hero__title-image"
|
|
110
|
+
src={titleImage.src}
|
|
111
|
+
alt={titleAlt}
|
|
112
|
+
width={titleImageSize?.width}
|
|
113
|
+
height={titleImageSize?.height}
|
|
114
|
+
data-width={titleImage.width ?? 'medium'}
|
|
115
|
+
data-shadow={titleImage.shadow ? '' : undefined}
|
|
116
|
+
loading="eager"
|
|
117
|
+
fetchpriority="high"
|
|
118
|
+
decoding="async"
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
</Heading>
|
|
86
122
|
{subtitle && <p class="b-hero__subtitle">{subtitle}</p>}
|
|
87
123
|
{cta && (
|
|
88
124
|
<div class="b-hero__cta">
|
|
@@ -260,6 +296,21 @@ const heroImg = isMedia && stillSrc ? stillSrc : undefined;
|
|
|
260
296
|
.b-hero__cta {
|
|
261
297
|
margin-top: 0.5rem;
|
|
262
298
|
}
|
|
299
|
+
/* The title as a picture (a wordmark): a width step on desktop, capped to the screen on
|
|
300
|
+
phones and to its column, never cropped; height follows the picture's own shape. */
|
|
301
|
+
.b-hero__title-image {
|
|
302
|
+
display: block;
|
|
303
|
+
width: min(var(--title-image-w, 32.5rem), 85vw);
|
|
304
|
+
max-width: 100%;
|
|
305
|
+
height: auto;
|
|
306
|
+
margin-inline: auto;
|
|
307
|
+
}
|
|
308
|
+
.b-hero__title-image[data-width='small'] { --title-image-w: 20rem; }
|
|
309
|
+
.b-hero__title-image[data-width='large'] { --title-image-w: 47.5rem; }
|
|
310
|
+
.b-hero[data-layout='split'] .b-hero__title-image { margin-inline: 0; }
|
|
311
|
+
/* A large wordmark may be wider than the text measure; the subtitle keeps its own. */
|
|
312
|
+
.b-hero[data-layout] .b-hero__text:has(.b-hero__title-image) { max-width: max(var(--max), 47.5rem); }
|
|
313
|
+
.b-hero__title-image[data-shadow] { filter: drop-shadow(var(--shadow-logo)); }
|
|
263
314
|
|
|
264
315
|
/* ── Mesh background: a soft, slowly drifting brand gradient behind the text.
|
|
265
316
|
Low opacity + blur keeps normal (dark) text perfectly readable. ── */
|
|
@@ -440,6 +491,55 @@ const heroImg = isMedia && stillSrc ? stillSrc : undefined;
|
|
|
440
491
|
color: #fff;
|
|
441
492
|
}
|
|
442
493
|
|
|
494
|
+
/* ── A picture shown whole (media.fit "contain"), e.g. a designed poster: never cropped,
|
|
495
|
+
edge to edge with `screen` or `fullBleed`, and as tall as the picture, not the screen.
|
|
496
|
+
The band takes the picture's shape (--hero-ratio, when the build read it; otherwise the
|
|
497
|
+
picture's own height as it loads). No scrim; the words sit below it, in the page's
|
|
498
|
+
colours, and keep clear of a header logo hanging over a short poster (--hero-clear). ── */
|
|
499
|
+
.b-hero[data-layout='media'][data-fit='contain'] {
|
|
500
|
+
display: flex;
|
|
501
|
+
flex-direction: column;
|
|
502
|
+
gap: 0;
|
|
503
|
+
min-height: 0;
|
|
504
|
+
padding: 0;
|
|
505
|
+
}
|
|
506
|
+
.b-hero[data-fit='contain'] .b-hero__bg {
|
|
507
|
+
position: relative;
|
|
508
|
+
inset: auto;
|
|
509
|
+
z-index: auto;
|
|
510
|
+
aspect-ratio: var(--hero-ratio, auto);
|
|
511
|
+
background-color: transparent;
|
|
512
|
+
}
|
|
513
|
+
.b-hero[data-fit='contain'] .b-hero__img,
|
|
514
|
+
.b-hero[data-fit='contain'] .b-hero__slide {
|
|
515
|
+
object-fit: contain;
|
|
516
|
+
}
|
|
517
|
+
.b-hero[data-fit='contain'] .b-hero__img,
|
|
518
|
+
.b-hero[data-fit='contain'] .b-hero__slide:first-of-type {
|
|
519
|
+
position: relative;
|
|
520
|
+
height: auto;
|
|
521
|
+
}
|
|
522
|
+
.b-hero[data-layout='media'][data-fit='contain'] .b-hero__text {
|
|
523
|
+
align-self: center;
|
|
524
|
+
padding: clamp(1.5rem, 4vw, 2.5rem) 1.5rem 0;
|
|
525
|
+
margin-top: max(0px, calc(var(--hero-clear, 0px) - 100vw / (var(--hero-ratio, 0.0001))));
|
|
526
|
+
color: var(--fg);
|
|
527
|
+
}
|
|
528
|
+
.b-hero[data-fit='contain'] .b-hero__text[data-words='none'] {
|
|
529
|
+
padding: 0;
|
|
530
|
+
margin: 0;
|
|
531
|
+
}
|
|
532
|
+
.b-hero[data-layout='media'][data-fit='contain'] .b-hero__subtitle {
|
|
533
|
+
color: var(--muted);
|
|
534
|
+
}
|
|
535
|
+
.b-hero[data-layout='media'][data-fit='contain'] .b-hero__eyebrow {
|
|
536
|
+
color: var(--gold);
|
|
537
|
+
opacity: 1;
|
|
538
|
+
}
|
|
539
|
+
.b-hero[data-layout='media'][data-fit='contain'] :global(h1) {
|
|
540
|
+
color: var(--fg);
|
|
541
|
+
}
|
|
542
|
+
|
|
443
543
|
/* A linked background: the whole picture opens the full video; the text and
|
|
444
544
|
its CTA stay clickable on top, and a visible cue carries the keyboard link. */
|
|
445
545
|
.b-hero__bglink {
|
|
@@ -487,7 +587,9 @@ const heroImg = isMedia && stillSrc ? stillSrc : undefined;
|
|
|
487
587
|
border-block: 0.35rem solid transparent;
|
|
488
588
|
border-inline-start: 0.6rem solid currentColor;
|
|
489
589
|
}
|
|
490
|
-
.
|
|
590
|
+
/* Read by screen readers, not shown: the watch link's note, and a hidden title (titleHidden). */
|
|
591
|
+
.b-hero__sr,
|
|
592
|
+
.b-hero[data-title-hidden] :global(h1) {
|
|
491
593
|
position: absolute;
|
|
492
594
|
width: 1px;
|
|
493
595
|
height: 1px;
|