@sinnstack/ui 0.2.0 → 0.3.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/CHANGELOG.md +74 -0
- package/README.md +6 -4
- package/docs/blocks.md +373 -364
- package/docs/data.md +128 -128
- package/docs/finishes.md +165 -0
- package/docs/primitives.md +4 -4
- package/docs/seo.md +191 -187
- package/package.json +15 -24
- package/src/blocks/BlockRenderer.astro +13 -7
- package/src/blocks/CTABanner.astro +8 -8
- package/src/blocks/CTAPair.astro +9 -9
- package/src/blocks/CardGrid.astro +7 -7
- package/src/blocks/ConsentEmbed.astro +1 -1
- package/src/blocks/ConsentManager.astro +1 -1
- package/src/blocks/ContactCard.astro +14 -14
- package/src/blocks/ContactForm.astro +4 -4
- package/src/blocks/ErrorPage.astro +1 -1
- package/src/blocks/FAQ.astro +9 -9
- package/src/blocks/FeatureGrid.astro +7 -7
- package/src/blocks/Hero.astro +11 -11
- package/src/blocks/HeroCarousel.astro +11 -11
- package/src/blocks/HighlightCards.astro +10 -10
- package/src/blocks/LocationHours.astro +14 -14
- package/src/blocks/LogoCloud.astro +7 -7
- package/src/blocks/MaintenancePage.astro +8 -3
- package/src/blocks/MediaText.astro +12 -12
- package/src/blocks/PageHeader.astro +9 -9
- package/src/blocks/ProseSection.astro +8 -8
- package/src/blocks/Reviews.astro +11 -11
- package/src/blocks/RichText.astro +58 -57
- package/src/blocks/StatsBand.astro +117 -117
- package/src/blocks/Steps.astro +9 -9
- package/src/blocks/Testimonials.astro +13 -13
- package/src/blocks/cms/card-grid.ts +48 -80
- package/src/blocks/cms/consent.ts +1 -30
- package/src/blocks/cms/contact-card.ts +4 -46
- package/src/blocks/cms/contact-form.ts +2 -20
- package/src/blocks/cms/cta-banner.ts +2 -23
- package/src/blocks/cms/cta-pair.ts +4 -37
- package/src/blocks/cms/data-base.ts +2 -4
- package/src/blocks/cms/data.ts +19 -19
- package/src/blocks/cms/faq.ts +4 -36
- package/src/blocks/cms/feature-grid.ts +47 -80
- package/src/blocks/cms/fixtures.ts +591 -599
- package/src/blocks/cms/hero-carousel.ts +4 -48
- package/src/blocks/cms/hero.ts +2 -46
- package/src/blocks/cms/highlight-cards.ts +4 -39
- package/src/blocks/cms/images.ts +1 -2
- package/src/blocks/cms/index.ts +59 -87
- package/src/blocks/cms/location-hours.ts +3 -85
- package/src/blocks/cms/logo-cloud.ts +36 -62
- package/src/blocks/cms/media-text.ts +2 -20
- package/src/blocks/cms/page-header.ts +27 -49
- package/src/blocks/cms/pages.ts +35 -81
- package/src/blocks/cms/prose-section.ts +2 -22
- package/src/blocks/cms/reviews.ts +5 -56
- package/src/blocks/cms/schema-dsl.ts +134 -0
- package/src/blocks/cms/schema.ts +794 -0
- package/src/blocks/cms/shared.ts +63 -115
- package/src/blocks/cms/stats-band.ts +35 -61
- package/src/blocks/cms/steps.ts +4 -31
- package/src/blocks/cms/testimonials.ts +4 -38
- package/src/blocks/cms/topbar.ts +4 -41
- package/src/blocks/cms/types.ts +1 -37
- package/src/blocks/consent.ts +2 -2
- package/src/blocks/index.ts +2 -2
- package/src/blocks/internal/Actions.astro +11 -5
- package/src/blocks/internal/BlockHeader.astro +7 -7
- package/src/blocks/internal/Placeholder.astro +3 -3
- package/src/blocks/internal/fields.ts +18 -0
- package/src/blocks/internal/registry-contract.ts +67 -0
- package/src/blocks/internal/util.ts +4 -4
- package/src/blocks/lib/contact.ts +10 -4
- package/src/blocks/lib/faq.ts +1 -1
- package/src/blocks/lib/markdown.ts +350 -0
- package/src/blocks/lib/rich-text.ts +132 -143
- package/src/blocks/scripts/consent-manager.ts +1 -1
- package/src/blocks/scripts/consent-store.ts +1 -1
- package/src/blocks/scripts/hours.ts +3 -2
- package/src/blocks/types.ts +33 -23
- package/src/data/ChartContainer.astro +2 -1
- package/src/data/cms.ts +130 -190
- package/src/data/lib/chart.ts +13 -4
- package/src/data/schema.ts +65 -0
- package/src/finishes/aurora.css +75 -0
- package/src/finishes/autumn.css +87 -0
- package/src/finishes/blueprint.css +69 -0
- package/src/finishes/brutalist.css +55 -0
- package/src/finishes/clay.css +48 -0
- package/src/finishes/day-cycle.css +46 -0
- package/src/finishes/fog.css +71 -0
- package/src/finishes/glass.css +149 -0
- package/src/finishes/holographic.css +91 -0
- package/src/finishes/night.css +77 -0
- package/src/finishes/paper.css +58 -0
- package/src/finishes/polished-glass.css +159 -0
- package/src/finishes/rain.css +84 -0
- package/src/finishes/scripts/day-cycle.ts +30 -0
- package/src/finishes/scripts/holographic.ts +37 -0
- package/src/finishes/scripts/spotlight.ts +30 -0
- package/src/finishes/spotlight.css +41 -0
- package/src/finishes/spring.css +80 -0
- package/src/finishes/terminal.css +49 -0
- package/src/primitives/Divider.astro +1 -1
- package/src/primitives/FocusRing.astro +1 -1
- package/src/primitives/FormField.astro +2 -2
- package/src/primitives/Image.astro +3 -3
- package/src/primitives/Input.astro +4 -2
- package/src/primitives/MetricCard.astro +3 -1
- package/src/primitives/Picture.astro +3 -3
- package/src/primitives/Prose.astro +1 -1
- package/src/primitives/Select.astro +4 -2
- package/src/primitives/Slider.astro +1 -1
- package/src/primitives/Table.astro +1 -1
- package/src/primitives/Textarea.astro +4 -2
- package/src/primitives/Thumbnail.astro +2 -2
- package/src/primitives/index.ts +4 -4
- package/src/primitives/internal/ChoiceField.astro +4 -2
- package/src/primitives/scripts/slider.ts +1 -1
- package/src/primitives/scripts/table-sort.ts +2 -2
- package/src/seo/cms.ts +59 -80
- package/src/seo/index.ts +1 -1
- package/src/seo/integration.ts +40 -3
- package/src/seo/lib/jsonld.ts +10 -2
- package/src/seo/lib/meta.ts +2 -2
- package/src/seo/lib/redirects.ts +14 -4
- package/src/seo/lib/rss.ts +1 -1
- package/src/seo/lib/sitemap.ts +1 -1
- package/src/seo/schema.ts +43 -0
- package/src/blocks/internal/tina.ts +0 -19
- /package/src/blocks/{lib → internal}/consent.ts +0 -0
- /package/src/blocks/{lib → internal}/reviews.ts +0 -0
- /package/src/blocks/{lib → internal}/slug.ts +0 -0
- /package/src/data/{lib → internal}/scale.ts +0 -0
- /package/src/primitives/{lib → internal}/image-plan.ts +0 -0
- /package/src/primitives/{lib → internal}/image.ts +0 -0
- /package/src/primitives/{lib → internal}/slider.ts +0 -0
- /package/src/seo/{lib → internal}/url.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContactFormData } from './data';
|
|
2
|
-
import type { MapContext
|
|
3
|
-
import { clean, compact,
|
|
2
|
+
import type { MapContext } from './types';
|
|
3
|
+
import { clean, compact, mapSettings } from './shared';
|
|
4
4
|
|
|
5
5
|
export const contactFormDefaults: ContactFormData = {
|
|
6
6
|
_template: 'contactForm',
|
|
@@ -12,24 +12,6 @@ export const contactFormDefaults: ContactFormData = {
|
|
|
12
12
|
* Where the form posts is not a CMS field: it comes from PUBLIC_FORM_ENDPOINT (or a site-level
|
|
13
13
|
* `action`), so an editor can't point messages at an unvetted service.
|
|
14
14
|
*/
|
|
15
|
-
export const contactFormTemplate: TinaTemplate = {
|
|
16
|
-
name: 'contactForm',
|
|
17
|
-
label: 'Contact form',
|
|
18
|
-
ui: { defaultItem: contactFormDefaults, itemProps: (item: ContactFormData) => ({ label: `Contact form: ${item?.heading ?? ''}` }) },
|
|
19
|
-
fields: [
|
|
20
|
-
textField('heading', 'Heading'),
|
|
21
|
-
longTextField('description', 'Text'),
|
|
22
|
-
{ type: 'string', name: 'nameFields', label: 'Name fields', options: [{ value: 'split', label: 'First and last name' }, { value: 'single', label: 'One name field' }] },
|
|
23
|
-
{ type: 'string', name: 'phone', label: 'Phone field', options: [{ value: 'optional', label: 'Optional' }, { value: 'required', label: 'Required' }, { value: 'hidden', label: 'Hidden' }] },
|
|
24
|
-
textField('messageLabel', 'Message label', { description: 'Default: “How can we help?”' }),
|
|
25
|
-
textField('messageHint', 'Hint under the message box', { description: 'E.g. “Please don’t include passwords or API keys.”' }),
|
|
26
|
-
textField('note', 'Small print beside the button', { description: 'E.g. “We reply within one business day.”' }),
|
|
27
|
-
textField('submitLabel', 'Button label', { description: 'Default: “Send message”.' }),
|
|
28
|
-
textField('fallbackPhone', 'Phone to show if online messages aren’t connected'),
|
|
29
|
-
textField('fallbackEmail', 'Email to show if online messages aren’t connected'),
|
|
30
|
-
settingsField(),
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
15
|
|
|
34
16
|
export function contactFormToProps(d: ContactFormData, ctx: MapContext) {
|
|
35
17
|
const { anchor, align, background, tone, spacing } = mapSettings(d.settings);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CtaBannerData } from './data';
|
|
2
|
-
import type { MapContext
|
|
3
|
-
import {
|
|
2
|
+
import type { MapContext } from './types';
|
|
3
|
+
import { clean, compact, mapActions, mapSettings, upgrade } from './shared';
|
|
4
4
|
|
|
5
5
|
export const ctaBannerDefaults: CtaBannerData = {
|
|
6
6
|
_template: 'ctaBanner',
|
|
@@ -10,27 +10,6 @@ export const ctaBannerDefaults: CtaBannerData = {
|
|
|
10
10
|
actions: [{ label: 'Contact us', href: '/contact', style: 'solid' }],
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export const ctaBannerTemplate: TinaTemplate = {
|
|
14
|
-
name: 'ctaBanner',
|
|
15
|
-
label: 'Call to action',
|
|
16
|
-
ui: { defaultItem: ctaBannerDefaults, itemProps: (item: CtaBannerData) => ({ label: `CTA: ${item?.heading ?? ''}` }) },
|
|
17
|
-
fields: [
|
|
18
|
-
textField('heading', 'Heading', { required: true }),
|
|
19
|
-
longTextField('description', 'Supporting text'),
|
|
20
|
-
actionsField(2),
|
|
21
|
-
textField('note', 'Small print'),
|
|
22
|
-
{
|
|
23
|
-
type: 'string',
|
|
24
|
-
name: 'variant',
|
|
25
|
-
label: 'Style',
|
|
26
|
-
options: [{ value: 'solid', label: 'Solid' }, { value: 'soft', label: 'Tinted' }, { value: 'outline', label: 'Outlined' }],
|
|
27
|
-
},
|
|
28
|
-
{ type: 'string', name: 'tone', label: 'Color', options: [{ value: 'accent', label: 'Brand' }, { value: 'neutral', label: 'Neutral' }] },
|
|
29
|
-
{ type: 'boolean', name: 'bleed', label: 'Full width band' },
|
|
30
|
-
settingsField({ background: false }),
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
|
|
34
13
|
export function ctaBannerToProps(d: CtaBannerData, ctx: MapContext) {
|
|
35
14
|
const { background: _bg, tone: _tone, ...settings } = mapSettings(d.settings);
|
|
36
15
|
return compact({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CtaPanelItem } from '../types';
|
|
2
2
|
import type { CtaPairData } from './data';
|
|
3
|
-
import type { MapContext
|
|
4
|
-
import {
|
|
3
|
+
import type { MapContext } from './types';
|
|
4
|
+
import { clean, compact, mapActions, mapSettings, withFields } from './shared';
|
|
5
5
|
|
|
6
6
|
export const ctaPairDefaults: CtaPairData = {
|
|
7
7
|
_template: 'ctaPair',
|
|
@@ -12,44 +12,11 @@ export const ctaPairDefaults: CtaPairData = {
|
|
|
12
12
|
],
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const ctaPairTemplate: TinaTemplate = {
|
|
16
|
-
name: 'ctaPair',
|
|
17
|
-
label: 'Two calls to action',
|
|
18
|
-
ui: { defaultItem: ctaPairDefaults, itemProps: (item: CtaPairData) => ({ label: `CTA pair: ${item?.items?.[0]?.heading ?? ''}` }) },
|
|
19
|
-
fields: [
|
|
20
|
-
textField('label', 'Section name (for screen readers)', { description: 'E.g. “Get in touch”.' }),
|
|
21
|
-
{
|
|
22
|
-
type: 'object',
|
|
23
|
-
name: 'items',
|
|
24
|
-
label: 'Panels',
|
|
25
|
-
list: true,
|
|
26
|
-
description: 'Two panels, one for each audience.',
|
|
27
|
-
ui: { max: 2, itemProps: (item: { heading?: string }) => ({ label: item?.heading || 'Panel' }), defaultItem: { heading: 'New panel' } },
|
|
28
|
-
fields: [
|
|
29
|
-
textField('heading', 'Heading', { required: true }),
|
|
30
|
-
longTextField('description', 'Text'),
|
|
31
|
-
actionsField(1),
|
|
32
|
-
{ type: 'string', name: 'tone', label: 'Color', options: [{ value: 'accent', label: 'Brand' }, { value: 'neutral', label: 'Neutral' }] },
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
{ type: 'boolean', name: 'bleed', label: 'Full width band', description: 'On by default.' },
|
|
36
|
-
{
|
|
37
|
-
type: 'object',
|
|
38
|
-
name: 'settings',
|
|
39
|
-
label: 'Section settings',
|
|
40
|
-
fields: [
|
|
41
|
-
{ type: 'string', name: 'anchor', label: 'Anchor ID' },
|
|
42
|
-
{ type: 'string', name: 'align', label: 'Alignment', options: [{ value: 'center', label: 'Center' }, { value: 'start', label: 'Start' }] },
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
|
|
48
15
|
export function ctaPairToProps(d: CtaPairData, ctx: MapContext) {
|
|
49
|
-
const items = (d.items
|
|
16
|
+
const items = withFields(d.items, 'items')
|
|
50
17
|
.filter((i) => clean(i?.heading))
|
|
51
18
|
.slice(0, 2)
|
|
52
|
-
.map((i) => compact({ heading: clean(i.heading)!, description: clean(i.description), actions: mapActions(i.actions), tone: i.tone,
|
|
19
|
+
.map((i) => compact({ heading: clean(i.heading)!, description: clean(i.description), actions: mapActions(i.actions), tone: i.tone, field: i._field }) as CtaPanelItem);
|
|
53
20
|
const { anchor, align } = mapSettings(d.settings);
|
|
54
21
|
return compact({
|
|
55
22
|
anchor,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export type { CmsAction, CmsSettings } from './types';
|
|
2
|
-
/**
|
|
3
|
-
export interface
|
|
2
|
+
/** Every stored block carries its template name. */
|
|
3
|
+
export interface BlockSourceLike {
|
|
4
4
|
_template?: string;
|
|
5
|
-
__typename?: string;
|
|
6
|
-
_content_source?: { queryId: string; path: Array<string | number> };
|
|
7
5
|
}
|
package/src/blocks/cms/data.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** CMS data shapes (what
|
|
2
|
-
import type { CmsAction, CmsSettings
|
|
1
|
+
/** CMS data shapes (what the content files store for each block). All fields optional. */
|
|
2
|
+
import type { BlockSourceLike, CmsAction, CmsSettings } from './data-base';
|
|
3
3
|
export type { CmsAction, CmsSettings };
|
|
4
4
|
|
|
5
|
-
interface Base extends
|
|
5
|
+
interface Base extends BlockSourceLike {
|
|
6
6
|
settings?: CmsSettings | null;
|
|
7
7
|
}
|
|
8
8
|
export interface HeroData extends Base {
|
|
@@ -36,7 +36,7 @@ export interface FeatureGridData extends Base {
|
|
|
36
36
|
eyebrow?: string;
|
|
37
37
|
heading?: string;
|
|
38
38
|
description?: string;
|
|
39
|
-
items?: Array<{ title?: string; description?: string; icon?: string; href?: string; badge?: string }
|
|
39
|
+
items?: Array<{ title?: string; description?: string; icon?: string; href?: string; badge?: string }>;
|
|
40
40
|
/** `cards` is an older stored value for `card`. */
|
|
41
41
|
variant?: 'plain' | 'card' | 'divided' | 'cards';
|
|
42
42
|
layout?: 'stacked' | 'inline';
|
|
@@ -48,7 +48,7 @@ export interface CardGridData extends Base {
|
|
|
48
48
|
eyebrow?: string;
|
|
49
49
|
heading?: string;
|
|
50
50
|
description?: string;
|
|
51
|
-
items?: Array<{ title?: string; description?: string; href?: string; image?: string; imageAlt?: string; eyebrow?: string; meta?: string }
|
|
51
|
+
items?: Array<{ title?: string; description?: string; href?: string; image?: string; imageAlt?: string; eyebrow?: string; meta?: string }>;
|
|
52
52
|
layout?: 'grid' | 'list';
|
|
53
53
|
featured?: boolean | null;
|
|
54
54
|
variant?: 'outline' | 'elevated' | 'filled';
|
|
@@ -61,7 +61,7 @@ export interface LogoCloudData extends Base {
|
|
|
61
61
|
_template?: 'logoCloud';
|
|
62
62
|
heading?: string;
|
|
63
63
|
compact?: boolean | null;
|
|
64
|
-
logos?: Array<{ image?: string; name?: string; href?: string }
|
|
64
|
+
logos?: Array<{ image?: string; name?: string; href?: string }>;
|
|
65
65
|
/** Stored as `variant`; maps to LogoCloud's `layout`. */
|
|
66
66
|
variant?: 'grid' | 'strip';
|
|
67
67
|
columns?: '2' | '3' | '4' | '5' | '6';
|
|
@@ -72,7 +72,7 @@ export interface LogoCloudData extends Base {
|
|
|
72
72
|
export interface HeroCarouselData extends Base {
|
|
73
73
|
_template?: 'heroCarousel';
|
|
74
74
|
label?: string;
|
|
75
|
-
slides?: Array<{ eyebrow?: string; heading?: string; description?: string; actions?: CmsAction[]; image?: string }
|
|
75
|
+
slides?: Array<{ eyebrow?: string; heading?: string; description?: string; actions?: CmsAction[]; image?: string }>;
|
|
76
76
|
autoplay?: number | null;
|
|
77
77
|
minHeight?: 'banner' | 'm' | 'l' | 'screen';
|
|
78
78
|
motion?: 'none' | 'zoom';
|
|
@@ -84,7 +84,7 @@ export interface PageHeaderData extends Base {
|
|
|
84
84
|
eyebrow?: string;
|
|
85
85
|
heading?: string;
|
|
86
86
|
description?: string;
|
|
87
|
-
breadcrumbs?: Array<{ label?: string; href?: string }
|
|
87
|
+
breadcrumbs?: Array<{ label?: string; href?: string }>;
|
|
88
88
|
breadcrumbPosition?: 'above' | 'below';
|
|
89
89
|
actions?: CmsAction[];
|
|
90
90
|
}
|
|
@@ -93,7 +93,7 @@ export interface ContactCardData extends Base {
|
|
|
93
93
|
eyebrow?: string;
|
|
94
94
|
heading?: string;
|
|
95
95
|
description?: string;
|
|
96
|
-
items?: Array<{ type?: 'address' | 'phone' | 'fax' | 'email' | 'hours' | 'link'; label?: string; value?: string; href?: string }
|
|
96
|
+
items?: Array<{ type?: 'address' | 'phone' | 'fax' | 'email' | 'hours' | 'link'; label?: string; value?: string; href?: string }>;
|
|
97
97
|
note?: string;
|
|
98
98
|
/** `card` is an older stored value for `outline`. */
|
|
99
99
|
variant?: 'outline' | 'plain' | 'card';
|
|
@@ -104,7 +104,7 @@ export interface StepsData extends Base {
|
|
|
104
104
|
eyebrow?: string;
|
|
105
105
|
heading?: string;
|
|
106
106
|
description?: string;
|
|
107
|
-
items?: Array<{ title?: string; description?: string; icon?: string }
|
|
107
|
+
items?: Array<{ title?: string; description?: string; icon?: string }>;
|
|
108
108
|
marker?: 'number' | 'icon' | 'none';
|
|
109
109
|
layout?: 'row' | 'list';
|
|
110
110
|
/** `cards` is an older stored value for `card`. */
|
|
@@ -125,21 +125,21 @@ export interface MediaTextData extends Base {
|
|
|
125
125
|
export interface CtaPairData extends Base {
|
|
126
126
|
_template?: 'ctaPair';
|
|
127
127
|
label?: string;
|
|
128
|
-
items?: Array<{ heading?: string; description?: string; actions?: CmsAction[]; tone?: 'accent' | 'neutral' }
|
|
128
|
+
items?: Array<{ heading?: string; description?: string; actions?: CmsAction[]; tone?: 'accent' | 'neutral' }>;
|
|
129
129
|
bleed?: boolean | null;
|
|
130
130
|
}
|
|
131
131
|
export interface StatsBandData extends Base {
|
|
132
132
|
_template?: 'statsBand';
|
|
133
133
|
heading?: string;
|
|
134
134
|
label?: string;
|
|
135
|
-
items?: Array<{ value?: string; label?: string; icon?: string }
|
|
135
|
+
items?: Array<{ value?: string; label?: string; icon?: string }>;
|
|
136
136
|
image?: string;
|
|
137
137
|
tone?: 'accent' | 'neutral';
|
|
138
138
|
}
|
|
139
139
|
export interface HighlightCardsData extends Base {
|
|
140
140
|
_template?: 'highlightCards';
|
|
141
141
|
label?: string;
|
|
142
|
-
items?: Array<{ heading?: string; description?: string; points?: string[]; actions?: CmsAction[]; tone?: string }
|
|
142
|
+
items?: Array<{ heading?: string; description?: string; points?: string[]; actions?: CmsAction[]; tone?: string }>;
|
|
143
143
|
overlap?: boolean | null;
|
|
144
144
|
gap?: 'none' | 'm';
|
|
145
145
|
}
|
|
@@ -165,7 +165,7 @@ export interface TopbarData {
|
|
|
165
165
|
/** `subtle` is an older stored value: it now lives in `background`. */
|
|
166
166
|
tone?: 'neutral' | 'accent' | 'subtle';
|
|
167
167
|
}
|
|
168
|
-
/**
|
|
168
|
+
/** Rich text: a root node, or a plain string (blank lines separate paragraphs). */
|
|
169
169
|
export type CmsRichText = import('../lib/rich-text').RichTextValue;
|
|
170
170
|
export interface ProseSectionData extends Base {
|
|
171
171
|
_template?: 'proseSection';
|
|
@@ -181,7 +181,7 @@ export interface FaqData extends Base {
|
|
|
181
181
|
eyebrow?: string;
|
|
182
182
|
heading?: string;
|
|
183
183
|
description?: string;
|
|
184
|
-
items?: Array<{ question?: string; answer?: CmsRichText; anchor?: string }
|
|
184
|
+
items?: Array<{ question?: string; answer?: CmsRichText; anchor?: string }>;
|
|
185
185
|
layout?: 'stacked' | 'split';
|
|
186
186
|
variant?: 'divided' | 'card';
|
|
187
187
|
mode?: 'multiple' | 'single';
|
|
@@ -194,7 +194,7 @@ export interface TestimonialsData extends Base {
|
|
|
194
194
|
heading?: string;
|
|
195
195
|
description?: string;
|
|
196
196
|
items?: Array<
|
|
197
|
-
{ quote?: string; name?: string; role?: string; organization?: string; image?: string; rating?: number | null; sourceLabel?: string; sourceHref?: string }
|
|
197
|
+
{ quote?: string; name?: string; role?: string; organization?: string; image?: string; rating?: number | null; sourceLabel?: string; sourceHref?: string }
|
|
198
198
|
>;
|
|
199
199
|
layout?: 'grid' | 'single';
|
|
200
200
|
variant?: 'card' | 'plain';
|
|
@@ -207,7 +207,7 @@ export interface ReviewsData extends Base {
|
|
|
207
207
|
heading?: string;
|
|
208
208
|
description?: string;
|
|
209
209
|
summary?: { rating?: number | null; count?: number | null; source?: string; href?: string; writeHref?: string } | null;
|
|
210
|
-
items?: Array<{ text?: string; author?: string; rating?: number | null; date?: string; sourceLabel?: string; sourceHref?: string; response?: string }
|
|
210
|
+
items?: Array<{ text?: string; author?: string; rating?: number | null; date?: string; sourceLabel?: string; sourceHref?: string; response?: string }>;
|
|
211
211
|
variant?: 'card' | 'plain';
|
|
212
212
|
columns?: '1' | '2' | '3';
|
|
213
213
|
}
|
|
@@ -220,8 +220,8 @@ export interface LocationHoursData extends Base {
|
|
|
220
220
|
address?: { street?: string; street2?: string; city?: string; region?: string; postalCode?: string; country?: string } | null;
|
|
221
221
|
phone?: string;
|
|
222
222
|
email?: string;
|
|
223
|
-
hours?: Array<{ days?: string[]; opens?: string; closes?: string; closed?: boolean | null }
|
|
224
|
-
special?: Array<{ date?: string; label?: string; opens?: string; closes?: string; closed?: boolean | null }
|
|
223
|
+
hours?: Array<{ days?: string[]; opens?: string; closes?: string; closed?: boolean | null }>;
|
|
224
|
+
special?: Array<{ date?: string; label?: string; opens?: string; closes?: string; closed?: boolean | null }>;
|
|
225
225
|
hoursNote?: string;
|
|
226
226
|
timeZone?: string;
|
|
227
227
|
map?: 'embed' | 'link' | 'none';
|
package/src/blocks/cms/faq.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FaqItem } from '../types';
|
|
2
2
|
import type { FaqData } from './data';
|
|
3
|
-
import type { MapContext
|
|
4
|
-
import {
|
|
3
|
+
import type { MapContext } from './types';
|
|
4
|
+
import { clean, compact, mapActions, mapSettings, withFields } from './shared';
|
|
5
5
|
import { isRichTextEmpty } from '../lib/rich-text';
|
|
6
6
|
|
|
7
7
|
const ANCHOR_RE = /^[a-z][a-z0-9-]*$/;
|
|
@@ -16,42 +16,10 @@ export const faqDefaults: FaqData = {
|
|
|
16
16
|
],
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const faqTemplate: TinaTemplate = {
|
|
20
|
-
name: 'faq',
|
|
21
|
-
label: 'FAQ',
|
|
22
|
-
ui: { defaultItem: faqDefaults, itemProps: (item: FaqData) => ({ label: `FAQ: ${item?.heading ?? ''}` }) },
|
|
23
|
-
fields: [
|
|
24
|
-
textField('eyebrow', 'Eyebrow'),
|
|
25
|
-
textField('heading', 'Heading'),
|
|
26
|
-
longTextField('description', 'Intro text'),
|
|
27
|
-
{
|
|
28
|
-
type: 'object',
|
|
29
|
-
name: 'items',
|
|
30
|
-
label: 'Questions',
|
|
31
|
-
list: true,
|
|
32
|
-
ui: { itemProps: (item: { question?: string }) => ({ label: item?.question || 'Question' }), defaultItem: { question: 'New question?' } },
|
|
33
|
-
fields: [
|
|
34
|
-
textField('question', 'Question', { required: true }),
|
|
35
|
-
{ type: 'rich-text', name: 'answer', label: 'Answer', required: true },
|
|
36
|
-
textField('anchor', 'Link ID (optional)', {
|
|
37
|
-
description: 'Keeps links like /faq#pricing working if you reword the question.',
|
|
38
|
-
ui: { validate: (v: unknown) => (v && !ANCHOR_RE.test(String(v)) ? 'Use lowercase letters, numbers and dashes, starting with a letter.' : undefined) },
|
|
39
|
-
}),
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
{ type: 'string', name: 'layout', label: 'Layout', options: [{ value: 'stacked', label: 'Heading above' }, { value: 'split', label: 'Heading beside' }] },
|
|
43
|
-
{ type: 'string', name: 'variant', label: 'Style', options: [{ value: 'divided', label: 'Lines between' }, { value: 'card', label: 'Boxes' }] },
|
|
44
|
-
{ type: 'string', name: 'mode', label: 'Opening', options: [{ value: 'multiple', label: 'Several answers open at once' }, { value: 'single', label: 'One answer at a time' }] },
|
|
45
|
-
{ type: 'boolean', name: 'openFirst', label: 'Open the first answer' },
|
|
46
|
-
actionsField(2),
|
|
47
|
-
settingsField(),
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
|
|
51
19
|
export function faqToProps(d: FaqData, ctx: MapContext) {
|
|
52
|
-
const items = (d.items
|
|
20
|
+
const items = withFields(d.items, 'items')
|
|
53
21
|
.filter((i) => clean(i?.question) && !isRichTextEmpty(i?.answer))
|
|
54
|
-
.map((i) => compact({ question: clean(i.question)!, answer: i.answer, id: i.anchor && ANCHOR_RE.test(i.anchor) ? i.anchor : undefined,
|
|
22
|
+
.map((i) => compact({ question: clean(i.question)!, answer: i.answer, id: i.anchor && ANCHOR_RE.test(i.anchor) ? i.anchor : undefined, field: i._field }) as FaqItem);
|
|
55
23
|
return compact({
|
|
56
24
|
...mapSettings(d.settings),
|
|
57
25
|
eyebrow: clean(d.eyebrow),
|
|
@@ -1,80 +1,47 @@
|
|
|
1
|
-
import { blockIconNames } from '../icons';
|
|
2
|
-
import type { FeatureGridData } from './data';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{ title: '
|
|
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
|
-
{ type: 'string', name: 'size', label: 'Size', options: [{ value: 's', label: 'Compact' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Large' }] },
|
|
49
|
-
settingsField(),
|
|
50
|
-
],
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export function featureGridToProps(d: FeatureGridData, ctx: MapContext) {
|
|
54
|
-
const items = (d.items ?? [])
|
|
55
|
-
.filter((i) => clean(i?.title))
|
|
56
|
-
.map((i) =>
|
|
57
|
-
compact({
|
|
58
|
-
title: clean(i.title)!,
|
|
59
|
-
description: clean(i.description),
|
|
60
|
-
// Only names from the icon set; never raw markup from the CMS.
|
|
61
|
-
icon: i.icon && (blockIconNames as string[]).includes(i.icon) ? i.icon : undefined,
|
|
62
|
-
href: clean(i.href),
|
|
63
|
-
badge: clean(i.badge),
|
|
64
|
-
tina: i as never,
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
67
|
-
return compact({
|
|
68
|
-
...mapSettings(d.settings),
|
|
69
|
-
eyebrow: clean(d.eyebrow),
|
|
70
|
-
heading: clean(d.heading),
|
|
71
|
-
description: clean(d.description),
|
|
72
|
-
items,
|
|
73
|
-
variant: upgrade(d.variant, { cards: 'card' }),
|
|
74
|
-
layout: d.layout,
|
|
75
|
-
columns: d.columns ? (Number(d.columns) as 1 | 2 | 3 | 4) : undefined,
|
|
76
|
-
size: d.size,
|
|
77
|
-
headingLevel: 2 as const,
|
|
78
|
-
placeholder: ctx.placeholder,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
1
|
+
import { blockIconNames } from '../icons';
|
|
2
|
+
import type { FeatureGridData } from './data';
|
|
3
|
+
import type { FeatureItem } from '../types';
|
|
4
|
+
import type { MapContext } from './types';
|
|
5
|
+
import { safeHref } from '../lib/contact';
|
|
6
|
+
import { clean, compact, mapSettings, upgrade, withFields } from './shared';
|
|
7
|
+
|
|
8
|
+
export const featureGridDefaults: FeatureGridData = {
|
|
9
|
+
_template: 'featureGrid',
|
|
10
|
+
heading: 'What we offer',
|
|
11
|
+
variant: 'plain',
|
|
12
|
+
columns: '3',
|
|
13
|
+
items: [
|
|
14
|
+
{ title: 'First feature', description: 'A sentence about why it matters.', icon: 'check' },
|
|
15
|
+
{ title: 'Second feature', description: 'A sentence about why it matters.', icon: 'clock' },
|
|
16
|
+
{ title: 'Third feature', description: 'A sentence about why it matters.', icon: 'shield' },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function featureGridToProps(d: FeatureGridData, ctx: MapContext) {
|
|
21
|
+
const items = withFields(d.items, 'items')
|
|
22
|
+
.filter((i) => clean(i?.title))
|
|
23
|
+
.map((i) =>
|
|
24
|
+
compact({
|
|
25
|
+
title: clean(i.title)!,
|
|
26
|
+
description: clean(i.description),
|
|
27
|
+
// Only names from the icon set; never raw markup from the CMS.
|
|
28
|
+
icon: i.icon && (blockIconNames as string[]).includes(i.icon) ? i.icon : undefined,
|
|
29
|
+
href: safeHref(i.href),
|
|
30
|
+
badge: clean(i.badge),
|
|
31
|
+
field: i._field,
|
|
32
|
+
}) as FeatureItem,
|
|
33
|
+
);
|
|
34
|
+
return compact({
|
|
35
|
+
...mapSettings(d.settings),
|
|
36
|
+
eyebrow: clean(d.eyebrow),
|
|
37
|
+
heading: clean(d.heading),
|
|
38
|
+
description: clean(d.description),
|
|
39
|
+
items,
|
|
40
|
+
variant: upgrade(d.variant, { cards: 'card' }),
|
|
41
|
+
layout: d.layout,
|
|
42
|
+
columns: d.columns ? (Number(d.columns) as 1 | 2 | 3 | 4) : undefined,
|
|
43
|
+
size: d.size,
|
|
44
|
+
headingLevel: 2 as const,
|
|
45
|
+
placeholder: ctx.placeholder,
|
|
46
|
+
});
|
|
47
|
+
}
|