ferst-core 0.7.7 → 0.7.9
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/bin/ferst-modules.mjs +18 -2
- package/components/BlockRenderer.astro +125 -119
- package/components/Button.astro +1 -1
- package/components/CalendarEmbed.astro +2 -1
- package/components/Card.astro +2 -0
- package/components/SiteHeader.astro +24 -0
- package/components/recipes/Accordion.astro +91 -87
- package/components/recipes/Bento.astro +7 -3
- package/components/recipes/ContactForm.astro +6 -3
- package/components/recipes/Cta.astro +5 -1
- package/components/recipes/Faq.astro +5 -1
- package/components/recipes/FeatureCards.astro +115 -112
- package/components/recipes/Hero.astro +521 -495
- package/components/recipes/LatestPosts.astro +1 -1
- package/components/recipes/MediaCards.astro +214 -213
- package/components/recipes/Notice.astro +90 -90
- package/components/recipes/Pricing.astro +7 -4
- package/components/recipes/Stats.astro +155 -152
- package/components/recipes/Steps.astro +124 -121
- package/components/recipes/Tabs.astro +138 -134
- package/components/recipes/Tiles.astro +291 -287
- package/content/blocks.ts +88 -52
- package/layouts/Base.astro +496 -484
- package/lib/inline-markdown.ts +13 -0
- package/lib/slug.ts +1 -1
- package/package.json +1 -1
- package/routes/calendar/index.astro +2 -1
|
@@ -1,134 +1,138 @@
|
|
|
1
|
-
---
|
|
2
|
-
/** Tabs — a Level-2 recipe: labelled panels, one open at a time. Progressive:
|
|
3
|
-
* the first panel is visible with no JavaScript; a small script adds selection,
|
|
4
|
-
* ARIA state and arrow-key navigation. Composes the Heading primitive. */
|
|
5
|
-
import Heading from '../blocks/Heading.astro';
|
|
6
|
-
|
|
7
|
-
import { inlineMarkdown } from '../../lib/inline-markdown';
|
|
8
|
-
interface Item { label: string; heading?: string; text?: string; image?: { src: string; alt?: string } }
|
|
9
|
-
interface Props {
|
|
10
|
-
title?: string;
|
|
11
|
-
items?: Item[];
|
|
12
|
-
}
|
|
13
|
-
const { title, items = [] } = Astro.props;
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
1
|
+
---
|
|
2
|
+
/** Tabs — a Level-2 recipe: labelled panels, one open at a time. Progressive:
|
|
3
|
+
* the first panel is visible with no JavaScript; a small script adds selection,
|
|
4
|
+
* ARIA state and arrow-key navigation. Composes the Heading primitive. */
|
|
5
|
+
import Heading from '../blocks/Heading.astro';
|
|
6
|
+
|
|
7
|
+
import { inlineMarkdown } from '../../lib/inline-markdown';
|
|
8
|
+
interface Item { label: string; heading?: string; text?: string; image?: { src: string; alt?: string } }
|
|
9
|
+
interface Props {
|
|
10
|
+
title?: string;
|
|
11
|
+
items?: Item[];
|
|
12
|
+
}
|
|
13
|
+
const { title, items = [] } = Astro.props;
|
|
14
|
+
// Alignment overrides (BlockLayout): the title + intro default to centred; the block's
|
|
15
|
+
// own `align`, or `headingAlign` for the title alone, overrides it from the page data.
|
|
16
|
+
const { align: blockAlign, headingAlign } = Astro.props as { align?: 'start' | 'center' | 'end'; headingAlign?: 'start' | 'center' | 'end' };
|
|
17
|
+
const headAlign = headingAlign ?? blockAlign ?? 'center';
|
|
18
|
+
const uid = 'tabs-' + Math.random().toString(36).slice(2, 9);
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<section class="b-tabs">
|
|
22
|
+
{title && <Heading text={title} level={2} align={headAlign} />}
|
|
23
|
+
<div class="b-tabs__inner">
|
|
24
|
+
<div class="b-tabs__list" role="tablist" aria-label={title ?? 'Tabs'}>
|
|
25
|
+
{items.map((item, i) => (
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
role="tab"
|
|
29
|
+
id={`${uid}-tab-${i}`}
|
|
30
|
+
aria-controls={`${uid}-panel-${i}`}
|
|
31
|
+
aria-selected={i === 0 ? 'true' : 'false'}
|
|
32
|
+
tabindex={i === 0 ? 0 : -1}
|
|
33
|
+
class="b-tabs__tab"
|
|
34
|
+
>
|
|
35
|
+
{item.label}
|
|
36
|
+
</button>
|
|
37
|
+
))}
|
|
38
|
+
</div>
|
|
39
|
+
{items.map((item, i) => (
|
|
40
|
+
<div
|
|
41
|
+
role="tabpanel"
|
|
42
|
+
id={`${uid}-panel-${i}`}
|
|
43
|
+
aria-labelledby={`${uid}-tab-${i}`}
|
|
44
|
+
class="b-tabs__panel"
|
|
45
|
+
hidden={i !== 0}
|
|
46
|
+
tabindex="0"
|
|
47
|
+
>
|
|
48
|
+
{item.image && (
|
|
49
|
+
<img class="b-tabs__img" src={item.image.src} alt={item.image.alt ?? ''} loading="lazy" decoding="async" />
|
|
50
|
+
)}
|
|
51
|
+
<div class="b-tabs__copy">
|
|
52
|
+
{item.heading && <h3 class="b-tabs__heading">{item.heading}</h3>}
|
|
53
|
+
{item.text && <p class="b-tabs__text" set:html={inlineMarkdown(item.text)} />}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
))}
|
|
57
|
+
</div>
|
|
58
|
+
</section>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
.b-tabs {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
gap: 1.5rem;
|
|
65
|
+
max-width: 60rem;
|
|
66
|
+
margin-inline: auto;
|
|
67
|
+
padding-inline: 1rem;
|
|
68
|
+
}
|
|
69
|
+
.b-tabs__list {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-wrap: wrap;
|
|
72
|
+
gap: 0.25rem;
|
|
73
|
+
border-bottom: 1px solid var(--border);
|
|
74
|
+
}
|
|
75
|
+
.b-tabs__tab {
|
|
76
|
+
appearance: none;
|
|
77
|
+
background: none;
|
|
78
|
+
border: none;
|
|
79
|
+
border-bottom: 2px solid transparent;
|
|
80
|
+
margin-bottom: -1px;
|
|
81
|
+
padding: 0.7rem 1rem;
|
|
82
|
+
font-family: var(--font-heading);
|
|
83
|
+
font-size: 0.95rem;
|
|
84
|
+
font-weight: 600;
|
|
85
|
+
color: var(--muted);
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
transition: color 0.15s, border-color 0.15s;
|
|
88
|
+
}
|
|
89
|
+
.b-tabs__tab:hover { color: var(--fg); }
|
|
90
|
+
.b-tabs__tab[aria-selected='true'] { color: var(--gold); border-bottom-color: var(--gold); }
|
|
91
|
+
.b-tabs__tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
|
|
92
|
+
.b-tabs__panel {
|
|
93
|
+
display: grid;
|
|
94
|
+
gap: 1.25rem;
|
|
95
|
+
}
|
|
96
|
+
/* A class `display` beats the UA `[hidden]{display:none}` (equal specificity,
|
|
97
|
+
author origin wins), so make the hidden state explicit — for the first paint
|
|
98
|
+
and every JS toggle. */
|
|
99
|
+
.b-tabs__panel[hidden] {
|
|
100
|
+
display: none;
|
|
101
|
+
}
|
|
102
|
+
@media (min-width: 48em) {
|
|
103
|
+
.b-tabs__panel:has(.b-tabs__img) { grid-template-columns: 1fr 1fr; align-items: center; }
|
|
104
|
+
}
|
|
105
|
+
.b-tabs__panel:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: var(--radius-sm); }
|
|
106
|
+
.b-tabs__img { width: 100%; height: auto; border-radius: var(--radius); }
|
|
107
|
+
.b-tabs__heading { margin: 0 0 0.5rem; color: var(--fg); }
|
|
108
|
+
.b-tabs__text { margin: 0; color: var(--muted); line-height: 1.65; }
|
|
109
|
+
</style>
|
|
110
|
+
|
|
111
|
+
<script>
|
|
112
|
+
// Wire every tabs group on the page: selection, ARIA state, arrow-key nav.
|
|
113
|
+
document.querySelectorAll<HTMLElement>('.b-tabs').forEach((root) => {
|
|
114
|
+
const tabs = Array.from(root.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
|
|
115
|
+
const panels = Array.from(root.querySelectorAll<HTMLElement>('[role="tabpanel"]'));
|
|
116
|
+
if (!tabs.length) return;
|
|
117
|
+
|
|
118
|
+
function select(index: number, focus = true) {
|
|
119
|
+
tabs.forEach((tab, i) => {
|
|
120
|
+
const on = i === index;
|
|
121
|
+
tab.setAttribute('aria-selected', on ? 'true' : 'false');
|
|
122
|
+
tab.tabIndex = on ? 0 : -1;
|
|
123
|
+
panels[i]?.toggleAttribute('hidden', !on);
|
|
124
|
+
});
|
|
125
|
+
if (focus) tabs[index]?.focus();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
tabs.forEach((tab, i) => {
|
|
129
|
+
tab.addEventListener('click', () => select(i, false));
|
|
130
|
+
tab.addEventListener('keydown', (e) => {
|
|
131
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') { e.preventDefault(); select((i + 1) % tabs.length); }
|
|
132
|
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') { e.preventDefault(); select((i - 1 + tabs.length) % tabs.length); }
|
|
133
|
+
else if (e.key === 'Home') { e.preventDefault(); select(0); }
|
|
134
|
+
else if (e.key === 'End') { e.preventDefault(); select(tabs.length - 1); }
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
</script>
|