ferst-core 0.14.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.
Files changed (62) hide show
  1. package/README.md +13 -4
  2. package/bin/ferst-media.mjs +96 -0
  3. package/cms/config.template.yml +11 -0
  4. package/components/Card.astro +53 -51
  5. package/components/PostCard.astro +138 -136
  6. package/components/SiteHeader.astro +1356 -1273
  7. package/components/blocks/Grid.astro +49 -48
  8. package/components/blocks/Heading.astro +4 -1
  9. package/components/recipes/Banner.astro +146 -146
  10. package/components/recipes/Book.astro +39 -4
  11. package/components/recipes/FeatureCards.astro +112 -118
  12. package/components/recipes/Gallery.astro +57 -59
  13. package/components/recipes/Hero.astro +638 -533
  14. package/components/recipes/LatestPosts.astro +295 -292
  15. package/components/recipes/Locations.astro +146 -143
  16. package/components/recipes/Marquee.astro +75 -75
  17. package/components/recipes/MediaCards.astro +213 -219
  18. package/components/recipes/Pricing.astro +149 -150
  19. package/components/recipes/Stats.astro +150 -157
  20. package/components/recipes/Tiles.astro +342 -296
  21. package/content/blocks.ts +1072 -1024
  22. package/content/imageSlots.mjs +542 -0
  23. package/content/schemas.ts +35 -2
  24. package/examples/recipes.ts +4 -0
  25. package/fonts/OFL.txt +1332 -287
  26. package/fonts/anton-latin-400-normal.woff2 +0 -0
  27. package/fonts/bangers-latin-400-normal.woff2 +0 -0
  28. package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
  29. package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
  30. package/fonts/fredoka-latin-400-normal.woff2 +0 -0
  31. package/fonts/fredoka-latin-600-normal.woff2 +0 -0
  32. package/fonts/fredoka-latin-700-normal.woff2 +0 -0
  33. package/fonts/knewave-latin-400-normal.woff2 +0 -0
  34. package/fonts/lora-latin-400-normal.woff2 +0 -0
  35. package/fonts/lora-latin-600-normal.woff2 +0 -0
  36. package/fonts/lora-latin-700-normal.woff2 +0 -0
  37. package/fonts/merriweather-latin-400-normal.woff2 +0 -0
  38. package/fonts/merriweather-latin-600-normal.woff2 +0 -0
  39. package/fonts/merriweather-latin-700-normal.woff2 +0 -0
  40. package/fonts/nunito-latin-400-normal.woff2 +0 -0
  41. package/fonts/nunito-latin-600-normal.woff2 +0 -0
  42. package/fonts/nunito-latin-700-normal.woff2 +0 -0
  43. package/fonts/oswald-latin-400-normal.woff2 +0 -0
  44. package/fonts/oswald-latin-600-normal.woff2 +0 -0
  45. package/fonts/oswald-latin-700-normal.woff2 +0 -0
  46. package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
  47. package/integration.mjs +253 -249
  48. package/layouts/Base.astro +13 -3
  49. package/lib/book.ts +94 -1
  50. package/lib/fonts.ts +130 -0
  51. package/lib/gridRows.ts +197 -0
  52. package/lib/image-fields.ts +140 -0
  53. package/lib/image-size.mjs +108 -0
  54. package/lib/image-sizes.ts +16 -0
  55. package/lib/logo-header.ts +46 -0
  56. package/lib/media-check.mjs +524 -0
  57. package/lib/theme-preview.ts +203 -140
  58. package/lib/themeTokens.ts +235 -220
  59. package/package.json +3 -2
  60. package/styles/fonts.css +239 -76
  61. package/styles/theme.css +228 -160
  62. package/lib/gridColumns.ts +0 -22
@@ -1,219 +1,213 @@
1
- ---
2
- /**
3
- * MediaCards — a Level-2 recipe: a grid of rich content cards with the IMAGE as a
4
- * header on top (cover-cropped to a uniform ratio, like PostCard), then an optional
5
- * icon badge, a title, a meta line (e.g. "Sundays 10:45 · Main hall"), a description, and
6
- * an optional CTA link. The image-HEADER pattern (distinct from `tiles`, which puts
7
- * the image BEHIND the text): use it for groups, team members, services or events —
8
- * anywhere the photo and the copy both need to be fully legible. Whole card links
9
- * when `href` is set. Token-driven, equal-height.
10
- */
11
- import Icon from '../Icon.astro';
12
- import { gridColumns } from '../../lib/gridColumns';
13
- import { isIconKey } from '../../lib/icons';
14
- import Heading from '../blocks/Heading.astro';
15
-
16
- import { inlineMarkdown, inlineMarkdownNoLinks } from '../../lib/inline-markdown';
17
- interface Card {
18
- image?: { src: string; alt?: string; focus?: string };
19
- icon?: string;
20
- title: string;
21
- meta?: string;
22
- text?: string;
23
- href?: string;
24
- linkLabel?: string;
25
- }
26
- interface Props {
27
- title?: string;
28
- intro?: string;
29
- columns?: 2 | 3;
30
- ratio?: '16/9' | '4/3' | '3/2' | '1/1' | '3/4';
31
- cards?: Card[];
32
- }
33
- const { title, intro, columns = 3, ratio = '16/9', cards = [] } = Astro.props;
34
- // Never reserve more columns than there are cards; `data-single` centres a lone one.
35
- const { tablet, desktop: cols } = gridColumns(cards.length, columns); // never a short last row
36
- ---
37
-
38
- <section class="b-media-cards">
39
- {(title || intro) && (
40
- <div class="b-media-cards__head">
41
- {title && <Heading text={title} level={2} />}
42
- {intro && <p class="b-media-cards__intro" set:html={inlineMarkdown(intro)} />}
43
- </div>
44
- )}
45
- <div class="b-media-cards__grid" data-cols={cols} data-tablet={tablet} data-single={cards.length === 1 ? 'true' : undefined}>
46
- {cards.map((card) => {
47
- // Surface a mailto:/tel: as visible, copyable text — a plain mailto does
48
- // nothing on a device with no mail app, so the address must be readable too.
49
- const email = card.href?.startsWith('mailto:') ? card.href.slice(7).split('?')[0] : null;
50
- const phone = card.href?.startsWith('tel:') ? card.href.slice(4) : null;
51
- return (
52
- <article class:list={['b-media-cards__card', 'ferst-tile', 'ferst-tile--sm', card.href && 'is-link']}>
53
- {card.image && (
54
- <div class="b-media-cards__media" data-ratio={ratio} style={`aspect-ratio: ${ratio.replace('/', ' / ')}`}>
55
- <img src={card.image.src} alt={card.image.alt ?? ''} loading="lazy" style={card.image.focus ? `object-position: ${card.image.focus}` : undefined} />
56
- </div>
57
- )}
58
- <div class="b-media-cards__body">
59
- {card.icon && isIconKey(card.icon) && (
60
- <span class="b-media-cards__badge" aria-hidden="true"><Icon name={card.icon} size={20} /></span>
61
- )}
62
- <h3 class="b-media-cards__title">
63
- {card.href ? <a href={card.href}>{card.title}</a> : card.title}
64
- </h3>
65
- {card.meta && <p class="b-media-cards__meta">{card.meta}</p>}
66
- {card.text && <p class="b-media-cards__text" set:html={card.href ? inlineMarkdownNoLinks(card.text) : inlineMarkdown(card.text)} />}
67
- {(email || phone) && (
68
- <span class="b-media-cards__contact">{email ?? phone}</span>
69
- )}
70
- {card.href && !email && !phone && (
71
- <span class="b-media-cards__cta" aria-hidden="true">{card.linkLabel ?? 'Learn more'} →</span>
72
- )}
73
- </div>
74
- </article>
75
- );
76
- })}
77
- </div>
78
- </section>
79
-
80
- <style>
81
- .b-media-cards {
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-media-cards__head {
90
- display: flex;
91
- flex-direction: column;
92
- gap: 0.75rem;
93
- }
94
- .b-media-cards__intro {
95
- margin: 0;
96
- color: var(--muted);
97
- font-size: 1.0625rem;
98
- line-height: 1.6;
99
- max-width: var(--max);
100
- }
101
- .b-media-cards__grid {
102
- display: grid;
103
- grid-template-columns: 1fr;
104
- gap: 1.5rem;
105
- }
106
- /* A solitary card is a centred feature, not a full-width slab. */
107
- .b-media-cards__grid[data-single] { max-width: 28rem; margin-inline: auto; }
108
- /* Never a short last row (lib/gridColumns): twos on tablet for an even count; on desktop
109
- everything in one row, or even rows. Phones stay one column. */
110
- @media (min-width: 40em) {
111
- .b-media-cards__grid[data-tablet='2'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
112
- }
113
- @media (min-width: 60em) {
114
- .b-media-cards__grid[data-cols='2'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
115
- .b-media-cards__grid[data-cols='3'] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
116
- .b-media-cards__grid[data-cols='4'] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
117
- }
118
- .b-media-cards__card {
119
- position: relative;
120
- display: flex;
121
- flex-direction: column;
122
- /* surface comes from .ferst-tile .ferst-tile--sm (bg/border/radius/shadow-sm) */
123
- overflow: hidden;
124
- transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
125
- }
126
- .b-media-cards__card.is-link:hover {
127
- transform: translateY(-2px);
128
- box-shadow: var(--shadow-md);
129
- border-color: var(--gold);
130
- }
131
- /* Image header — cover-cropped to a uniform 16:9 so any source ratio fits (the
132
- PostCard technique; also out-specifies the global img{height:auto}). */
133
- .b-media-cards__media {
134
- position: relative;
135
- aspect-ratio: 16 / 9;
136
- overflow: hidden;
137
- background: var(--bg-section);
138
- }
139
- .b-media-cards .b-media-cards__media img {
140
- position: absolute;
141
- inset: 0;
142
- width: 100%;
143
- height: 100%;
144
- object-fit: cover;
145
- display: block;
146
- }
147
- .b-media-cards__body {
148
- display: flex;
149
- flex-direction: column;
150
- align-items: var(--content-items, stretch); /* follows the page / section alignment */
151
- gap: 0.5rem;
152
- padding: 1.1rem 1.2rem 1.3rem;
153
- flex: 1;
154
- }
155
- /* Icon badge — a small brand chip; slightly lifted over the image edge when an
156
- image is present (the negative margin only bites inside a card with a header). */
157
- .b-media-cards__badge {
158
- display: inline-flex;
159
- align-items: center;
160
- justify-content: center;
161
- width: 2.25rem;
162
- height: 2.25rem;
163
- border-radius: 999px;
164
- background: var(--gold-light);
165
- color: var(--gold);
166
- margin-top: -2.3rem;
167
- margin-bottom: 0.2rem;
168
- border: 3px solid var(--bg-surface);
169
- }
170
- /* No image → the badge sits normally at the top of the body. */
171
- .b-media-cards__card:not(:has(.b-media-cards__media)) .b-media-cards__badge {
172
- margin-top: 0;
173
- border: none;
174
- }
175
- .b-media-cards__title {
176
- margin: 0;
177
- font-size: 1.2rem;
178
- color: var(--fg);
179
- }
180
- .b-media-cards__card.is-link:hover .b-media-cards__title a { color: var(--gold); }
181
- .b-media-cards__title a { color: var(--fg); }
182
- /* Stretch the title link over the whole card so it's clickable. */
183
- .b-media-cards__title a::after { content: ''; position: absolute; inset: 0; }
184
- .b-media-cards__meta {
185
- margin: 0;
186
- align-self: var(--content-self, flex-start); /* a pill keeps its width, follows the alignment */
187
- padding: 0.2rem 0.6rem;
188
- border-radius: 999px;
189
- background: var(--bg-section);
190
- color: var(--muted);
191
- font-family: var(--font-heading);
192
- font-size: 0.72rem;
193
- font-weight: 600;
194
- letter-spacing: 0.03em;
195
- }
196
- .b-media-cards__text {
197
- margin: 0;
198
- color: var(--muted);
199
- line-height: 1.6;
200
- }
201
- .b-media-cards__cta {
202
- margin-top: auto;
203
- padding-top: 0.5rem;
204
- font-family: var(--font-heading);
205
- font-size: 0.85rem;
206
- font-weight: 600;
207
- color: var(--gold);
208
- }
209
- /* A mailto/tel shown as visible, copyable text (below any description). */
210
- .b-media-cards__contact {
211
- margin-top: auto;
212
- padding-top: 0.5rem;
213
- font-family: var(--font-heading);
214
- font-size: 0.85rem;
215
- font-weight: 600;
216
- color: var(--gold);
217
- overflow-wrap: anywhere;
218
- }
219
- </style>
1
+ ---
2
+ /**
3
+ * MediaCards — a Level-2 recipe: a grid of rich content cards with the IMAGE as a
4
+ * header on top (cover-cropped to a uniform ratio, like PostCard), then an optional
5
+ * icon badge, a title, a meta line (e.g. "Sundays 10:45 · Main hall"), a description, and
6
+ * an optional CTA link. The image-HEADER pattern (distinct from `tiles`, which puts
7
+ * the image BEHIND the text): use it for groups, team members, services or events —
8
+ * anywhere the photo and the copy both need to be fully legible. Whole card links
9
+ * when `href` is set. Token-driven, equal-height.
10
+ */
11
+ import Icon from '../Icon.astro';
12
+ import { planGrid } from '../../lib/gridRows';
13
+ import { isIconKey } from '../../lib/icons';
14
+ import Heading from '../blocks/Heading.astro';
15
+
16
+ import { inlineMarkdown, inlineMarkdownNoLinks } from '../../lib/inline-markdown';
17
+ interface Card {
18
+ image?: { src: string; alt?: string; focus?: string };
19
+ icon?: string;
20
+ title: string;
21
+ meta?: string;
22
+ text?: string;
23
+ href?: string;
24
+ linkLabel?: string;
25
+ }
26
+ interface Props {
27
+ title?: string;
28
+ intro?: string;
29
+ columns?: 2 | 3;
30
+ ratio?: '16/9' | '4/3' | '3/2' | '1/1' | '3/4';
31
+ cards?: Card[];
32
+ /** How the ragged last row lays out (lib/gridRows). */
33
+ lastRow?: 'auto' | 'fill' | 'center';
34
+ }
35
+ const { title, intro, columns = 3, ratio = '16/9', cards = [], lastRow = 'auto' } = Astro.props;
36
+ // Rows planned per screen (lib/gridRows); `data-single` centres a lone card.
37
+ const plan = planGrid(cards.length, { columns, item: 'mediaCards', lastRow });
38
+ ---
39
+
40
+ <section class="b-media-cards">
41
+ {(title || intro) && (
42
+ <div class="b-media-cards__head">
43
+ {title && <Heading text={title} level={2} />}
44
+ {intro && <p class="b-media-cards__intro" set:html={inlineMarkdown(intro)} />}
45
+ </div>
46
+ )}
47
+ <div class="b-media-cards__grid ferst-rows" data-cols={plan.cols} data-single={cards.length === 1 ? 'true' : undefined} style={plan.gridStyle}>
48
+ {cards.map((card, i) => {
49
+ // Surface a mailto:/tel: as visible, copyable text — a plain mailto does
50
+ // nothing on a device with no mail app, so the address must be readable too.
51
+ const email = card.href?.startsWith('mailto:') ? card.href.slice(7).split('?')[0] : null;
52
+ const phone = card.href?.startsWith('tel:') ? card.href.slice(4) : null;
53
+ return (
54
+ <article class:list={['b-media-cards__card', 'ferst-tile', 'ferst-tile--sm', card.href && 'is-link']} style={plan.itemStyles[i]}>
55
+ {card.image && (
56
+ <div class="b-media-cards__media" data-ratio={ratio} style={`aspect-ratio: ${ratio.replace('/', ' / ')}`}>
57
+ <img src={card.image.src} alt={card.image.alt ?? ''} loading="lazy" style={card.image.focus ? `object-position: ${card.image.focus}` : undefined} />
58
+ </div>
59
+ )}
60
+ <div class="b-media-cards__body">
61
+ {card.icon && isIconKey(card.icon) && (
62
+ <span class="b-media-cards__badge" aria-hidden="true"><Icon name={card.icon} size={20} /></span>
63
+ )}
64
+ <h3 class="b-media-cards__title">
65
+ {card.href ? <a href={card.href}>{card.title}</a> : card.title}
66
+ </h3>
67
+ {card.meta && <p class="b-media-cards__meta">{card.meta}</p>}
68
+ {card.text && <p class="b-media-cards__text" set:html={card.href ? inlineMarkdownNoLinks(card.text) : inlineMarkdown(card.text)} />}
69
+ {(email || phone) && (
70
+ <span class="b-media-cards__contact">{email ?? phone}</span>
71
+ )}
72
+ {card.href && !email && !phone && (
73
+ <span class="b-media-cards__cta" aria-hidden="true">{card.linkLabel ?? 'Learn more'} →</span>
74
+ )}
75
+ </div>
76
+ </article>
77
+ );
78
+ })}
79
+ </div>
80
+ </section>
81
+
82
+ <style>
83
+ .b-media-cards {
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: 2rem;
87
+ width: 100%; /* the full content width, whatever its items hold (lib/gridRows) */
88
+ max-width: 72rem;
89
+ margin-inline: auto;
90
+ padding-inline: 1rem;
91
+ }
92
+ .b-media-cards__head {
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: 0.75rem;
96
+ }
97
+ .b-media-cards__intro {
98
+ margin: 0;
99
+ color: var(--muted);
100
+ font-size: 1.0625rem;
101
+ line-height: 1.6;
102
+ max-width: var(--max);
103
+ }
104
+ .b-media-cards__grid {
105
+ display: grid;
106
+ gap: 1.5rem;
107
+ }
108
+ /* A solitary card is a centred feature, not a full-width slab. */
109
+ .b-media-cards__grid[data-single] { max-width: 28rem; margin-inline: auto; }
110
+ /* Rows come from lib/gridRows (the global .ferst-rows rules): even rows where the
111
+ count allows by using fewer columns, else full rows and a tidied last row. */
112
+ .b-media-cards__card {
113
+ position: relative;
114
+ display: flex;
115
+ flex-direction: column;
116
+ /* surface comes from .ferst-tile .ferst-tile--sm (bg/border/radius/shadow-sm) */
117
+ overflow: hidden;
118
+ transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
119
+ }
120
+ .b-media-cards__card.is-link:hover {
121
+ transform: translateY(-2px);
122
+ box-shadow: var(--shadow-md);
123
+ border-color: var(--gold);
124
+ }
125
+ /* Image header — cover-cropped to a uniform 16:9 so any source ratio fits (the
126
+ PostCard technique; also out-specifies the global img{height:auto}). */
127
+ .b-media-cards__media {
128
+ position: relative;
129
+ aspect-ratio: 16 / 9;
130
+ overflow: hidden;
131
+ background: var(--bg-section);
132
+ }
133
+ .b-media-cards .b-media-cards__media img {
134
+ position: absolute;
135
+ inset: 0;
136
+ width: 100%;
137
+ height: 100%;
138
+ object-fit: cover;
139
+ display: block;
140
+ }
141
+ .b-media-cards__body {
142
+ display: flex;
143
+ flex-direction: column;
144
+ align-items: var(--content-items, stretch); /* follows the page / section alignment */
145
+ gap: 0.5rem;
146
+ padding: 1.1rem 1.2rem 1.3rem;
147
+ flex: 1;
148
+ }
149
+ /* Icon badge — a small brand chip; slightly lifted over the image edge when an
150
+ image is present (the negative margin only bites inside a card with a header). */
151
+ .b-media-cards__badge {
152
+ display: inline-flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ width: 2.25rem;
156
+ height: 2.25rem;
157
+ border-radius: 999px;
158
+ background: var(--gold-light);
159
+ color: var(--gold);
160
+ margin-top: -2.3rem;
161
+ margin-bottom: 0.2rem;
162
+ border: 3px solid var(--bg-surface);
163
+ }
164
+ /* No image → the badge sits normally at the top of the body. */
165
+ .b-media-cards__card:not(:has(.b-media-cards__media)) .b-media-cards__badge {
166
+ margin-top: 0;
167
+ border: none;
168
+ }
169
+ .b-media-cards__title {
170
+ margin: 0;
171
+ font-size: 1.2rem;
172
+ color: var(--fg);
173
+ }
174
+ .b-media-cards__card.is-link:hover .b-media-cards__title a { color: var(--gold); }
175
+ .b-media-cards__title a { color: var(--fg); }
176
+ /* Stretch the title link over the whole card so it's clickable. */
177
+ .b-media-cards__title a::after { content: ''; position: absolute; inset: 0; }
178
+ .b-media-cards__meta {
179
+ margin: 0;
180
+ align-self: var(--content-self, flex-start); /* a pill keeps its width, follows the alignment */
181
+ padding: 0.2rem 0.6rem;
182
+ border-radius: 999px;
183
+ background: var(--bg-section);
184
+ color: var(--muted);
185
+ font-family: var(--font-heading);
186
+ font-size: 0.72rem;
187
+ font-weight: 600;
188
+ letter-spacing: 0.03em;
189
+ }
190
+ .b-media-cards__text {
191
+ margin: 0;
192
+ color: var(--muted);
193
+ line-height: 1.6;
194
+ }
195
+ .b-media-cards__cta {
196
+ margin-top: auto;
197
+ padding-top: 0.5rem;
198
+ font-family: var(--font-heading);
199
+ font-size: 0.85rem;
200
+ font-weight: 600;
201
+ color: var(--gold);
202
+ }
203
+ /* A mailto/tel shown as visible, copyable text (below any description). */
204
+ .b-media-cards__contact {
205
+ margin-top: auto;
206
+ padding-top: 0.5rem;
207
+ font-family: var(--font-heading);
208
+ font-size: 0.85rem;
209
+ font-weight: 600;
210
+ color: var(--gold);
211
+ overflow-wrap: anywhere;
212
+ }
213
+ </style>