@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.
Files changed (280) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +373 -0
  3. package/README.md +186 -2
  4. package/docs/blocks.md +364 -0
  5. package/docs/data.md +128 -0
  6. package/docs/motion.md +166 -0
  7. package/docs/primitives.md +510 -0
  8. package/docs/seo.md +187 -0
  9. package/docs/tokens.md +122 -0
  10. package/package.json +141 -3
  11. package/scripts/check-contrast.mjs +180 -0
  12. package/src/blocks/BlockRenderer.astro +54 -0
  13. package/src/blocks/CTABanner.astro +121 -0
  14. package/src/blocks/CTAPair.astro +110 -0
  15. package/src/blocks/CardGrid.astro +167 -0
  16. package/src/blocks/ConsentEmbed.astro +125 -0
  17. package/src/blocks/ConsentManager.astro +147 -0
  18. package/src/blocks/ConsentScript.astro +47 -0
  19. package/src/blocks/ContactCard.astro +164 -0
  20. package/src/blocks/ContactForm.astro +224 -0
  21. package/src/blocks/ErrorPage.astro +242 -0
  22. package/src/blocks/FAQ.astro +135 -0
  23. package/src/blocks/FeatureGrid.astro +148 -0
  24. package/src/blocks/Hero.astro +171 -0
  25. package/src/blocks/HeroCarousel.astro +220 -0
  26. package/src/blocks/HighlightCards.astro +107 -0
  27. package/src/blocks/LocationHours.astro +311 -0
  28. package/src/blocks/LogoCloud.astro +135 -0
  29. package/src/blocks/MaintenancePage.astro +168 -0
  30. package/src/blocks/MediaText.astro +177 -0
  31. package/src/blocks/PageHeader.astro +126 -0
  32. package/src/blocks/ProseSection.astro +98 -0
  33. package/src/blocks/Reviews.astro +194 -0
  34. package/src/blocks/RichText.astro +57 -0
  35. package/src/blocks/StatsBand.astro +117 -0
  36. package/src/blocks/Steps.astro +141 -0
  37. package/src/blocks/Testimonials.astro +144 -0
  38. package/src/blocks/Topbar.astro +158 -0
  39. package/src/blocks/cms/card-grid.ts +80 -0
  40. package/src/blocks/cms/consent.ts +45 -0
  41. package/src/blocks/cms/contact-card.ts +88 -0
  42. package/src/blocks/cms/contact-form.ts +55 -0
  43. package/src/blocks/cms/cta-banner.ts +48 -0
  44. package/src/blocks/cms/cta-pair.ts +63 -0
  45. package/src/blocks/cms/data-base.ts +7 -0
  46. package/src/blocks/cms/data.ts +257 -0
  47. package/src/blocks/cms/faq.ts +70 -0
  48. package/src/blocks/cms/feature-grid.ts +80 -0
  49. package/src/blocks/cms/fixtures.ts +599 -0
  50. package/src/blocks/cms/hero-carousel.ts +80 -0
  51. package/src/blocks/cms/hero.ts +77 -0
  52. package/src/blocks/cms/highlight-cards.ts +76 -0
  53. package/src/blocks/cms/images.ts +38 -0
  54. package/src/blocks/cms/index.ts +87 -0
  55. package/src/blocks/cms/location-hours.ts +149 -0
  56. package/src/blocks/cms/logo-cloud.ts +62 -0
  57. package/src/blocks/cms/media-text.ts +44 -0
  58. package/src/blocks/cms/page-header.ts +49 -0
  59. package/src/blocks/cms/pages.ts +81 -0
  60. package/src/blocks/cms/prose-section.ts +45 -0
  61. package/src/blocks/cms/reviews.ts +101 -0
  62. package/src/blocks/cms/shared.ts +115 -0
  63. package/src/blocks/cms/stats-band.ts +61 -0
  64. package/src/blocks/cms/steps.ts +67 -0
  65. package/src/blocks/cms/testimonials.ts +80 -0
  66. package/src/blocks/cms/topbar.ts +64 -0
  67. package/src/blocks/cms/types.ts +63 -0
  68. package/src/blocks/consent.ts +14 -0
  69. package/src/blocks/icons.ts +47 -0
  70. package/src/blocks/index.ts +42 -0
  71. package/src/blocks/internal/Actions.astro +29 -0
  72. package/src/blocks/internal/BlockHeader.astro +45 -0
  73. package/src/blocks/internal/BlockShell.astro +58 -0
  74. package/src/blocks/internal/CarouselScript.astro +7 -0
  75. package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
  76. package/src/blocks/internal/ConsentManagerScript.astro +7 -0
  77. package/src/blocks/internal/HoursScript.astro +7 -0
  78. package/src/blocks/internal/Placeholder.astro +13 -0
  79. package/src/blocks/internal/RichTextNode.astro +133 -0
  80. package/src/blocks/internal/StandaloneDocument.astro +53 -0
  81. package/src/blocks/internal/tina.ts +19 -0
  82. package/src/blocks/internal/util.ts +23 -0
  83. package/src/blocks/lib/consent.ts +96 -0
  84. package/src/blocks/lib/contact.ts +86 -0
  85. package/src/blocks/lib/error-pages.ts +119 -0
  86. package/src/blocks/lib/faq.ts +37 -0
  87. package/src/blocks/lib/hours.ts +201 -0
  88. package/src/blocks/lib/maintenance.ts +129 -0
  89. package/src/blocks/lib/reviews.ts +22 -0
  90. package/src/blocks/lib/rich-text.ts +143 -0
  91. package/src/blocks/lib/slug.ts +12 -0
  92. package/src/blocks/registry.ts +79 -0
  93. package/src/blocks/scripts/carousel.ts +218 -0
  94. package/src/blocks/scripts/consent-embed.ts +105 -0
  95. package/src/blocks/scripts/consent-manager.ts +112 -0
  96. package/src/blocks/scripts/consent-store.ts +86 -0
  97. package/src/blocks/scripts/error-page.ts +71 -0
  98. package/src/blocks/scripts/hours.ts +106 -0
  99. package/src/blocks/scripts/maintenance.ts +109 -0
  100. package/src/blocks/styles/blocks.css +1320 -0
  101. package/src/blocks/styles/consent.css +102 -0
  102. package/src/blocks/styles/faq.css +28 -0
  103. package/src/blocks/styles/location.css +92 -0
  104. package/src/blocks/styles/prose-section.css +13 -0
  105. package/src/blocks/styles/quotes.css +123 -0
  106. package/src/blocks/styles/rich-text.css +14 -0
  107. package/src/blocks/types.ts +283 -0
  108. package/src/data/ChartAxis.astro +19 -0
  109. package/src/data/ChartContainer.astro +151 -0
  110. package/src/data/ChartLegend.astro +25 -0
  111. package/src/data/ChartSeries.astro +14 -0
  112. package/src/data/ChartTable.astro +17 -0
  113. package/src/data/ChartTooltip.astro +20 -0
  114. package/src/data/Sparkline.astro +55 -0
  115. package/src/data/cms.ts +190 -0
  116. package/src/data/index.ts +10 -0
  117. package/src/data/lib/chart.ts +450 -0
  118. package/src/data/lib/render.ts +219 -0
  119. package/src/data/lib/scale.ts +107 -0
  120. package/src/data/lib/sparkline.ts +117 -0
  121. package/src/data/scripts/chart.ts +324 -0
  122. package/src/data/styles/chart.css +392 -0
  123. package/src/motion/Marquee.astro +90 -0
  124. package/src/motion/MotionProvider.astro +50 -0
  125. package/src/motion/PageTransitions.astro +61 -0
  126. package/src/motion/Parallax.astro +44 -0
  127. package/src/motion/ParallaxLayer.astro +31 -0
  128. package/src/motion/RevealOnScroll.astro +59 -0
  129. package/src/motion/SceneRegistry.astro +38 -0
  130. package/src/motion/ScrollScene.astro +81 -0
  131. package/src/motion/index.ts +12 -0
  132. package/src/motion/integration.ts +48 -0
  133. package/src/motion/runtime/page-transitions.ts +68 -0
  134. package/src/motion/runtime/runtime.ts +180 -0
  135. package/src/motion/runtime/scenes.ts +248 -0
  136. package/src/motion/runtime/types.ts +103 -0
  137. package/src/motion/styles/motion.css +332 -0
  138. package/src/motion/transitions.ts +74 -0
  139. package/src/motion/virtual.d.ts +4 -0
  140. package/src/primitives/Accordion.astro +129 -0
  141. package/src/primitives/Breadcrumbs.astro +50 -0
  142. package/src/primitives/BulletList.astro +69 -0
  143. package/src/primitives/Button.astro +73 -0
  144. package/src/primitives/ButtonGroup.astro +54 -0
  145. package/src/primitives/Callout.astro +137 -0
  146. package/src/primitives/Caption.astro +35 -0
  147. package/src/primitives/Card.astro +72 -0
  148. package/src/primitives/CardContent.astro +24 -0
  149. package/src/primitives/CardFooter.astro +36 -0
  150. package/src/primitives/CardHeader.astro +86 -0
  151. package/src/primitives/Checkbox.astro +38 -0
  152. package/src/primitives/ChoiceGroup.astro +23 -0
  153. package/src/primitives/Cluster.astro +49 -0
  154. package/src/primitives/Container.astro +44 -0
  155. package/src/primitives/DescriptionList.astro +83 -0
  156. package/src/primitives/Dialog.astro +38 -0
  157. package/src/primitives/Disclosure.astro +67 -0
  158. package/src/primitives/Divider.astro +93 -0
  159. package/src/primitives/Drawer.astro +33 -0
  160. package/src/primitives/Fieldset.astro +80 -0
  161. package/src/primitives/Flex.astro +64 -0
  162. package/src/primitives/FocusRing.astro +63 -0
  163. package/src/primitives/FocusTrap.astro +64 -0
  164. package/src/primitives/Footer.astro +155 -0
  165. package/src/primitives/Form.astro +68 -0
  166. package/src/primitives/FormDescription.astro +26 -0
  167. package/src/primitives/FormError.astro +106 -0
  168. package/src/primitives/FormField.astro +72 -0
  169. package/src/primitives/Grid.astro +64 -0
  170. package/src/primitives/Heading.astro +45 -0
  171. package/src/primitives/IconButton.astro +48 -0
  172. package/src/primitives/Image.astro +125 -0
  173. package/src/primitives/Input.astro +84 -0
  174. package/src/primitives/Label.astro +50 -0
  175. package/src/primitives/Link.astro +81 -0
  176. package/src/primitives/LinkButton.astro +66 -0
  177. package/src/primitives/List.astro +39 -0
  178. package/src/primitives/ListItem.astro +178 -0
  179. package/src/primitives/MediaObject.astro +66 -0
  180. package/src/primitives/MetricCard.astro +276 -0
  181. package/src/primitives/NavLink.astro +81 -0
  182. package/src/primitives/NavMenu.astro +109 -0
  183. package/src/primitives/Navbar.astro +197 -0
  184. package/src/primitives/Panel.astro +153 -0
  185. package/src/primitives/Picture.astro +167 -0
  186. package/src/primitives/Popover.astro +95 -0
  187. package/src/primitives/Prose.astro +45 -0
  188. package/src/primitives/Radio.astro +21 -0
  189. package/src/primitives/Rating.astro +135 -0
  190. package/src/primitives/ReducedMotion.astro +90 -0
  191. package/src/primitives/SegmentedControl.astro +132 -0
  192. package/src/primitives/Select.astro +107 -0
  193. package/src/primitives/Sheet.astro +45 -0
  194. package/src/primitives/SkipLink.astro +31 -0
  195. package/src/primitives/Slider.astro +186 -0
  196. package/src/primitives/Spacer.astro +35 -0
  197. package/src/primitives/Stack.astro +51 -0
  198. package/src/primitives/Surface.astro +70 -0
  199. package/src/primitives/Switch.astro +22 -0
  200. package/src/primitives/Table.astro +382 -0
  201. package/src/primitives/Tabs.astro +126 -0
  202. package/src/primitives/Text.astro +56 -0
  203. package/src/primitives/Textarea.astro +73 -0
  204. package/src/primitives/Thumbnail.astro +154 -0
  205. package/src/primitives/Toggle.astro +99 -0
  206. package/src/primitives/Tooltip.astro +50 -0
  207. package/src/primitives/VisuallyHidden.astro +29 -0
  208. package/src/primitives/index.ts +103 -0
  209. package/src/primitives/internal/AccordionScript.astro +7 -0
  210. package/src/primitives/internal/ChoiceField.astro +89 -0
  211. package/src/primitives/internal/FocusTrapScript.astro +8 -0
  212. package/src/primitives/internal/FormValidationScript.astro +10 -0
  213. package/src/primitives/internal/IndeterminateScript.astro +13 -0
  214. package/src/primitives/internal/ModalPanel.astro +114 -0
  215. package/src/primitives/internal/OverlayScript.astro +7 -0
  216. package/src/primitives/internal/ReducedMotionScript.astro +7 -0
  217. package/src/primitives/internal/SliderScript.astro +7 -0
  218. package/src/primitives/internal/SparklineScript.astro +7 -0
  219. package/src/primitives/internal/TableSortScript.astro +7 -0
  220. package/src/primitives/internal/TabsScript.astro +7 -0
  221. package/src/primitives/internal/TooltipScript.astro +7 -0
  222. package/src/primitives/lib/deprecate.ts +47 -0
  223. package/src/primitives/lib/focus-trap.ts +197 -0
  224. package/src/primitives/lib/focus.ts +60 -0
  225. package/src/primitives/lib/image-plan.ts +82 -0
  226. package/src/primitives/lib/image.ts +129 -0
  227. package/src/primitives/lib/motion.ts +68 -0
  228. package/src/primitives/lib/slider.ts +170 -0
  229. package/src/primitives/scripts/accordion.ts +123 -0
  230. package/src/primitives/scripts/form-validation.ts +225 -0
  231. package/src/primitives/scripts/overlay.ts +71 -0
  232. package/src/primitives/scripts/reduced-motion.ts +59 -0
  233. package/src/primitives/scripts/slider.ts +150 -0
  234. package/src/primitives/scripts/sparkline.ts +131 -0
  235. package/src/primitives/scripts/table-sort.ts +68 -0
  236. package/src/primitives/scripts/tabs.ts +151 -0
  237. package/src/primitives/scripts/tooltip.ts +28 -0
  238. package/src/primitives/styles/a11y.css +104 -0
  239. package/src/primitives/styles/accordion.css +53 -0
  240. package/src/primitives/styles/breadcrumbs.css +59 -0
  241. package/src/primitives/styles/bullet-list.css +89 -0
  242. package/src/primitives/styles/button.css +237 -0
  243. package/src/primitives/styles/choice.css +164 -0
  244. package/src/primitives/styles/cluster.css +24 -0
  245. package/src/primitives/styles/container.css +19 -0
  246. package/src/primitives/styles/data.css +849 -0
  247. package/src/primitives/styles/disclosure.css +140 -0
  248. package/src/primitives/styles/divider.css +50 -0
  249. package/src/primitives/styles/flex.css +42 -0
  250. package/src/primitives/styles/form.css +241 -0
  251. package/src/primitives/styles/grid.css +36 -0
  252. package/src/primitives/styles/media.css +247 -0
  253. package/src/primitives/styles/nav.css +792 -0
  254. package/src/primitives/styles/overlay.css +362 -0
  255. package/src/primitives/styles/prose.css +146 -0
  256. package/src/primitives/styles/scale.css +175 -0
  257. package/src/primitives/styles/segmented.css +165 -0
  258. package/src/primitives/styles/slider.css +170 -0
  259. package/src/primitives/styles/spacer.css +17 -0
  260. package/src/primitives/styles/stack.css +25 -0
  261. package/src/primitives/styles/surface.css +403 -0
  262. package/src/primitives/styles/tabs.css +223 -0
  263. package/src/primitives/styles/typography.css +144 -0
  264. package/src/primitives/styles/utilities.css +24 -0
  265. package/src/primitives/types.ts +385 -0
  266. package/src/primitives/utils.ts +254 -0
  267. package/src/seo/JSONLD.astro +35 -0
  268. package/src/seo/SEOHead.astro +47 -0
  269. package/src/seo/cms.ts +80 -0
  270. package/src/seo/index.ts +10 -0
  271. package/src/seo/integration.ts +231 -0
  272. package/src/seo/lib/jsonld.ts +334 -0
  273. package/src/seo/lib/meta.ts +205 -0
  274. package/src/seo/lib/redirects.ts +283 -0
  275. package/src/seo/lib/robots.ts +33 -0
  276. package/src/seo/lib/rss.ts +98 -0
  277. package/src/seo/lib/sitemap.ts +105 -0
  278. package/src/seo/lib/url.ts +68 -0
  279. package/src/tokens/base.css +71 -0
  280. package/src/tokens/tokens.css +210 -0
@@ -0,0 +1,45 @@
1
+ import type { ConsentData } from './data';
2
+ import type { TinaField } from './types';
3
+ import { clean, compact, longTextField, textField } from './shared';
4
+ import { safeHref } from '../lib/contact';
5
+
6
+ const CATEGORY_OPTIONS = [
7
+ { value: 'media', label: 'Embedded content (maps, videos, booking tools)' },
8
+ { value: 'analytics', label: 'Analytics' },
9
+ { value: 'marketing', label: 'Marketing' },
10
+ ];
11
+
12
+ /** Site-settings field for ConsentManager. Add it to your Tina settings collection. */
13
+ export function consentField(): TinaField {
14
+ return {
15
+ type: 'object',
16
+ name: 'consent',
17
+ label: 'Privacy banner',
18
+ fields: [
19
+ longTextField('message', 'Banner text (optional)', { description: 'Say which outside services the site uses.' }),
20
+ textField('policyHref', 'Privacy policy link', { description: 'e.g. /privacy' }),
21
+ {
22
+ type: 'string',
23
+ name: 'categories',
24
+ label: 'What the site uses',
25
+ list: true,
26
+ options: CATEGORY_OPTIONS,
27
+ ui: { component: 'checkbox-group' },
28
+ },
29
+ textField('version', 'Policy version', { description: 'Change it (e.g. to 2) when you add a service, and every visitor is asked again.' }),
30
+ ],
31
+ };
32
+ }
33
+
34
+ /** Site settings → ConsentManager props. */
35
+ export function consentProps(d: ConsentData | null | undefined) {
36
+ const data = d ?? {};
37
+ const categories = (data.categories ?? []).filter((c): c is 'media' | 'analytics' | 'marketing' => c === 'media' || c === 'analytics' || c === 'marketing');
38
+ const message = clean(data.message);
39
+ return compact({
40
+ policyHref: safeHref(clean(data.policyHref)),
41
+ version: clean(data.version),
42
+ categories: categories.length ? categories : undefined,
43
+ labels: message ? { message } : undefined,
44
+ });
45
+ }
@@ -0,0 +1,88 @@
1
+ import type { ContactItem } from '../types';
2
+ import type { ContactCardData } from './data';
3
+ import type { MapContext, TinaTemplate } from './types';
4
+ import { clean, compact, longTextField, mapSettings, settingsField, textField, upgrade } from './shared';
5
+
6
+ const TYPES = ['address', 'phone', 'fax', 'email', 'hours', 'link'] as const;
7
+
8
+ export const contactCardDefaults: ContactCardData = {
9
+ _template: 'contactCard',
10
+ heading: 'Contact us',
11
+ items: [
12
+ { type: 'phone', value: '(555) 555-0100' },
13
+ { type: 'email', value: 'hello@example.com' },
14
+ ],
15
+ };
16
+
17
+ export const contactCardTemplate: TinaTemplate = {
18
+ name: 'contactCard',
19
+ label: 'Contact card',
20
+ ui: { defaultItem: contactCardDefaults, itemProps: (item: ContactCardData) => ({ label: `Contact: ${item?.heading ?? ''}` }) },
21
+ fields: [
22
+ textField('eyebrow', 'Eyebrow'),
23
+ textField('heading', 'Heading'),
24
+ longTextField('description', 'Intro text'),
25
+ {
26
+ type: 'object',
27
+ name: 'items',
28
+ label: 'Contact details',
29
+ list: true,
30
+ description: 'Phone numbers become click-to-call links; fax numbers stay plain text.',
31
+ ui: { itemProps: (item: { type?: string; value?: string }) => ({ label: [item?.type, item?.value].filter(Boolean).join(': ') || 'Detail' }), defaultItem: { type: 'phone', value: '' } },
32
+ fields: [
33
+ {
34
+ type: 'string',
35
+ name: 'type',
36
+ label: 'Type',
37
+ required: true,
38
+ options: [
39
+ { value: 'phone', label: 'Phone (click to call)' },
40
+ { value: 'email', label: 'Email' },
41
+ { value: 'address', label: 'Address' },
42
+ { value: 'fax', label: 'Fax' },
43
+ { value: 'hours', label: 'Hours' },
44
+ { value: 'link', label: 'Link' },
45
+ ],
46
+ },
47
+ longTextField('value', 'Value', { required: true, description: 'Addresses and hours can use several lines.' }),
48
+ textField('label', 'Label (optional)', { description: 'Shown above the value. Defaults to the type (“Phone”).' }),
49
+ textField('href', 'Link (links only)', { description: 'For “Link” items: the URL.' }),
50
+ ],
51
+ },
52
+ longTextField('note', 'Small print', { description: 'E.g. “Please don’t email passwords or API keys.”' }),
53
+ { type: 'string', name: 'variant', label: 'Style', options: [{ value: 'outline', label: 'Card' }, { value: 'plain', label: 'Plain' }] },
54
+ { type: 'string', name: 'columns', label: 'Columns (when wide)', options: ['1', '2', '3'] },
55
+ settingsField(),
56
+ ],
57
+ };
58
+
59
+ export function mapContactItems(items: ContactCardData['items']): ContactItem[] {
60
+ return (items ?? [])
61
+ .filter((i) => i && (TYPES as readonly string[]).includes(i.type ?? '') && clean(i.value))
62
+ .map((i) =>
63
+ compact({
64
+ type: i.type!,
65
+ value: clean(i.value)!,
66
+ // An empty label in the CMS means "use the default"; only code can hide labels with "".
67
+ label: clean(i.label),
68
+ href: i.type === 'link' ? clean(i.href) : undefined,
69
+ tina: i as never,
70
+ }) as ContactItem,
71
+ );
72
+ }
73
+
74
+ export function contactCardToProps(d: ContactCardData, ctx: MapContext) {
75
+ return compact({
76
+ ...mapSettings(d.settings),
77
+ eyebrow: clean(d.eyebrow),
78
+ heading: clean(d.heading),
79
+ description: clean(d.description),
80
+ items: mapContactItems(d.items),
81
+ note: clean(d.note),
82
+ variant: upgrade(d.variant, { card: 'outline' }),
83
+ columns: d.columns ? (Number(d.columns) as 1 | 2 | 3) : undefined,
84
+ headingLevel: 2 as const,
85
+ placeholder: ctx.placeholder,
86
+ });
87
+ }
88
+
@@ -0,0 +1,55 @@
1
+ import type { ContactFormData } from './data';
2
+ import type { MapContext, TinaTemplate } from './types';
3
+ import { clean, compact, longTextField, mapSettings, settingsField, textField } from './shared';
4
+
5
+ export const contactFormDefaults: ContactFormData = {
6
+ _template: 'contactForm',
7
+ heading: 'Send us a message',
8
+ description: 'We’ll get back to you within one business day.',
9
+ };
10
+
11
+ /**
12
+ * Where the form posts is not a CMS field: it comes from PUBLIC_FORM_ENDPOINT (or a site-level
13
+ * `action`), so an editor can't point messages at an unvetted service.
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
+
34
+ export function contactFormToProps(d: ContactFormData, ctx: MapContext) {
35
+ const { anchor, align, background, tone, spacing } = mapSettings(d.settings);
36
+ const message = clean(d.messageLabel);
37
+ return compact({
38
+ anchor,
39
+ align,
40
+ background,
41
+ tone,
42
+ spacing,
43
+ heading: clean(d.heading),
44
+ description: clean(d.description),
45
+ headingLevel: ctx.headingLevel === 1 ? (2 as const) : ctx.headingLevel,
46
+ nameFields: d.nameFields,
47
+ phone: d.phone,
48
+ messageHint: clean(d.messageHint),
49
+ note: clean(d.note),
50
+ submitLabel: clean(d.submitLabel),
51
+ fallbackPhone: clean(d.fallbackPhone),
52
+ fallbackEmail: clean(d.fallbackEmail),
53
+ labels: message ? { message } : undefined,
54
+ });
55
+ }
@@ -0,0 +1,48 @@
1
+ import type { CtaBannerData } from './data';
2
+ import type { MapContext, TinaTemplate } from './types';
3
+ import { actionsField, clean, compact, longTextField, mapActions, mapSettings, settingsField, textField, upgrade } from './shared';
4
+
5
+ export const ctaBannerDefaults: CtaBannerData = {
6
+ _template: 'ctaBanner',
7
+ variant: 'solid',
8
+ heading: 'Ready to get started?',
9
+ description: 'Tell people what happens next.',
10
+ actions: [{ label: 'Contact us', href: '/contact', style: 'solid' }],
11
+ };
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
+ export function ctaBannerToProps(d: CtaBannerData, ctx: MapContext) {
35
+ const { background: _bg, tone: _tone, ...settings } = mapSettings(d.settings);
36
+ return compact({
37
+ ...settings,
38
+ heading: clean(d.heading),
39
+ description: clean(d.description),
40
+ actions: mapActions(d.actions),
41
+ note: clean(d.note),
42
+ variant: upgrade(d.variant, { filled: 'solid', subtle: 'soft' }),
43
+ tone: d.tone,
44
+ bleed: d.bleed ?? undefined,
45
+ headingLevel: 2 as const,
46
+ placeholder: ctx.placeholder,
47
+ });
48
+ }
@@ -0,0 +1,63 @@
1
+ import type { CtaPanelItem } from '../types';
2
+ import type { CtaPairData } from './data';
3
+ import type { MapContext, TinaTemplate } from './types';
4
+ import { actionsField, clean, compact, longTextField, mapActions, mapSettings, textField } from './shared';
5
+
6
+ export const ctaPairDefaults: CtaPairData = {
7
+ _template: 'ctaPair',
8
+ label: 'Get in touch',
9
+ items: [
10
+ { heading: 'Questions? We’re here to help', actions: [{ label: 'Contact us', href: '/contact', style: 'solid' }] },
11
+ { heading: 'Agency partner?', actions: [{ label: 'Send a brief', href: '/partners', style: 'solid' }] },
12
+ ],
13
+ };
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
+ export function ctaPairToProps(d: CtaPairData, ctx: MapContext) {
49
+ const items = (d.items ?? [])
50
+ .filter((i) => clean(i?.heading))
51
+ .slice(0, 2)
52
+ .map((i) => compact({ heading: clean(i.heading)!, description: clean(i.description), actions: mapActions(i.actions), tone: i.tone, tina: i as never }) as CtaPanelItem);
53
+ const { anchor, align } = mapSettings(d.settings);
54
+ return compact({
55
+ anchor,
56
+ align,
57
+ label: clean(d.label),
58
+ items,
59
+ bleed: d.bleed ?? undefined,
60
+ headingLevel: 2 as const,
61
+ placeholder: ctx.placeholder,
62
+ });
63
+ }
@@ -0,0 +1,7 @@
1
+ export type { CmsAction, CmsSettings } from './types';
2
+ /** Tina query results carry these (template name, GraphQL type, visual-editing source). */
3
+ export interface TinaSourceLike {
4
+ _template?: string;
5
+ __typename?: string;
6
+ _content_source?: { queryId: string; path: Array<string | number> };
7
+ }
@@ -0,0 +1,257 @@
1
+ /** CMS data shapes (what Tina stores and returns for each template). All fields optional. */
2
+ import type { CmsAction, CmsSettings, TinaSourceLike } from './data-base';
3
+ export type { CmsAction, CmsSettings };
4
+
5
+ interface Base extends TinaSourceLike {
6
+ settings?: CmsSettings | null;
7
+ }
8
+ export interface HeroData extends Base {
9
+ _template?: 'hero';
10
+ /** Stored as `variant`; maps to Hero's `layout`. */
11
+ variant?: 'text' | 'split' | 'media';
12
+ eyebrow?: string;
13
+ heading?: string;
14
+ description?: string;
15
+ actions?: CmsAction[];
16
+ meta?: string;
17
+ image?: string;
18
+ imageAlt?: string;
19
+ mediaPosition?: 'start' | 'end';
20
+ scrim?: 'even' | 'gradient';
21
+ minHeight?: 'auto' | 'm' | 'l' | 'screen';
22
+ }
23
+ export interface CtaBannerData extends Base {
24
+ _template?: 'ctaBanner';
25
+ heading?: string;
26
+ description?: string;
27
+ actions?: CmsAction[];
28
+ note?: string;
29
+ /** `filled` / `subtle` are older stored values for `solid` / `soft`. */
30
+ variant?: 'solid' | 'soft' | 'outline' | 'filled' | 'subtle';
31
+ tone?: 'accent' | 'neutral';
32
+ bleed?: boolean | null;
33
+ }
34
+ export interface FeatureGridData extends Base {
35
+ _template?: 'featureGrid';
36
+ eyebrow?: string;
37
+ heading?: string;
38
+ description?: string;
39
+ items?: Array<{ title?: string; description?: string; icon?: string; href?: string; badge?: string } & TinaSourceLike>;
40
+ /** `cards` is an older stored value for `card`. */
41
+ variant?: 'plain' | 'card' | 'divided' | 'cards';
42
+ layout?: 'stacked' | 'inline';
43
+ columns?: '1' | '2' | '3' | '4';
44
+ size?: 's' | 'm' | 'l';
45
+ }
46
+ export interface CardGridData extends Base {
47
+ _template?: 'cardGrid';
48
+ eyebrow?: string;
49
+ heading?: string;
50
+ description?: string;
51
+ items?: Array<{ title?: string; description?: string; href?: string; image?: string; imageAlt?: string; eyebrow?: string; meta?: string } & TinaSourceLike>;
52
+ layout?: 'grid' | 'list';
53
+ featured?: boolean | null;
54
+ variant?: 'outline' | 'elevated' | 'filled';
55
+ columns?: '2' | '3' | '4';
56
+ /** The dash forms are older stored values. */
57
+ mediaAspect?: '16/9' | '3/2' | '4/3' | '1/1' | '16-9' | '3-2' | '4-3' | '1-1';
58
+ emptyMessage?: string;
59
+ }
60
+ export interface LogoCloudData extends Base {
61
+ _template?: 'logoCloud';
62
+ heading?: string;
63
+ compact?: boolean | null;
64
+ logos?: Array<{ image?: string; name?: string; href?: string } & TinaSourceLike>;
65
+ /** Stored as `variant`; maps to LogoCloud's `layout`. */
66
+ variant?: 'grid' | 'strip';
67
+ columns?: '2' | '3' | '4' | '5' | '6';
68
+ size?: 's' | 'm' | 'l';
69
+ mono?: boolean | null;
70
+ tile?: boolean | null;
71
+ }
72
+ export interface HeroCarouselData extends Base {
73
+ _template?: 'heroCarousel';
74
+ label?: string;
75
+ slides?: Array<{ eyebrow?: string; heading?: string; description?: string; actions?: CmsAction[]; image?: string } & TinaSourceLike>;
76
+ autoplay?: number | null;
77
+ minHeight?: 'banner' | 'm' | 'l' | 'screen';
78
+ motion?: 'none' | 'zoom';
79
+ controls?: 'bar' | 'split';
80
+ scrim?: 'even' | 'gradient';
81
+ }
82
+ export interface PageHeaderData extends Base {
83
+ _template?: 'pageHeader';
84
+ eyebrow?: string;
85
+ heading?: string;
86
+ description?: string;
87
+ breadcrumbs?: Array<{ label?: string; href?: string } & TinaSourceLike>;
88
+ breadcrumbPosition?: 'above' | 'below';
89
+ actions?: CmsAction[];
90
+ }
91
+ export interface ContactCardData extends Base {
92
+ _template?: 'contactCard';
93
+ eyebrow?: string;
94
+ heading?: string;
95
+ description?: string;
96
+ items?: Array<{ type?: 'address' | 'phone' | 'fax' | 'email' | 'hours' | 'link'; label?: string; value?: string; href?: string } & TinaSourceLike>;
97
+ note?: string;
98
+ /** `card` is an older stored value for `outline`. */
99
+ variant?: 'outline' | 'plain' | 'card';
100
+ columns?: '1' | '2' | '3';
101
+ }
102
+ export interface StepsData extends Base {
103
+ _template?: 'steps';
104
+ eyebrow?: string;
105
+ heading?: string;
106
+ description?: string;
107
+ items?: Array<{ title?: string; description?: string; icon?: string } & TinaSourceLike>;
108
+ marker?: 'number' | 'icon' | 'none';
109
+ layout?: 'row' | 'list';
110
+ /** `cards` is an older stored value for `card`. */
111
+ variant?: 'plain' | 'card' | 'cards';
112
+ }
113
+ export interface MediaTextData extends Base {
114
+ _template?: 'mediaText';
115
+ eyebrow?: string;
116
+ heading?: string;
117
+ description?: string;
118
+ points?: string[];
119
+ actions?: CmsAction[];
120
+ image?: string;
121
+ imageAlt?: string;
122
+ mediaPosition?: 'start' | 'end';
123
+ mediaAspect?: '1/1' | '4/3' | '3/2' | '16/9' | '4/5';
124
+ }
125
+ export interface CtaPairData extends Base {
126
+ _template?: 'ctaPair';
127
+ label?: string;
128
+ items?: Array<{ heading?: string; description?: string; actions?: CmsAction[]; tone?: 'accent' | 'neutral' } & TinaSourceLike>;
129
+ bleed?: boolean | null;
130
+ }
131
+ export interface StatsBandData extends Base {
132
+ _template?: 'statsBand';
133
+ heading?: string;
134
+ label?: string;
135
+ items?: Array<{ value?: string; label?: string; icon?: string } & TinaSourceLike>;
136
+ image?: string;
137
+ tone?: 'accent' | 'neutral';
138
+ }
139
+ export interface HighlightCardsData extends Base {
140
+ _template?: 'highlightCards';
141
+ label?: string;
142
+ items?: Array<{ heading?: string; description?: string; points?: string[]; actions?: CmsAction[]; tone?: string } & TinaSourceLike>;
143
+ overlap?: boolean | null;
144
+ gap?: 'none' | 'm';
145
+ }
146
+ export interface ContactFormData extends Base {
147
+ _template?: 'contactForm';
148
+ heading?: string;
149
+ description?: string;
150
+ nameFields?: 'split' | 'single';
151
+ phone?: 'optional' | 'required' | 'hidden';
152
+ messageLabel?: string;
153
+ messageHint?: string;
154
+ note?: string;
155
+ submitLabel?: string;
156
+ fallbackPhone?: string;
157
+ fallbackEmail?: string;
158
+ }
159
+ /** Site settings (not a page block): the strip above the Navbar. */
160
+ export interface TopbarData {
161
+ message?: string;
162
+ items?: Array<{ type?: 'address' | 'phone' | 'fax' | 'email' | 'hours' | 'link'; value?: string; href?: string; label?: string }>;
163
+ links?: Array<{ label?: string; href?: string; newTab?: boolean | null }>;
164
+ background?: 'strong' | 'tinted' | 'subtle';
165
+ /** `subtle` is an older stored value: it now lives in `background`. */
166
+ tone?: 'neutral' | 'accent' | 'subtle';
167
+ }
168
+ /** Tina rich text (`type: 'rich-text'`): a root node, or a string from older plain-text fields. */
169
+ export type CmsRichText = import('../lib/rich-text').RichTextValue;
170
+ export interface ProseSectionData extends Base {
171
+ _template?: 'proseSection';
172
+ eyebrow?: string;
173
+ heading?: string;
174
+ body?: CmsRichText;
175
+ actions?: CmsAction[];
176
+ measure?: boolean | null;
177
+ size?: 's' | 'm' | 'l';
178
+ }
179
+ export interface FaqData extends Base {
180
+ _template?: 'faq';
181
+ eyebrow?: string;
182
+ heading?: string;
183
+ description?: string;
184
+ items?: Array<{ question?: string; answer?: CmsRichText; anchor?: string } & TinaSourceLike>;
185
+ layout?: 'stacked' | 'split';
186
+ variant?: 'divided' | 'card';
187
+ mode?: 'multiple' | 'single';
188
+ openFirst?: boolean | null;
189
+ actions?: CmsAction[];
190
+ }
191
+ export interface TestimonialsData extends Base {
192
+ _template?: 'testimonials';
193
+ eyebrow?: string;
194
+ heading?: string;
195
+ description?: string;
196
+ items?: Array<
197
+ { quote?: string; name?: string; role?: string; organization?: string; image?: string; rating?: number | null; sourceLabel?: string; sourceHref?: string } & TinaSourceLike
198
+ >;
199
+ layout?: 'grid' | 'single';
200
+ variant?: 'card' | 'plain';
201
+ columns?: '1' | '2' | '3';
202
+ actions?: CmsAction[];
203
+ }
204
+ export interface ReviewsData extends Base {
205
+ _template?: 'reviews';
206
+ eyebrow?: string;
207
+ heading?: string;
208
+ description?: string;
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 } & TinaSourceLike>;
211
+ variant?: 'card' | 'plain';
212
+ columns?: '1' | '2' | '3';
213
+ }
214
+ export interface LocationHoursData extends Base {
215
+ _template?: 'locationHours';
216
+ eyebrow?: string;
217
+ heading?: string;
218
+ description?: string;
219
+ name?: string;
220
+ address?: { street?: string; street2?: string; city?: string; region?: string; postalCode?: string; country?: string } | null;
221
+ phone?: string;
222
+ email?: string;
223
+ hours?: Array<{ days?: string[]; opens?: string; closes?: string; closed?: boolean | null } & TinaSourceLike>;
224
+ special?: Array<{ date?: string; label?: string; opens?: string; closes?: string; closed?: boolean | null } & TinaSourceLike>;
225
+ hoursNote?: string;
226
+ timeZone?: string;
227
+ map?: 'embed' | 'link' | 'none';
228
+ mapEmbedUrl?: string;
229
+ layout?: 'split' | 'stacked';
230
+ }
231
+ /** Site settings (not a page block): the consent banner's text and categories. */
232
+ export interface ConsentData {
233
+ message?: string;
234
+ policyHref?: string;
235
+ version?: string;
236
+ categories?: string[];
237
+ }
238
+ export type BlockData =
239
+ | HeroData
240
+ | CtaBannerData
241
+ | FeatureGridData
242
+ | CardGridData
243
+ | LogoCloudData
244
+ | HeroCarouselData
245
+ | PageHeaderData
246
+ | ContactCardData
247
+ | StepsData
248
+ | MediaTextData
249
+ | CtaPairData
250
+ | StatsBandData
251
+ | HighlightCardsData
252
+ | ContactFormData
253
+ | ProseSectionData
254
+ | FaqData
255
+ | TestimonialsData
256
+ | ReviewsData
257
+ | LocationHoursData;
@@ -0,0 +1,70 @@
1
+ import type { FaqItem } from '../types';
2
+ import type { FaqData } from './data';
3
+ import type { MapContext, TinaTemplate } from './types';
4
+ import { actionsField, clean, compact, longTextField, mapActions, mapSettings, settingsField, textField } from './shared';
5
+ import { isRichTextEmpty } from '../lib/rich-text';
6
+
7
+ const ANCHOR_RE = /^[a-z][a-z0-9-]*$/;
8
+
9
+ export const faqDefaults: FaqData = {
10
+ _template: 'faq',
11
+ heading: 'Questions we hear a lot',
12
+ items: [
13
+ { question: 'How long does a website take?', answer: 'Most small-business sites launch four to six weeks after the discovery call.' },
14
+ { question: 'Can my team edit the site?', answer: 'Yes. Every site comes with a CMS, and we walk your team through it before launch.' },
15
+ { question: 'Do you host the site?', answer: 'We can, or we can deploy to the host you already use.' },
16
+ ],
17
+ };
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
+ export function faqToProps(d: FaqData, ctx: MapContext) {
52
+ const items = (d.items ?? [])
53
+ .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, tina: i as never }) as FaqItem);
55
+ return compact({
56
+ ...mapSettings(d.settings),
57
+ eyebrow: clean(d.eyebrow),
58
+ heading: clean(d.heading),
59
+ description: clean(d.description),
60
+ items,
61
+ layout: d.layout,
62
+ variant: d.variant,
63
+ mode: d.mode,
64
+ openFirst: d.openFirst === true ? true : undefined,
65
+ actions: mapActions(d.actions),
66
+ resolveImage: ctx.resolveImage,
67
+ headingLevel: 2 as const,
68
+ placeholder: ctx.placeholder,
69
+ });
70
+ }