@sinnstack/ui 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +6 -4
  3. package/docs/blocks.md +373 -364
  4. package/docs/data.md +128 -128
  5. package/docs/finishes.md +165 -0
  6. package/docs/primitives.md +4 -4
  7. package/docs/seo.md +191 -187
  8. package/package.json +15 -24
  9. package/src/blocks/BlockRenderer.astro +13 -7
  10. package/src/blocks/CTABanner.astro +8 -8
  11. package/src/blocks/CTAPair.astro +9 -9
  12. package/src/blocks/CardGrid.astro +7 -7
  13. package/src/blocks/ConsentEmbed.astro +1 -1
  14. package/src/blocks/ConsentManager.astro +1 -1
  15. package/src/blocks/ContactCard.astro +14 -14
  16. package/src/blocks/ContactForm.astro +4 -4
  17. package/src/blocks/ErrorPage.astro +1 -1
  18. package/src/blocks/FAQ.astro +9 -9
  19. package/src/blocks/FeatureGrid.astro +7 -7
  20. package/src/blocks/Hero.astro +11 -11
  21. package/src/blocks/HeroCarousel.astro +11 -11
  22. package/src/blocks/HighlightCards.astro +10 -10
  23. package/src/blocks/LocationHours.astro +14 -14
  24. package/src/blocks/LogoCloud.astro +7 -7
  25. package/src/blocks/MaintenancePage.astro +8 -3
  26. package/src/blocks/MediaText.astro +12 -12
  27. package/src/blocks/PageHeader.astro +9 -9
  28. package/src/blocks/ProseSection.astro +8 -8
  29. package/src/blocks/Reviews.astro +11 -11
  30. package/src/blocks/RichText.astro +58 -57
  31. package/src/blocks/StatsBand.astro +117 -117
  32. package/src/blocks/Steps.astro +9 -9
  33. package/src/blocks/Testimonials.astro +13 -13
  34. package/src/blocks/cms/card-grid.ts +48 -80
  35. package/src/blocks/cms/consent.ts +1 -30
  36. package/src/blocks/cms/contact-card.ts +4 -46
  37. package/src/blocks/cms/contact-form.ts +2 -20
  38. package/src/blocks/cms/cta-banner.ts +2 -23
  39. package/src/blocks/cms/cta-pair.ts +4 -37
  40. package/src/blocks/cms/data-base.ts +2 -4
  41. package/src/blocks/cms/data.ts +19 -19
  42. package/src/blocks/cms/faq.ts +4 -36
  43. package/src/blocks/cms/feature-grid.ts +47 -80
  44. package/src/blocks/cms/fixtures.ts +591 -599
  45. package/src/blocks/cms/hero-carousel.ts +4 -48
  46. package/src/blocks/cms/hero.ts +2 -46
  47. package/src/blocks/cms/highlight-cards.ts +4 -39
  48. package/src/blocks/cms/images.ts +1 -2
  49. package/src/blocks/cms/index.ts +59 -87
  50. package/src/blocks/cms/location-hours.ts +3 -85
  51. package/src/blocks/cms/logo-cloud.ts +36 -62
  52. package/src/blocks/cms/media-text.ts +2 -20
  53. package/src/blocks/cms/page-header.ts +27 -49
  54. package/src/blocks/cms/pages.ts +35 -81
  55. package/src/blocks/cms/prose-section.ts +2 -22
  56. package/src/blocks/cms/reviews.ts +5 -56
  57. package/src/blocks/cms/schema-dsl.ts +134 -0
  58. package/src/blocks/cms/schema.ts +794 -0
  59. package/src/blocks/cms/shared.ts +63 -115
  60. package/src/blocks/cms/stats-band.ts +35 -61
  61. package/src/blocks/cms/steps.ts +4 -31
  62. package/src/blocks/cms/testimonials.ts +4 -38
  63. package/src/blocks/cms/topbar.ts +4 -41
  64. package/src/blocks/cms/types.ts +1 -37
  65. package/src/blocks/consent.ts +2 -2
  66. package/src/blocks/index.ts +2 -2
  67. package/src/blocks/internal/Actions.astro +11 -5
  68. package/src/blocks/internal/BlockHeader.astro +7 -7
  69. package/src/blocks/internal/Placeholder.astro +3 -3
  70. package/src/blocks/internal/fields.ts +18 -0
  71. package/src/blocks/internal/registry-contract.ts +67 -0
  72. package/src/blocks/internal/util.ts +4 -4
  73. package/src/blocks/lib/contact.ts +10 -4
  74. package/src/blocks/lib/faq.ts +1 -1
  75. package/src/blocks/lib/markdown.ts +350 -0
  76. package/src/blocks/lib/rich-text.ts +132 -143
  77. package/src/blocks/scripts/consent-manager.ts +1 -1
  78. package/src/blocks/scripts/consent-store.ts +1 -1
  79. package/src/blocks/scripts/hours.ts +3 -2
  80. package/src/blocks/types.ts +33 -23
  81. package/src/data/ChartContainer.astro +2 -1
  82. package/src/data/cms.ts +130 -190
  83. package/src/data/lib/chart.ts +13 -4
  84. package/src/data/schema.ts +65 -0
  85. package/src/finishes/aurora.css +75 -0
  86. package/src/finishes/autumn.css +87 -0
  87. package/src/finishes/blueprint.css +69 -0
  88. package/src/finishes/brutalist.css +55 -0
  89. package/src/finishes/clay.css +48 -0
  90. package/src/finishes/day-cycle.css +46 -0
  91. package/src/finishes/fog.css +71 -0
  92. package/src/finishes/glass.css +149 -0
  93. package/src/finishes/holographic.css +91 -0
  94. package/src/finishes/night.css +77 -0
  95. package/src/finishes/paper.css +58 -0
  96. package/src/finishes/polished-glass.css +159 -0
  97. package/src/finishes/rain.css +84 -0
  98. package/src/finishes/scripts/day-cycle.ts +30 -0
  99. package/src/finishes/scripts/holographic.ts +37 -0
  100. package/src/finishes/scripts/spotlight.ts +30 -0
  101. package/src/finishes/spotlight.css +41 -0
  102. package/src/finishes/spring.css +80 -0
  103. package/src/finishes/terminal.css +49 -0
  104. package/src/primitives/Divider.astro +1 -1
  105. package/src/primitives/FocusRing.astro +1 -1
  106. package/src/primitives/FormField.astro +2 -2
  107. package/src/primitives/Image.astro +3 -3
  108. package/src/primitives/Input.astro +4 -2
  109. package/src/primitives/MetricCard.astro +3 -1
  110. package/src/primitives/Picture.astro +3 -3
  111. package/src/primitives/Prose.astro +1 -1
  112. package/src/primitives/Select.astro +4 -2
  113. package/src/primitives/Slider.astro +1 -1
  114. package/src/primitives/Table.astro +1 -1
  115. package/src/primitives/Textarea.astro +4 -2
  116. package/src/primitives/Thumbnail.astro +2 -2
  117. package/src/primitives/index.ts +4 -4
  118. package/src/primitives/internal/ChoiceField.astro +4 -2
  119. package/src/primitives/scripts/slider.ts +1 -1
  120. package/src/primitives/scripts/table-sort.ts +2 -2
  121. package/src/seo/cms.ts +59 -80
  122. package/src/seo/index.ts +1 -1
  123. package/src/seo/integration.ts +40 -3
  124. package/src/seo/lib/jsonld.ts +10 -2
  125. package/src/seo/lib/meta.ts +2 -2
  126. package/src/seo/lib/redirects.ts +14 -4
  127. package/src/seo/lib/rss.ts +1 -1
  128. package/src/seo/lib/sitemap.ts +1 -1
  129. package/src/seo/schema.ts +43 -0
  130. package/src/blocks/internal/tina.ts +0 -19
  131. /package/src/blocks/{lib → internal}/consent.ts +0 -0
  132. /package/src/blocks/{lib → internal}/reviews.ts +0 -0
  133. /package/src/blocks/{lib → internal}/slug.ts +0 -0
  134. /package/src/data/{lib → internal}/scale.ts +0 -0
  135. /package/src/primitives/{lib → internal}/image-plan.ts +0 -0
  136. /package/src/primitives/{lib → internal}/image.ts +0 -0
  137. /package/src/primitives/{lib → internal}/slider.ts +0 -0
  138. /package/src/seo/{lib → internal}/url.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { SlideItem } from '../types';
2
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';
3
+ import type { MapContext } from './types';
4
+ import { clean, compact, mapActions, mapImage, mapSettings, withFields } from './shared';
5
5
 
6
6
  export const heroCarouselDefaults: HeroCarouselData = {
7
7
  _template: 'heroCarousel',
@@ -12,55 +12,11 @@ export const heroCarouselDefaults: HeroCarouselData = {
12
12
  ],
13
13
  };
14
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
15
  export function heroCarouselToProps(d: HeroCarouselData, ctx: MapContext) {
60
- const slides = (d.slides ?? [])
16
+ const slides = withFields(d.slides, 'slides')
61
17
  .filter((s) => clean(s?.heading))
62
18
  // 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);
19
+ .map((s) => compact({ eyebrow: clean(s.eyebrow), heading: clean(s.heading)!, description: clean(s.description), actions: mapActions(s.actions), image: mapImage(s.image, '', ctx), field: s._field }) as SlideItem);
64
20
  const { anchor, align } = mapSettings(d.settings);
65
21
  const autoplay = Number(d.autoplay);
66
22
  return compact({
@@ -1,6 +1,6 @@
1
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';
2
+ import type { MapContext } from './types';
3
+ import { clean, compact, mapActions, mapImage, mapSettings } from './shared';
4
4
 
5
5
  export const heroDefaults: HeroData = {
6
6
  _template: 'hero',
@@ -10,50 +10,6 @@ export const heroDefaults: HeroData = {
10
10
  actions: [{ label: 'Get started', href: '/contact', style: 'solid' }],
11
11
  };
12
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
13
  export function heroToProps(d: HeroData, ctx: MapContext) {
58
14
  // Stored as `variant` (no content migration); the component prop is `layout`.
59
15
  const layout = d.variant ?? 'text';
@@ -1,7 +1,7 @@
1
1
  import type { HighlightCardItem } from '../types';
2
2
  import type { HighlightCardsData } from './data';
3
- import type { MapContext, TinaTemplate } from './types';
4
- import { actionsField, clean, compact, longTextField, mapActions, mapSettings, textField } from './shared';
3
+ import type { MapContext } from './types';
4
+ import { clean, compact, mapActions, mapSettings, withFields } from './shared';
5
5
 
6
6
  export const highlightCardsDefaults: HighlightCardsData = {
7
7
  _template: 'highlightCards',
@@ -13,43 +13,8 @@ export const highlightCardsDefaults: HighlightCardsData = {
13
13
  ],
14
14
  };
15
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
16
  export function highlightCardsToProps(d: HighlightCardsData, ctx: MapContext) {
52
- const items = (d.items ?? [])
17
+ const items = withFields(d.items, 'items')
53
18
  .filter((i) => clean(i?.heading))
54
19
  .slice(0, 4)
55
20
  .map((i) =>
@@ -59,7 +24,7 @@ export function highlightCardsToProps(d: HighlightCardsData, ctx: MapContext) {
59
24
  points: (i.points ?? []).map((p) => clean(p)).filter(Boolean) as string[],
60
25
  actions: mapActions(i.actions),
61
26
  tone: clean(i.tone),
62
- tina: i as never,
27
+ field: i._field,
63
28
  }) as HighlightCardItem,
64
29
  );
65
30
  const { anchor, align } = mapSettings(d.settings);
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Turns CMS image paths into images astro:assets can optimize.
3
3
  *
4
- * // Tina: media: { tina: { publicFolder: 'src', mediaRoot: 'assets/uploads' } }
5
4
  * const resolveImage = createImageResolver(import.meta.glob('/src/assets/**\/*.{jpg,jpeg,png,webp,avif,svg}', { eager: true }));
6
5
  * <BlockRenderer blocks={page.blocks} resolveImage={resolveImage} />
7
6
  *
8
- * Paths are matched as given, with `/src` prepended (Tina stores paths relative to publicFolder),
7
+ * Paths are matched as given, with `/src` prepended (for CMSs that store paths relative to `src/`),
9
8
  * and by filename-suffix as a last resort. Absolute URLs need `remote` sizes.
10
9
  */
11
10
  import type { ImageResolver, ResolvedImage } from './types';
@@ -1,87 +1,59 @@
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
- }
1
+ /**
2
+ * CMS side of @sinnstack/ui/blocks: stored data shapes, defaults, fixtures and the data → props
3
+ * mappers that BlockRenderer uses. CMS-agnostic: any CMS that writes JSON/YAML/Markdown content
4
+ * with a `_template` key per block works. SinnStackCMS schemas for every block ship in
5
+ * `@sinnstack/ui/blocks/schema` (./schema.ts), typed against these data shapes.
6
+ *
7
+ * The data shapes are a contract: a field rename or removal is breaking, with a migration note.
8
+ */
9
+ import { heroDefaults, heroToProps } from './hero';
10
+ import { ctaBannerDefaults, ctaBannerToProps } from './cta-banner';
11
+ import { featureGridDefaults, featureGridToProps } from './feature-grid';
12
+ import { cardGridDefaults, cardGridToProps } from './card-grid';
13
+ import { logoCloudDefaults, logoCloudToProps } from './logo-cloud';
14
+ import { heroCarouselDefaults, heroCarouselToProps } from './hero-carousel';
15
+ import { pageHeaderDefaults, pageHeaderToProps } from './page-header';
16
+ import { contactCardDefaults, contactCardToProps } from './contact-card';
17
+ import { stepsDefaults, stepsToProps } from './steps';
18
+ import { mediaTextDefaults, mediaTextToProps } from './media-text';
19
+ import { ctaPairDefaults, ctaPairToProps } from './cta-pair';
20
+ import { statsBandDefaults, statsBandToProps } from './stats-band';
21
+ import { highlightCardsDefaults, highlightCardsToProps } from './highlight-cards';
22
+ import { contactFormDefaults, contactFormToProps } from './contact-form';
23
+ import { proseSectionDefaults, proseSectionToProps } from './prose-section';
24
+ import { faqDefaults, faqToProps } from './faq';
25
+ import { testimonialsDefaults, testimonialsToProps } from './testimonials';
26
+ import { reviewsDefaults, reviewsToProps } from './reviews';
27
+ import { locationHoursDefaults, locationHoursToProps } from './location-hours';
28
+
29
+ export * from './types';
30
+ export * from './data';
31
+ export * from './fixtures';
32
+ export { createImageResolver, noImages } from './images';
33
+ export { errorPageProps, type ErrorPagesSettings } from './pages';
34
+ export { heroDefaults, heroToProps };
35
+ export { ctaBannerDefaults, ctaBannerToProps };
36
+ export { featureGridDefaults, featureGridToProps };
37
+ export { cardGridDefaults, cardGridToProps };
38
+ export { logoCloudDefaults, logoCloudToProps };
39
+ export { heroCarouselDefaults, heroCarouselToProps };
40
+ export { pageHeaderDefaults, pageHeaderToProps };
41
+ export { contactCardDefaults, contactCardToProps };
42
+ export { stepsDefaults, stepsToProps };
43
+ export { mediaTextDefaults, mediaTextToProps };
44
+ export { ctaPairDefaults, ctaPairToProps };
45
+ export { statsBandDefaults, statsBandToProps };
46
+ export { highlightCardsDefaults, highlightCardsToProps };
47
+ export { contactFormDefaults, contactFormToProps };
48
+ export { proseSectionDefaults, proseSectionToProps };
49
+ export { faqDefaults, faqToProps };
50
+ export { testimonialsDefaults, testimonialsToProps };
51
+ export { reviewsDefaults, reviewsToProps };
52
+ export { locationHoursDefaults, locationHoursToProps };
53
+ export { topbarProps } from './topbar';
54
+ export { consentProps } from './consent';
55
+
56
+ /** Template name of a stored block (its `_template` key). */
57
+ export function templateName(block: { _template?: unknown }): string | undefined {
58
+ return typeof block._template === 'string' && block._template ? block._template : undefined;
59
+ }
@@ -1,21 +1,9 @@
1
1
  import type { DayCode, HoursRow, PostalAddress, SpecialHours } from '../types';
2
2
  import type { LocationHoursData } from './data';
3
- import type { MapContext, TinaField, TinaTemplate } from './types';
4
- import { clean, compact, longTextField, mapSettings, settingsField, textField } from './shared';
3
+ import type { MapContext } from './types';
4
+ import { clean, compact, mapSettings } from './shared';
5
5
  import { DAY_CODES, parseTime } from '../lib/hours';
6
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
7
  /** Validates an IANA time zone name with the browser's own list. */
20
8
  export function isTimeZone(value: string | undefined): boolean {
21
9
  if (!value) return false;
@@ -41,76 +29,6 @@ export const locationHoursDefaults: LocationHoursData = {
41
29
  ],
42
30
  };
43
31
 
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
32
  const days = (v: unknown): DayCode[] => (Array.isArray(v) ? (v.filter((d) => (DAY_CODES as readonly string[]).includes(d)) as DayCode[]) : []);
115
33
 
116
34
  export function locationHoursToProps(d: LocationHoursData, ctx: MapContext) {
@@ -120,7 +38,7 @@ export function locationHoursToProps(d: LocationHoursData, ctx: MapContext) {
120
38
  ? (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
39
  : undefined;
122
40
  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)
41
+ .map((r) => compact({ days: days(r?.days), opens: clean(r?.opens), closes: clean(r?.closes), closed: r?.closed === true ? true : undefined }) as HoursRow)
124
42
  .filter((r) => r.days.length && (r.closed || (parseTime(r.opens) !== undefined && parseTime(r.closes) !== undefined)));
125
43
  const special = (d.special ?? [])
126
44
  .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)
@@ -1,62 +1,36 @@
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
- }
1
+ import type { LogoCloudData } from './data';
2
+ import type { LogoItem } from '../types';
3
+ import type { MapContext } from './types';
4
+ import { safeHref } from '../lib/contact';
5
+ import { clean, compact, mapImage, mapSettings, withFields } from './shared';
6
+
7
+ export const logoCloudDefaults: LogoCloudData = {
8
+ _template: 'logoCloud',
9
+ heading: 'Trusted by',
10
+ compact: true,
11
+ variant: 'strip',
12
+ logos: [],
13
+ };
14
+
15
+ export function logoCloudToProps(d: LogoCloudData, ctx: MapContext) {
16
+ const logos = withFields(d.logos, 'logos').flatMap((l) => {
17
+ const name = clean(l?.name);
18
+ const image = name ? mapImage(l.image, name, ctx) : undefined;
19
+ if (!image) return [];
20
+ return [compact({ src: image.src, alt: name!, width: image.width, height: image.height, href: safeHref(l.href), field: l._field }) as LogoItem];
21
+ });
22
+ return compact({
23
+ ...mapSettings(d.settings),
24
+ heading: clean(d.heading),
25
+ compact: d.compact ?? undefined,
26
+ logos,
27
+ // Stored as `variant` (no content migration); the component prop is `layout`.
28
+ layout: d.variant,
29
+ columns: d.columns ? (Number(d.columns) as 2 | 3 | 4 | 5 | 6) : undefined,
30
+ size: d.size,
31
+ mono: d.mono ?? undefined,
32
+ tile: d.tile ?? undefined,
33
+ headingLevel: 2 as const,
34
+ placeholder: ctx.placeholder,
35
+ });
36
+ }
@@ -1,6 +1,6 @@
1
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';
2
+ import type { MapContext } from './types';
3
+ import { clean, compact, mapActions, mapImage, mapSettings } from './shared';
4
4
 
5
5
  export const mediaTextDefaults: MediaTextData = {
6
6
  _template: 'mediaText',
@@ -9,24 +9,6 @@ export const mediaTextDefaults: MediaTextData = {
9
9
  points: ['A short reason to choose you', 'Another one'],
10
10
  };
11
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
12
  export function mediaTextToProps(d: MediaTextData, ctx: MapContext) {
31
13
  return compact({
32
14
  ...mapSettings(d.settings),