@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,49 @@
1
+ import type { PageHeaderData } from './data';
2
+ import type { MapContext, TinaTemplate } from './types';
3
+ import { actionsField, clean, compact, longTextField, mapActions, mapSettings, settingsField, textField } from './shared';
4
+
5
+ export const pageHeaderDefaults: PageHeaderData = {
6
+ _template: 'pageHeader',
7
+ heading: 'Page title',
8
+ breadcrumbs: [{ label: 'Home', href: '/' }],
9
+ };
10
+
11
+ export const pageHeaderTemplate: TinaTemplate = {
12
+ name: 'pageHeader',
13
+ label: 'Page header',
14
+ ui: { defaultItem: pageHeaderDefaults, itemProps: (item: PageHeaderData) => ({ label: `Page header: ${item?.heading ?? ''}` }) },
15
+ fields: [
16
+ textField('eyebrow', 'Eyebrow'),
17
+ textField('heading', 'Page title', { required: true }),
18
+ longTextField('description', 'Intro text'),
19
+ {
20
+ type: 'object',
21
+ name: 'breadcrumbs',
22
+ label: 'Breadcrumbs',
23
+ list: true,
24
+ description: 'From Home down to the parent of this page. This page is added at the end automatically.',
25
+ ui: { max: 6, itemProps: (item: { label?: string }) => ({ label: item?.label || 'Crumb' }), defaultItem: { label: 'Section', href: '/' } },
26
+ fields: [textField('label', 'Label', { required: true }), textField('href', 'Link', { required: true })],
27
+ },
28
+ { type: 'string', name: 'breadcrumbPosition', label: 'Breadcrumbs position', options: [{ value: 'above', label: 'Above the title' }, { value: 'below', label: 'Below the title' }] },
29
+ actionsField(2),
30
+ settingsField(),
31
+ ],
32
+ };
33
+
34
+ export function pageHeaderToProps(d: PageHeaderData, ctx: MapContext) {
35
+ const breadcrumbs = (d.breadcrumbs ?? [])
36
+ .filter((c) => clean(c?.label))
37
+ .map((c) => compact({ label: clean(c.label)!, href: clean(c.href) }) as { label: string; href?: string });
38
+ return compact({
39
+ ...mapSettings(d.settings),
40
+ eyebrow: clean(d.eyebrow),
41
+ heading: clean(d.heading),
42
+ description: clean(d.description),
43
+ breadcrumbs,
44
+ breadcrumbPosition: d.breadcrumbPosition,
45
+ actions: mapActions(d.actions),
46
+ headingLevel: ctx.headingLevel,
47
+ placeholder: ctx.placeholder,
48
+ });
49
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Tina fields for site-wide page settings (not page-builder blocks): error-page copy and links,
3
+ * and maintenance mode. Add them to a "Site settings" singleton collection:
4
+ *
5
+ * { name: 'settings', label: 'Site settings', path: 'content/settings', format: 'json',
6
+ * ui: { allowedActions: { create: false, delete: false } },
7
+ * fields: [errorPagesField, maintenanceField] }
8
+ *
9
+ * Note: a static site needs a rebuild for maintenance changes to show; on SSR, read the setting in
10
+ * `createMaintenanceMiddleware({ enabled: async () => (await getSettings()).maintenance.enabled })`.
11
+ */
12
+ import { blockIconNames } from '../icons';
13
+ import type { TinaField } from './types';
14
+ import { longTextField, textField } from './shared';
15
+
16
+ export const errorPagesField: TinaField = {
17
+ type: 'object',
18
+ name: 'errorPages',
19
+ label: 'Error pages',
20
+ fields: [
21
+ textField('notFoundHeading', 'Page not found: heading', { description: 'Leave empty for the default.' }),
22
+ longTextField('notFoundDescription', 'Page not found: text'),
23
+ textField('serverErrorHeading', 'Server error: heading'),
24
+ longTextField('serverErrorDescription', 'Server error: text'),
25
+ {
26
+ type: 'object',
27
+ name: 'links',
28
+ label: 'Popular pages',
29
+ list: true,
30
+ ui: { max: 6, itemProps: (item: { label?: string }) => ({ label: item?.label || 'Link' }) },
31
+ fields: [
32
+ textField('label', 'Label', { required: true }),
33
+ textField('href', 'Link', { required: true }),
34
+ textField('description', 'Short description'),
35
+ { type: 'string', name: 'icon', label: 'Icon', options: blockIconNames },
36
+ ],
37
+ },
38
+ textField('contactText', 'Help line intro', { description: 'e.g. “Need help now?”' }),
39
+ textField('contactLabel', 'Help line link text', { description: 'e.g. “Call (817) 555-0100”' }),
40
+ textField('contactHref', 'Help line link', { description: 'tel:, mailto: or a page.' }),
41
+ ],
42
+ };
43
+
44
+ export const maintenanceField: TinaField = {
45
+ type: 'object',
46
+ name: 'maintenance',
47
+ label: 'Maintenance mode',
48
+ fields: [
49
+ { type: 'boolean', name: 'enabled', label: 'Site is down for maintenance' },
50
+ { type: 'datetime', name: 'until', label: 'Expected back', ui: { component: 'date' } as never },
51
+ textField('heading', 'Heading'),
52
+ longTextField('description', 'Message'),
53
+ textField('notice', 'Important notice', { description: 'e.g. “Client dashboards are unaffected.”' }),
54
+ ],
55
+ };
56
+
57
+ export interface ErrorPagesSettings {
58
+ notFoundHeading?: string;
59
+ notFoundDescription?: string;
60
+ serverErrorHeading?: string;
61
+ serverErrorDescription?: string;
62
+ links?: Array<{ label?: string; href?: string; description?: string; icon?: string }>;
63
+ contactText?: string;
64
+ contactLabel?: string;
65
+ contactHref?: string;
66
+ }
67
+
68
+ /** Props for <ErrorPage> from the settings singleton (empty fields fall back to defaults). */
69
+ export function errorPageProps(settings: ErrorPagesSettings | null | undefined, status: number) {
70
+ const s = settings ?? {};
71
+ const t = (v?: string) => (v && v.trim() ? v.trim() : undefined);
72
+ const server = status >= 500;
73
+ const links = (s.links ?? []).filter((l) => t(l.label) && t(l.href)).map((l) => ({ label: t(l.label)!, href: t(l.href)!, description: t(l.description), icon: l.icon && (blockIconNames as string[]).includes(l.icon) ? l.icon : undefined }));
74
+ return {
75
+ status,
76
+ heading: t(server ? s.serverErrorHeading : s.notFoundHeading),
77
+ description: t(server ? s.serverErrorDescription : s.notFoundDescription),
78
+ links,
79
+ contact: t(s.contactLabel) && t(s.contactHref) ? { text: t(s.contactText), label: t(s.contactLabel)!, href: t(s.contactHref)! } : undefined,
80
+ };
81
+ }
@@ -0,0 +1,45 @@
1
+ import type { ProseSectionData } from './data';
2
+ import type { MapContext, TinaTemplate } from './types';
3
+ import { actionsField, clean, compact, mapActions, mapSettings, settingsField, textField } from './shared';
4
+ import { isRichTextEmpty } from '../lib/rich-text';
5
+
6
+ export const proseSectionDefaults: ProseSectionData = {
7
+ _template: 'proseSection',
8
+ heading: 'About the studio',
9
+ body: 'Sinnstack builds fast, accessible websites for small businesses.\n\nEvery project starts with a short discovery call, and every site ships with a CMS your team can edit.',
10
+ };
11
+
12
+ export const proseSectionTemplate: TinaTemplate = {
13
+ name: 'proseSection',
14
+ label: 'Text',
15
+ ui: { defaultItem: proseSectionDefaults, itemProps: (item: ProseSectionData) => ({ label: `Text: ${item?.heading ?? ''}` }) },
16
+ fields: [
17
+ textField('eyebrow', 'Eyebrow'),
18
+ textField('heading', 'Heading'),
19
+ {
20
+ type: 'rich-text',
21
+ name: 'body',
22
+ label: 'Text',
23
+ description: 'Headings inside the text are placed under the section heading automatically.',
24
+ },
25
+ actionsField(2),
26
+ { type: 'boolean', name: 'measure', label: 'Readable line length', description: 'On by default. Turn off to use the full width.' },
27
+ { type: 'string', name: 'size', label: 'Text size', options: [{ value: 's', label: 'Small' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Large' }] },
28
+ settingsField(),
29
+ ],
30
+ };
31
+
32
+ export function proseSectionToProps(d: ProseSectionData, ctx: MapContext) {
33
+ return compact({
34
+ ...mapSettings(d.settings),
35
+ eyebrow: clean(d.eyebrow),
36
+ heading: clean(d.heading),
37
+ body: isRichTextEmpty(d.body) ? undefined : d.body,
38
+ actions: mapActions(d.actions),
39
+ measure: d.measure === false ? false : undefined,
40
+ size: d.size,
41
+ resolveImage: ctx.resolveImage,
42
+ headingLevel: 2 as const,
43
+ placeholder: ctx.placeholder,
44
+ });
45
+ }
@@ -0,0 +1,101 @@
1
+ import type { ReviewItem, ReviewSummary } from '../types';
2
+ import type { ReviewsData } from './data';
3
+ import type { MapContext, TinaTemplate } from './types';
4
+ import { clean, compact, longTextField, mapSettings, settingsField, textField } from './shared';
5
+ import { safeHref } from '../lib/contact';
6
+ import { validReviews } from '../lib/reviews';
7
+
8
+ const ratingField = (name: string, label: string) => ({
9
+ type: 'number' as const,
10
+ name,
11
+ label,
12
+ ui: { validate: (v: unknown) => (v != null && v !== '' && !(Number(v) >= 1 && Number(v) <= 5) ? 'Use a number from 1 to 5.' : undefined) },
13
+ });
14
+
15
+ export const reviewsDefaults: ReviewsData = {
16
+ _template: 'reviews',
17
+ heading: 'Reviews',
18
+ summary: { rating: 4.9, count: 37, source: 'Google' },
19
+ items: [
20
+ { text: 'Clear plan, fair price, and the site was live ahead of schedule.', author: 'Reviewer name', rating: 5, date: '2026-09-12', sourceLabel: 'Google' },
21
+ { text: 'Quick replies and a site that loads fast on phones.', author: 'Reviewer name', rating: 5, date: '2026-08-03', sourceLabel: 'Google' },
22
+ ],
23
+ };
24
+
25
+ export const reviewsTemplate: TinaTemplate = {
26
+ name: 'reviews',
27
+ label: 'Reviews',
28
+ ui: { defaultItem: reviewsDefaults, itemProps: (item: ReviewsData) => ({ label: `Reviews: ${item?.heading ?? ''}` }) },
29
+ fields: [
30
+ textField('eyebrow', 'Eyebrow'),
31
+ textField('heading', 'Heading'),
32
+ longTextField('description', 'Intro text'),
33
+ {
34
+ type: 'object',
35
+ name: 'summary',
36
+ label: 'Overall rating (optional)',
37
+ description: 'Copy these from the platform and keep them current.',
38
+ fields: [
39
+ { type: 'number', name: 'rating', label: 'Average rating (e.g. 4.8)' },
40
+ { type: 'number', name: 'count', label: 'Number of reviews' },
41
+ textField('source', 'Platform', { description: 'e.g. Google.' }),
42
+ textField('href', 'Link to all reviews'),
43
+ textField('writeHref', 'Link to leave a review'),
44
+ ],
45
+ },
46
+ {
47
+ type: 'object',
48
+ name: 'items',
49
+ label: 'Reviews',
50
+ list: true,
51
+ description: 'Copy reviews word for word, with the platform and date. Don’t leave out the critical ones.',
52
+ ui: { itemProps: (item: { author?: string; rating?: number }) => ({ label: [item?.rating ? `${item.rating}★` : '', item?.author].filter(Boolean).join(' ') || 'Review' }), defaultItem: { rating: 5 } },
53
+ fields: [
54
+ longTextField('text', 'Review', { required: true }),
55
+ textField('author', 'Author', { required: true }),
56
+ { ...ratingField('rating', 'Stars (1–5)'), required: true },
57
+ { type: 'datetime', name: 'date', label: 'Date' },
58
+ textField('sourceLabel', 'Platform', { description: 'e.g. Google, Yelp.' }),
59
+ textField('sourceHref', 'Link to the review (optional)'),
60
+ longTextField('response', 'Your public reply (optional)'),
61
+ ],
62
+ },
63
+ { type: 'string', name: 'variant', label: 'Style', options: [{ value: 'card', label: 'Boxes' }, { value: 'plain', label: 'Plain' }] },
64
+ { type: 'string', name: 'columns', label: 'Columns (at most)', options: ['1', '2', '3'] },
65
+ settingsField(),
66
+ ],
67
+ };
68
+
69
+ export function reviewsToProps(d: ReviewsData, ctx: MapContext) {
70
+ const items = validReviews(
71
+ (d.items ?? []).map((i) => {
72
+ const label = clean(i?.sourceLabel);
73
+ return compact({
74
+ text: clean(i?.text) ?? '',
75
+ author: clean(i?.author) ?? '',
76
+ rating: typeof i?.rating === 'number' ? i.rating : NaN,
77
+ date: clean(i?.date)?.slice(0, 10),
78
+ source: label ? compact({ label, href: safeHref(clean(i.sourceHref)) }) : undefined,
79
+ response: clean(i?.response),
80
+ tina: i as never,
81
+ }) as ReviewItem;
82
+ }),
83
+ );
84
+ const s = d.summary;
85
+ const summary: ReviewSummary | undefined =
86
+ s && typeof s.rating === 'number' && s.rating > 0 && typeof s.count === 'number' && s.count > 0
87
+ ? (compact({ rating: Math.min(5, s.rating), count: Math.round(s.count), source: clean(s.source), href: safeHref(clean(s.href)), writeHref: safeHref(clean(s.writeHref)) }) as ReviewSummary)
88
+ : undefined;
89
+ return compact({
90
+ ...mapSettings(d.settings),
91
+ eyebrow: clean(d.eyebrow),
92
+ heading: clean(d.heading),
93
+ description: clean(d.description),
94
+ items,
95
+ summary,
96
+ variant: d.variant,
97
+ columns: d.columns ? (Number(d.columns) as 1 | 2 | 3) : undefined,
98
+ headingLevel: 2 as const,
99
+ placeholder: ctx.placeholder,
100
+ });
101
+ }
@@ -0,0 +1,115 @@
1
+ /** Field builders and mappers shared by every block's CMS module. */
2
+ import type { ActionItem, BlockProps, ImageSource } from '../types';
3
+ import type { CmsAction, CmsSettings, MapContext, TinaField } from './types';
4
+
5
+ const ANCHOR_RE = /^[a-z][a-z0-9-]*$/;
6
+
7
+ /** "Section settings": anchor, background, tone, spacing, align (checklist §5 shared props). */
8
+ export function settingsField(options: { align?: 'start' | 'center'; background?: boolean } = {}): TinaField {
9
+ const fields: TinaField[] = [
10
+ {
11
+ type: 'string',
12
+ name: 'anchor',
13
+ label: 'Anchor ID',
14
+ description: 'Lowercase letters, numbers and dashes. Link to it with #anchor.',
15
+ ui: { validate: (v: unknown) => (v && !ANCHOR_RE.test(String(v)) ? 'Use lowercase letters, numbers and dashes, starting with a letter.' : undefined) },
16
+ },
17
+ ];
18
+ if (options.background !== false) {
19
+ fields.push(
20
+ {
21
+ type: 'string',
22
+ name: 'background',
23
+ label: 'Background',
24
+ options: [
25
+ { value: 'none', label: 'None' },
26
+ { value: 'subtle', label: 'Subtle gray' },
27
+ { value: 'sunken', label: 'Darker gray' },
28
+ { value: 'tinted', label: 'Tinted (tone color, soft)' },
29
+ { value: 'strong', label: 'Strong (tone color, solid)' },
30
+ ],
31
+ },
32
+ { type: 'string', name: 'tone', label: 'Tone', description: 'Color for tinted and strong backgrounds.', options: [{ value: 'accent', label: 'Brand' }, { value: 'neutral', label: 'Neutral' }] },
33
+ );
34
+ }
35
+ fields.push(
36
+ { type: 'string', name: 'spacing', label: 'Spacing', options: [{ value: 's', label: 'Small' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Large' }, { value: 'xl', label: 'Extra large' }] },
37
+ { type: 'string', name: 'align', label: 'Alignment', options: [{ value: 'start', label: 'Start' }, { value: 'center', label: 'Center' }] },
38
+ );
39
+ return { type: 'object', name: 'settings', label: 'Section settings', fields };
40
+ }
41
+
42
+ export function actionsField(max = 2): TinaField {
43
+ return {
44
+ type: 'object',
45
+ name: 'actions',
46
+ label: 'Buttons',
47
+ list: true,
48
+ description: 'The first button is the main action. Keep it to one or two.',
49
+ ui: { max, itemProps: (item: CmsAction) => ({ label: item?.label || 'Button' }), defaultItem: { label: 'Learn more', href: '/', style: 'outline' } },
50
+ fields: [
51
+ { type: 'string', name: 'label', label: 'Label', required: true },
52
+ { type: 'string', name: 'href', label: 'Link', required: true, description: 'A page path (/contact), a full URL, tel: or mailto:.' },
53
+ { type: 'string', name: 'style', label: 'Style', options: [{ value: 'solid', label: 'Primary' }, { value: 'outline', label: 'Outline' }, { value: 'ghost', label: 'Text' }] },
54
+ { type: 'boolean', name: 'arrow', label: 'Arrow after the label' },
55
+ ],
56
+ };
57
+ }
58
+
59
+ export const textField = (name: string, label: string, extra: Partial<TinaField> = {}): TinaField => ({ type: 'string', name, label, ...extra });
60
+ export const longTextField = (name: string, label: string, extra: Partial<TinaField> = {}): TinaField => ({
61
+ type: 'string',
62
+ name,
63
+ label,
64
+ ui: { component: 'textarea' },
65
+ ...extra,
66
+ });
67
+
68
+ /** Plain text only: CMS strings are rendered as text (escaped), never as HTML. */
69
+ export function clean(value: unknown): string | undefined {
70
+ if (typeof value !== 'string') return undefined;
71
+ const v = value.trim();
72
+ return v.length ? v : undefined;
73
+ }
74
+
75
+ export function mapSettings(settings: CmsSettings | null | undefined): Partial<BlockProps> {
76
+ const s = settings ?? {};
77
+ return {
78
+ anchor: clean(s.anchor),
79
+ background: s.background,
80
+ tone: s.tone,
81
+ spacing: s.spacing,
82
+ align: s.align,
83
+ };
84
+ }
85
+
86
+ export function mapActions(actions: CmsAction[] | undefined): ActionItem[] {
87
+ return (actions ?? [])
88
+ .filter((a) => clean(a?.label) && clean(a?.href))
89
+ .map((a, i) => ({ label: clean(a.label)!, href: clean(a.href)!, variant: a.style ?? (i === 0 ? 'solid' : 'outline'), ...(a.arrow ? { arrow: true } : {}) }));
90
+ }
91
+
92
+ export function mapImage(src: unknown, alt: unknown, ctx: MapContext): ImageSource | undefined {
93
+ const path = clean(src);
94
+ if (!path) return undefined;
95
+ const resolved = ctx.resolveImage(path);
96
+ if (!resolved) {
97
+ if (import.meta.env?.DEV) console.warn(`[blocks] Image "${path}" couldn't be resolved; skipped. Pass resolveImage to BlockRenderer.`);
98
+ return undefined;
99
+ }
100
+ return 'format' in resolved ? { src: resolved, alt: clean(alt) ?? '' } : { src: resolved.src, width: resolved.width, height: resolved.height, alt: clean(alt) ?? '' };
101
+ }
102
+
103
+ /**
104
+ * Map a value stored by an older schema to the current vocabulary. Content keeps working
105
+ * without a migration; the schema offers only current values, so the next save stores those.
106
+ */
107
+ export function upgrade<T extends string>(value: T | undefined | null, renames: Readonly<Record<string, string>>): T | undefined {
108
+ if (value == null) return undefined;
109
+ return (Object.prototype.hasOwnProperty.call(renames, value) ? renames[value] : value) as T;
110
+ }
111
+
112
+ /** Drops undefined values so component defaults apply. */
113
+ export function compact<T extends Record<string, unknown>>(obj: T): Partial<T> {
114
+ return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as Partial<T>;
115
+ }
@@ -0,0 +1,61 @@
1
+ import type { StatItem } from '../types';
2
+ import type { StatsBandData } from './data';
3
+ import type { MapContext, TinaTemplate } from './types';
4
+ import { blockIconNames } from '../icons';
5
+ import { clean, compact, mapImage, mapSettings, settingsField, textField } from './shared';
6
+
7
+ export const statsBandDefaults: StatsBandData = {
8
+ _template: 'statsBand',
9
+ label: 'At a glance',
10
+ items: [
11
+ { value: '24', label: 'Hours a day' },
12
+ { value: '7', label: 'Days a week' },
13
+ { value: '15', label: 'Counties served' },
14
+ ],
15
+ };
16
+
17
+ export const statsBandTemplate: TinaTemplate = {
18
+ name: 'statsBand',
19
+ label: 'Stats band',
20
+ ui: { defaultItem: statsBandDefaults, itemProps: (item: StatsBandData) => ({ label: `Stats: ${item?.items?.map((i) => i.value).join(' · ') ?? ''}` }) },
21
+ fields: [
22
+ textField('heading', 'Heading (optional)', { description: 'Leave empty for a band of figures with no visible heading.' }),
23
+ textField('label', 'Section name (for screen readers)', { description: 'Used when there is no heading, e.g. “At a glance”.' }),
24
+ {
25
+ type: 'object',
26
+ name: 'items',
27
+ label: 'Figures',
28
+ list: true,
29
+ description: 'Two to six. Write the figure as it should read (“100%”, “15+”).',
30
+ ui: { max: 6, itemProps: (item: { value?: string; label?: string }) => ({ label: [item?.value, item?.label].filter(Boolean).join(' ') || 'Figure' }), defaultItem: { value: '10', label: 'Years' } },
31
+ fields: [
32
+ textField('value', 'Figure', { required: true }),
33
+ textField('label', 'Label', { required: true }),
34
+ { type: 'string', name: 'icon', label: 'Icon (optional)', options: blockIconNames.map((n) => ({ value: n, label: n })) },
35
+ ],
36
+ },
37
+ { type: 'image', name: 'image', label: 'Background photo (optional)', description: 'Decorative: it sits under the band color.' },
38
+ { type: 'string', name: 'tone', label: 'Color', options: [{ value: 'accent', label: 'Brand' }, { value: 'neutral', label: 'Neutral' }] },
39
+ settingsField({ background: false }),
40
+ ],
41
+ };
42
+
43
+ export function statsBandToProps(d: StatsBandData, ctx: MapContext) {
44
+ const items = (d.items ?? [])
45
+ .filter((i) => clean(i?.value) && clean(i?.label))
46
+ .slice(0, 6)
47
+ .map((i) => compact({ value: clean(i.value)!, label: clean(i.label)!, icon: clean(i.icon), tina: i as never }) as StatItem);
48
+ const { anchor, align, spacing } = mapSettings(d.settings);
49
+ return compact({
50
+ anchor,
51
+ align,
52
+ spacing,
53
+ heading: clean(d.heading),
54
+ label: clean(d.label),
55
+ items,
56
+ image: mapImage(d.image, '', ctx),
57
+ tone: d.tone,
58
+ headingLevel: ctx.headingLevel === 1 ? (2 as const) : ctx.headingLevel,
59
+ placeholder: ctx.placeholder,
60
+ });
61
+ }
@@ -0,0 +1,67 @@
1
+ import { blockIconNames } from '../icons';
2
+ import type { StepItem } from '../types';
3
+ import type { StepsData } from './data';
4
+ import type { MapContext, TinaTemplate } from './types';
5
+ import { clean, compact, longTextField, mapSettings, settingsField, textField, upgrade } from './shared';
6
+
7
+ export const stepsDefaults: StepsData = {
8
+ _template: 'steps',
9
+ heading: 'How it works',
10
+ items: [
11
+ { title: 'First step', description: 'What happens, and who does it.' },
12
+ { title: 'Second step', description: 'What happens next.' },
13
+ { title: 'Third step', description: 'How it ends.' },
14
+ ],
15
+ };
16
+
17
+ export const stepsTemplate: TinaTemplate = {
18
+ name: 'steps',
19
+ label: 'Steps',
20
+ ui: { defaultItem: stepsDefaults, itemProps: (item: StepsData) => ({ label: `Steps: ${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: 'Steps',
29
+ list: true,
30
+ ui: { itemProps: (item: { title?: string }) => ({ label: item?.title || 'Step' }), defaultItem: { title: 'New step' } },
31
+ fields: [
32
+ textField('title', 'Title', { required: true }),
33
+ longTextField('description', 'Description'),
34
+ { type: 'string', name: 'icon', label: 'Icon (when markers are icons)', options: blockIconNames },
35
+ ],
36
+ },
37
+ { type: 'string', name: 'marker', label: 'Marker', options: [{ value: 'number', label: 'Numbers' }, { value: 'icon', label: 'Icons' }, { value: 'none', label: 'None' }] },
38
+ { type: 'string', name: 'layout', label: 'Layout', options: [{ value: 'row', label: 'Side by side' }, { value: 'list', label: 'Vertical list' }] },
39
+ { type: 'string', name: 'variant', label: 'Style', options: [{ value: 'plain', label: 'Plain' }, { value: 'card', label: 'Cards' }] },
40
+ settingsField(),
41
+ ],
42
+ };
43
+
44
+ export function stepsToProps(d: StepsData, ctx: MapContext) {
45
+ const items = (d.items ?? [])
46
+ .filter((i) => clean(i?.title))
47
+ .map((i) =>
48
+ compact({
49
+ title: clean(i.title)!,
50
+ description: clean(i.description),
51
+ icon: i.icon && (blockIconNames as string[]).includes(i.icon) ? i.icon : undefined,
52
+ tina: i as never,
53
+ }) as StepItem,
54
+ );
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
+ marker: d.marker,
62
+ layout: d.layout,
63
+ variant: upgrade(d.variant, { cards: 'card' }),
64
+ headingLevel: 2 as const,
65
+ placeholder: ctx.placeholder,
66
+ });
67
+ }
@@ -0,0 +1,80 @@
1
+ import type { TestimonialItem } from '../types';
2
+ import type { TestimonialsData } from './data';
3
+ import type { MapContext, TinaTemplate } from './types';
4
+ import { actionsField, clean, compact, longTextField, mapActions, mapImage, mapSettings, settingsField, textField } from './shared';
5
+ import { safeHref } from '../lib/contact';
6
+
7
+ export const testimonialsDefaults: TestimonialsData = {
8
+ _template: 'testimonials',
9
+ heading: 'What clients say',
10
+ items: [
11
+ { quote: 'Our bookings doubled the month the new site went live.', name: 'Client name', role: 'Owner', organization: 'Company' },
12
+ { quote: 'We update the menu ourselves now. It takes a minute.', name: 'Client name', role: 'Manager', organization: 'Company' },
13
+ ],
14
+ };
15
+
16
+ export const testimonialsTemplate: TinaTemplate = {
17
+ name: 'testimonials',
18
+ label: 'Testimonials',
19
+ ui: { defaultItem: testimonialsDefaults, itemProps: (item: TestimonialsData) => ({ label: `Testimonials: ${item?.heading ?? ''}` }) },
20
+ fields: [
21
+ textField('eyebrow', 'Eyebrow'),
22
+ textField('heading', 'Heading'),
23
+ longTextField('description', 'Intro text'),
24
+ {
25
+ type: 'object',
26
+ name: 'items',
27
+ label: 'Quotes',
28
+ list: true,
29
+ description: 'Real quotes only, word for word, used with the person’s permission.',
30
+ ui: { itemProps: (item: { name?: string }) => ({ label: item?.name || 'Quote' }), defaultItem: { quote: 'What they said.', name: 'Their name' } },
31
+ fields: [
32
+ longTextField('quote', 'Quote', { required: true }),
33
+ textField('name', 'Name', { required: true }),
34
+ textField('role', 'Role (optional)'),
35
+ textField('organization', 'Company (optional)'),
36
+ { type: 'image', name: 'image', label: 'Photo (optional)', description: 'A square portrait works best.' },
37
+ { type: 'number', name: 'rating', label: 'Star rating (optional, 1–5)', ui: { validate: (v: unknown) => (v != null && v !== '' && !(Number(v) >= 1 && Number(v) <= 5) ? 'Use a number from 1 to 5.' : undefined) } },
38
+ textField('sourceLabel', 'Published on (optional)', { description: 'e.g. Google, Clutch, LinkedIn.' }),
39
+ textField('sourceHref', 'Link to the original (optional)'),
40
+ ],
41
+ },
42
+ { type: 'string', name: 'layout', label: 'Layout', options: [{ value: 'grid', label: 'Grid of quotes' }, { value: 'single', label: 'One large quote' }] },
43
+ { type: 'string', name: 'variant', label: 'Style', options: [{ value: 'card', label: 'Boxes' }, { value: 'plain', label: 'Plain' }] },
44
+ { type: 'string', name: 'columns', label: 'Columns (at most)', options: ['1', '2', '3'] },
45
+ actionsField(2),
46
+ settingsField(),
47
+ ],
48
+ };
49
+
50
+ export function testimonialsToProps(d: TestimonialsData, ctx: MapContext) {
51
+ const items = (d.items ?? [])
52
+ .filter((i) => clean(i?.quote) && clean(i?.name))
53
+ .map((i) => {
54
+ const rating = typeof i.rating === 'number' && i.rating >= 1 && i.rating <= 5 ? i.rating : undefined;
55
+ const label = clean(i.sourceLabel);
56
+ return compact({
57
+ quote: clean(i.quote)!,
58
+ name: clean(i.name)!,
59
+ role: clean(i.role),
60
+ organization: clean(i.organization),
61
+ image: mapImage(i.image, '', ctx),
62
+ rating,
63
+ source: label ? compact({ label, href: safeHref(clean(i.sourceHref)) }) : undefined,
64
+ tina: i as never,
65
+ }) as TestimonialItem;
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
+ layout: d.layout,
74
+ variant: d.variant,
75
+ columns: d.columns ? (Number(d.columns) as 1 | 2 | 3) : undefined,
76
+ actions: mapActions(d.actions),
77
+ headingLevel: 2 as const,
78
+ placeholder: ctx.placeholder,
79
+ });
80
+ }