@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,64 @@
1
+ /**
2
+ * Topbar is site chrome, not a page block: its content lives in site settings (a Tina global
3
+ * document), like the error and maintenance pages. Add `topbarField()` to that collection and
4
+ * pass `topbarProps(settings.topbar)` to <Topbar> in the layout.
5
+ */
6
+ import type { ContactItem } from '../types';
7
+ import type { TopbarData } from './data';
8
+ import type { TinaField } from './types';
9
+ import { clean, compact, textField } from './shared';
10
+ import { mapContactItems } from './contact-card';
11
+ import { safeHref } from '../lib/contact';
12
+
13
+ export function topbarField(): TinaField {
14
+ return {
15
+ type: 'object',
16
+ name: 'topbar',
17
+ label: 'Top bar (above the menu)',
18
+ fields: [
19
+ textField('message', 'Message', { description: 'One short line, e.g. “Now booking new projects”.' }),
20
+ {
21
+ type: 'object',
22
+ name: 'items',
23
+ label: 'Contact details',
24
+ list: true,
25
+ description: 'On phones only phone numbers stay visible.',
26
+ ui: { max: 4, itemProps: (item: { type?: string; value?: string }) => ({ label: [item?.type, item?.value].filter(Boolean).join(': ') || 'Detail' }) },
27
+ fields: [
28
+ { type: 'string', name: 'type', label: 'Type', required: true, options: ['phone', 'email', 'address', 'fax', 'hours', 'link'] },
29
+ textField('value', 'Value', { required: true }),
30
+ textField('href', 'Link (links only)'),
31
+ ],
32
+ },
33
+ {
34
+ type: 'object',
35
+ name: 'links',
36
+ label: 'Links (end side)',
37
+ list: true,
38
+ description: 'Social profiles or quick links. Name the network (“Facebook”).',
39
+ ui: { max: 5, itemProps: (item: { label?: string }) => ({ label: item?.label || 'Link' }) },
40
+ fields: [textField('label', 'Label', { required: true }), textField('href', 'Link', { required: true }), { type: 'boolean', name: 'newTab', label: 'Open in a new tab' }],
41
+ },
42
+ { type: 'string', name: 'background', label: 'Background', options: [{ value: 'strong', label: 'Solid color' }, { value: 'tinted', label: 'Tinted' }, { value: 'subtle', label: 'Light gray' }] },
43
+ { type: 'string', name: 'tone', label: 'Color', description: 'For solid and tinted backgrounds.', options: [{ value: 'neutral', label: 'Dark / neutral' }, { value: 'accent', label: 'Brand' }] },
44
+ ],
45
+ };
46
+ }
47
+
48
+ export function topbarProps(d: TopbarData | null | undefined) {
49
+ const data = d ?? {};
50
+ const items: ContactItem[] = mapContactItems(data.items as never).map(({ tina: _t, ...rest }) => rest);
51
+ const links = (data.links ?? [])
52
+ .map((l) => ({ label: clean(l?.label), href: safeHref(clean(l?.href)), newTab: l?.newTab ?? undefined }))
53
+ .filter((l): l is { label: string; href: string; newTab: boolean | undefined } => Boolean(l.label && l.href))
54
+ .map((l) => compact(l) as { label: string; href: string; newTab?: boolean });
55
+ // Older content stored tone: 'subtle'; that is background: 'subtle' now.
56
+ const legacySubtle = data.tone === 'subtle';
57
+ return compact({
58
+ message: clean(data.message),
59
+ items,
60
+ links,
61
+ background: legacySubtle ? 'subtle' : data.background,
62
+ tone: legacySubtle ? undefined : data.tone,
63
+ });
64
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Structural types for Tina schema fragments, so this package doesn't depend on tinacms.
3
+ * They match the shape of tinacms's `Template` / `TinaField` (v2). The real `defineConfig`
4
+ * accepts these objects as-is.
5
+ */
6
+ export type TinaOption = string | { value: string; label: string };
7
+
8
+ export interface TinaField {
9
+ type: 'string' | 'number' | 'boolean' | 'image' | 'object' | 'datetime' | 'rich-text' | 'reference';
10
+ name: string;
11
+ label?: string;
12
+ description?: string;
13
+ required?: boolean;
14
+ list?: boolean;
15
+ options?: TinaOption[];
16
+ fields?: TinaField[];
17
+ ui?: {
18
+ component?: string;
19
+ validate?: (value: any) => string | undefined | void;
20
+ itemProps?: (item: any) => { label?: string };
21
+ defaultItem?: object | (() => object);
22
+ max?: number;
23
+ min?: number;
24
+ };
25
+ }
26
+
27
+ export interface TinaTemplate {
28
+ name: string;
29
+ label: string;
30
+ ui?: {
31
+ defaultItem?: object;
32
+ previewSrc?: string;
33
+ itemProps?: (item: any) => { label?: string };
34
+ };
35
+ fields: TinaField[];
36
+ }
37
+
38
+ /** What a CMS image string resolves to: an imported asset, or a URL with its size. */
39
+ export type ResolvedImage = import('astro').ImageMetadata | { src: string; width: number; height: number };
40
+ export type ImageResolver = (src: string) => ResolvedImage | undefined;
41
+
42
+ export interface MapContext {
43
+ resolveImage: ImageResolver;
44
+ /** Heading level the renderer chose for this block (1 for the first hero, else 2). */
45
+ headingLevel: 1 | 2;
46
+ /** Show placeholders for empty content (CMS preview / dev). */
47
+ placeholder: boolean;
48
+ }
49
+
50
+ /** Shared section settings, nested under `settings` in every block. */
51
+ export interface CmsSettings {
52
+ anchor?: string;
53
+ background?: 'none' | 'subtle' | 'sunken' | 'tinted' | 'strong';
54
+ tone?: 'accent' | 'neutral';
55
+ spacing?: 's' | 'm' | 'l' | 'xl';
56
+ align?: 'start' | 'center';
57
+ }
58
+ export interface CmsAction {
59
+ label?: string;
60
+ href?: string;
61
+ style?: 'solid' | 'outline' | 'ghost';
62
+ arrow?: boolean | null;
63
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Consent API for your own code (browser only; SSR-safe to import).
3
+ *
4
+ * import { hasConsent, onConsentChange, openConsentSettings } from '@sinnstack/ui/blocks/consent';
5
+ * if (hasConsent('analytics')) startAnalytics();
6
+ * onConsentChange(({ choices }) => choices.analytics && startAnalytics());
7
+ *
8
+ * Prefer ConsentScript for third-party script tags and ConsentEmbed for iframes: they already
9
+ * wait for consent. Use this for anything else that must not run before it.
10
+ */
11
+ export { hasConsent, setConsent, onConsentChange, openConsentSettings, getConsentRecord } from './scripts/consent-store';
12
+ export type { ConsentChangeDetail } from './scripts/consent-store';
13
+ export { consentCategoryPresets, CONSENT_EVENT, CONSENT_KEY } from './lib/consent';
14
+ export type { ConsentCategory, ConsentChoices, ConsentRecord } from './lib/consent';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Built-in icon set for FeatureGrid (24×24, stroked with currentColor, lucide-style geometry
3
+ * drawn for this library). Referenced by name, so CMS content never carries raw SVG.
4
+ * Extend or replace it per site: <FeatureGrid icons={{ ...blockIcons, tooth: '<svg…>' }} />.
5
+ */
6
+ const svg = (body: string) =>
7
+ `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${body}</svg>`;
8
+
9
+ export const blockIcons = {
10
+ check: svg('<path d="M20 6 9 17l-5-5"/>'),
11
+ // Social profiles (simplified, stroked to match the set). Use with a visible or visually hidden network name.
12
+ facebook: svg('<path d="M15 3.5h-2.2A3.8 3.8 0 0 0 9 7.3V10H6.5v3.5H9v7h3.5v-7H15l.5-3.5h-3V7.8c0-.6.4-1 1-1H15Z"/>'),
13
+ x: svg('<path d="M4 4h4.5L20 20h-4.5Z"/><path d="m20 4-6.8 7.6M10.8 12.4 4 20"/>'),
14
+ instagram: svg('<rect x="3.5" y="3.5" width="17" height="17" rx="5"/><circle cx="12" cy="12" r="4"/><path d="M17.2 6.8h.01"/>'),
15
+ linkedin: svg('<rect x="3.5" y="3.5" width="17" height="17" rx="2.5"/><path d="M8 10.5V16M8 7.5v.01M11.5 16v-5.5M11.5 13a2.5 2.5 0 0 1 5 0v3"/>'),
16
+ youtube: svg('<rect x="2.5" y="5.5" width="19" height="13" rx="4"/><path d="m10 9 5 3-5 3Z"/>'),
17
+ heart: svg('<path d="M12 20s-7.5-4.6-9.2-9.3A4.9 4.9 0 0 1 12 6.6a4.9 4.9 0 0 1 9.2 4.1C19.5 15.4 12 20 12 20Z"/>'),
18
+ shield: svg('<path d="M12 3 4.5 6v5.5c0 4.6 3.2 8.4 7.5 9.5 4.3-1.1 7.5-4.9 7.5-9.5V6L12 3Z"/><path d="m9 12 2 2 4-4"/>'),
19
+ clock: svg('<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>'),
20
+ calendar: svg('<rect x="3.5" y="5" width="17" height="15.5" rx="2"/><path d="M3.5 10h17M8 3v4M16 3v4"/>'),
21
+ phone: svg('<path d="M6.6 3.5h2.9l1.5 4.2-2.1 1.4a11.5 11.5 0 0 0 6 6l1.4-2.1 4.2 1.5v2.9a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z"/>'),
22
+ chat: svg('<path d="M20.5 12a8 8 0 0 1-11.8 7L4 20l1-4.4A8 8 0 1 1 20.5 12Z"/>'),
23
+ video: svg('<rect x="2.5" y="6" width="13" height="12" rx="2"/><path d="m15.5 10.5 6-3.5v10l-6-3.5"/>'),
24
+ home: svg('<path d="m3 10.5 9-7 9 7"/><path d="M5.5 9v11h13V9"/><path d="M10 20v-5.5h4V20"/>'),
25
+ mapPin: svg('<path d="M12 21s-7-6.2-7-11.5a7 7 0 0 1 14 0C19 14.8 12 21 12 21Z"/><circle cx="12" cy="9.5" r="2.5"/>'),
26
+ users: svg('<circle cx="9" cy="8" r="3.5"/><path d="M2.5 20a6.5 6.5 0 0 1 13 0"/><path d="M16 4.6a3.5 3.5 0 0 1 0 6.8M18.5 14a6.5 6.5 0 0 1 3 6"/>'),
27
+ star: svg('<path d="m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2L12 17.3l-5.6 2.9 1.1-6.2L3 9.6l6.2-.9L12 3Z"/>'),
28
+ sparkle: svg('<path d="M12 3v4M12 17v4M3 12h4M17 12h4M6.3 6.3l2.4 2.4M15.3 15.3l2.4 2.4M6.3 17.7l2.4-2.4M15.3 8.7l2.4-2.4"/>'),
29
+ stethoscope: svg('<path d="M5 3v5a5 5 0 0 0 10 0V3"/><path d="M10 13v2.5a5 5 0 0 0 10 0V13"/><circle cx="20" cy="11" r="2"/>'),
30
+ activity: svg('<path d="M3 12h4l3-8 4 16 3-8h4"/>'),
31
+ lock: svg('<rect x="4.5" y="10.5" width="15" height="10" rx="2"/><path d="M8 10.5V7a4 4 0 0 1 8 0v3.5"/>'),
32
+ box: svg('<path d="m3.5 7.5 8.5-4 8.5 4-8.5 4-8.5-4Z"/><path d="M3.5 7.5v9l8.5 4 8.5-4v-9M12 11.5v9"/>'),
33
+ truck: svg('<path d="M2.5 6h11v10h-11zM13.5 9.5h4l3 3.5V16h-7"/><circle cx="6.5" cy="17.5" r="1.8"/><circle cx="17" cy="17.5" r="1.8"/>'),
34
+ card: svg('<rect x="2.5" y="5" width="19" height="14" rx="2"/><path d="M2.5 10h19M6.5 15h4"/>'),
35
+ globe: svg('<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/>'),
36
+ bolt: svg('<path d="M13 2.5 4.5 13.5H12l-1 8 8.5-11H12l1-8Z"/>'),
37
+ chart: svg('<path d="M3.5 20.5h17"/><path d="M6.5 16v-4M11 16V8M15.5 16v-6M20 16V5"/>'),
38
+ code: svg('<path d="m8 7-5 5 5 5M16 7l5 5-5 5M13.5 4.5l-3 15"/>'),
39
+ mail: svg('<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3.5 6.5 8.5 6.5 8.5-6.5"/>'),
40
+ fax: svg('<path d="M7 8V3.5h10V8"/><rect x="3" y="8" width="18" height="9" rx="2"/><path d="M7 14h10v6.5H7z"/><path d="M17.5 11h.01"/>'),
41
+ link: svg('<path d="M10 14a4 4 0 0 0 5.7 0l3.5-3.5a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3.5 3.5a4 4 0 0 0 5.7 5.7l1-1"/>'),
42
+ file: svg('<path d="M14 3H6.5A1.5 1.5 0 0 0 5 4.5v15A1.5 1.5 0 0 0 6.5 21h11a1.5 1.5 0 0 0 1.5-1.5V8l-5-5Z"/><path d="M14 3v5h5M8.5 13h7M8.5 17h5"/>'),
43
+ leaf: svg('<path d="M5 19c0-8 5.5-14 15-14 0 9.5-6 15-14 15"/><path d="M5 19 13 11"/>'),
44
+ } as const;
45
+
46
+ export type BlockIconName = keyof typeof blockIcons;
47
+ export const blockIconNames = Object.keys(blockIcons) as BlockIconName[];
@@ -0,0 +1,42 @@
1
+ // @sinnstack/ui/blocks — page sections composed from primitives.
2
+ export { default as Hero } from './Hero.astro';
3
+ export { default as CTABanner } from './CTABanner.astro';
4
+ export { default as FeatureGrid } from './FeatureGrid.astro';
5
+ export { default as CardGrid } from './CardGrid.astro';
6
+ export { default as LogoCloud } from './LogoCloud.astro';
7
+ export { default as HeroCarousel } from './HeroCarousel.astro';
8
+ export { default as PageHeader } from './PageHeader.astro';
9
+ export { default as ContactCard } from './ContactCard.astro';
10
+ export { default as Steps } from './Steps.astro';
11
+ export { default as MediaText } from './MediaText.astro';
12
+ export { default as CTAPair } from './CTAPair.astro';
13
+ export { default as StatsBand } from './StatsBand.astro';
14
+ export { default as HighlightCards } from './HighlightCards.astro';
15
+ export { default as ContactForm } from './ContactForm.astro';
16
+ export { default as ProseSection } from './ProseSection.astro';
17
+ export { default as RichText } from './RichText.astro';
18
+ export { default as FAQ } from './FAQ.astro';
19
+ export { default as Testimonials } from './Testimonials.astro';
20
+ export { default as Reviews } from './Reviews.astro';
21
+ export { default as LocationHours } from './LocationHours.astro';
22
+ export { default as ConsentManager } from './ConsentManager.astro';
23
+ export { default as ConsentEmbed } from './ConsentEmbed.astro';
24
+ export { default as ConsentScript } from './ConsentScript.astro';
25
+ export { default as Topbar } from './Topbar.astro';
26
+ export { default as BlockRenderer } from './BlockRenderer.astro';
27
+ export { default as ErrorPage } from './ErrorPage.astro';
28
+ export { default as MaintenancePage } from './MaintenancePage.astro';
29
+ export { errorCopy, copyFor, suggestPage } from './lib/error-pages';
30
+ export type { ErrorStatus, ErrorCopy, SuggestCandidate } from './lib/error-pages';
31
+
32
+ export { telHref, mailHref, contactHref } from './lib/contact';
33
+ export { faqStructuredData } from './lib/faq';
34
+ export { locationStructuredData, directionsHref, mapEmbedSrc, mapSearchHref } from './lib/hours';
35
+ export { richTextPlain, isRichTextEmpty } from './lib/rich-text';
36
+ export type { RichTextValue, RichTextNode, RichTextRoot } from './lib/rich-text';
37
+ export { consentCategoryPresets } from './lib/consent';
38
+ export type { ConsentCategory } from './lib/consent';
39
+ export type { SinnSlideChangeDetail } from './scripts/carousel';
40
+ export { blockIcons, blockIconNames } from './icons';
41
+ export type { BlockIconName } from './icons';
42
+ export type * from './types';
@@ -0,0 +1,29 @@
1
+ ---
2
+ /** @internal Renders `actions` data as LinkButtons, then any `actions` slot content. */
3
+ import LinkButton from '../../primitives/LinkButton.astro';
4
+ import VisuallyHidden from '../../primitives/VisuallyHidden.astro';
5
+ import type { ActionItem, TinaSource } from '../types';
6
+ import { actionVariant } from './util';
7
+ import { tf } from './tina';
8
+
9
+ type Props = { actions?: ActionItem[]; size?: 's' | 'm' | 'l'; class: string; tina?: TinaSource };
10
+ const { actions = [], size = 'l', class: className, tina } = Astro.props;
11
+ const hasSlot = Astro.slots.has('default');
12
+ ---
13
+
14
+ {
15
+ (actions.length > 0 || hasSlot) && (
16
+ <div class={className}>
17
+ {actions.map((action, i) => (
18
+ <LinkButton href={action.href} size={size} variant={actionVariant(action, i)} newTab={action.newTab} {...tf(tina, 'actions', i)}>
19
+ {action.label}
20
+ {action.srLabel && <VisuallyHidden> {action.srLabel}</VisuallyHidden>}
21
+ {action.arrow && (
22
+ <svg slot="icon-end" class="sinn-action-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M5 12h14M13 6l6 6-6 6" /></svg>
23
+ )}
24
+ </LinkButton>
25
+ ))}
26
+ <slot />
27
+ </div>
28
+ )
29
+ }
@@ -0,0 +1,45 @@
1
+ ---
2
+ /** @internal Eyebrow, heading and description above a block's content. Renders nothing if empty. */
3
+ import Heading from '../../primitives/Heading.astro';
4
+ import Text from '../../primitives/Text.astro';
5
+ import type { TextSize } from '../../primitives/types';
6
+ import type { HeadingLevelNumber, TinaSource } from '../types';
7
+ import { tf } from './tina';
8
+
9
+ type Props = {
10
+ eyebrow?: string;
11
+ heading?: string;
12
+ headingId?: string;
13
+ headingLevel?: HeadingLevelNumber;
14
+ headingSize?: TextSize;
15
+ /** Small muted heading ("Trusted by…"). Still a real heading. */
16
+ compact?: boolean;
17
+ description?: string;
18
+ tina?: TinaSource;
19
+ };
20
+
21
+ const { eyebrow, heading, headingId, headingLevel = 2, headingSize = '2xl', compact = false, description, tina } = Astro.props;
22
+ const hasContent = Boolean(eyebrow || heading || description);
23
+ ---
24
+
25
+ {
26
+ hasContent && (
27
+ <header class="sinn-block__header" data-compact={compact ? '' : undefined}>
28
+ {eyebrow && <p class="sinn-block__eyebrow" {...tf(tina, 'eyebrow')}>{eyebrow}</p>}
29
+ {heading && (
30
+ <Heading
31
+ level={headingLevel}
32
+ size={compact ? 's' : headingSize}
33
+ tone={compact ? 'muted' : 'default'}
34
+ weight={compact ? 'semibold' : 'bold'}
35
+ id={headingId}
36
+ class="sinn-block__title"
37
+ {...tf(tina, 'heading')}
38
+ >
39
+ {heading}
40
+ </Heading>
41
+ )}
42
+ {description && <Text size="l" tone="muted" class="sinn-block__description" {...tf(tina, 'description')}>{description}</Text>}
43
+ </header>
44
+ )
45
+ }
@@ -0,0 +1,58 @@
1
+ ---
2
+ /**
3
+ * @internal The outer element every section block shares: a <section> (a named landmark when it
4
+ * has a heading), vertical rhythm, background/tone/scheme, and the inner container.
5
+ * The `bleed` slot renders behind the container (full-bleed media, scrims).
6
+ */
7
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
8
+ import Container from '../../primitives/Container.astro';
9
+ import type { BlockBackground, BlockSize, BlockSpacing, BlockTone } from '../types';
10
+ import '../styles/blocks.css';
11
+
12
+ type Props = HTMLAttributes<'section'> & {
13
+ as?: HTMLTag;
14
+ name: string;
15
+ spacing?: BlockSpacing;
16
+ background?: BlockBackground;
17
+ tone?: BlockTone;
18
+ scheme?: 'light' | 'dark';
19
+ size?: BlockSize;
20
+ containerSize?: 'narrow' | 'default' | 'wide' | 'full';
21
+ labelledby?: string;
22
+ align?: 'start' | 'center';
23
+ };
24
+
25
+ const {
26
+ as: Tag = 'section',
27
+ name,
28
+ spacing = 'l',
29
+ background = 'none',
30
+ tone = 'accent',
31
+ scheme,
32
+ size,
33
+ containerSize = 'default',
34
+ labelledby,
35
+ align,
36
+ class: className,
37
+ ...rest
38
+ } = Astro.props;
39
+ const surface = background === 'tinted' || background === 'strong' ? background : undefined;
40
+ ---
41
+
42
+ <Tag
43
+ class:list={['sinn-block', `sinn-${name}`, className]}
44
+ data-spacing={spacing === 'l' ? undefined : spacing}
45
+ data-background={background === 'subtle' || background === 'sunken' ? background : undefined}
46
+ data-surface={surface}
47
+ data-tone={surface ? tone : undefined}
48
+ data-scheme={scheme}
49
+ data-size={size && size !== 'm' ? size : undefined}
50
+ data-align={align === 'center' ? 'center' : undefined}
51
+ aria-labelledby={labelledby}
52
+ {...rest}
53
+ >
54
+ <slot name="bleed" />
55
+ <Container size={containerSize} class="sinn-block__container" query={false}>
56
+ <slot />
57
+ </Container>
58
+ </Tag>
@@ -0,0 +1,7 @@
1
+ ---
2
+ /** @internal Loaded once per page that renders a HeroCarousel with 2+ slides. ~2 KB. */
3
+ ---
4
+
5
+ <script>
6
+ import '../scripts/carousel';
7
+ </script>
@@ -0,0 +1,7 @@
1
+ ---
2
+ /** @internal Loaded once per page with a ConsentManager, ConsentEmbed or ConsentScript. ~1 KB gzipped, plus the shared consent store (~1 KB). */
3
+ ---
4
+
5
+ <script>
6
+ import '../scripts/consent-embed';
7
+ </script>
@@ -0,0 +1,7 @@
1
+ ---
2
+ /** @internal Loaded once per page that renders a ConsentManager. ~1 KB gzipped, plus the shared consent store (~1 KB). */
3
+ ---
4
+
5
+ <script>
6
+ import '../scripts/consent-manager';
7
+ </script>
@@ -0,0 +1,7 @@
1
+ ---
2
+ /** @internal Loaded once per page that renders LocationHours with a time zone. ~2 KB gzipped. */
3
+ ---
4
+
5
+ <script>
6
+ import '../scripts/hours';
7
+ </script>
@@ -0,0 +1,13 @@
1
+ ---
2
+ /**
3
+ * @internal Shown in place of a block whose required content is missing, when placeholders
4
+ * are on (dev and CMS preview). Never rendered in production builds by default.
5
+ */
6
+ type Props = { label: string; hint: string; tinaField?: string };
7
+ const { label, hint, tinaField } = Astro.props;
8
+ ---
9
+
10
+ <div class="sinn-block-placeholder" role="note" data-tina-field={tinaField}>
11
+ <strong>{label}</strong>
12
+ <span>{hint}</span>
13
+ </div>
@@ -0,0 +1,133 @@
1
+ ---
2
+ /**
3
+ * @internal Renders one rich-text node and, recursively, its children. Only allowlisted node
4
+ * types render; text is escaped by Astro; URLs pass safeLinkUrl / safeMediaUrl first.
5
+ */
6
+ import Image from '../../primitives/Image.astro';
7
+ import { BLOCK_TYPES, INLINE_TYPES, safeLinkUrl, safeMediaUrl, shiftedHeading, type RichTextNode } from '../lib/rich-text';
8
+ import type { ImageResolver } from '../cms/types';
9
+
10
+ type Props = {
11
+ node: RichTextNode;
12
+ contentTop?: number;
13
+ topLevel: number;
14
+ resolveImage?: ImageResolver;
15
+ labels: { table: string };
16
+ };
17
+
18
+ const { node, contentTop, topLevel, resolveImage, labels } = Astro.props;
19
+ const type = typeof node?.type === 'string' ? node.type : '';
20
+ const known = BLOCK_TYPES.has(type) || INLINE_TYPES.has(type);
21
+ if (!known && import.meta.env?.DEV && type) console.warn(`[RichText] "${type}" content isn't supported and was left out.`);
22
+ const kids = Array.isArray(node?.children) ? node.children : [];
23
+ const Self = Astro.self;
24
+ const child = (n: RichTextNode) => ({ node: n, contentTop, topLevel, resolveImage, labels });
25
+
26
+ // Headings
27
+ const hMatch = /^h([1-6])$/.exec(type);
28
+ const H = hMatch ? (`h${shiftedHeading(Number(hMatch[1]), contentTop, topLevel)}` as 'h2') : undefined;
29
+
30
+ // Links
31
+ const href = type === 'a' ? safeLinkUrl(node.url) : undefined;
32
+ const external = href ? /^https?:\/\//i.test(href) : false;
33
+
34
+ // Images
35
+ let img: { meta?: any; src?: string; alt: string; caption?: string } | undefined;
36
+ if (type === 'img') {
37
+ const url = safeMediaUrl(node.url);
38
+ const resolved = url && resolveImage ? resolveImage(url) : undefined;
39
+ const alt = typeof node.alt === 'string' ? node.alt : '';
40
+ const caption = typeof node.caption === 'string' && node.caption.trim() ? node.caption.trim() : undefined;
41
+ if (resolved) img = { meta: resolved, alt, caption };
42
+ else if (url) {
43
+ img = { src: url, alt, caption };
44
+ if (import.meta.env?.DEV) console.warn(`[RichText] Image "${url}" has no known size; pass resolveImage so it doesn't shift the layout.`);
45
+ }
46
+ }
47
+
48
+ // Tables: a first row of header cells becomes the <thead>.
49
+ const sectioned = type === 'table' && kids.some((k) => k?.type === 'thead' || k?.type === 'tbody');
50
+ const headRow = type === 'table' && !sectioned && kids[0]?.type === 'tr' && (kids[0].children ?? []).length > 0 && (kids[0].children ?? []).every((c) => c?.type === 'th');
51
+
52
+ // Text leaf with marks. Underline is left out on purpose: underlined text reads as a link.
53
+ const text = type === 'text' && typeof node.text === 'string' ? node.text : undefined;
54
+ ---
55
+
56
+ {
57
+ text !== undefined ? (
58
+ node.code ? (
59
+ <code>{text}</code>
60
+ ) : node.bold && node.italic ? (
61
+ <strong><em>{node.strikethrough ? <s>{text}</s> : text}</em></strong>
62
+ ) : node.bold ? (
63
+ <strong>{node.strikethrough ? <s>{text}</s> : text}</strong>
64
+ ) : node.italic ? (
65
+ <em>{node.strikethrough ? <s>{text}</s> : text}</em>
66
+ ) : node.strikethrough ? (
67
+ <s>{text}</s>
68
+ ) : (
69
+ <Fragment>{text}</Fragment>
70
+ )
71
+ ) : type === 'break' ? (
72
+ <br />
73
+ ) : type === 'p' ? (
74
+ <p>{kids.map((k) => <Self {...child(k)} />)}</p>
75
+ ) : H ? (
76
+ <H>{kids.map((k) => <Self {...child(k)} />)}</H>
77
+ ) : type === 'ul' ? (
78
+ <ul>{kids.map((k) => <Self {...child(k)} />)}</ul>
79
+ ) : type === 'ol' ? (
80
+ <ol>{kids.map((k) => <Self {...child(k)} />)}</ol>
81
+ ) : type === 'li' ? (
82
+ <li>{kids.map((k) => <Self {...child(k)} />)}</li>
83
+ ) : type === 'lic' ? (
84
+ <Fragment>{kids.map((k) => <Self {...child(k)} />)}</Fragment>
85
+ ) : type === 'blockquote' ? (
86
+ <blockquote>{kids.map((k) => <Self {...child(k)} />)}</blockquote>
87
+ ) : type === 'a' ? (
88
+ href ? (
89
+ <a href={href} title={typeof node.title === 'string' ? node.title : undefined} rel={external ? 'noopener' : undefined}>
90
+ {kids.map((k) => <Self {...child(k)} />)}
91
+ </a>
92
+ ) : (
93
+ <Fragment>{kids.map((k) => <Self {...child(k)} />)}</Fragment>
94
+ )
95
+ ) : type === 'code_block' ? (
96
+ typeof node.value === 'string' && node.value.trim() ? (
97
+ <pre tabindex="0" data-lang={typeof node.lang === 'string' && node.lang ? node.lang : undefined}><code>{node.value}</code></pre>
98
+ ) : null
99
+ ) : type === 'hr' ? (
100
+ <hr />
101
+ ) : type === 'img' ? (
102
+ img ? (
103
+ img.caption ? (
104
+ <figure>
105
+ {img.meta ? <Image src={img.meta} alt={img.alt} placeholder={false} /> : <img src={img.src} alt={img.alt} loading="lazy" decoding="async" />}
106
+ <figcaption>{img.caption}</figcaption>
107
+ </figure>
108
+ ) : img.meta ? (
109
+ <Image src={img.meta} alt={img.alt} placeholder={false} />
110
+ ) : (
111
+ <img src={img.src} alt={img.alt} loading="lazy" decoding="async" />
112
+ )
113
+ ) : null
114
+ ) : type === 'table' ? (
115
+ <div class="sinn-prose__table" tabindex="0" role="region" aria-label={labels.table}>
116
+ <table>
117
+ {sectioned && kids.map((k) => <Self {...child(k)} />)}
118
+ {!sectioned && headRow && <thead><Self {...child(kids[0])} /></thead>}
119
+ {!sectioned && <tbody>{(headRow ? kids.slice(1) : kids).map((k) => <Self {...child(k)} />)}</tbody>}
120
+ </table>
121
+ </div>
122
+ ) : type === 'thead' ? (
123
+ <thead>{kids.map((k) => <Self {...child(k)} />)}</thead>
124
+ ) : type === 'tbody' ? (
125
+ <tbody>{kids.map((k) => <Self {...child(k)} />)}</tbody>
126
+ ) : type === 'tr' ? (
127
+ <tr>{kids.map((k) => <Self {...child(k)} />)}</tr>
128
+ ) : type === 'th' ? (
129
+ <th scope="col">{kids.map((k) => <Self {...child(k)} />)}</th>
130
+ ) : type === 'td' ? (
131
+ <td>{kids.map((k) => <Self {...child(k)} />)}</td>
132
+ ) : null
133
+ }
@@ -0,0 +1,53 @@
1
+ ---
2
+ /**
3
+ * @internal A minimal, self-contained HTML document for pages that must not depend on the site
4
+ * layout: a 500 page (the layout may be what failed) and the maintenance page (the CMS, nav data
5
+ * and other services may be down). Tokens + base styles, a plain header, <main>, noindex.
6
+ */
7
+ import '../../tokens/tokens.css';
8
+ import '../../tokens/base.css';
9
+ import SkipLink from '../../primitives/SkipLink.astro';
10
+
11
+ type Props = {
12
+ title: string;
13
+ description?: string;
14
+ lang?: string;
15
+ siteName?: string;
16
+ /** Link the site name to this URL (omit while the site is down). */
17
+ homeHref?: string;
18
+ };
19
+ const { title, description, lang = 'en', siteName, homeHref } = Astro.props;
20
+ const hasBrand = Boolean(siteName) || Astro.slots.has('brand');
21
+ ---
22
+
23
+ <!doctype html>
24
+ <html lang={lang}>
25
+ <head>
26
+ <meta charset="utf-8" />
27
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
28
+ <meta name="robots" content="noindex" />
29
+ <meta name="color-scheme" content="light dark" />
30
+ <title>{siteName ? `${title} | ${siteName}` : title}</title>
31
+ {description && <meta name="description" content={description} />}
32
+ <slot name="head" />
33
+ </head>
34
+ <body class="sinn-standalone">
35
+ <SkipLink />
36
+ {
37
+ hasBrand && (
38
+ <header class="sinn-standalone__header">
39
+ {Astro.slots.has('brand') ? (
40
+ <slot name="brand" />
41
+ ) : homeHref ? (
42
+ <a class="sinn-standalone__brand" href={homeHref}>{siteName}</a>
43
+ ) : (
44
+ <span class="sinn-standalone__brand">{siteName}</span>
45
+ )}
46
+ </header>
47
+ )
48
+ }
49
+ <main id="main" tabindex="-1" class="sinn-standalone__main">
50
+ <slot />
51
+ </main>
52
+ </body>
53
+ </html>
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @internal Builds `data-tina-field` values for click-to-edit, without depending on tinacms.
3
+ * Mirrors tinacms's `tinaField(object, property, index)`: `${queryId}---${path.join('.')}`.
4
+ * Returns undefined (attribute omitted) when the data didn't come from a Tina query.
5
+ */
6
+ import type { TinaSource } from '../types';
7
+
8
+ export function tinaField(source: TinaSource | undefined, property?: string, index?: number): string | undefined {
9
+ const cs = source?._content_source;
10
+ if (!cs || !cs.queryId || !Array.isArray(cs.path)) return undefined;
11
+ const path = property === undefined ? cs.path : typeof index === 'number' ? [...cs.path, property, index] : [...cs.path, property];
12
+ return `${cs.queryId}---${path.join('.')}`;
13
+ }
14
+
15
+ /** Spread helper: {...tf(src, 'heading')} → { 'data-tina-field': '…' } or {}. */
16
+ export function tf(source: TinaSource | undefined, property?: string, index?: number): Record<string, string> {
17
+ const value = tinaField(source, property, index);
18
+ return value ? { 'data-tina-field': value } : {};
19
+ }
@@ -0,0 +1,23 @@
1
+ /** @internal Small helpers shared by blocks. */
2
+ import { uid } from '../../primitives/utils';
3
+ import type { ActionItem } from '../types';
4
+
5
+ export { slugify } from '../lib/slug';
6
+ import { slugify } from '../lib/slug';
7
+
8
+ /** The section's id (from `anchor` or `id`) and a heading id derived from it. */
9
+ export function blockIds(name: string, anchor?: string, id?: string): { sectionId?: string; headingId: string } {
10
+ const sectionId = anchor ? slugify(anchor) || undefined : id;
11
+ return { sectionId, headingId: `${sectionId ?? uid(`sinn-${name}`)}-title` };
12
+ }
13
+
14
+ export function actionVariant(action: ActionItem, index: number): NonNullable<ActionItem['variant']> {
15
+ return action.variant ?? (index === 0 ? 'solid' : 'outline');
16
+ }
17
+
18
+ export function isNonEmpty(value: unknown): boolean {
19
+ return typeof value === 'string' ? value.trim().length > 0 : value != null;
20
+ }
21
+
22
+ /** Placeholder default: on in `astro dev`, off in builds (overridable per block). */
23
+ export const PLACEHOLDER_DEFAULT: boolean = Boolean(import.meta.env?.DEV);