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.
Files changed (59) hide show
  1. package/README.md +13 -4
  2. package/bin/ferst-media.mjs +96 -0
  3. package/components/Card.astro +53 -51
  4. package/components/PostCard.astro +138 -136
  5. package/components/SiteHeader.astro +10 -14
  6. package/components/blocks/Grid.astro +49 -48
  7. package/components/blocks/Heading.astro +4 -1
  8. package/components/recipes/Banner.astro +146 -146
  9. package/components/recipes/FeatureCards.astro +112 -118
  10. package/components/recipes/Gallery.astro +57 -59
  11. package/components/recipes/Hero.astro +112 -10
  12. package/components/recipes/LatestPosts.astro +295 -292
  13. package/components/recipes/Locations.astro +146 -143
  14. package/components/recipes/Marquee.astro +75 -75
  15. package/components/recipes/MediaCards.astro +213 -219
  16. package/components/recipes/Pricing.astro +149 -150
  17. package/components/recipes/Stats.astro +150 -157
  18. package/components/recipes/Tiles.astro +342 -296
  19. package/content/blocks.ts +1072 -1024
  20. package/content/imageSlots.mjs +542 -0
  21. package/content/schemas.ts +13 -11
  22. package/examples/recipes.ts +4 -0
  23. package/fonts/OFL.txt +1332 -287
  24. package/fonts/anton-latin-400-normal.woff2 +0 -0
  25. package/fonts/bangers-latin-400-normal.woff2 +0 -0
  26. package/fonts/bebas-neue-latin-400-normal.woff2 +0 -0
  27. package/fonts/bowlby-one-latin-400-normal.woff2 +0 -0
  28. package/fonts/fredoka-latin-400-normal.woff2 +0 -0
  29. package/fonts/fredoka-latin-600-normal.woff2 +0 -0
  30. package/fonts/fredoka-latin-700-normal.woff2 +0 -0
  31. package/fonts/knewave-latin-400-normal.woff2 +0 -0
  32. package/fonts/lora-latin-400-normal.woff2 +0 -0
  33. package/fonts/lora-latin-600-normal.woff2 +0 -0
  34. package/fonts/lora-latin-700-normal.woff2 +0 -0
  35. package/fonts/merriweather-latin-400-normal.woff2 +0 -0
  36. package/fonts/merriweather-latin-600-normal.woff2 +0 -0
  37. package/fonts/merriweather-latin-700-normal.woff2 +0 -0
  38. package/fonts/nunito-latin-400-normal.woff2 +0 -0
  39. package/fonts/nunito-latin-600-normal.woff2 +0 -0
  40. package/fonts/nunito-latin-700-normal.woff2 +0 -0
  41. package/fonts/oswald-latin-400-normal.woff2 +0 -0
  42. package/fonts/oswald-latin-600-normal.woff2 +0 -0
  43. package/fonts/oswald-latin-700-normal.woff2 +0 -0
  44. package/fonts/rubik-dirt-latin-400-normal.woff2 +0 -0
  45. package/integration.mjs +4 -14
  46. package/layouts/Base.astro +7 -16
  47. package/lib/fonts.ts +130 -0
  48. package/lib/gridRows.ts +197 -0
  49. package/lib/image-fields.ts +140 -0
  50. package/lib/image-size.mjs +108 -73
  51. package/lib/image-sizes.ts +16 -0
  52. package/lib/logo-header.ts +46 -0
  53. package/lib/media-check.mjs +524 -0
  54. package/lib/theme-preview.ts +203 -140
  55. package/lib/themeTokens.ts +235 -220
  56. package/package.json +3 -2
  57. package/styles/fonts.css +239 -76
  58. package/styles/theme.css +228 -160
  59. package/lib/gridColumns.ts +0 -22
package/README.md CHANGED
@@ -67,17 +67,26 @@ No code change; the colours live in your repo, edited by hand or in the CMS:
67
67
  "corners": "rounded",
68
68
  "elevation": "raised",
69
69
  "stroke": "on",
70
- "fields": "boxed"
70
+ "fields": "boxed",
71
+ "titleEffect": "none"
71
72
  }
72
73
  ```
73
74
 
74
75
  `brand` drives buttons/links/accents, `ink` text, `surface` backgrounds (cards,
75
- sections and borders are tinted from it). The four knobs — `corners` /
76
- `elevation` / `stroke` / `fields` — are set once and apply to every card, tile
77
- and input. Set no brand and the neutral defaults stand. For the rare token that
76
+ sections and borders are tinted from it). The knobs — `corners` /
77
+ `elevation` / `stroke` / `fields` / `titleEffect` — are set once and apply across
78
+ the whole site. Set no brand and the neutral defaults stand. For the rare token that
78
79
  must differ from what the three colours derive, `advanced.light` / `advanced.dark`
79
80
  are raw `{ "--token": "value" }` escape hatches layered last.
80
81
 
82
+ Fonts are picked from a curated set of self-hosted, open-licence faces grouped by
83
+ mood (`lib/fonts.ts`: clean, rounded, serif, bold condensed, punchy, brush), each
84
+ offered only for the roles it suits; poster and brush faces are for display titles,
85
+ never body text. A face downloads only when a page uses it. `titleEffect` (`none`,
86
+ `stroke`, `shadow` or `glow`) gives the display titles (the opener, banners, the
87
+ marquee) an outline, a poster shadow or a glow in the brand colour; it never changes
88
+ the text colour itself, so the theme's contrast holds.
89
+
81
90
  ## Licence
82
91
 
83
92
  [Business Source License 1.1](./LICENSE) from v0.2.0 (v0.1.x was Apache-2.0 and stays
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ // ferst-media — the site's pictures against the places they're shown (content/imageSlots.mjs).
3
+ // Run it in a site's folder:
4
+ //
5
+ // npx --no-install ferst-media check # each picture used, per place: ok, fixable or remake
6
+ // npx --no-install ferst-media brief # the shape and size each place on this site needs
7
+ // npx --no-install ferst-media brief --all # every place a picture can go, used or not
8
+ // npx --no-install ferst-media check --json # the same, as JSON (also for brief)
9
+ // npx --no-install ferst-media check <folder> # a site in another folder
10
+ //
11
+ // Advice only: it never changes a picture and always exits 0, so it can't fail a build.
12
+ import { readFileSync, realpathSync } from 'node:fs';
13
+ import { join, resolve } from 'node:path';
14
+ import { pathToFileURL } from 'node:url';
15
+ import { briefSite, checkSite, formatBrief, formatCheck } from '../lib/media-check.mjs';
16
+
17
+ export const HELP = `ferst-media: the site's pictures against the places they're shown.
18
+
19
+ ferst-media check [folder] [--json]
20
+ Each picture the pages, posts and logo settings use, per place:
21
+ ok fits the place
22
+ fixable close to the place's shape, too big, or with a plain border baked in
23
+ remake too far from the shape, or too small: it needs a new version
24
+ and the media rules each file breaks (names in lower case with hyphens,
25
+ nothing wider than 2400 pixels, no location data).
26
+
27
+ ferst-media brief [folder] [--all] [--json]
28
+ The places this site's pages show pictures, with the shape, size and tips for
29
+ each: a brief for whoever supplies the pictures. --all lists every place.
30
+
31
+ Nothing is changed and the exit code is always 0. Fitting pictures to their places
32
+ automatically (ferst-media fit) is planned; until then, a fixable picture is trimmed,
33
+ cropped or scaled in any image editor.`;
34
+
35
+ /**
36
+ * True when THIS file is run as a CLI (not imported). Each bin needs its own copy:
37
+ * `import.meta.url` is per file. Handles npm's `node_modules/.bin` symlink via realpath.
38
+ */
39
+ export function isDirectInvocation(argv1) {
40
+ if (!argv1) return false;
41
+ if (import.meta.url === pathToFileURL(argv1).href) return true;
42
+ try {
43
+ return import.meta.url === pathToFileURL(realpathSync(argv1)).href;
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+
49
+ /** The command, the site's folder and the flags from the arguments. */
50
+ export function parseArgs(argv) {
51
+ const flags = new Set(argv.filter((a) => a.startsWith('--')));
52
+ const rest = argv.filter((a) => !a.startsWith('--'));
53
+ const command = ['check', 'brief'].includes(rest[0]) ? rest.shift() : rest[0] ? 'help' : 'check';
54
+ return { command, root: resolve(rest[0] ?? '.'), json: flags.has('--json'), all: flags.has('--all'), help: flags.has('--help') || flags.has('-h') };
55
+ }
56
+
57
+ /** sharp, when the site has it (it comes with Astro): it finds borders baked into pictures. */
58
+ async function loadSharp() {
59
+ try {
60
+ return (await import('sharp')).default;
61
+ } catch {
62
+ return undefined;
63
+ }
64
+ }
65
+
66
+ function siteName(root) {
67
+ try {
68
+ const s = JSON.parse(readFileSync(join(root, 'src/content/siteSettings/index.json'), 'utf8'));
69
+ return s?.identity?.siteTitle || s?.identity?.shortName || '';
70
+ } catch {
71
+ return '';
72
+ }
73
+ }
74
+
75
+ /** Run one command and return what it prints. */
76
+ export async function run(argv, { sharp } = {}) {
77
+ const args = parseArgs(argv);
78
+ if (args.help || args.command === 'help') return HELP;
79
+ if (args.command === 'brief') {
80
+ const entries = briefSite(args.root, { all: args.all });
81
+ return args.json ? JSON.stringify(entries, null, 2) : formatBrief(entries, { siteName: siteName(args.root) });
82
+ }
83
+ const result = await checkSite(args.root, { sharp: sharp === undefined ? await loadSharp() : sharp });
84
+ return args.json ? JSON.stringify(result, null, 2) : formatCheck(result);
85
+ }
86
+
87
+ async function main() {
88
+ try {
89
+ console.log(await run(process.argv.slice(2)));
90
+ } catch (err) {
91
+ console.log(`ferst-media couldn't finish: ${err instanceof Error ? err.message : err}`);
92
+ }
93
+ process.exitCode = 0;
94
+ }
95
+
96
+ if (isDirectInvocation(process.argv[1])) main();
@@ -1,51 +1,53 @@
1
- ---
2
- interface Props {
3
- as?: string;
4
- hover?: boolean;
5
- padding?: string;
6
- overflow?: string;
7
- class?: string;
8
- }
9
-
10
- const { as: Tag = 'div', hover = true, padding = '1.25rem 1.5rem', overflow = 'hidden', class: className } = Astro.props;
11
- ---
12
-
13
- <Tag class:list={['card', { 'card--hover': hover }, className]} style={`--card-padding: ${padding}; --card-overflow: ${overflow}`}>
14
- <slot />
15
- </Tag>
16
-
17
- <style>
18
- /* Token-driven so the global surface "knobs" (--radius / --card-border /
19
- --shadow-*) restyle every card at once, in both themes. */
20
- .card {
21
- position: relative;
22
- border-radius: var(--radius);
23
- background: var(--bg-surface);
24
- border: var(--card-border);
25
- box-shadow: var(--shadow-md);
26
- overflow: var(--card-overflow, hidden);
27
- padding: var(--card-padding);
28
- display: flex;
29
- flex-direction: column;
30
- /* Children follow the page / section alignment (Base: --content-items). */
31
- align-items: var(--content-items, stretch);
32
- }
33
-
34
- .card--hover {
35
- transition: transform 0.2s ease, box-shadow 0.2s ease;
36
- }
37
-
38
- .card--hover:hover {
39
- transform: translateY(-4px);
40
- box-shadow: var(--shadow-lg);
41
- }
42
-
43
- @media (prefers-reduced-motion: reduce) {
44
- .card--hover {
45
- transition: none;
46
- }
47
- .card--hover:hover {
48
- transform: none;
49
- }
50
- }
51
- </style>
1
+ ---
2
+ interface Props {
3
+ as?: string;
4
+ hover?: boolean;
5
+ padding?: string;
6
+ overflow?: string;
7
+ class?: string;
8
+ /** Extra inline style, e.g. a planned grid's placement (lib/gridRows). */
9
+ style?: string;
10
+ }
11
+
12
+ const { as: Tag = 'div', hover = true, padding = '1.25rem 1.5rem', overflow = 'hidden', class: className, style } = Astro.props;
13
+ ---
14
+
15
+ <Tag class:list={['card', { 'card--hover': hover }, className]} style={`--card-padding: ${padding}; --card-overflow: ${overflow}${style ? `; ${style}` : ''}`}>
16
+ <slot />
17
+ </Tag>
18
+
19
+ <style>
20
+ /* Token-driven so the global surface "knobs" (--radius / --card-border /
21
+ --shadow-*) restyle every card at once, in both themes. */
22
+ .card {
23
+ position: relative;
24
+ border-radius: var(--radius);
25
+ background: var(--bg-surface);
26
+ border: var(--card-border);
27
+ box-shadow: var(--shadow-md);
28
+ overflow: var(--card-overflow, hidden);
29
+ padding: var(--card-padding);
30
+ display: flex;
31
+ flex-direction: column;
32
+ /* Children follow the page / section alignment (Base: --content-items). */
33
+ align-items: var(--content-items, stretch);
34
+ }
35
+
36
+ .card--hover {
37
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
38
+ }
39
+
40
+ .card--hover:hover {
41
+ transform: translateY(-4px);
42
+ box-shadow: var(--shadow-lg);
43
+ }
44
+
45
+ @media (prefers-reduced-motion: reduce) {
46
+ .card--hover {
47
+ transition: none;
48
+ }
49
+ .card--hover:hover {
50
+ transform: none;
51
+ }
52
+ }
53
+ </style>
@@ -1,136 +1,138 @@
1
- ---
2
- /**
3
- * PostCard — a post preview for the news index and tag pages. Token-driven (radius,
4
- * border, shadow, colours all from the theme), equal-height in a grid, with the
5
- * whole card clickable via a stretched title link.
6
- */
7
- interface Props {
8
- href: string;
9
- title: string;
10
- date: Date | string;
11
- summary?: string;
12
- heroImage?: string;
13
- /** Optional tag labels shown as a small eyebrow. */
14
- tagLabels?: string[];
15
- /** Open the link in a new tab (e.g. a post that's just an attached PDF). */
16
- newTab?: boolean;
17
- /** The call-to-action label (default "Read more"). */
18
- moreLabel?: string;
19
- }
20
- const { href, title, date, summary, heroImage, tagLabels = [], newTab = false, moreLabel = 'Read more' } = Astro.props;
21
- const linkRel = newTab ? 'noopener' : undefined;
22
- const linkTarget = newTab ? '_blank' : undefined;
23
- const d = date instanceof Date ? date : new Date(date);
24
- const iso = Number.isNaN(d.valueOf()) ? undefined : d.toISOString().slice(0, 10);
25
- const display = Number.isNaN(d.valueOf())
26
- ? ''
27
- : d.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
28
- ---
29
-
30
- <article class="b-post-card">
31
- {heroImage && (
32
- <a class="b-post-card__media" href={href} target={linkTarget} rel={linkRel} tabindex="-1" aria-hidden="true">
33
- <img src={heroImage} alt="" loading="lazy" />
34
- </a>
35
- )}
36
- <div class="b-post-card__body">
37
- <div class="b-post-card__meta">
38
- {tagLabels.length > 0 && <span class="b-post-card__eyebrow">{tagLabels[0]}</span>}
39
- {display && <time datetime={iso}>{display}</time>}
40
- </div>
41
- <h3 class="b-post-card__title">
42
- <a href={href} target={linkTarget} rel={linkRel}>{title}</a>
43
- </h3>
44
- {summary && <p class="b-post-card__summary">{summary}</p>}
45
- <span class="b-post-card__more" aria-hidden="true">{moreLabel}</span>
46
- </div>
47
- </article>
48
-
49
- <style>
50
- .b-post-card {
51
- display: flex;
52
- flex-direction: column;
53
- background: var(--bg-surface);
54
- border: var(--card-border);
55
- border-radius: var(--radius);
56
- box-shadow: var(--shadow-sm);
57
- overflow: hidden;
58
- position: relative;
59
- transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
60
- }
61
- .b-post-card:hover {
62
- transform: translateY(-2px);
63
- box-shadow: var(--shadow-md);
64
- border-color: var(--gold);
65
- }
66
- .b-post-card__media {
67
- display: block;
68
- position: relative;
69
- aspect-ratio: 16 / 9;
70
- overflow: hidden;
71
- background: var(--bg-section);
72
- }
73
- /* Absolutely-positioned + object-fit:cover so ANY source ratio is cropped to a
74
- uniform 16:9 tile — never stretched, never overflowing into the text. The
75
- compound selector (and inset/size) also out-specifies the global
76
- `img { height:auto }` in Base, which otherwise lets tall images blow the box. */
77
- .b-post-card .b-post-card__media img {
78
- position: absolute;
79
- inset: 0;
80
- width: 100%;
81
- height: 100%;
82
- object-fit: cover;
83
- display: block;
84
- }
85
- .b-post-card__body {
86
- display: flex;
87
- flex-direction: column;
88
- gap: 0.5rem;
89
- padding: 1.1rem 1.2rem 1.3rem;
90
- flex: 1;
91
- }
92
- .b-post-card__meta {
93
- display: flex;
94
- flex-wrap: wrap;
95
- align-items: center;
96
- gap: 0.5rem 0.75rem;
97
- }
98
- .b-post-card__eyebrow {
99
- font-family: var(--font-heading);
100
- font-size: 0.7rem;
101
- font-weight: 600;
102
- letter-spacing: 0.08em;
103
- text-transform: uppercase;
104
- color: var(--gold);
105
- }
106
- .b-post-card__title {
107
- margin: 0;
108
- }
109
- /* Stretch the title link over the whole card so the card is clickable, while
110
- the meta/summary stay selectable. */
111
- .b-post-card__title a::after {
112
- content: '';
113
- position: absolute;
114
- inset: 0;
115
- }
116
- .b-post-card__title a {
117
- color: var(--fg);
118
- }
119
- .b-post-card:hover .b-post-card__title a {
120
- color: var(--gold);
121
- }
122
- .b-post-card__summary {
123
- margin: 0;
124
- color: var(--muted);
125
- font-size: 0.95rem;
126
- line-height: 1.55;
127
- }
128
- .b-post-card__more {
129
- margin-top: auto;
130
- padding-top: 0.4rem;
131
- font-family: var(--font-heading);
132
- font-size: 0.85rem;
133
- font-weight: 600;
134
- color: var(--gold);
135
- }
136
- </style>
1
+ ---
2
+ /**
3
+ * PostCard — a post preview for the news index and tag pages. Token-driven (radius,
4
+ * border, shadow, colours all from the theme), equal-height in a grid, with the
5
+ * whole card clickable via a stretched title link.
6
+ */
7
+ interface Props {
8
+ href: string;
9
+ title: string;
10
+ date: Date | string;
11
+ summary?: string;
12
+ heroImage?: string;
13
+ /** Optional tag labels shown as a small eyebrow. */
14
+ tagLabels?: string[];
15
+ /** Open the link in a new tab (e.g. a post that's just an attached PDF). */
16
+ newTab?: boolean;
17
+ /** The call-to-action label (default "Read more"). */
18
+ moreLabel?: string;
19
+ /** Inline style, e.g. a planned grid's placement (lib/gridRows). */
20
+ style?: string;
21
+ }
22
+ const { href, title, date, summary, heroImage, tagLabels = [], newTab = false, moreLabel = 'Read more', style } = Astro.props;
23
+ const linkRel = newTab ? 'noopener' : undefined;
24
+ const linkTarget = newTab ? '_blank' : undefined;
25
+ const d = date instanceof Date ? date : new Date(date);
26
+ const iso = Number.isNaN(d.valueOf()) ? undefined : d.toISOString().slice(0, 10);
27
+ const display = Number.isNaN(d.valueOf())
28
+ ? ''
29
+ : d.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
30
+ ---
31
+
32
+ <article class="b-post-card" style={style}>
33
+ {heroImage && (
34
+ <a class="b-post-card__media" href={href} target={linkTarget} rel={linkRel} tabindex="-1" aria-hidden="true">
35
+ <img src={heroImage} alt="" loading="lazy" />
36
+ </a>
37
+ )}
38
+ <div class="b-post-card__body">
39
+ <div class="b-post-card__meta">
40
+ {tagLabels.length > 0 && <span class="b-post-card__eyebrow">{tagLabels[0]}</span>}
41
+ {display && <time datetime={iso}>{display}</time>}
42
+ </div>
43
+ <h3 class="b-post-card__title">
44
+ <a href={href} target={linkTarget} rel={linkRel}>{title}</a>
45
+ </h3>
46
+ {summary && <p class="b-post-card__summary">{summary}</p>}
47
+ <span class="b-post-card__more" aria-hidden="true">{moreLabel}</span>
48
+ </div>
49
+ </article>
50
+
51
+ <style>
52
+ .b-post-card {
53
+ display: flex;
54
+ flex-direction: column;
55
+ background: var(--bg-surface);
56
+ border: var(--card-border);
57
+ border-radius: var(--radius);
58
+ box-shadow: var(--shadow-sm);
59
+ overflow: hidden;
60
+ position: relative;
61
+ transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
62
+ }
63
+ .b-post-card:hover {
64
+ transform: translateY(-2px);
65
+ box-shadow: var(--shadow-md);
66
+ border-color: var(--gold);
67
+ }
68
+ .b-post-card__media {
69
+ display: block;
70
+ position: relative;
71
+ aspect-ratio: 16 / 9;
72
+ overflow: hidden;
73
+ background: var(--bg-section);
74
+ }
75
+ /* Absolutely-positioned + object-fit:cover so ANY source ratio is cropped to a
76
+ uniform 16:9 tile — never stretched, never overflowing into the text. The
77
+ compound selector (and inset/size) also out-specifies the global
78
+ `img { height:auto }` in Base, which otherwise lets tall images blow the box. */
79
+ .b-post-card .b-post-card__media img {
80
+ position: absolute;
81
+ inset: 0;
82
+ width: 100%;
83
+ height: 100%;
84
+ object-fit: cover;
85
+ display: block;
86
+ }
87
+ .b-post-card__body {
88
+ display: flex;
89
+ flex-direction: column;
90
+ gap: 0.5rem;
91
+ padding: 1.1rem 1.2rem 1.3rem;
92
+ flex: 1;
93
+ }
94
+ .b-post-card__meta {
95
+ display: flex;
96
+ flex-wrap: wrap;
97
+ align-items: center;
98
+ gap: 0.5rem 0.75rem;
99
+ }
100
+ .b-post-card__eyebrow {
101
+ font-family: var(--font-heading);
102
+ font-size: 0.7rem;
103
+ font-weight: 600;
104
+ letter-spacing: 0.08em;
105
+ text-transform: uppercase;
106
+ color: var(--gold);
107
+ }
108
+ .b-post-card__title {
109
+ margin: 0;
110
+ }
111
+ /* Stretch the title link over the whole card so the card is clickable, while
112
+ the meta/summary stay selectable. */
113
+ .b-post-card__title a::after {
114
+ content: '';
115
+ position: absolute;
116
+ inset: 0;
117
+ }
118
+ .b-post-card__title a {
119
+ color: var(--fg);
120
+ }
121
+ .b-post-card:hover .b-post-card__title a {
122
+ color: var(--gold);
123
+ }
124
+ .b-post-card__summary {
125
+ margin: 0;
126
+ color: var(--muted);
127
+ font-size: 0.95rem;
128
+ line-height: 1.55;
129
+ }
130
+ .b-post-card__more {
131
+ margin-top: auto;
132
+ padding-top: 0.4rem;
133
+ font-family: var(--font-heading);
134
+ font-size: 0.85rem;
135
+ font-weight: 600;
136
+ color: var(--gold);
137
+ }
138
+ </style>
@@ -13,6 +13,8 @@ import Button from './Button.astro';
13
13
  import type { NavLink, NavGroup, LogoHeader } from '../content/schemas';
14
14
 
15
15
  import { navWithoutCta } from '../lib/nav';
16
+ import { logoHeaderLayout } from '../lib/logo-header';
17
+ import { imageSizeOf } from '../lib/image-sizes';
16
18
  interface Props {
17
19
  path: string;
18
20
  headerClass?: string;
@@ -20,8 +22,6 @@ interface Props {
20
22
  primaryLogoDark?: string;
21
23
  /** The logo's size and placement (logoSettings.header). Omitted: a standard logo in the bar. */
22
24
  logoHeader?: Partial<LogoHeader>;
23
- /** The logo image's own width and height, so its box keeps the image's shape before it loads. */
24
- logoSize?: { width: number; height: number };
25
25
  brandAlt: string;
26
26
  primaryNav: NavLink[];
27
27
  /** Optional dropdown / mega-menu group. Client-configured — the core ships none. */
@@ -30,12 +30,11 @@ interface Props {
30
30
  cta?: { label: string; href: string } | null;
31
31
  }
32
32
 
33
- const { path, headerClass, primaryLogoLight, primaryLogoDark, logoHeader = {}, logoSize, brandAlt, primaryNav, dropdown, cta = { label: 'Contact', href: '/contact/' } } = Astro.props;
34
- // Only a setting that differs from the default reaches the markup, so a site that sets
35
- // nothing gets exactly the header it always had.
36
- const logoSizeName = primaryLogoLight && logoHeader.size && logoHeader.size !== 'standard' ? logoHeader.size : undefined;
37
- const overhang = !!primaryLogoLight && logoHeader.placement === 'overhang';
38
- const logoRatio = logoSize && logoSize.width > 0 && logoSize.height > 0 ? +(logoSize.width / logoSize.height).toFixed(4) : undefined;
33
+ const { path, headerClass, primaryLogoLight, primaryLogoDark, logoHeader = {}, brandAlt, primaryNav, dropdown, cta = { label: 'Contact', href: '/contact/' } } = Astro.props;
34
+ // The logo's own size (read from the site's files at build), so its box keeps the image's
35
+ // shape before it loads; and the header's attributes for the logo's size and placement.
36
+ const logoSize = imageSizeOf(primaryLogoLight);
37
+ const logoLayout = logoHeaderLayout({ header: logoHeader, hasLogo: !!primaryLogoLight, size: logoSize });
39
38
  // A menu link to the same place as the button would show it twice: the button wins.
40
39
  const navLinks = navWithoutCta(primaryNav, cta);
41
40
  const ctaActive = !!cta && cta.href.startsWith('/') && path.startsWith(cta.href.replace(/\/$/, '') || '/#');
@@ -71,11 +70,8 @@ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
71
70
  -->
72
71
  <header
73
72
  class:list={['site-header', headerClass]}
74
- data-logo-size={logoSizeName}
75
- data-logo-placement={overhang ? 'overhang' : undefined}
76
- data-logo-hang={overhang && logoHeader.shrinkOnScroll === false ? '' : undefined}
77
- data-logo-shadow={primaryLogoLight && logoHeader.shadow ? '' : undefined}
78
- style={logoRatio ? `--logo-ratio: ${logoRatio}` : undefined}
73
+ {...logoLayout.attributes}
74
+ style={logoLayout.ratio ? `--logo-ratio: ${logoLayout.ratio}` : undefined}
79
75
  transition:persist transition:name="site-header" transition:animate="none">
80
76
  <a href="/" class="brand">
81
77
  {primaryLogoLight ? (
@@ -375,7 +371,7 @@ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
375
371
  }
376
372
  /* A soft shadow, so a dark round badge stands apart from a dark header. */
377
373
  .site-header[data-logo-shadow] .primary-logo {
378
- filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
374
+ filter: drop-shadow(var(--shadow-logo));
379
375
  }
380
376
  @media (prefers-reduced-motion: reduce) {
381
377
  .site-header[data-logo-placement='overhang'] .brand,