@sinnstack/ui 0.0.0-stage → 0.2.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 +15 -0
- package/LICENSE +373 -0
- package/README.md +186 -2
- package/docs/blocks.md +364 -0
- package/docs/data.md +128 -0
- package/docs/motion.md +166 -0
- package/docs/primitives.md +510 -0
- package/docs/seo.md +187 -0
- package/docs/tokens.md +122 -0
- package/package.json +141 -3
- package/scripts/check-contrast.mjs +180 -0
- package/src/blocks/BlockRenderer.astro +54 -0
- package/src/blocks/CTABanner.astro +121 -0
- package/src/blocks/CTAPair.astro +110 -0
- package/src/blocks/CardGrid.astro +167 -0
- package/src/blocks/ConsentEmbed.astro +125 -0
- package/src/blocks/ConsentManager.astro +147 -0
- package/src/blocks/ConsentScript.astro +47 -0
- package/src/blocks/ContactCard.astro +164 -0
- package/src/blocks/ContactForm.astro +224 -0
- package/src/blocks/ErrorPage.astro +242 -0
- package/src/blocks/FAQ.astro +135 -0
- package/src/blocks/FeatureGrid.astro +148 -0
- package/src/blocks/Hero.astro +171 -0
- package/src/blocks/HeroCarousel.astro +220 -0
- package/src/blocks/HighlightCards.astro +107 -0
- package/src/blocks/LocationHours.astro +311 -0
- package/src/blocks/LogoCloud.astro +135 -0
- package/src/blocks/MaintenancePage.astro +168 -0
- package/src/blocks/MediaText.astro +177 -0
- package/src/blocks/PageHeader.astro +126 -0
- package/src/blocks/ProseSection.astro +98 -0
- package/src/blocks/Reviews.astro +194 -0
- package/src/blocks/RichText.astro +57 -0
- package/src/blocks/StatsBand.astro +117 -0
- package/src/blocks/Steps.astro +141 -0
- package/src/blocks/Testimonials.astro +144 -0
- package/src/blocks/Topbar.astro +158 -0
- package/src/blocks/cms/card-grid.ts +80 -0
- package/src/blocks/cms/consent.ts +45 -0
- package/src/blocks/cms/contact-card.ts +88 -0
- package/src/blocks/cms/contact-form.ts +55 -0
- package/src/blocks/cms/cta-banner.ts +48 -0
- package/src/blocks/cms/cta-pair.ts +63 -0
- package/src/blocks/cms/data-base.ts +7 -0
- package/src/blocks/cms/data.ts +257 -0
- package/src/blocks/cms/faq.ts +70 -0
- package/src/blocks/cms/feature-grid.ts +80 -0
- package/src/blocks/cms/fixtures.ts +599 -0
- package/src/blocks/cms/hero-carousel.ts +80 -0
- package/src/blocks/cms/hero.ts +77 -0
- package/src/blocks/cms/highlight-cards.ts +76 -0
- package/src/blocks/cms/images.ts +38 -0
- package/src/blocks/cms/index.ts +87 -0
- package/src/blocks/cms/location-hours.ts +149 -0
- package/src/blocks/cms/logo-cloud.ts +62 -0
- package/src/blocks/cms/media-text.ts +44 -0
- package/src/blocks/cms/page-header.ts +49 -0
- package/src/blocks/cms/pages.ts +81 -0
- package/src/blocks/cms/prose-section.ts +45 -0
- package/src/blocks/cms/reviews.ts +101 -0
- package/src/blocks/cms/shared.ts +115 -0
- package/src/blocks/cms/stats-band.ts +61 -0
- package/src/blocks/cms/steps.ts +67 -0
- package/src/blocks/cms/testimonials.ts +80 -0
- package/src/blocks/cms/topbar.ts +64 -0
- package/src/blocks/cms/types.ts +63 -0
- package/src/blocks/consent.ts +14 -0
- package/src/blocks/icons.ts +47 -0
- package/src/blocks/index.ts +42 -0
- package/src/blocks/internal/Actions.astro +29 -0
- package/src/blocks/internal/BlockHeader.astro +45 -0
- package/src/blocks/internal/BlockShell.astro +58 -0
- package/src/blocks/internal/CarouselScript.astro +7 -0
- package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
- package/src/blocks/internal/ConsentManagerScript.astro +7 -0
- package/src/blocks/internal/HoursScript.astro +7 -0
- package/src/blocks/internal/Placeholder.astro +13 -0
- package/src/blocks/internal/RichTextNode.astro +133 -0
- package/src/blocks/internal/StandaloneDocument.astro +53 -0
- package/src/blocks/internal/tina.ts +19 -0
- package/src/blocks/internal/util.ts +23 -0
- package/src/blocks/lib/consent.ts +96 -0
- package/src/blocks/lib/contact.ts +86 -0
- package/src/blocks/lib/error-pages.ts +119 -0
- package/src/blocks/lib/faq.ts +37 -0
- package/src/blocks/lib/hours.ts +201 -0
- package/src/blocks/lib/maintenance.ts +129 -0
- package/src/blocks/lib/reviews.ts +22 -0
- package/src/blocks/lib/rich-text.ts +143 -0
- package/src/blocks/lib/slug.ts +12 -0
- package/src/blocks/registry.ts +79 -0
- package/src/blocks/scripts/carousel.ts +218 -0
- package/src/blocks/scripts/consent-embed.ts +105 -0
- package/src/blocks/scripts/consent-manager.ts +112 -0
- package/src/blocks/scripts/consent-store.ts +86 -0
- package/src/blocks/scripts/error-page.ts +71 -0
- package/src/blocks/scripts/hours.ts +106 -0
- package/src/blocks/scripts/maintenance.ts +109 -0
- package/src/blocks/styles/blocks.css +1320 -0
- package/src/blocks/styles/consent.css +102 -0
- package/src/blocks/styles/faq.css +28 -0
- package/src/blocks/styles/location.css +92 -0
- package/src/blocks/styles/prose-section.css +13 -0
- package/src/blocks/styles/quotes.css +123 -0
- package/src/blocks/styles/rich-text.css +14 -0
- package/src/blocks/types.ts +283 -0
- package/src/data/ChartAxis.astro +19 -0
- package/src/data/ChartContainer.astro +151 -0
- package/src/data/ChartLegend.astro +25 -0
- package/src/data/ChartSeries.astro +14 -0
- package/src/data/ChartTable.astro +17 -0
- package/src/data/ChartTooltip.astro +20 -0
- package/src/data/Sparkline.astro +55 -0
- package/src/data/cms.ts +190 -0
- package/src/data/index.ts +10 -0
- package/src/data/lib/chart.ts +450 -0
- package/src/data/lib/render.ts +219 -0
- package/src/data/lib/scale.ts +107 -0
- package/src/data/lib/sparkline.ts +117 -0
- package/src/data/scripts/chart.ts +324 -0
- package/src/data/styles/chart.css +392 -0
- package/src/motion/Marquee.astro +90 -0
- package/src/motion/MotionProvider.astro +50 -0
- package/src/motion/PageTransitions.astro +61 -0
- package/src/motion/Parallax.astro +44 -0
- package/src/motion/ParallaxLayer.astro +31 -0
- package/src/motion/RevealOnScroll.astro +59 -0
- package/src/motion/SceneRegistry.astro +38 -0
- package/src/motion/ScrollScene.astro +81 -0
- package/src/motion/index.ts +12 -0
- package/src/motion/integration.ts +48 -0
- package/src/motion/runtime/page-transitions.ts +68 -0
- package/src/motion/runtime/runtime.ts +180 -0
- package/src/motion/runtime/scenes.ts +248 -0
- package/src/motion/runtime/types.ts +103 -0
- package/src/motion/styles/motion.css +332 -0
- package/src/motion/transitions.ts +74 -0
- package/src/motion/virtual.d.ts +4 -0
- package/src/primitives/Accordion.astro +129 -0
- package/src/primitives/Breadcrumbs.astro +50 -0
- package/src/primitives/BulletList.astro +69 -0
- package/src/primitives/Button.astro +73 -0
- package/src/primitives/ButtonGroup.astro +54 -0
- package/src/primitives/Callout.astro +137 -0
- package/src/primitives/Caption.astro +35 -0
- package/src/primitives/Card.astro +72 -0
- package/src/primitives/CardContent.astro +24 -0
- package/src/primitives/CardFooter.astro +36 -0
- package/src/primitives/CardHeader.astro +86 -0
- package/src/primitives/Checkbox.astro +38 -0
- package/src/primitives/ChoiceGroup.astro +23 -0
- package/src/primitives/Cluster.astro +49 -0
- package/src/primitives/Container.astro +44 -0
- package/src/primitives/DescriptionList.astro +83 -0
- package/src/primitives/Dialog.astro +38 -0
- package/src/primitives/Disclosure.astro +67 -0
- package/src/primitives/Divider.astro +93 -0
- package/src/primitives/Drawer.astro +33 -0
- package/src/primitives/Fieldset.astro +80 -0
- package/src/primitives/Flex.astro +64 -0
- package/src/primitives/FocusRing.astro +63 -0
- package/src/primitives/FocusTrap.astro +64 -0
- package/src/primitives/Footer.astro +155 -0
- package/src/primitives/Form.astro +68 -0
- package/src/primitives/FormDescription.astro +26 -0
- package/src/primitives/FormError.astro +106 -0
- package/src/primitives/FormField.astro +72 -0
- package/src/primitives/Grid.astro +64 -0
- package/src/primitives/Heading.astro +45 -0
- package/src/primitives/IconButton.astro +48 -0
- package/src/primitives/Image.astro +125 -0
- package/src/primitives/Input.astro +84 -0
- package/src/primitives/Label.astro +50 -0
- package/src/primitives/Link.astro +81 -0
- package/src/primitives/LinkButton.astro +66 -0
- package/src/primitives/List.astro +39 -0
- package/src/primitives/ListItem.astro +178 -0
- package/src/primitives/MediaObject.astro +66 -0
- package/src/primitives/MetricCard.astro +276 -0
- package/src/primitives/NavLink.astro +81 -0
- package/src/primitives/NavMenu.astro +109 -0
- package/src/primitives/Navbar.astro +197 -0
- package/src/primitives/Panel.astro +153 -0
- package/src/primitives/Picture.astro +167 -0
- package/src/primitives/Popover.astro +95 -0
- package/src/primitives/Prose.astro +45 -0
- package/src/primitives/Radio.astro +21 -0
- package/src/primitives/Rating.astro +135 -0
- package/src/primitives/ReducedMotion.astro +90 -0
- package/src/primitives/SegmentedControl.astro +132 -0
- package/src/primitives/Select.astro +107 -0
- package/src/primitives/Sheet.astro +45 -0
- package/src/primitives/SkipLink.astro +31 -0
- package/src/primitives/Slider.astro +186 -0
- package/src/primitives/Spacer.astro +35 -0
- package/src/primitives/Stack.astro +51 -0
- package/src/primitives/Surface.astro +70 -0
- package/src/primitives/Switch.astro +22 -0
- package/src/primitives/Table.astro +382 -0
- package/src/primitives/Tabs.astro +126 -0
- package/src/primitives/Text.astro +56 -0
- package/src/primitives/Textarea.astro +73 -0
- package/src/primitives/Thumbnail.astro +154 -0
- package/src/primitives/Toggle.astro +99 -0
- package/src/primitives/Tooltip.astro +50 -0
- package/src/primitives/VisuallyHidden.astro +29 -0
- package/src/primitives/index.ts +103 -0
- package/src/primitives/internal/AccordionScript.astro +7 -0
- package/src/primitives/internal/ChoiceField.astro +89 -0
- package/src/primitives/internal/FocusTrapScript.astro +8 -0
- package/src/primitives/internal/FormValidationScript.astro +10 -0
- package/src/primitives/internal/IndeterminateScript.astro +13 -0
- package/src/primitives/internal/ModalPanel.astro +114 -0
- package/src/primitives/internal/OverlayScript.astro +7 -0
- package/src/primitives/internal/ReducedMotionScript.astro +7 -0
- package/src/primitives/internal/SliderScript.astro +7 -0
- package/src/primitives/internal/SparklineScript.astro +7 -0
- package/src/primitives/internal/TableSortScript.astro +7 -0
- package/src/primitives/internal/TabsScript.astro +7 -0
- package/src/primitives/internal/TooltipScript.astro +7 -0
- package/src/primitives/lib/deprecate.ts +47 -0
- package/src/primitives/lib/focus-trap.ts +197 -0
- package/src/primitives/lib/focus.ts +60 -0
- package/src/primitives/lib/image-plan.ts +82 -0
- package/src/primitives/lib/image.ts +129 -0
- package/src/primitives/lib/motion.ts +68 -0
- package/src/primitives/lib/slider.ts +170 -0
- package/src/primitives/scripts/accordion.ts +123 -0
- package/src/primitives/scripts/form-validation.ts +225 -0
- package/src/primitives/scripts/overlay.ts +71 -0
- package/src/primitives/scripts/reduced-motion.ts +59 -0
- package/src/primitives/scripts/slider.ts +150 -0
- package/src/primitives/scripts/sparkline.ts +131 -0
- package/src/primitives/scripts/table-sort.ts +68 -0
- package/src/primitives/scripts/tabs.ts +151 -0
- package/src/primitives/scripts/tooltip.ts +28 -0
- package/src/primitives/styles/a11y.css +104 -0
- package/src/primitives/styles/accordion.css +53 -0
- package/src/primitives/styles/breadcrumbs.css +59 -0
- package/src/primitives/styles/bullet-list.css +89 -0
- package/src/primitives/styles/button.css +237 -0
- package/src/primitives/styles/choice.css +164 -0
- package/src/primitives/styles/cluster.css +24 -0
- package/src/primitives/styles/container.css +19 -0
- package/src/primitives/styles/data.css +849 -0
- package/src/primitives/styles/disclosure.css +140 -0
- package/src/primitives/styles/divider.css +50 -0
- package/src/primitives/styles/flex.css +42 -0
- package/src/primitives/styles/form.css +241 -0
- package/src/primitives/styles/grid.css +36 -0
- package/src/primitives/styles/media.css +247 -0
- package/src/primitives/styles/nav.css +792 -0
- package/src/primitives/styles/overlay.css +362 -0
- package/src/primitives/styles/prose.css +146 -0
- package/src/primitives/styles/scale.css +175 -0
- package/src/primitives/styles/segmented.css +165 -0
- package/src/primitives/styles/slider.css +170 -0
- package/src/primitives/styles/spacer.css +17 -0
- package/src/primitives/styles/stack.css +25 -0
- package/src/primitives/styles/surface.css +403 -0
- package/src/primitives/styles/tabs.css +223 -0
- package/src/primitives/styles/typography.css +144 -0
- package/src/primitives/styles/utilities.css +24 -0
- package/src/primitives/types.ts +385 -0
- package/src/primitives/utils.ts +254 -0
- package/src/seo/JSONLD.astro +35 -0
- package/src/seo/SEOHead.astro +47 -0
- package/src/seo/cms.ts +80 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/integration.ts +231 -0
- package/src/seo/lib/jsonld.ts +334 -0
- package/src/seo/lib/meta.ts +205 -0
- package/src/seo/lib/redirects.ts +283 -0
- package/src/seo/lib/robots.ts +33 -0
- package/src/seo/lib/rss.ts +98 -0
- package/src/seo/lib/sitemap.ts +105 -0
- package/src/seo/lib/url.ts +68 -0
- package/src/tokens/base.css +71 -0
- package/src/tokens/tokens.css +210 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { SlideItem } from '../types';
|
|
2
|
+
import type { HeroCarouselData } from './data';
|
|
3
|
+
import type { MapContext, TinaTemplate } from './types';
|
|
4
|
+
import { actionsField, clean, compact, longTextField, mapActions, mapImage, mapSettings, textField } from './shared';
|
|
5
|
+
|
|
6
|
+
export const heroCarouselDefaults: HeroCarouselData = {
|
|
7
|
+
_template: 'heroCarousel',
|
|
8
|
+
label: 'Featured',
|
|
9
|
+
slides: [
|
|
10
|
+
{ heading: 'Your main message goes on the first slide', description: 'Most visitors only see this one.', actions: [{ label: 'Learn more', href: '/about', style: 'solid' }] },
|
|
11
|
+
{ heading: 'A second message', actions: [{ label: 'See services', href: '/services', style: 'solid' }] },
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const heroCarouselTemplate: TinaTemplate = {
|
|
16
|
+
name: 'heroCarousel',
|
|
17
|
+
label: 'Hero carousel',
|
|
18
|
+
ui: { defaultItem: heroCarouselDefaults, itemProps: (item: HeroCarouselData) => ({ label: `Carousel: ${item?.slides?.[0]?.heading ?? ''}` }) },
|
|
19
|
+
fields: [
|
|
20
|
+
textField('label', 'Carousel name (for screen readers)', { description: 'E.g. “Featured messages”.' }),
|
|
21
|
+
{
|
|
22
|
+
type: 'object',
|
|
23
|
+
name: 'slides',
|
|
24
|
+
label: 'Slides',
|
|
25
|
+
list: true,
|
|
26
|
+
description: 'Put the most important message first: most visitors never see the others. 2–4 slides.',
|
|
27
|
+
ui: { max: 5, itemProps: (item: { heading?: string }) => ({ label: item?.heading || 'Slide' }), defaultItem: { heading: 'New slide' } },
|
|
28
|
+
fields: [
|
|
29
|
+
textField('eyebrow', 'Eyebrow'),
|
|
30
|
+
textField('heading', 'Headline', { required: true }),
|
|
31
|
+
longTextField('description', 'Supporting text'),
|
|
32
|
+
actionsField(2),
|
|
33
|
+
{ type: 'image', name: 'image', label: 'Background image', description: 'Decorative: it sits behind dark shading, so it needs no description.' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'number',
|
|
38
|
+
name: 'autoplay',
|
|
39
|
+
label: 'Rotate automatically every … seconds',
|
|
40
|
+
description: 'Leave empty to rotate only when visitors choose (recommended). Minimum 5; a pause button is always shown.',
|
|
41
|
+
ui: { validate: (v: unknown) => (v != null && v !== '' && Number(v) > 0 && Number(v) < 5 ? 'Use at least 5 seconds, or leave it empty.' : undefined) },
|
|
42
|
+
},
|
|
43
|
+
{ type: 'string', name: 'minHeight', label: 'Height', options: [{ value: 'banner', label: 'Banner' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Tall' }, { value: 'screen', label: 'Full screen' }] },
|
|
44
|
+
{ type: 'string', name: 'motion', label: 'Photo motion', description: 'Slow zoom while the slide show plays (never with reduced motion).', options: [{ value: 'none', label: 'None' }, { value: 'zoom', label: 'Slow zoom' }] },
|
|
45
|
+
{ type: 'string', name: 'controls', label: 'Controls', options: [{ value: 'bar', label: 'One bar' }, { value: 'split', label: 'Arrows on the sides' }] },
|
|
46
|
+
{ type: 'string', name: 'scrim', label: 'Image darkening', options: [{ value: 'even', label: 'Even' }, { value: 'gradient', label: 'Text side only' }] },
|
|
47
|
+
{
|
|
48
|
+
type: 'object',
|
|
49
|
+
name: 'settings',
|
|
50
|
+
label: 'Section settings',
|
|
51
|
+
fields: [
|
|
52
|
+
{ type: 'string', name: 'anchor', label: 'Anchor ID' },
|
|
53
|
+
{ type: 'string', name: 'align', label: 'Alignment', options: [{ value: 'start', label: 'Start' }, { value: 'center', label: 'Center' }] },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export function heroCarouselToProps(d: HeroCarouselData, ctx: MapContext) {
|
|
60
|
+
const slides = (d.slides ?? [])
|
|
61
|
+
.filter((s) => clean(s?.heading))
|
|
62
|
+
// Background images are decorative: alt is always empty.
|
|
63
|
+
.map((s) => compact({ eyebrow: clean(s.eyebrow), heading: clean(s.heading)!, description: clean(s.description), actions: mapActions(s.actions), image: mapImage(s.image, '', ctx), tina: s as never }) as SlideItem);
|
|
64
|
+
const { anchor, align } = mapSettings(d.settings);
|
|
65
|
+
const autoplay = Number(d.autoplay);
|
|
66
|
+
return compact({
|
|
67
|
+
anchor,
|
|
68
|
+
align,
|
|
69
|
+
label: clean(d.label),
|
|
70
|
+
slides,
|
|
71
|
+
autoplay: Number.isFinite(autoplay) && autoplay > 0 ? Math.max(5, autoplay) : undefined,
|
|
72
|
+
minHeight: d.minHeight,
|
|
73
|
+
motion: d.motion,
|
|
74
|
+
controls: d.controls,
|
|
75
|
+
scrim: d.scrim,
|
|
76
|
+
// A carousel never takes the page's h1 from the renderer (see HeroCarousel docs).
|
|
77
|
+
headingLevel: 2 as const,
|
|
78
|
+
placeholder: ctx.placeholder,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { HeroData } from './data';
|
|
2
|
+
import type { MapContext, TinaTemplate } from './types';
|
|
3
|
+
import { actionsField, clean, compact, longTextField, mapActions, mapImage, mapSettings, settingsField, textField } from './shared';
|
|
4
|
+
|
|
5
|
+
export const heroDefaults: HeroData = {
|
|
6
|
+
_template: 'hero',
|
|
7
|
+
variant: 'text',
|
|
8
|
+
heading: 'A clear headline about what you do',
|
|
9
|
+
description: 'One or two sentences on who it’s for and why it matters.',
|
|
10
|
+
actions: [{ label: 'Get started', href: '/contact', style: 'solid' }],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const heroTemplate: TinaTemplate = {
|
|
14
|
+
name: 'hero',
|
|
15
|
+
label: 'Hero',
|
|
16
|
+
ui: { defaultItem: heroDefaults, itemProps: (item: HeroData) => ({ label: `Hero: ${item?.heading ?? ''}` }) },
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
type: 'string',
|
|
20
|
+
name: 'variant',
|
|
21
|
+
label: 'Layout',
|
|
22
|
+
options: [
|
|
23
|
+
{ value: 'text', label: 'Text only' },
|
|
24
|
+
{ value: 'split', label: 'Text and image side by side' },
|
|
25
|
+
{ value: 'media', label: 'Text over a background image' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
textField('eyebrow', 'Eyebrow', { description: 'A short label above the headline (optional).' }),
|
|
29
|
+
textField('heading', 'Headline', { required: true }),
|
|
30
|
+
longTextField('description', 'Supporting text'),
|
|
31
|
+
actionsField(2),
|
|
32
|
+
textField('meta', 'Small print', { description: 'Under the buttons, e.g. “Fixed-price projects · No lock-in”.' }),
|
|
33
|
+
{ type: 'image', name: 'image', label: 'Image', description: 'Side image (split) or background (over image).' },
|
|
34
|
+
textField('imageAlt', 'Image description (alt text)', { description: 'Describe the image for people who can’t see it. Leave empty only for background images.' }),
|
|
35
|
+
{
|
|
36
|
+
type: 'string',
|
|
37
|
+
name: 'mediaPosition',
|
|
38
|
+
label: 'Image side (split)',
|
|
39
|
+
options: [{ value: 'end', label: 'After the text' }, { value: 'start', label: 'Before the text' }],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'string',
|
|
43
|
+
name: 'scrim',
|
|
44
|
+
label: 'Image darkening (over image)',
|
|
45
|
+
options: [{ value: 'even', label: 'Even' }, { value: 'gradient', label: 'Text side only' }],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'string',
|
|
49
|
+
name: 'minHeight',
|
|
50
|
+
label: 'Height (over image)',
|
|
51
|
+
options: [{ value: 'auto', label: 'Fit content' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Tall' }, { value: 'screen', label: 'Full screen' }],
|
|
52
|
+
},
|
|
53
|
+
settingsField(),
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export function heroToProps(d: HeroData, ctx: MapContext) {
|
|
58
|
+
// Stored as `variant` (no content migration); the component prop is `layout`.
|
|
59
|
+
const layout = d.variant ?? 'text';
|
|
60
|
+
// Background images are decorative: their alt is always empty.
|
|
61
|
+
const image = mapImage(d.image, layout === 'media' ? '' : d.imageAlt, ctx);
|
|
62
|
+
return compact({
|
|
63
|
+
...mapSettings(d.settings),
|
|
64
|
+
layout: layout !== 'text' && !image ? 'text' : layout,
|
|
65
|
+
eyebrow: clean(d.eyebrow),
|
|
66
|
+
heading: clean(d.heading),
|
|
67
|
+
description: clean(d.description),
|
|
68
|
+
actions: mapActions(d.actions),
|
|
69
|
+
meta: clean(d.meta),
|
|
70
|
+
image,
|
|
71
|
+
mediaPosition: d.mediaPosition,
|
|
72
|
+
scrim: d.scrim,
|
|
73
|
+
minHeight: d.minHeight,
|
|
74
|
+
headingLevel: ctx.headingLevel,
|
|
75
|
+
placeholder: ctx.placeholder,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { HighlightCardItem } from '../types';
|
|
2
|
+
import type { HighlightCardsData } from './data';
|
|
3
|
+
import type { MapContext, TinaTemplate } from './types';
|
|
4
|
+
import { actionsField, clean, compact, longTextField, mapActions, mapSettings, textField } from './shared';
|
|
5
|
+
|
|
6
|
+
export const highlightCardsDefaults: HighlightCardsData = {
|
|
7
|
+
_template: 'highlightCards',
|
|
8
|
+
label: 'How can we help?',
|
|
9
|
+
items: [
|
|
10
|
+
{ heading: 'New projects', description: 'Tell us a little about your site and we’ll call you back.', actions: [{ label: 'Get started', href: '/contact', style: 'outline', arrow: true }] },
|
|
11
|
+
{ heading: 'Agency partners', description: 'Send a brief and we’ll respond within 24 hours.', actions: [{ label: 'Send a brief', href: '/partners', style: 'outline', arrow: true }] },
|
|
12
|
+
{ heading: 'Opening hours', points: ['24 hours a day', '7 days a week'], actions: [{ label: 'Contact us', href: '/contact', style: 'outline', arrow: true }] },
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const highlightCardsTemplate: TinaTemplate = {
|
|
17
|
+
name: 'highlightCards',
|
|
18
|
+
label: 'Highlight cards',
|
|
19
|
+
ui: { defaultItem: highlightCardsDefaults, itemProps: (item: HighlightCardsData) => ({ label: `Highlight cards: ${item?.items?.map((i) => i.heading).join(' · ') ?? ''}` }) },
|
|
20
|
+
fields: [
|
|
21
|
+
textField('label', 'Section name (for screen readers)', { description: 'E.g. “How can we help?”.' }),
|
|
22
|
+
{
|
|
23
|
+
type: 'object',
|
|
24
|
+
name: 'items',
|
|
25
|
+
label: 'Cards',
|
|
26
|
+
list: true,
|
|
27
|
+
description: 'Two to four colored cards.',
|
|
28
|
+
ui: { max: 4, itemProps: (item: { heading?: string }) => ({ label: item?.heading || 'Card' }), defaultItem: { heading: 'New card' } },
|
|
29
|
+
fields: [
|
|
30
|
+
textField('heading', 'Heading', { required: true }),
|
|
31
|
+
longTextField('description', 'Text'),
|
|
32
|
+
{ type: 'string', name: 'points', label: 'Bullet points', list: true },
|
|
33
|
+
actionsField(1),
|
|
34
|
+
{ type: 'string', name: 'tone', label: 'Color', description: 'Your theme may add more colors.', options: [{ value: 'accent', label: 'Brand' }, { value: 'neutral', label: 'Neutral' }] },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{ type: 'boolean', name: 'overlap', label: 'Overlap the section above', description: 'On wide screens, pulls the cards up over a hero or carousel.' },
|
|
38
|
+
{ type: 'string', name: 'gap', label: 'Card spacing', options: [{ value: 'none', label: 'Touching (one band)' }, { value: 'm', label: 'Separate cards' }] },
|
|
39
|
+
{
|
|
40
|
+
type: 'object',
|
|
41
|
+
name: 'settings',
|
|
42
|
+
label: 'Section settings',
|
|
43
|
+
fields: [
|
|
44
|
+
{ type: 'string', name: 'anchor', label: 'Anchor ID' },
|
|
45
|
+
{ type: 'string', name: 'align', label: 'Alignment', options: [{ value: 'start', label: 'Start' }, { value: 'center', label: 'Center' }] },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function highlightCardsToProps(d: HighlightCardsData, ctx: MapContext) {
|
|
52
|
+
const items = (d.items ?? [])
|
|
53
|
+
.filter((i) => clean(i?.heading))
|
|
54
|
+
.slice(0, 4)
|
|
55
|
+
.map((i) =>
|
|
56
|
+
compact({
|
|
57
|
+
heading: clean(i.heading)!,
|
|
58
|
+
description: clean(i.description),
|
|
59
|
+
points: (i.points ?? []).map((p) => clean(p)).filter(Boolean) as string[],
|
|
60
|
+
actions: mapActions(i.actions),
|
|
61
|
+
tone: clean(i.tone),
|
|
62
|
+
tina: i as never,
|
|
63
|
+
}) as HighlightCardItem,
|
|
64
|
+
);
|
|
65
|
+
const { anchor, align } = mapSettings(d.settings);
|
|
66
|
+
return compact({
|
|
67
|
+
anchor,
|
|
68
|
+
align,
|
|
69
|
+
label: clean(d.label),
|
|
70
|
+
items,
|
|
71
|
+
overlap: d.overlap ?? undefined,
|
|
72
|
+
gap: d.gap,
|
|
73
|
+
headingLevel: 2 as const,
|
|
74
|
+
placeholder: ctx.placeholder,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns CMS image paths into images astro:assets can optimize.
|
|
3
|
+
*
|
|
4
|
+
* // Tina: media: { tina: { publicFolder: 'src', mediaRoot: 'assets/uploads' } }
|
|
5
|
+
* const resolveImage = createImageResolver(import.meta.glob('/src/assets/**\/*.{jpg,jpeg,png,webp,avif,svg}', { eager: true }));
|
|
6
|
+
* <BlockRenderer blocks={page.blocks} resolveImage={resolveImage} />
|
|
7
|
+
*
|
|
8
|
+
* Paths are matched as given, with `/src` prepended (Tina stores paths relative to publicFolder),
|
|
9
|
+
* and by filename-suffix as a last resort. Absolute URLs need `remote` sizes.
|
|
10
|
+
*/
|
|
11
|
+
import type { ImageResolver, ResolvedImage } from './types';
|
|
12
|
+
|
|
13
|
+
type GlobResult = Record<string, { default: import('astro').ImageMetadata } | import('astro').ImageMetadata>;
|
|
14
|
+
|
|
15
|
+
export function createImageResolver(
|
|
16
|
+
modules: GlobResult,
|
|
17
|
+
options: { remote?: Record<string, { width: number; height: number }> } = {},
|
|
18
|
+
): ImageResolver {
|
|
19
|
+
const byPath = new Map<string, import('astro').ImageMetadata>();
|
|
20
|
+
for (const [key, mod] of Object.entries(modules)) {
|
|
21
|
+
byPath.set(key, 'default' in mod ? mod.default : mod);
|
|
22
|
+
}
|
|
23
|
+
return (src: string): ResolvedImage | undefined => {
|
|
24
|
+
if (/^https?:\/\//.test(src)) {
|
|
25
|
+
const size = options.remote?.[src];
|
|
26
|
+
return size ? { src, ...size } : undefined;
|
|
27
|
+
}
|
|
28
|
+
const clean = src.split(/[?#]/)[0];
|
|
29
|
+
const path = clean.startsWith('/') ? clean : `/${clean}`;
|
|
30
|
+
const hit = byPath.get(path) ?? byPath.get(`/src${path}`);
|
|
31
|
+
if (hit) return hit;
|
|
32
|
+
for (const [key, value] of byPath) if (key.endsWith(path)) return value;
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A resolver that resolves nothing (images are skipped, with a dev warning). */
|
|
38
|
+
export const noImages: ImageResolver = () => undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS side of @sinnstack/ui/blocks (TinaCMS): schema fragments, defaults, fixtures and the
|
|
3
|
+
* data → props mappers. No tinacms dependency; the objects are plain Tina templates.
|
|
4
|
+
*
|
|
5
|
+
* // tina/config.ts
|
|
6
|
+
* import { blockTemplates } from '@sinnstack/ui/blocks/cms';
|
|
7
|
+
* fields: [{ type: 'object', name: 'blocks', label: 'Sections', list: true, templates: blockTemplates }]
|
|
8
|
+
*
|
|
9
|
+
* Schema changes are breaking: a field rename or removal is a major version with a migration note.
|
|
10
|
+
*/
|
|
11
|
+
import { heroTemplate, heroDefaults, heroToProps } from './hero';
|
|
12
|
+
import { ctaBannerTemplate, ctaBannerDefaults, ctaBannerToProps } from './cta-banner';
|
|
13
|
+
import { featureGridTemplate, featureGridDefaults, featureGridToProps } from './feature-grid';
|
|
14
|
+
import { cardGridTemplate, cardGridDefaults, cardGridToProps } from './card-grid';
|
|
15
|
+
import { logoCloudTemplate, logoCloudDefaults, logoCloudToProps } from './logo-cloud';
|
|
16
|
+
import { heroCarouselTemplate, heroCarouselDefaults, heroCarouselToProps } from './hero-carousel';
|
|
17
|
+
import { pageHeaderTemplate, pageHeaderDefaults, pageHeaderToProps } from './page-header';
|
|
18
|
+
import { contactCardTemplate, contactCardDefaults, contactCardToProps } from './contact-card';
|
|
19
|
+
import { stepsTemplate, stepsDefaults, stepsToProps } from './steps';
|
|
20
|
+
import { mediaTextTemplate, mediaTextDefaults, mediaTextToProps } from './media-text';
|
|
21
|
+
import { ctaPairTemplate, ctaPairDefaults, ctaPairToProps } from './cta-pair';
|
|
22
|
+
import { statsBandTemplate, statsBandDefaults, statsBandToProps } from './stats-band';
|
|
23
|
+
import { highlightCardsTemplate, highlightCardsDefaults, highlightCardsToProps } from './highlight-cards';
|
|
24
|
+
import { contactFormTemplate, contactFormDefaults, contactFormToProps } from './contact-form';
|
|
25
|
+
import { proseSectionTemplate, proseSectionDefaults, proseSectionToProps } from './prose-section';
|
|
26
|
+
import { faqTemplate, faqDefaults, faqToProps } from './faq';
|
|
27
|
+
import { testimonialsTemplate, testimonialsDefaults, testimonialsToProps } from './testimonials';
|
|
28
|
+
import { reviewsTemplate, reviewsDefaults, reviewsToProps } from './reviews';
|
|
29
|
+
import { locationHoursTemplate, locationHoursDefaults, locationHoursToProps } from './location-hours';
|
|
30
|
+
|
|
31
|
+
export * from './types';
|
|
32
|
+
export * from './data';
|
|
33
|
+
export * from './fixtures';
|
|
34
|
+
export { createImageResolver, noImages } from './images';
|
|
35
|
+
export { settingsField, actionsField } from './shared';
|
|
36
|
+
export { errorPagesField, maintenanceField, errorPageProps, type ErrorPagesSettings } from './pages';
|
|
37
|
+
export { heroTemplate, heroDefaults, heroToProps };
|
|
38
|
+
export { ctaBannerTemplate, ctaBannerDefaults, ctaBannerToProps };
|
|
39
|
+
export { featureGridTemplate, featureGridDefaults, featureGridToProps };
|
|
40
|
+
export { cardGridTemplate, cardGridDefaults, cardGridToProps };
|
|
41
|
+
export { logoCloudTemplate, logoCloudDefaults, logoCloudToProps };
|
|
42
|
+
export { heroCarouselTemplate, heroCarouselDefaults, heroCarouselToProps };
|
|
43
|
+
export { pageHeaderTemplate, pageHeaderDefaults, pageHeaderToProps };
|
|
44
|
+
export { contactCardTemplate, contactCardDefaults, contactCardToProps };
|
|
45
|
+
export { stepsTemplate, stepsDefaults, stepsToProps };
|
|
46
|
+
export { mediaTextTemplate, mediaTextDefaults, mediaTextToProps };
|
|
47
|
+
export { ctaPairTemplate, ctaPairDefaults, ctaPairToProps };
|
|
48
|
+
export { statsBandTemplate, statsBandDefaults, statsBandToProps };
|
|
49
|
+
export { highlightCardsTemplate, highlightCardsDefaults, highlightCardsToProps };
|
|
50
|
+
export { contactFormTemplate, contactFormDefaults, contactFormToProps };
|
|
51
|
+
export { proseSectionTemplate, proseSectionDefaults, proseSectionToProps };
|
|
52
|
+
export { faqTemplate, faqDefaults, faqToProps };
|
|
53
|
+
export { testimonialsTemplate, testimonialsDefaults, testimonialsToProps };
|
|
54
|
+
export { reviewsTemplate, reviewsDefaults, reviewsToProps };
|
|
55
|
+
export { locationHoursTemplate, locationHoursDefaults, locationHoursToProps };
|
|
56
|
+
export { topbarField, topbarProps } from './topbar';
|
|
57
|
+
export { consentField, consentProps } from './consent';
|
|
58
|
+
|
|
59
|
+
/** All block templates, for a Tina `templates` list. */
|
|
60
|
+
export const blockTemplates = [
|
|
61
|
+
heroTemplate,
|
|
62
|
+
heroCarouselTemplate,
|
|
63
|
+
highlightCardsTemplate,
|
|
64
|
+
pageHeaderTemplate,
|
|
65
|
+
mediaTextTemplate,
|
|
66
|
+
featureGridTemplate,
|
|
67
|
+
stepsTemplate,
|
|
68
|
+
statsBandTemplate,
|
|
69
|
+
cardGridTemplate,
|
|
70
|
+
logoCloudTemplate,
|
|
71
|
+
contactCardTemplate,
|
|
72
|
+
ctaBannerTemplate,
|
|
73
|
+
ctaPairTemplate,
|
|
74
|
+
contactFormTemplate,
|
|
75
|
+
proseSectionTemplate,
|
|
76
|
+
faqTemplate,
|
|
77
|
+
testimonialsTemplate,
|
|
78
|
+
reviewsTemplate,
|
|
79
|
+
locationHoursTemplate,
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
/** Template name of a block from Tina data: `_template`, or the GraphQL `__typename` suffix. */
|
|
83
|
+
export function templateName(block: { _template?: string; __typename?: string }): string | undefined {
|
|
84
|
+
if (block._template) return block._template;
|
|
85
|
+
const match = /Blocks([A-Z]\w*)$/.exec(block.__typename ?? '');
|
|
86
|
+
return match ? match[1][0].toLowerCase() + match[1].slice(1) : undefined;
|
|
87
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { DayCode, HoursRow, PostalAddress, SpecialHours } from '../types';
|
|
2
|
+
import type { LocationHoursData } from './data';
|
|
3
|
+
import type { MapContext, TinaField, TinaTemplate } from './types';
|
|
4
|
+
import { clean, compact, longTextField, mapSettings, settingsField, textField } from './shared';
|
|
5
|
+
import { DAY_CODES, parseTime } from '../lib/hours';
|
|
6
|
+
|
|
7
|
+
const DAY_OPTIONS = [
|
|
8
|
+
{ value: 'Mo', label: 'Monday' },
|
|
9
|
+
{ value: 'Tu', label: 'Tuesday' },
|
|
10
|
+
{ value: 'We', label: 'Wednesday' },
|
|
11
|
+
{ value: 'Th', label: 'Thursday' },
|
|
12
|
+
{ value: 'Fr', label: 'Friday' },
|
|
13
|
+
{ value: 'Sa', label: 'Saturday' },
|
|
14
|
+
{ value: 'Su', label: 'Sunday' },
|
|
15
|
+
];
|
|
16
|
+
const timeValidate = (v: unknown) => (v && parseTime(String(v)) === undefined ? 'Use 24-hour time, e.g. 09:00 or 17:30.' : undefined);
|
|
17
|
+
const timeField = (name: string, label: string): TinaField => textField(name, label, { description: '24-hour time, e.g. 09:00.', ui: { validate: timeValidate } });
|
|
18
|
+
|
|
19
|
+
/** Validates an IANA time zone name with the browser's own list. */
|
|
20
|
+
export function isTimeZone(value: string | undefined): boolean {
|
|
21
|
+
if (!value) return false;
|
|
22
|
+
try {
|
|
23
|
+
new Intl.DateTimeFormat('en-US', { timeZone: value });
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const locationHoursDefaults: LocationHoursData = {
|
|
31
|
+
_template: 'locationHours',
|
|
32
|
+
heading: 'Visit us',
|
|
33
|
+
name: 'Sinnstack',
|
|
34
|
+
address: { street: '500 Main St', street2: 'Suite 210', city: 'Fort Worth', region: 'TX', postalCode: '76102' },
|
|
35
|
+
phone: '(817) 555-0100',
|
|
36
|
+
email: 'hello@example.com',
|
|
37
|
+
timeZone: 'America/Chicago',
|
|
38
|
+
hours: [
|
|
39
|
+
{ days: ['Mo', 'Tu', 'We', 'Th', 'Fr'], opens: '09:00', closes: '17:00' },
|
|
40
|
+
{ days: ['Sa', 'Su'], closed: true },
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const locationHoursTemplate: TinaTemplate = {
|
|
45
|
+
name: 'locationHours',
|
|
46
|
+
label: 'Location and hours',
|
|
47
|
+
ui: { defaultItem: locationHoursDefaults, itemProps: (item: LocationHoursData) => ({ label: `Location: ${item?.name ?? item?.address?.city ?? ''}` }) },
|
|
48
|
+
fields: [
|
|
49
|
+
textField('eyebrow', 'Eyebrow'),
|
|
50
|
+
textField('heading', 'Heading'),
|
|
51
|
+
longTextField('description', 'Intro text'),
|
|
52
|
+
textField('name', 'Business or location name'),
|
|
53
|
+
{
|
|
54
|
+
type: 'object',
|
|
55
|
+
name: 'address',
|
|
56
|
+
label: 'Address',
|
|
57
|
+
fields: [
|
|
58
|
+
textField('street', 'Street', { required: true }),
|
|
59
|
+
textField('street2', 'Suite, unit (optional)'),
|
|
60
|
+
textField('city', 'City', { required: true }),
|
|
61
|
+
textField('region', 'State', { required: true }),
|
|
62
|
+
textField('postalCode', 'ZIP code', { required: true }),
|
|
63
|
+
textField('country', 'Country code (optional)', { description: 'Two letters, e.g. US (the default) or CA.' }),
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
textField('phone', 'Phone'),
|
|
67
|
+
textField('email', 'Email'),
|
|
68
|
+
{
|
|
69
|
+
type: 'object',
|
|
70
|
+
name: 'hours',
|
|
71
|
+
label: 'Opening hours',
|
|
72
|
+
list: true,
|
|
73
|
+
description: 'One row per set of days with the same hours. Days not listed show as closed.',
|
|
74
|
+
ui: {
|
|
75
|
+
itemProps: (item: { days?: string[]; opens?: string; closes?: string; closed?: boolean }) => ({
|
|
76
|
+
label: `${(item?.days ?? []).join(', ') || 'Days'}: ${item?.closed ? 'closed' : [item?.opens, item?.closes].filter(Boolean).join('–')}`,
|
|
77
|
+
}),
|
|
78
|
+
defaultItem: { days: ['Mo', 'Tu', 'We', 'Th', 'Fr'], opens: '09:00', closes: '17:00' },
|
|
79
|
+
},
|
|
80
|
+
fields: [
|
|
81
|
+
{ type: 'string', name: 'days', label: 'Days', list: true, options: DAY_OPTIONS, ui: { component: 'checkbox-group' } },
|
|
82
|
+
timeField('opens', 'Opens'),
|
|
83
|
+
timeField('closes', 'Closes'),
|
|
84
|
+
{ type: 'boolean', name: 'closed', label: 'Closed on these days' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'object',
|
|
89
|
+
name: 'special',
|
|
90
|
+
label: 'Holiday hours',
|
|
91
|
+
list: true,
|
|
92
|
+
description: 'Closures or different hours on a date. Past dates hide themselves.',
|
|
93
|
+
ui: { itemProps: (item: { date?: string; label?: string }) => ({ label: [item?.date?.slice(0, 10), item?.label].filter(Boolean).join(' · ') || 'Date' }) },
|
|
94
|
+
fields: [
|
|
95
|
+
{ type: 'datetime', name: 'date', label: 'Date', required: true },
|
|
96
|
+
textField('label', 'Name (optional)', { description: 'e.g. Thanksgiving.' }),
|
|
97
|
+
{ type: 'boolean', name: 'closed', label: 'Closed all day' },
|
|
98
|
+
timeField('opens', 'Opens'),
|
|
99
|
+
timeField('closes', 'Closes'),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
textField('hoursNote', 'Note under the hours (optional)', { description: 'e.g. Visits by appointment.' }),
|
|
103
|
+
textField('timeZone', 'Time zone', {
|
|
104
|
+
description: 'For “Open now”, e.g. America/Chicago or America/New_York.',
|
|
105
|
+
ui: { validate: (v: unknown) => (v && !isTimeZone(String(v)) ? 'Use a time zone name like America/Chicago.' : undefined) },
|
|
106
|
+
}),
|
|
107
|
+
{ type: 'string', name: 'map', label: 'Map', options: [{ value: 'embed', label: 'Map (loads after visitor consent)' }, { value: 'link', label: 'Links only' }, { value: 'none', label: 'None' }] },
|
|
108
|
+
textField('mapEmbedUrl', 'Custom map embed link (optional)', { description: 'From Google Maps → Share → Embed a map: the https:// link inside src="…".' }),
|
|
109
|
+
{ type: 'string', name: 'layout', label: 'Layout', options: [{ value: 'split', label: 'Map beside the details' }, { value: 'stacked', label: 'Map below' }] },
|
|
110
|
+
settingsField(),
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const days = (v: unknown): DayCode[] => (Array.isArray(v) ? (v.filter((d) => (DAY_CODES as readonly string[]).includes(d)) as DayCode[]) : []);
|
|
115
|
+
|
|
116
|
+
export function locationHoursToProps(d: LocationHoursData, ctx: MapContext) {
|
|
117
|
+
const a = d.address ?? {};
|
|
118
|
+
const address: PostalAddress | undefined =
|
|
119
|
+
clean(a.street) && clean(a.city)
|
|
120
|
+
? (compact({ street: clean(a.street)!, street2: clean(a.street2), city: clean(a.city)!, region: clean(a.region) ?? '', postalCode: clean(a.postalCode) ?? '', country: clean(a.country)?.toUpperCase() }) as PostalAddress)
|
|
121
|
+
: undefined;
|
|
122
|
+
const hours = (d.hours ?? [])
|
|
123
|
+
.map((r) => compact({ days: days(r?.days), opens: clean(r?.opens), closes: clean(r?.closes), closed: r?.closed === true ? true : undefined, tina: r as never }) as HoursRow)
|
|
124
|
+
.filter((r) => r.days.length && (r.closed || (parseTime(r.opens) !== undefined && parseTime(r.closes) !== undefined)));
|
|
125
|
+
const special = (d.special ?? [])
|
|
126
|
+
.map((s) => compact({ date: clean(s?.date)?.slice(0, 10) ?? '', label: clean(s?.label), opens: clean(s?.opens), closes: clean(s?.closes), closed: s?.closed === true ? true : undefined }) as SpecialHours)
|
|
127
|
+
.filter((s) => /^\d{4}-\d{2}-\d{2}$/.test(s.date));
|
|
128
|
+
const tz = clean(d.timeZone);
|
|
129
|
+
const embed = clean(d.mapEmbedUrl);
|
|
130
|
+
return compact({
|
|
131
|
+
...mapSettings(d.settings),
|
|
132
|
+
eyebrow: clean(d.eyebrow),
|
|
133
|
+
heading: clean(d.heading),
|
|
134
|
+
description: clean(d.description),
|
|
135
|
+
name: clean(d.name),
|
|
136
|
+
address,
|
|
137
|
+
phone: clean(d.phone),
|
|
138
|
+
email: clean(d.email),
|
|
139
|
+
hours,
|
|
140
|
+
special: special.length ? special : undefined,
|
|
141
|
+
hoursNote: clean(d.hoursNote),
|
|
142
|
+
timeZone: tz && isTimeZone(tz) ? tz : undefined,
|
|
143
|
+
map: d.map,
|
|
144
|
+
mapEmbedUrl: embed && /^https:\/\//i.test(embed) ? embed : undefined,
|
|
145
|
+
layout: d.layout,
|
|
146
|
+
headingLevel: 2 as const,
|
|
147
|
+
placeholder: ctx.placeholder,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { LogoCloudData } from './data';
|
|
2
|
+
import type { MapContext, TinaTemplate } from './types';
|
|
3
|
+
import { clean, compact, mapImage, mapSettings, settingsField, textField } from './shared';
|
|
4
|
+
|
|
5
|
+
export const logoCloudDefaults: LogoCloudData = {
|
|
6
|
+
_template: 'logoCloud',
|
|
7
|
+
heading: 'Trusted by',
|
|
8
|
+
compact: true,
|
|
9
|
+
variant: 'strip',
|
|
10
|
+
logos: [],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const logoCloudTemplate: TinaTemplate = {
|
|
14
|
+
name: 'logoCloud',
|
|
15
|
+
label: 'Logo cloud',
|
|
16
|
+
ui: { defaultItem: logoCloudDefaults, itemProps: (item: LogoCloudData) => ({ label: `Logos: ${item?.heading ?? ''}` }) },
|
|
17
|
+
fields: [
|
|
18
|
+
textField('heading', 'Heading'),
|
|
19
|
+
{ type: 'boolean', name: 'compact', label: 'Small heading', description: 'A quiet label like “Trusted by” instead of a section title.' },
|
|
20
|
+
{
|
|
21
|
+
type: 'object',
|
|
22
|
+
name: 'logos',
|
|
23
|
+
label: 'Logos',
|
|
24
|
+
list: true,
|
|
25
|
+
ui: { itemProps: (item: { name?: string }) => ({ label: item?.name || 'Logo' }) },
|
|
26
|
+
fields: [
|
|
27
|
+
{ type: 'image', name: 'image', label: 'Logo', required: true, description: 'SVG preferred.' },
|
|
28
|
+
textField('name', 'Organization name', { required: true, description: 'Used as the logo’s alt text.' }),
|
|
29
|
+
textField('href', 'Link (optional)'),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{ type: 'string', name: 'variant', label: 'Layout', options: [{ value: 'strip', label: 'Row' }, { value: 'grid', label: 'Grid' }] },
|
|
33
|
+
{ type: 'string', name: 'columns', label: 'Columns (grid)', options: ['2', '3', '4', '5', '6'] },
|
|
34
|
+
{ type: 'string', name: 'size', label: 'Logo size', options: [{ value: 's', label: 'Small' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Large' }] },
|
|
35
|
+
{ type: 'boolean', name: 'mono', label: 'Grayscale until hover' },
|
|
36
|
+
{ type: 'boolean', name: 'tile', label: 'White tiles behind logos' },
|
|
37
|
+
settingsField(),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export function logoCloudToProps(d: LogoCloudData, ctx: MapContext) {
|
|
42
|
+
const logos = (d.logos ?? []).flatMap((l) => {
|
|
43
|
+
const name = clean(l?.name);
|
|
44
|
+
const image = name ? mapImage(l.image, name, ctx) : undefined;
|
|
45
|
+
if (!image) return [];
|
|
46
|
+
return [compact({ src: image.src, alt: name!, width: image.width, height: image.height, href: clean(l.href), tina: l as never })];
|
|
47
|
+
});
|
|
48
|
+
return compact({
|
|
49
|
+
...mapSettings(d.settings),
|
|
50
|
+
heading: clean(d.heading),
|
|
51
|
+
compact: d.compact ?? undefined,
|
|
52
|
+
logos,
|
|
53
|
+
// Stored as `variant` (no content migration); the component prop is `layout`.
|
|
54
|
+
layout: d.variant,
|
|
55
|
+
columns: d.columns ? (Number(d.columns) as 2 | 3 | 4 | 5 | 6) : undefined,
|
|
56
|
+
size: d.size,
|
|
57
|
+
mono: d.mono ?? undefined,
|
|
58
|
+
tile: d.tile ?? undefined,
|
|
59
|
+
headingLevel: 2 as const,
|
|
60
|
+
placeholder: ctx.placeholder,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { MediaTextData } from './data';
|
|
2
|
+
import type { MapContext, TinaTemplate } from './types';
|
|
3
|
+
import { actionsField, clean, compact, longTextField, mapActions, mapImage, mapSettings, settingsField, textField } from './shared';
|
|
4
|
+
|
|
5
|
+
export const mediaTextDefaults: MediaTextData = {
|
|
6
|
+
_template: 'mediaText',
|
|
7
|
+
heading: 'A heading about who you help',
|
|
8
|
+
description: 'One or two sentences of supporting text.',
|
|
9
|
+
points: ['A short reason to choose you', 'Another one'],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const mediaTextTemplate: TinaTemplate = {
|
|
13
|
+
name: 'mediaText',
|
|
14
|
+
label: 'Image and text',
|
|
15
|
+
ui: { defaultItem: mediaTextDefaults, itemProps: (item: MediaTextData) => ({ label: `Image + text: ${item?.heading ?? ''}` }) },
|
|
16
|
+
fields: [
|
|
17
|
+
textField('eyebrow', 'Eyebrow'),
|
|
18
|
+
textField('heading', 'Heading', { required: true }),
|
|
19
|
+
longTextField('description', 'Text'),
|
|
20
|
+
{ type: 'string', name: 'points', label: 'Checklist', list: true, description: 'Short lines shown with check marks.' },
|
|
21
|
+
actionsField(2),
|
|
22
|
+
{ type: 'image', name: 'image', label: 'Image' },
|
|
23
|
+
textField('imageAlt', 'Image description (alt text)', { description: 'Describe the image for people who can’t see it.' }),
|
|
24
|
+
{ type: 'string', name: 'mediaPosition', label: 'Image side', options: [{ value: 'start', label: 'Before the text' }, { value: 'end', label: 'After the text' }] },
|
|
25
|
+
{ type: 'string', name: 'mediaAspect', label: 'Image shape', options: [{ value: '4/3', label: 'Landscape 4:3' }, { value: '3/2', label: 'Landscape 3:2' }, { value: '16/9', label: 'Wide 16:9' }, { value: '1/1', label: 'Square' }, { value: '4/5', label: 'Portrait 4:5' }] },
|
|
26
|
+
settingsField(),
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function mediaTextToProps(d: MediaTextData, ctx: MapContext) {
|
|
31
|
+
return compact({
|
|
32
|
+
...mapSettings(d.settings),
|
|
33
|
+
eyebrow: clean(d.eyebrow),
|
|
34
|
+
heading: clean(d.heading),
|
|
35
|
+
description: clean(d.description),
|
|
36
|
+
points: (d.points ?? []).map((p) => clean(p)).filter((p): p is string => Boolean(p)),
|
|
37
|
+
actions: mapActions(d.actions),
|
|
38
|
+
image: mapImage(d.image, d.imageAlt, ctx),
|
|
39
|
+
mediaPosition: d.mediaPosition,
|
|
40
|
+
mediaAspect: d.mediaAspect,
|
|
41
|
+
headingLevel: 2 as const,
|
|
42
|
+
placeholder: ctx.placeholder,
|
|
43
|
+
});
|
|
44
|
+
}
|