@contentrain/astro-kit 0.21.1 → 0.22.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/catalog.json +21 -4
- package/components/contact-form/ContactForm.astro +6 -1
- package/components/contact-form/contact-form.ts +8 -0
- package/components/contact-form/fixtures.json +2 -2
- package/components/contact-form/meta.json +2 -2
- package/components/hero/Hero.astro +18 -8
- package/components/hero/fixtures.json +24 -0
- package/components/hero/hero.ts +9 -0
- package/components/hero/meta.json +15 -0
- package/package.json +2 -2
package/catalog.json
CHANGED
|
@@ -507,7 +507,7 @@
|
|
|
507
507
|
{
|
|
508
508
|
"id": "contact-form",
|
|
509
509
|
"name": "Contact form",
|
|
510
|
-
"description": "The contact section: heading, introduction, contact details (email, phone, address) and a Contentrain Studio form — fields, spam protection and notifications set in Studio, submissions reviewed there. Replaces form plugins; renders the details alone until the site is bound to a Studio project. When the owner chose another home at migration (site.config.ts `features.forms`) the form posts to their form service, or the section shows an address to write to or a link to the form on WordPress.",
|
|
510
|
+
"description": "The contact section: heading, introduction, contact details (email, phone, address) and a Contentrain Studio form — fields, spam protection and notifications set in Studio, submissions reviewed there. Replaces form plugins; renders the details alone until the site is bound to a Studio project (a section left with only its heading is not drawn: the heading would title a form that is not there). When the owner chose another home at migration (site.config.ts `features.forms`) the form posts to their form service, or the section shows an address to write to or a link to the form on WordPress.",
|
|
511
511
|
"category": "section",
|
|
512
512
|
"uses": [],
|
|
513
513
|
"shared": [
|
|
@@ -612,9 +612,10 @@
|
|
|
612
612
|
"classic/ninja-forms"
|
|
613
613
|
]
|
|
614
614
|
},
|
|
615
|
-
"a11y": "Contact details are a description list when every one has a label, a plain list otherwise; links say what they open. The form's labels, errors and focus handling are Studio's form runtime (FormMount). The section is labelled by its heading.",
|
|
615
|
+
"a11y": "Contact details are a description list when every one has a label, a plain list otherwise; links say what they open. The form's labels, errors and focus handling are Studio's form runtime (FormMount). The section is labelled by its heading. Without a form to show and with no introduction or details, the section is not drawn at all.",
|
|
616
616
|
"files": [
|
|
617
|
-
"ContactForm.astro"
|
|
617
|
+
"ContactForm.astro",
|
|
618
|
+
"contact-form.ts"
|
|
618
619
|
],
|
|
619
620
|
"contentFields": {
|
|
620
621
|
"heading": "heading",
|
|
@@ -1672,6 +1673,14 @@
|
|
|
1672
1673
|
],
|
|
1673
1674
|
"default": "full",
|
|
1674
1675
|
"description": "Layout cover only. full: the image runs the full window width. content: the cover sits in the reading column, as a WordPress cover block that is not alignfull does under the page title."
|
|
1676
|
+
},
|
|
1677
|
+
"headingScale": {
|
|
1678
|
+
"options": [
|
|
1679
|
+
"default",
|
|
1680
|
+
"theme"
|
|
1681
|
+
],
|
|
1682
|
+
"default": "default",
|
|
1683
|
+
"description": "default: the layout's own type scale. theme: the heading takes the site's size for its level (`--text-heading-1` for the page-opening hero, `-2` otherwise), as the source's own h1 does under a block theme."
|
|
1675
1684
|
}
|
|
1676
1685
|
},
|
|
1677
1686
|
"props": {
|
|
@@ -1770,6 +1779,13 @@
|
|
|
1770
1779
|
"type": "string",
|
|
1771
1780
|
"content": false,
|
|
1772
1781
|
"description": "Anchor id of the section; the heading gets `<id>-title`."
|
|
1782
|
+
},
|
|
1783
|
+
"minHeight": {
|
|
1784
|
+
"type": "integer",
|
|
1785
|
+
"content": false,
|
|
1786
|
+
"min": 100,
|
|
1787
|
+
"max": 2000,
|
|
1788
|
+
"description": "Layout cover only: the cover's own height in pixels, as the source sets it (520); absent, the layout's default."
|
|
1773
1789
|
}
|
|
1774
1790
|
},
|
|
1775
1791
|
"slots": {},
|
|
@@ -1790,7 +1806,8 @@
|
|
|
1790
1806
|
},
|
|
1791
1807
|
"a11y": "A labelled region (aria-labelledby the heading). One h1 by default; `level: 2` inside pages that already have one. The cover image is decorative when its alt is empty; text sits on an ink scrim for contrast.",
|
|
1792
1808
|
"files": [
|
|
1793
|
-
"Hero.astro"
|
|
1809
|
+
"Hero.astro",
|
|
1810
|
+
"hero.ts"
|
|
1794
1811
|
],
|
|
1795
1812
|
"contentFields": {
|
|
1796
1813
|
"heading": "heading",
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// StudioForm): its fields, spam protection and notifications live in Studio,
|
|
5
5
|
// and submissions arrive there for review — no form plugin, no mail server.
|
|
6
6
|
// Until the site is bound to a Studio project the form renders nothing and the
|
|
7
|
-
// contact details still show
|
|
7
|
+
// contact details still show — and a section left with its heading alone is not
|
|
8
|
+
// drawn (a heading over a form that is not there). When the owner chose another home for forms at
|
|
8
9
|
// migration (site.config.ts `features.forms`), the same place holds a form
|
|
9
10
|
// that posts to their form service, an address to write to, or a link to the
|
|
10
11
|
// form on WordPress.
|
|
@@ -12,6 +13,7 @@ import { tv } from 'tailwind-variants'
|
|
|
12
13
|
import Section from '../_shared/Section.astro'
|
|
13
14
|
import StudioForm from '../../studio/StudioForm.astro'
|
|
14
15
|
import { formHome } from '../../../lib/features'
|
|
16
|
+
import { contactSectionBare } from './contact-form'
|
|
15
17
|
|
|
16
18
|
export interface ContactDetail {
|
|
17
19
|
/** What the detail is (Phone, Email); a source's icon list often has none. */
|
|
@@ -69,6 +71,7 @@ interface Props {
|
|
|
69
71
|
const { model, heading, intro, formHeading, details = [], layout, align, tone, id = 'contact' } = Astro.props
|
|
70
72
|
// Nothing to render (Studio not bound yet): a split would leave an empty column — the details stand alone.
|
|
71
73
|
const formShown = formHome(model) !== null
|
|
74
|
+
const bare = contactSectionBare({ formShown, intro, details })
|
|
72
75
|
const s = contact({ layout: formShown ? layout : 'stacked', align, tone })
|
|
73
76
|
const headingId = heading ? `${id}-title` : undefined
|
|
74
77
|
// A description list needs a term for every detail; an icon list carried from the source has values only.
|
|
@@ -77,6 +80,7 @@ const LINK = 'underline decoration-line underline-offset-4 hover:decoration-curr
|
|
|
77
80
|
// One level under the section heading, or the section's heading when there is none.
|
|
78
81
|
const FormHeading = heading ? 'h3' : 'h2'
|
|
79
82
|
---
|
|
83
|
+
{!bare && (
|
|
80
84
|
<Section tone={tone} spacing="md" id={id} aria-labelledby={headingId}>
|
|
81
85
|
<div class={s.grid()}>
|
|
82
86
|
{(heading || intro || details.length > 0) && (
|
|
@@ -116,3 +120,4 @@ const FormHeading = heading ? 'h3' : 'h2'
|
|
|
116
120
|
: <StudioForm model={model} class={s.form()} />)}
|
|
117
121
|
</div>
|
|
118
122
|
</Section>
|
|
123
|
+
)}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// When the contact section has nothing to show. Its form is drawn only where a home for it exists (Studio bound, the
|
|
2
|
+
// WordPress page known, a service address that is https); until then the section stands on its heading, introduction
|
|
3
|
+
// and details. A section left with a heading ALONE titles a form that is not there — the page would print "Tell us about
|
|
4
|
+
// your project" over empty space — so it is not drawn at all, and appears with its form once the form has a home.
|
|
5
|
+
|
|
6
|
+
export function contactSectionBare(input: { formShown: boolean, intro?: string | undefined, details?: readonly unknown[] | undefined }): boolean {
|
|
7
|
+
return !input.formShown && !input.intro && !(input.details?.length ?? 0)
|
|
8
|
+
}
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
{ "name": "stacked-muted", "props": { "model": "contact-submissions", "heading": "Write to us", "layout": "stacked", "tone": "muted", "id": "write" } },
|
|
15
|
+
{ "name": "stacked-muted", "props": { "model": "contact-submissions", "heading": "Write to us", "intro": "We read every message and answer within two working days.", "layout": "stacked", "tone": "muted", "id": "write" } },
|
|
16
16
|
{ "name": "stacked-start", "props": { "model": "contact-submissions", "intro": "Tell us what you make and when you want to launch.", "details": [{ "value": "Studio 4, Harbour Lane" }], "layout": "stacked", "align": "start", "id": "start" } },
|
|
17
17
|
{ "name": "split-inverse", "props": { "model": "contact-submissions", "heading": "Press", "tone": "inverse", "id": "press", "details": [{ "label": "Press office", "value": "press@northwind.example", "href": "mailto:press@northwind.example" }] } },
|
|
18
|
-
{ "name": "stacked-accent", "props": { "model": "newsletter-requests", "heading": "Request a print copy", "layout": "stacked", "tone": "accent", "id": "print" } },
|
|
18
|
+
{ "name": "stacked-accent", "props": { "model": "newsletter-requests", "heading": "Request a print copy", "intro": "Print copies ship in the first week of each quarter.", "layout": "stacked", "tone": "accent", "id": "print" } },
|
|
19
19
|
{ "name": "form-heading", "props": { "model": "contact-submissions", "heading": "Contact", "intro": "Tell us where you are and what you need.", "formHeading": "Tell us about your project", "details": [{ "label": "Address", "value": "12 Harbour Street, Leith" }] } }
|
|
20
20
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "contact-form",
|
|
3
3
|
"name": "Contact form",
|
|
4
|
-
"description": "The contact section: heading, introduction, contact details (email, phone, address) and a Contentrain Studio form — fields, spam protection and notifications set in Studio, submissions reviewed there. Replaces form plugins; renders the details alone until the site is bound to a Studio project. When the owner chose another home at migration (site.config.ts `features.forms`) the form posts to their form service, or the section shows an address to write to or a link to the form on WordPress.",
|
|
4
|
+
"description": "The contact section: heading, introduction, contact details (email, phone, address) and a Contentrain Studio form — fields, spam protection and notifications set in Studio, submissions reviewed there. Replaces form plugins; renders the details alone until the site is bound to a Studio project (a section left with only its heading is not drawn: the heading would title a form that is not there). When the owner chose another home at migration (site.config.ts `features.forms`) the form posts to their form service, or the section shows an address to write to or a link to the form on WordPress.",
|
|
5
5
|
"category": "section",
|
|
6
6
|
"uses": [],
|
|
7
7
|
"shared": ["Section.astro"],
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"divi": ["divi/et_pb_contact_form"],
|
|
27
27
|
"classic": ["classic/contact-form-7", "classic/wpforms", "classic/gravityforms", "classic/ninja-forms"]
|
|
28
28
|
},
|
|
29
|
-
"a11y": "Contact details are a description list when every one has a label, a plain list otherwise; links say what they open. The form's labels, errors and focus handling are Studio's form runtime (FormMount). The section is labelled by its heading."
|
|
29
|
+
"a11y": "Contact details are a description list when every one has a label, a plain list otherwise; links say what they open. The form's labels, errors and focus handling are Studio's form runtime (FormMount). The section is labelled by its heading. Without a form to show and with no introduction or details, the section is not drawn at all."
|
|
30
30
|
}
|
|
@@ -6,6 +6,7 @@ import Button from '../_shared/Button.astro'
|
|
|
6
6
|
import KitImage from '../_shared/KitImage.astro'
|
|
7
7
|
import Section from '../_shared/Section.astro'
|
|
8
8
|
import type { ActionInput, ImageInput } from '../_shared/types'
|
|
9
|
+
import { coverHeight as heightOf, headingStyle as styleOf } from './hero'
|
|
9
10
|
|
|
10
11
|
const hero = tv({
|
|
11
12
|
slots: {
|
|
@@ -36,6 +37,8 @@ const hero = tv({
|
|
|
36
37
|
// How wide a cover runs: the full window, or the reading column — a WordPress cover block that is not
|
|
37
38
|
// alignfull sits in the content column, the page title above it.
|
|
38
39
|
width: { full: {}, content: {} },
|
|
40
|
+
// The heading's size: the layout's own scale, or the site's size for its level (set inline, see ./hero).
|
|
41
|
+
headingScale: { default: {}, theme: {} },
|
|
39
42
|
},
|
|
40
43
|
compoundVariants: [
|
|
41
44
|
// After the layout's own heights, so a boxed cover keeps WordPress's 430px default.
|
|
@@ -45,7 +48,7 @@ const hero = tv({
|
|
|
45
48
|
{ leadAlign: 'start', class: { lead: 'mx-0 max-w-none self-stretch text-start' } },
|
|
46
49
|
{ actionsAlign: 'start', class: { actions: 'justify-start self-stretch' } },
|
|
47
50
|
],
|
|
48
|
-
defaultVariants: { layout: 'split', tone: 'default', align: 'center', leadAlign: 'inherit', actionsAlign: 'inherit', width: 'full' },
|
|
51
|
+
defaultVariants: { layout: 'split', tone: 'default', align: 'center', leadAlign: 'inherit', actionsAlign: 'inherit', width: 'full', headingScale: 'default' },
|
|
49
52
|
})
|
|
50
53
|
|
|
51
54
|
interface Props {
|
|
@@ -67,13 +70,20 @@ interface Props {
|
|
|
67
70
|
width?: 'full' | 'content' | undefined
|
|
68
71
|
tone?: 'default' | 'muted' | 'inverse' | 'accent' | undefined
|
|
69
72
|
id?: string | undefined
|
|
73
|
+
/** A cover's own height in pixels, as the source sets it (`520`); absent, the layout's default. Layout cover only. */
|
|
74
|
+
minHeight?: number | undefined
|
|
75
|
+
/** `theme`: the heading takes the site's size for its level (the source's own `h1` size), not the layout's scale. */
|
|
76
|
+
headingScale?: 'default' | 'theme' | undefined
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
|
|
73
|
-
const
|
|
79
|
+
|
|
80
|
+
const { heading, level = 1, eyebrow, lead, actions = [], image, layout = 'split', align, leadAlign, actionsAlign, width = 'full', tone, id, minHeight, headingScale } = Astro.props
|
|
81
|
+
const s = hero({ layout, align, leadAlign, actionsAlign, width, tone, headingScale })
|
|
74
82
|
const Heading = level === 1 ? 'h1' : 'h2'
|
|
75
83
|
const headingId = id ? `${id}-title` : undefined
|
|
76
84
|
const cover = layout === 'cover' && image
|
|
85
|
+
const coverHeight = cover ? heightOf(minHeight) : undefined
|
|
86
|
+
const headingStyle = styleOf(headingScale, level)
|
|
77
87
|
---
|
|
78
88
|
{cover && width === 'content'
|
|
79
89
|
? (
|
|
@@ -82,10 +92,10 @@ const cover = layout === 'cover' && image
|
|
|
82
92
|
<KitImage image={image} priority sizes="(min-width: 768px) 46rem, 100vw" class="absolute inset-0 -z-10 h-full w-full object-cover" />
|
|
83
93
|
<div class="absolute inset-0 -z-10 bg-ink/60" aria-hidden="true" />
|
|
84
94
|
<div class="px-6 py-10 md:px-10">
|
|
85
|
-
<div class={s.grid()}>
|
|
95
|
+
<div class={s.grid()} style={coverHeight ? `min-height: ${coverHeight}` : undefined}>
|
|
86
96
|
<div class={s.copy()}>
|
|
87
97
|
{eyebrow && <p class={s.eyebrow()}>{eyebrow}</p>}
|
|
88
|
-
<Heading id={headingId} class={s.heading()}>{heading}</Heading>
|
|
98
|
+
<Heading id={headingId} class={s.heading()} style={headingStyle}>{heading}</Heading>
|
|
89
99
|
{lead && <p class={s.lead()} data-kit-text>{lead}</p>}
|
|
90
100
|
{actions.length > 0 && <div class={s.actions()}>{actions.map(action => <Button action={action} size="lg" />)}</div>}
|
|
91
101
|
</div>
|
|
@@ -100,10 +110,10 @@ const cover = layout === 'cover' && image
|
|
|
100
110
|
<KitImage image={image} priority sizes="100vw" class="absolute inset-0 -z-10 h-full w-full object-cover" />
|
|
101
111
|
<div class="absolute inset-0 -z-10 bg-ink/60" aria-hidden="true" />
|
|
102
112
|
<div class="container-page py-16 md:py-28">
|
|
103
|
-
<div class={s.grid()}>
|
|
113
|
+
<div class={s.grid()} style={coverHeight ? `min-height: ${coverHeight}` : undefined}>
|
|
104
114
|
<div class={s.copy()}>
|
|
105
115
|
{eyebrow && <p class={s.eyebrow()}>{eyebrow}</p>}
|
|
106
|
-
<Heading id={headingId} class={s.heading()}>{heading}</Heading>
|
|
116
|
+
<Heading id={headingId} class={s.heading()} style={headingStyle}>{heading}</Heading>
|
|
107
117
|
{lead && <p class={s.lead()} data-kit-text>{lead}</p>}
|
|
108
118
|
{actions.length > 0 && <div class={s.actions()}>{actions.map(action => <Button action={action} size="lg" />)}</div>}
|
|
109
119
|
</div>
|
|
@@ -117,7 +127,7 @@ const cover = layout === 'cover' && image
|
|
|
117
127
|
<div class={s.grid({ class: image ? undefined : 'md:grid-cols-1' })}>
|
|
118
128
|
<div class={s.copy()}>
|
|
119
129
|
{eyebrow && <p class={s.eyebrow()}>{eyebrow}</p>}
|
|
120
|
-
<Heading id={headingId} class={s.heading()}>{heading}</Heading>
|
|
130
|
+
<Heading id={headingId} class={s.heading()} style={headingStyle}>{heading}</Heading>
|
|
121
131
|
{lead && <p class={s.lead()} data-kit-text>{lead}</p>}
|
|
122
132
|
{actions.length > 0 && <div class={s.actions()}>{actions.map(action => <Button action={action} size="lg" />)}</div>}
|
|
123
133
|
</div>
|
|
@@ -167,5 +167,29 @@
|
|
|
167
167
|
"level": 2,
|
|
168
168
|
"actionsAlign": "start"
|
|
169
169
|
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "cover-content-theme-size",
|
|
173
|
+
"props": {
|
|
174
|
+
"heading": "Independent cinema, a neighbourhood hall",
|
|
175
|
+
"lead": "A hundred and twenty seats, fresh popcorn.",
|
|
176
|
+
"layout": "cover",
|
|
177
|
+
"actions": [
|
|
178
|
+
{
|
|
179
|
+
"label": "This week's programme",
|
|
180
|
+
"href": "/programme/"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"image": {
|
|
184
|
+
"src": "/kit-fixtures/photo-1.svg",
|
|
185
|
+
"alt": "",
|
|
186
|
+
"width": 1600,
|
|
187
|
+
"height": 900
|
|
188
|
+
},
|
|
189
|
+
"width": "content",
|
|
190
|
+
"level": 2,
|
|
191
|
+
"minHeight": 520,
|
|
192
|
+
"headingScale": "theme"
|
|
193
|
+
}
|
|
170
194
|
}
|
|
171
195
|
]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// A cover's height reaches the style attribute only as a whole number of pixels: a value from a plan is data, not CSS.
|
|
2
|
+
export const coverHeight = (value: number | undefined): string | undefined => (Number.isInteger(value) && value! >= 100 && value! <= 2000 ? `${value}px` : undefined)
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `theme`: the heading's size is the site's for its level, the one the source's own `h1`/`h2` has (`--text-heading-1`,
|
|
6
|
+
* fluid where the theme's is); the layout's scale is the fallback while the site declares none.
|
|
7
|
+
*/
|
|
8
|
+
export const headingStyle = (scale: 'default' | 'theme' | undefined, level: 1 | 2): string | undefined =>
|
|
9
|
+
scale === 'theme' ? `font-size: var(--text-heading-${level}, var(--text-5xl)); line-height: var(--leading-heading, 1.2)` : undefined
|
|
@@ -61,6 +61,14 @@
|
|
|
61
61
|
],
|
|
62
62
|
"default": "full",
|
|
63
63
|
"description": "Layout cover only. full: the image runs the full window width. content: the cover sits in the reading column, as a WordPress cover block that is not alignfull does under the page title."
|
|
64
|
+
},
|
|
65
|
+
"headingScale": {
|
|
66
|
+
"options": [
|
|
67
|
+
"default",
|
|
68
|
+
"theme"
|
|
69
|
+
],
|
|
70
|
+
"default": "default",
|
|
71
|
+
"description": "default: the layout's own type scale. theme: the heading takes the site's size for its level (`--text-heading-1` for the page-opening hero, `-2` otherwise), as the source's own h1 does under a block theme."
|
|
64
72
|
}
|
|
65
73
|
},
|
|
66
74
|
"props": {
|
|
@@ -159,6 +167,13 @@
|
|
|
159
167
|
"type": "string",
|
|
160
168
|
"content": false,
|
|
161
169
|
"description": "Anchor id of the section; the heading gets `<id>-title`."
|
|
170
|
+
},
|
|
171
|
+
"minHeight": {
|
|
172
|
+
"type": "integer",
|
|
173
|
+
"content": false,
|
|
174
|
+
"min": 100,
|
|
175
|
+
"max": 2000,
|
|
176
|
+
"description": "Layout cover only: the cover's own height in pixels, as the source sets it (520); absent, the layout's default."
|
|
162
177
|
}
|
|
163
178
|
},
|
|
164
179
|
"slots": {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentrain/astro-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Copy-in Astro components for Contentrain sites (shadcn model): typed props, tailwind-variants, zero JavaScript by default — with a machine-readable catalog",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"mapping"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@contentrain/types": "1.
|
|
45
|
+
"@contentrain/types": "1.41.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^22.10.0",
|