@contentrain/astro-kit 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.
- package/catalog.json +8 -0
- package/components/cta/Cta.astro +11 -3
- package/components/cta/fixtures.json +2 -1
- package/components/cta/meta.json +2 -1
- package/package.json +1 -1
package/catalog.json
CHANGED
|
@@ -657,6 +657,14 @@
|
|
|
657
657
|
],
|
|
658
658
|
"default": "accent",
|
|
659
659
|
"description": "Background. On accent, primary buttons are drawn in the secondary style so they stay visible. none: no fill of its own; the page background shows through (a source colour the palette does not have)."
|
|
660
|
+
},
|
|
661
|
+
"actionsAlign": {
|
|
662
|
+
"options": [
|
|
663
|
+
"inherit",
|
|
664
|
+
"start"
|
|
665
|
+
],
|
|
666
|
+
"default": "inherit",
|
|
667
|
+
"description": "The buttons' alignment. inherit: as the layout sets it. start: at the start edge under centred heading and text (layout centered; a WordPress buttons block with no justification in a centred group). inline and stacked ignore it."
|
|
660
668
|
}
|
|
661
669
|
},
|
|
662
670
|
"props": {
|
package/components/cta/Cta.astro
CHANGED
|
@@ -28,6 +28,11 @@ const cta = tv({
|
|
|
28
28
|
// accent/accent-ink is only ~5:1 — dimming text on it drops body copy under 4.5:1 (WCAG 1.4.3), so accent keeps it at full strength.
|
|
29
29
|
// none: no fill of its own — the page background and text colour show through.
|
|
30
30
|
tone: { default: {}, muted: {}, inverse: {}, accent: { body: 'opacity-100' }, none: {} },
|
|
31
|
+
// The buttons' own alignment: `start` keeps them at the start edge under centred text (a WordPress buttons block
|
|
32
|
+
// with no justification sits left in a group whose heading and paragraph are centred). The row is the text's
|
|
33
|
+
// column, as WordPress's content width is, not the whole section. Only centred needs it: inline and stacked
|
|
34
|
+
// already start them there.
|
|
35
|
+
actionsAlign: { inherit: {}, start: {} },
|
|
31
36
|
},
|
|
32
37
|
compoundVariants: [
|
|
33
38
|
// A card carries the tone itself, on a plain section; a plain card still needs a surface to read as one.
|
|
@@ -35,8 +40,9 @@ const cta = tv({
|
|
|
35
40
|
{ frame: 'card', tone: 'muted', class: { box: 'border-transparent bg-surface-muted text-ink' } },
|
|
36
41
|
{ frame: 'card', tone: 'inverse', class: { box: 'border-transparent bg-ink text-surface' } },
|
|
37
42
|
{ frame: 'card', tone: 'accent', class: { box: 'border-transparent bg-accent text-accent-ink' } },
|
|
43
|
+
{ layout: 'centered', actionsAlign: 'start', class: { actions: 'w-full max-w-2xl justify-start' } },
|
|
38
44
|
],
|
|
39
|
-
defaultVariants: { layout: 'inline', frame: 'full', tone: 'accent' },
|
|
45
|
+
defaultVariants: { layout: 'inline', frame: 'full', tone: 'accent', actionsAlign: 'inherit' },
|
|
40
46
|
})
|
|
41
47
|
|
|
42
48
|
interface Props {
|
|
@@ -46,11 +52,13 @@ interface Props {
|
|
|
46
52
|
layout?: 'inline' | 'centered' | 'stacked' | undefined
|
|
47
53
|
frame?: 'full' | 'card' | undefined
|
|
48
54
|
tone?: 'default' | 'muted' | 'inverse' | 'accent' | 'none' | undefined
|
|
55
|
+
/** The buttons' alignment: as the layout sets it, or at the start edge under centred text (layout centered). */
|
|
56
|
+
actionsAlign?: 'inherit' | 'start' | undefined
|
|
49
57
|
id?: string | undefined
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
const { heading, body, actions, layout, frame, tone = 'accent', id } = Astro.props
|
|
53
|
-
const s = cta({ layout, frame, tone })
|
|
60
|
+
const { heading, body, actions, layout, frame, tone = 'accent', actionsAlign, id } = Astro.props
|
|
61
|
+
const s = cta({ layout, frame, tone, actionsAlign })
|
|
54
62
|
const headingId = id ? `${id}-title` : undefined
|
|
55
63
|
// On the accent background the primary button (accent) would vanish: it is drawn as the secondary style there.
|
|
56
64
|
const onAccent = (action: ActionInput): ActionInput => ({ label: action.label, href: action.href, newTab: action.newTab, style: 'secondary' })
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
{ "name": "centered-inverse", "props": { "heading": "Planning a trip?", "body": "Start with the guides readers use most.", "layout": "centered", "tone": "inverse", "actions": [{ "label": "Popular guides", "href": "/guides/" }, { "label": "Ask a question", "href": "/contact/", "style": "ghost" }] } },
|
|
4
4
|
{ "name": "card-default", "props": { "heading": "Write for the journal", "body": "We publish reader essays every season.", "frame": "card", "tone": "default", "actions": [{ "label": "Pitch an essay", "href": "/pitch/" }] } },
|
|
5
5
|
{ "name": "card-muted", "props": { "heading": "Support independent travel writing", "frame": "card", "tone": "muted", "layout": "centered", "actions": [{ "label": "Become a member", "href": "/members/" }] } },
|
|
6
|
-
{ "name": "stacked-none", "props": { "heading": "Ready when you are", "body": "Tell us where you want to go and we will send a first plan within a week.", "layout": "stacked", "tone": "none", "actions": [{ "label": "Start planning", "href": "/contact/" }] } }
|
|
6
|
+
{ "name": "stacked-none", "props": { "heading": "Ready when you are", "body": "Tell us where you want to go and we will send a first plan within a week.", "layout": "stacked", "tone": "none", "actions": [{ "label": "Start planning", "href": "/contact/" }] } },
|
|
7
|
+
{ "name": "centered-actions-start", "props": { "heading": "See what is on this week", "body": "New films every Thursday, and a late show on Saturdays.", "layout": "centered", "tone": "inverse", "actionsAlign": "start", "actions": [{ "label": "Programme", "href": "/programme/" }] } }
|
|
7
8
|
]
|
package/components/cta/meta.json
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"variants": {
|
|
9
9
|
"layout": { "options": ["inline", "centered", "stacked"], "default": "inline", "description": "inline: text left, buttons right on wide screens. centered: everything centred. stacked: heading, text and buttons in one column at the start edge on every width." },
|
|
10
10
|
"frame": { "options": ["full", "card"], "default": "full", "description": "full: the tone fills the section. card: a rounded box in a plain section carries the tone." },
|
|
11
|
-
"tone": { "options": ["default", "muted", "inverse", "accent", "none"], "default": "accent", "description": "Background. On accent, primary buttons are drawn in the secondary style so they stay visible. none: no fill of its own; the page background shows through (a source colour the palette does not have)." }
|
|
11
|
+
"tone": { "options": ["default", "muted", "inverse", "accent", "none"], "default": "accent", "description": "Background. On accent, primary buttons are drawn in the secondary style so they stay visible. none: no fill of its own; the page background shows through (a source colour the palette does not have)." },
|
|
12
|
+
"actionsAlign": { "options": ["inherit", "start"], "default": "inherit", "description": "The buttons' alignment. inherit: as the layout sets it. start: at the start edge under centred heading and text (layout centered; a WordPress buttons block with no justification in a centred group). inline and stacked ignore it." }
|
|
12
13
|
},
|
|
13
14
|
"props": {
|
|
14
15
|
"heading": { "type": "string", "label": "Heading", "required": true, "description": "The call's heading (Divi CTA title, Elementor call-to-action title)." },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentrain/astro-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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",
|