@contentrain/astro-kit 0.21.1 → 0.23.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 +46 -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/header/Header.astro +22 -8
- package/components/header/meta.json +6 -0
- 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",
|
|
@@ -1490,6 +1491,31 @@
|
|
|
1490
1491
|
"type": "string",
|
|
1491
1492
|
"description": "The site name's size where the source theme sets its own (a CSS length)."
|
|
1492
1493
|
},
|
|
1494
|
+
"bordered": {
|
|
1495
|
+
"type": "boolean",
|
|
1496
|
+
"default": true,
|
|
1497
|
+
"description": "The line under the bar on the default tone; false where the source's header draws none."
|
|
1498
|
+
},
|
|
1499
|
+
"brandWeight": {
|
|
1500
|
+
"type": "string",
|
|
1501
|
+
"description": "The site name's weight where the source theme sets its own (a CSS font-weight)."
|
|
1502
|
+
},
|
|
1503
|
+
"brandTracking": {
|
|
1504
|
+
"type": "string",
|
|
1505
|
+
"description": "The site name's letter-spacing where the source theme sets its own (a CSS length, or normal)."
|
|
1506
|
+
},
|
|
1507
|
+
"offsetTop": {
|
|
1508
|
+
"type": "string",
|
|
1509
|
+
"description": "Space above the bar where the source's header has its own (a CSS length)."
|
|
1510
|
+
},
|
|
1511
|
+
"padTop": {
|
|
1512
|
+
"type": "string",
|
|
1513
|
+
"description": "Space inside the bar above its content where the source's header has its own (a CSS length)."
|
|
1514
|
+
},
|
|
1515
|
+
"padBottom": {
|
|
1516
|
+
"type": "string",
|
|
1517
|
+
"description": "Space inside the bar below its content where the source's header has its own (a CSS length)."
|
|
1518
|
+
},
|
|
1493
1519
|
"linkNav": {
|
|
1494
1520
|
"type": "boolean",
|
|
1495
1521
|
"default": false,
|
|
@@ -1672,6 +1698,14 @@
|
|
|
1672
1698
|
],
|
|
1673
1699
|
"default": "full",
|
|
1674
1700
|
"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."
|
|
1701
|
+
},
|
|
1702
|
+
"headingScale": {
|
|
1703
|
+
"options": [
|
|
1704
|
+
"default",
|
|
1705
|
+
"theme"
|
|
1706
|
+
],
|
|
1707
|
+
"default": "default",
|
|
1708
|
+
"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
1709
|
}
|
|
1676
1710
|
},
|
|
1677
1711
|
"props": {
|
|
@@ -1770,6 +1804,13 @@
|
|
|
1770
1804
|
"type": "string",
|
|
1771
1805
|
"content": false,
|
|
1772
1806
|
"description": "Anchor id of the section; the heading gets `<id>-title`."
|
|
1807
|
+
},
|
|
1808
|
+
"minHeight": {
|
|
1809
|
+
"type": "integer",
|
|
1810
|
+
"content": false,
|
|
1811
|
+
"min": 100,
|
|
1812
|
+
"max": 2000,
|
|
1813
|
+
"description": "Layout cover only: the cover's own height in pixels, as the source sets it (520); absent, the layout's default."
|
|
1773
1814
|
}
|
|
1774
1815
|
},
|
|
1775
1816
|
"slots": {},
|
|
@@ -1790,7 +1831,8 @@
|
|
|
1790
1831
|
},
|
|
1791
1832
|
"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
1833
|
"files": [
|
|
1793
|
-
"Hero.astro"
|
|
1834
|
+
"Hero.astro",
|
|
1835
|
+
"hero.ts"
|
|
1794
1836
|
],
|
|
1795
1837
|
"contentFields": {
|
|
1796
1838
|
"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
|
}
|
|
@@ -20,13 +20,15 @@ const header = tv({
|
|
|
20
20
|
'brand-left': { inner: 'justify-start [&>nav]:ms-10' },
|
|
21
21
|
},
|
|
22
22
|
tone: {
|
|
23
|
-
default: { root: '
|
|
23
|
+
default: { root: 'bg-surface text-ink' },
|
|
24
24
|
inverse: { root: 'bg-ink text-surface' },
|
|
25
25
|
transparent: { root: 'absolute inset-x-0 top-0 bg-transparent text-surface' },
|
|
26
26
|
},
|
|
27
27
|
position: { static: {}, sticky: { root: 'sticky top-0' } },
|
|
28
|
+
bordered: { true: {}, false: {} },
|
|
28
29
|
},
|
|
29
|
-
|
|
30
|
+
compoundVariants: [{ tone: 'default', bordered: true, class: { root: 'border-b border-line' } }],
|
|
31
|
+
defaultVariants: { layout: 'split', tone: 'default', position: 'static', bordered: true },
|
|
30
32
|
})
|
|
31
33
|
|
|
32
34
|
interface Props {
|
|
@@ -35,6 +37,15 @@ interface Props {
|
|
|
35
37
|
tagline?: string | undefined
|
|
36
38
|
/** The site name's size, where the source theme sets its own (a CSS length). */
|
|
37
39
|
brandSize?: string | undefined
|
|
40
|
+
/** The line under the bar on the default tone; `false` where the source's header draws none. */
|
|
41
|
+
bordered?: boolean | undefined
|
|
42
|
+
/** The site name's weight and letter-spacing, where the source theme sets its own (CSS values). */
|
|
43
|
+
brandWeight?: string | undefined
|
|
44
|
+
brandTracking?: string | undefined
|
|
45
|
+
/** Space above the bar, and inside it above and below the content, where the source's header has its own (CSS lengths). */
|
|
46
|
+
offsetTop?: string | undefined
|
|
47
|
+
padTop?: string | undefined
|
|
48
|
+
padBottom?: string | undefined
|
|
38
49
|
/** The navigation in the site's link colour, as themes that colour every link do (Hello Elementor). */
|
|
39
50
|
linkNav?: boolean | undefined
|
|
40
51
|
logo?: ImageInput | undefined
|
|
@@ -51,17 +62,20 @@ interface Props {
|
|
|
51
62
|
position?: 'static' | 'sticky' | undefined
|
|
52
63
|
}
|
|
53
64
|
|
|
54
|
-
const { siteName, tagline, brandSize, linkNav, logo, showName = true, homeHref = '/', items, action, navLabel, menuLabel, closeLabel, layout, tone, position } = Astro.props
|
|
55
|
-
const { root, inner, brand } = header({ layout, tone, position })
|
|
65
|
+
const { siteName, tagline, brandSize, brandWeight, brandTracking, bordered, offsetTop, padTop, padBottom, linkNav, logo, showName = true, homeHref = '/', items, action, navLabel, menuLabel, closeLabel, layout, tone, position } = Astro.props
|
|
66
|
+
const { root, inner, brand } = header({ layout, tone, position, bordered })
|
|
67
|
+
const rootStyle = offsetTop ? `margin-top: ${offsetTop}` : undefined
|
|
68
|
+
const innerStyle = [padTop && `padding-top: ${padTop}`, padBottom && `padding-bottom: ${padBottom}`].filter(Boolean).join('; ') || undefined
|
|
69
|
+
const brandStyle = [brandSize && `font-size: ${brandSize}`, brandWeight && `font-weight: ${brandWeight}`, brandTracking && `letter-spacing: ${brandTracking}`].filter(Boolean).join('; ') || undefined
|
|
56
70
|
// A tagline under the name keeps its line on a phone, as themes print it: the navigation wraps below.
|
|
57
71
|
const wrap = tagline ? 'flex-wrap md:flex-nowrap' : undefined
|
|
58
72
|
---
|
|
59
|
-
<header class={root()}>
|
|
60
|
-
<div class={inner({ class: wrap })}>
|
|
73
|
+
<header class={root()} style={rootStyle}>
|
|
74
|
+
<div class={inner({ class: wrap })} style={innerStyle}>
|
|
61
75
|
{tagline
|
|
62
76
|
? (
|
|
63
77
|
<div class="flex min-w-0 basis-full flex-col gap-1 md:basis-auto">
|
|
64
|
-
<a href={homeHref} class={brand()} aria-label={showName ? undefined : siteName} style={
|
|
78
|
+
<a href={homeHref} class={brand()} aria-label={showName ? undefined : siteName} style={brandStyle} data-kit-brand>
|
|
65
79
|
{logo && <KitImage image={logo} priority class="h-8 w-auto" sizes="160px" />}
|
|
66
80
|
{showName && <span>{siteName}</span>}
|
|
67
81
|
</a>
|
|
@@ -69,7 +83,7 @@ const wrap = tagline ? 'flex-wrap md:flex-nowrap' : undefined
|
|
|
69
83
|
</div>
|
|
70
84
|
)
|
|
71
85
|
: (
|
|
72
|
-
<a href={homeHref} class={brand()} aria-label={showName ? undefined : siteName} style={
|
|
86
|
+
<a href={homeHref} class={brand()} aria-label={showName ? undefined : siteName} style={brandStyle} data-kit-brand>
|
|
73
87
|
{logo && <KitImage image={logo} priority class="h-8 w-auto" sizes="160px" />}
|
|
74
88
|
{showName && <span>{siteName}</span>}
|
|
75
89
|
</a>
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
"siteName": { "type": "string", "required": true, "description": "Site title (site.title)." },
|
|
15
15
|
"tagline": { "type": "string", "description": "A line under the site name, as themes that print the tagline in the header do (site.tagline)." },
|
|
16
16
|
"brandSize": { "type": "string", "description": "The site name's size where the source theme sets its own (a CSS length)." },
|
|
17
|
+
"bordered": { "type": "boolean", "default": true, "description": "The line under the bar on the default tone; false where the source's header draws none." },
|
|
18
|
+
"brandWeight": { "type": "string", "description": "The site name's weight where the source theme sets its own (a CSS font-weight)." },
|
|
19
|
+
"brandTracking": { "type": "string", "description": "The site name's letter-spacing where the source theme sets its own (a CSS length, or normal)." },
|
|
20
|
+
"offsetTop": { "type": "string", "description": "Space above the bar where the source's header has its own (a CSS length)." },
|
|
21
|
+
"padTop": { "type": "string", "description": "Space inside the bar above its content where the source's header has its own (a CSS length)." },
|
|
22
|
+
"padBottom": { "type": "string", "description": "Space inside the bar below its content where the source's header has its own (a CSS length)." },
|
|
17
23
|
"linkNav": { "type": "boolean", "default": false, "description": "The navigation in the site's link colour, as themes that colour every link do." },
|
|
18
24
|
"logo": { "type": "object", "fields": { "src": { "type": "image", "required": true }, "alt": { "type": "string", "required": true }, "width": { "type": "integer" }, "height": { "type": "integer" } }, "description": "Logo image (site.logo)." },
|
|
19
25
|
"showName": { "type": "boolean", "default": true, "description": "Show the site name next to the logo." },
|
|
@@ -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.23.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.42.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^22.10.0",
|