@sinnstack/ui 0.0.0-stage → 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 (306) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +373 -0
  3. package/README.md +188 -2
  4. package/docs/blocks.md +373 -0
  5. package/docs/data.md +128 -0
  6. package/docs/finishes.md +165 -0
  7. package/docs/motion.md +166 -0
  8. package/docs/primitives.md +510 -0
  9. package/docs/seo.md +191 -0
  10. package/docs/tokens.md +122 -0
  11. package/package.json +132 -3
  12. package/scripts/check-contrast.mjs +180 -0
  13. package/src/blocks/BlockRenderer.astro +60 -0
  14. package/src/blocks/CTABanner.astro +121 -0
  15. package/src/blocks/CTAPair.astro +110 -0
  16. package/src/blocks/CardGrid.astro +167 -0
  17. package/src/blocks/ConsentEmbed.astro +125 -0
  18. package/src/blocks/ConsentManager.astro +147 -0
  19. package/src/blocks/ConsentScript.astro +47 -0
  20. package/src/blocks/ContactCard.astro +164 -0
  21. package/src/blocks/ContactForm.astro +224 -0
  22. package/src/blocks/ErrorPage.astro +242 -0
  23. package/src/blocks/FAQ.astro +135 -0
  24. package/src/blocks/FeatureGrid.astro +148 -0
  25. package/src/blocks/Hero.astro +171 -0
  26. package/src/blocks/HeroCarousel.astro +220 -0
  27. package/src/blocks/HighlightCards.astro +107 -0
  28. package/src/blocks/LocationHours.astro +311 -0
  29. package/src/blocks/LogoCloud.astro +135 -0
  30. package/src/blocks/MaintenancePage.astro +173 -0
  31. package/src/blocks/MediaText.astro +177 -0
  32. package/src/blocks/PageHeader.astro +126 -0
  33. package/src/blocks/ProseSection.astro +98 -0
  34. package/src/blocks/Reviews.astro +194 -0
  35. package/src/blocks/RichText.astro +58 -0
  36. package/src/blocks/StatsBand.astro +117 -0
  37. package/src/blocks/Steps.astro +141 -0
  38. package/src/blocks/Testimonials.astro +144 -0
  39. package/src/blocks/Topbar.astro +158 -0
  40. package/src/blocks/cms/card-grid.ts +48 -0
  41. package/src/blocks/cms/consent.ts +16 -0
  42. package/src/blocks/cms/contact-card.ts +46 -0
  43. package/src/blocks/cms/contact-form.ts +37 -0
  44. package/src/blocks/cms/cta-banner.ts +27 -0
  45. package/src/blocks/cms/cta-pair.ts +30 -0
  46. package/src/blocks/cms/data-base.ts +5 -0
  47. package/src/blocks/cms/data.ts +257 -0
  48. package/src/blocks/cms/faq.ts +38 -0
  49. package/src/blocks/cms/feature-grid.ts +47 -0
  50. package/src/blocks/cms/fixtures.ts +591 -0
  51. package/src/blocks/cms/hero-carousel.ts +36 -0
  52. package/src/blocks/cms/hero.ts +33 -0
  53. package/src/blocks/cms/highlight-cards.ts +41 -0
  54. package/src/blocks/cms/images.ts +37 -0
  55. package/src/blocks/cms/index.ts +59 -0
  56. package/src/blocks/cms/location-hours.ts +67 -0
  57. package/src/blocks/cms/logo-cloud.ts +36 -0
  58. package/src/blocks/cms/media-text.ts +26 -0
  59. package/src/blocks/cms/page-header.ts +27 -0
  60. package/src/blocks/cms/pages.ts +35 -0
  61. package/src/blocks/cms/prose-section.ts +25 -0
  62. package/src/blocks/cms/reviews.ts +50 -0
  63. package/src/blocks/cms/schema-dsl.ts +134 -0
  64. package/src/blocks/cms/schema.ts +794 -0
  65. package/src/blocks/cms/shared.ts +63 -0
  66. package/src/blocks/cms/stats-band.ts +35 -0
  67. package/src/blocks/cms/steps.ts +40 -0
  68. package/src/blocks/cms/testimonials.ts +46 -0
  69. package/src/blocks/cms/topbar.ts +27 -0
  70. package/src/blocks/cms/types.ts +27 -0
  71. package/src/blocks/consent.ts +14 -0
  72. package/src/blocks/icons.ts +47 -0
  73. package/src/blocks/index.ts +42 -0
  74. package/src/blocks/internal/Actions.astro +35 -0
  75. package/src/blocks/internal/BlockHeader.astro +45 -0
  76. package/src/blocks/internal/BlockShell.astro +58 -0
  77. package/src/blocks/internal/CarouselScript.astro +7 -0
  78. package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
  79. package/src/blocks/internal/ConsentManagerScript.astro +7 -0
  80. package/src/blocks/internal/HoursScript.astro +7 -0
  81. package/src/blocks/internal/Placeholder.astro +13 -0
  82. package/src/blocks/internal/RichTextNode.astro +133 -0
  83. package/src/blocks/internal/StandaloneDocument.astro +53 -0
  84. package/src/blocks/internal/consent.ts +96 -0
  85. package/src/blocks/internal/fields.ts +18 -0
  86. package/src/blocks/internal/registry-contract.ts +67 -0
  87. package/src/blocks/internal/reviews.ts +22 -0
  88. package/src/blocks/internal/slug.ts +12 -0
  89. package/src/blocks/internal/util.ts +23 -0
  90. package/src/blocks/lib/contact.ts +92 -0
  91. package/src/blocks/lib/error-pages.ts +119 -0
  92. package/src/blocks/lib/faq.ts +37 -0
  93. package/src/blocks/lib/hours.ts +201 -0
  94. package/src/blocks/lib/maintenance.ts +129 -0
  95. package/src/blocks/lib/markdown.ts +350 -0
  96. package/src/blocks/lib/rich-text.ts +132 -0
  97. package/src/blocks/registry.ts +79 -0
  98. package/src/blocks/scripts/carousel.ts +218 -0
  99. package/src/blocks/scripts/consent-embed.ts +105 -0
  100. package/src/blocks/scripts/consent-manager.ts +112 -0
  101. package/src/blocks/scripts/consent-store.ts +86 -0
  102. package/src/blocks/scripts/error-page.ts +71 -0
  103. package/src/blocks/scripts/hours.ts +107 -0
  104. package/src/blocks/scripts/maintenance.ts +109 -0
  105. package/src/blocks/styles/blocks.css +1320 -0
  106. package/src/blocks/styles/consent.css +102 -0
  107. package/src/blocks/styles/faq.css +28 -0
  108. package/src/blocks/styles/location.css +92 -0
  109. package/src/blocks/styles/prose-section.css +13 -0
  110. package/src/blocks/styles/quotes.css +123 -0
  111. package/src/blocks/styles/rich-text.css +14 -0
  112. package/src/blocks/types.ts +293 -0
  113. package/src/data/ChartAxis.astro +19 -0
  114. package/src/data/ChartContainer.astro +152 -0
  115. package/src/data/ChartLegend.astro +25 -0
  116. package/src/data/ChartSeries.astro +14 -0
  117. package/src/data/ChartTable.astro +17 -0
  118. package/src/data/ChartTooltip.astro +20 -0
  119. package/src/data/Sparkline.astro +55 -0
  120. package/src/data/cms.ts +130 -0
  121. package/src/data/index.ts +10 -0
  122. package/src/data/internal/scale.ts +107 -0
  123. package/src/data/lib/chart.ts +459 -0
  124. package/src/data/lib/render.ts +219 -0
  125. package/src/data/lib/sparkline.ts +117 -0
  126. package/src/data/schema.ts +65 -0
  127. package/src/data/scripts/chart.ts +324 -0
  128. package/src/data/styles/chart.css +392 -0
  129. package/src/finishes/aurora.css +75 -0
  130. package/src/finishes/autumn.css +87 -0
  131. package/src/finishes/blueprint.css +69 -0
  132. package/src/finishes/brutalist.css +55 -0
  133. package/src/finishes/clay.css +48 -0
  134. package/src/finishes/day-cycle.css +46 -0
  135. package/src/finishes/fog.css +71 -0
  136. package/src/finishes/glass.css +149 -0
  137. package/src/finishes/holographic.css +91 -0
  138. package/src/finishes/night.css +77 -0
  139. package/src/finishes/paper.css +58 -0
  140. package/src/finishes/polished-glass.css +159 -0
  141. package/src/finishes/rain.css +84 -0
  142. package/src/finishes/scripts/day-cycle.ts +30 -0
  143. package/src/finishes/scripts/holographic.ts +37 -0
  144. package/src/finishes/scripts/spotlight.ts +30 -0
  145. package/src/finishes/spotlight.css +41 -0
  146. package/src/finishes/spring.css +80 -0
  147. package/src/finishes/terminal.css +49 -0
  148. package/src/motion/Marquee.astro +90 -0
  149. package/src/motion/MotionProvider.astro +50 -0
  150. package/src/motion/PageTransitions.astro +61 -0
  151. package/src/motion/Parallax.astro +44 -0
  152. package/src/motion/ParallaxLayer.astro +31 -0
  153. package/src/motion/RevealOnScroll.astro +59 -0
  154. package/src/motion/SceneRegistry.astro +38 -0
  155. package/src/motion/ScrollScene.astro +81 -0
  156. package/src/motion/index.ts +12 -0
  157. package/src/motion/integration.ts +48 -0
  158. package/src/motion/runtime/page-transitions.ts +68 -0
  159. package/src/motion/runtime/runtime.ts +180 -0
  160. package/src/motion/runtime/scenes.ts +248 -0
  161. package/src/motion/runtime/types.ts +103 -0
  162. package/src/motion/styles/motion.css +332 -0
  163. package/src/motion/transitions.ts +74 -0
  164. package/src/motion/virtual.d.ts +4 -0
  165. package/src/primitives/Accordion.astro +129 -0
  166. package/src/primitives/Breadcrumbs.astro +50 -0
  167. package/src/primitives/BulletList.astro +69 -0
  168. package/src/primitives/Button.astro +73 -0
  169. package/src/primitives/ButtonGroup.astro +54 -0
  170. package/src/primitives/Callout.astro +137 -0
  171. package/src/primitives/Caption.astro +35 -0
  172. package/src/primitives/Card.astro +72 -0
  173. package/src/primitives/CardContent.astro +24 -0
  174. package/src/primitives/CardFooter.astro +36 -0
  175. package/src/primitives/CardHeader.astro +86 -0
  176. package/src/primitives/Checkbox.astro +38 -0
  177. package/src/primitives/ChoiceGroup.astro +23 -0
  178. package/src/primitives/Cluster.astro +49 -0
  179. package/src/primitives/Container.astro +44 -0
  180. package/src/primitives/DescriptionList.astro +83 -0
  181. package/src/primitives/Dialog.astro +38 -0
  182. package/src/primitives/Disclosure.astro +67 -0
  183. package/src/primitives/Divider.astro +93 -0
  184. package/src/primitives/Drawer.astro +33 -0
  185. package/src/primitives/Fieldset.astro +80 -0
  186. package/src/primitives/Flex.astro +64 -0
  187. package/src/primitives/FocusRing.astro +63 -0
  188. package/src/primitives/FocusTrap.astro +64 -0
  189. package/src/primitives/Footer.astro +155 -0
  190. package/src/primitives/Form.astro +68 -0
  191. package/src/primitives/FormDescription.astro +26 -0
  192. package/src/primitives/FormError.astro +106 -0
  193. package/src/primitives/FormField.astro +72 -0
  194. package/src/primitives/Grid.astro +64 -0
  195. package/src/primitives/Heading.astro +45 -0
  196. package/src/primitives/IconButton.astro +48 -0
  197. package/src/primitives/Image.astro +125 -0
  198. package/src/primitives/Input.astro +86 -0
  199. package/src/primitives/Label.astro +50 -0
  200. package/src/primitives/Link.astro +81 -0
  201. package/src/primitives/LinkButton.astro +66 -0
  202. package/src/primitives/List.astro +39 -0
  203. package/src/primitives/ListItem.astro +178 -0
  204. package/src/primitives/MediaObject.astro +66 -0
  205. package/src/primitives/MetricCard.astro +278 -0
  206. package/src/primitives/NavLink.astro +81 -0
  207. package/src/primitives/NavMenu.astro +109 -0
  208. package/src/primitives/Navbar.astro +197 -0
  209. package/src/primitives/Panel.astro +153 -0
  210. package/src/primitives/Picture.astro +167 -0
  211. package/src/primitives/Popover.astro +95 -0
  212. package/src/primitives/Prose.astro +45 -0
  213. package/src/primitives/Radio.astro +21 -0
  214. package/src/primitives/Rating.astro +135 -0
  215. package/src/primitives/ReducedMotion.astro +90 -0
  216. package/src/primitives/SegmentedControl.astro +132 -0
  217. package/src/primitives/Select.astro +109 -0
  218. package/src/primitives/Sheet.astro +45 -0
  219. package/src/primitives/SkipLink.astro +31 -0
  220. package/src/primitives/Slider.astro +186 -0
  221. package/src/primitives/Spacer.astro +35 -0
  222. package/src/primitives/Stack.astro +51 -0
  223. package/src/primitives/Surface.astro +70 -0
  224. package/src/primitives/Switch.astro +22 -0
  225. package/src/primitives/Table.astro +382 -0
  226. package/src/primitives/Tabs.astro +126 -0
  227. package/src/primitives/Text.astro +56 -0
  228. package/src/primitives/Textarea.astro +75 -0
  229. package/src/primitives/Thumbnail.astro +154 -0
  230. package/src/primitives/Toggle.astro +99 -0
  231. package/src/primitives/Tooltip.astro +50 -0
  232. package/src/primitives/VisuallyHidden.astro +29 -0
  233. package/src/primitives/index.ts +103 -0
  234. package/src/primitives/internal/AccordionScript.astro +7 -0
  235. package/src/primitives/internal/ChoiceField.astro +91 -0
  236. package/src/primitives/internal/FocusTrapScript.astro +8 -0
  237. package/src/primitives/internal/FormValidationScript.astro +10 -0
  238. package/src/primitives/internal/IndeterminateScript.astro +13 -0
  239. package/src/primitives/internal/ModalPanel.astro +114 -0
  240. package/src/primitives/internal/OverlayScript.astro +7 -0
  241. package/src/primitives/internal/ReducedMotionScript.astro +7 -0
  242. package/src/primitives/internal/SliderScript.astro +7 -0
  243. package/src/primitives/internal/SparklineScript.astro +7 -0
  244. package/src/primitives/internal/TableSortScript.astro +7 -0
  245. package/src/primitives/internal/TabsScript.astro +7 -0
  246. package/src/primitives/internal/TooltipScript.astro +7 -0
  247. package/src/primitives/internal/image-plan.ts +82 -0
  248. package/src/primitives/internal/image.ts +129 -0
  249. package/src/primitives/internal/slider.ts +170 -0
  250. package/src/primitives/lib/deprecate.ts +47 -0
  251. package/src/primitives/lib/focus-trap.ts +197 -0
  252. package/src/primitives/lib/focus.ts +60 -0
  253. package/src/primitives/lib/motion.ts +68 -0
  254. package/src/primitives/scripts/accordion.ts +123 -0
  255. package/src/primitives/scripts/form-validation.ts +225 -0
  256. package/src/primitives/scripts/overlay.ts +71 -0
  257. package/src/primitives/scripts/reduced-motion.ts +59 -0
  258. package/src/primitives/scripts/slider.ts +150 -0
  259. package/src/primitives/scripts/sparkline.ts +131 -0
  260. package/src/primitives/scripts/table-sort.ts +68 -0
  261. package/src/primitives/scripts/tabs.ts +151 -0
  262. package/src/primitives/scripts/tooltip.ts +28 -0
  263. package/src/primitives/styles/a11y.css +104 -0
  264. package/src/primitives/styles/accordion.css +53 -0
  265. package/src/primitives/styles/breadcrumbs.css +59 -0
  266. package/src/primitives/styles/bullet-list.css +89 -0
  267. package/src/primitives/styles/button.css +237 -0
  268. package/src/primitives/styles/choice.css +164 -0
  269. package/src/primitives/styles/cluster.css +24 -0
  270. package/src/primitives/styles/container.css +19 -0
  271. package/src/primitives/styles/data.css +849 -0
  272. package/src/primitives/styles/disclosure.css +140 -0
  273. package/src/primitives/styles/divider.css +50 -0
  274. package/src/primitives/styles/flex.css +42 -0
  275. package/src/primitives/styles/form.css +241 -0
  276. package/src/primitives/styles/grid.css +36 -0
  277. package/src/primitives/styles/media.css +247 -0
  278. package/src/primitives/styles/nav.css +792 -0
  279. package/src/primitives/styles/overlay.css +362 -0
  280. package/src/primitives/styles/prose.css +146 -0
  281. package/src/primitives/styles/scale.css +175 -0
  282. package/src/primitives/styles/segmented.css +165 -0
  283. package/src/primitives/styles/slider.css +170 -0
  284. package/src/primitives/styles/spacer.css +17 -0
  285. package/src/primitives/styles/stack.css +25 -0
  286. package/src/primitives/styles/surface.css +403 -0
  287. package/src/primitives/styles/tabs.css +223 -0
  288. package/src/primitives/styles/typography.css +144 -0
  289. package/src/primitives/styles/utilities.css +24 -0
  290. package/src/primitives/types.ts +385 -0
  291. package/src/primitives/utils.ts +254 -0
  292. package/src/seo/JSONLD.astro +35 -0
  293. package/src/seo/SEOHead.astro +47 -0
  294. package/src/seo/cms.ts +59 -0
  295. package/src/seo/index.ts +10 -0
  296. package/src/seo/integration.ts +268 -0
  297. package/src/seo/internal/url.ts +68 -0
  298. package/src/seo/lib/jsonld.ts +342 -0
  299. package/src/seo/lib/meta.ts +205 -0
  300. package/src/seo/lib/redirects.ts +293 -0
  301. package/src/seo/lib/robots.ts +33 -0
  302. package/src/seo/lib/rss.ts +98 -0
  303. package/src/seo/lib/sitemap.ts +105 -0
  304. package/src/seo/schema.ts +43 -0
  305. package/src/tokens/base.css +71 -0
  306. package/src/tokens/tokens.css +210 -0
@@ -0,0 +1,242 @@
1
+ ---
2
+ /**
3
+ * ErrorPage — 404, 410, 403 and 500 pages that lead visitors back into the site.
4
+ *
5
+ * Use it in `src/pages/404.astro` and `src/pages/500.astro`:
6
+ *
7
+ * // 404.astro — inside your normal layout
8
+ * <Site title="Page not found"><ErrorPage status={404} links={popular} pages={allPages} search={{ action: '/search' }} /></Site>
9
+ *
10
+ * // 500.astro — standalone, so a broken layout or CMS can't take the error page down too
11
+ * ---
12
+ * const { error } = Astro.props;
13
+ * ---
14
+ * <ErrorPage status={500} document siteName="Sinnstack" error={error} contact={{ text: 'Need help now?', label: 'Call (817) 555-0100', href: 'tel:+18175550100' }} />
15
+ *
16
+ * What it does
17
+ * - Calm copy per status (override `heading`, `description`, `eyebrow`; translate per site).
18
+ * - 404/410: shows the address that failed, suggests the closest real page ("Did you mean…?")
19
+ * from `pages`, and prefills site search with words from the address (`search`).
20
+ * - 500: "Try again" reloads the failing URL; error details render only in development
21
+ * (`showDetails`), as plain text, never in production.
22
+ * - "Go back" appears only when the visitor arrived from another page of this site.
23
+ * - `links`: a short "Popular pages" navigation (a <nav> landmark), icons by name.
24
+ * - Dispatches `sinn:error-page` { status, path, referrer } on document, for analytics.
25
+ * - `document`: renders a complete minimal HTML page (noindex) instead of a section. Inside your
26
+ * own layout, set `<meta name="robots" content="noindex">` and the title there.
27
+ * - The HTTP status comes from the page: Astro sends 404/500 for 404.astro/500.astro; elsewhere
28
+ * set `Astro.response.status` in the page before rendering this.
29
+ */
30
+ import Heading from '../primitives/Heading.astro';
31
+ import Text from '../primitives/Text.astro';
32
+ import Button from '../primitives/Button.astro';
33
+ import Input from '../primitives/Input.astro';
34
+ import type { HTMLAttributes } from 'astro/types';
35
+ import type { ActionItem, BlockProps } from './types';
36
+ import { blockIcons } from './icons';
37
+ import BlockShell from './internal/BlockShell.astro';
38
+ import Actions from './internal/Actions.astro';
39
+ import StandaloneDocument from './internal/StandaloneDocument.astro';
40
+ import { blockIds } from './internal/util';
41
+ import { copyFor, isMissing, isServerError, type SuggestCandidate } from './lib/error-pages';
42
+
43
+ export interface ErrorPageLink {
44
+ label: string;
45
+ href: string;
46
+ description?: string;
47
+ /** Icon name from the built-in set (or your `icons` map). */
48
+ icon?: string;
49
+ }
50
+
51
+ type Props = Omit<HTMLAttributes<'section'>, 'title'> &
52
+ Omit<BlockProps, 'placeholder' | 'fieldPath'> & {
53
+ status?: number;
54
+ eyebrow?: string;
55
+ heading?: string;
56
+ description?: string;
57
+ /** Show the status number large above the heading (decorative; hidden from assistive tech). */
58
+ showCode?: boolean;
59
+ /** Replace the default actions (home page; "Try again" for server errors). */
60
+ actions?: ActionItem[];
61
+ homeHref?: string;
62
+ homeLabel?: string;
63
+ /** Offer "Go back" when the visitor came from this site (needs JS; hidden otherwise). */
64
+ backButton?: boolean;
65
+ backLabel?: string;
66
+ links?: ErrorPageLink[];
67
+ linksHeading?: string;
68
+ /** Pages to match a missing address against ("Did you mean…?"). Defaults to `links`. */
69
+ pages?: SuggestCandidate[];
70
+ /** Site search: GET `action?param=…`. */
71
+ search?: { action: string; param?: string; label?: string; buttonLabel?: string };
72
+ /** A way to reach a person ("Need help now? Call …"). */
73
+ contact?: { text?: string; label: string; href: string };
74
+ /** The error Astro passes to 500.astro. Details are shown only when `showDetails`. */
75
+ error?: unknown;
76
+ showDetails?: boolean;
77
+ icons?: Record<string, string>;
78
+ /** Render a complete standalone HTML document (use for 500 pages). */
79
+ document?: boolean;
80
+ siteName?: string;
81
+ lang?: string;
82
+ };
83
+
84
+ const {
85
+ status = 404,
86
+ eyebrow,
87
+ heading,
88
+ description,
89
+ showCode = true,
90
+ actions,
91
+ homeHref = '/',
92
+ homeLabel = 'Go to the home page',
93
+ backButton = true,
94
+ backLabel = 'Go back',
95
+ links = [],
96
+ linksHeading = 'Popular pages',
97
+ pages,
98
+ search,
99
+ contact,
100
+ error,
101
+ showDetails = Boolean(import.meta.env?.DEV),
102
+ icons = blockIcons as Record<string, string>,
103
+ document: asDocument = false,
104
+ siteName,
105
+ lang,
106
+ anchor,
107
+ spacing = 'xl',
108
+ background = 'none',
109
+ tone = 'accent',
110
+ scheme,
111
+ align = 'start',
112
+ containerSize = 'default',
113
+ id,
114
+ class: className,
115
+ ...rest
116
+ } = Astro.props;
117
+
118
+ const copy = copyFor(status);
119
+ const missing = isMissing(status);
120
+ const serverError = isServerError(status);
121
+ const { sectionId, headingId } = blockIds('error', anchor, id);
122
+ const navHeadingId = `${headingId}-links`;
123
+
124
+ // On-demand rendering knows the real URL; a prerendered 404 learns it in the browser.
125
+ const live = !Astro.isPrerendered;
126
+ const requestedPath = live && missing ? Astro.url.pathname : undefined;
127
+ const retryHref = live && serverError ? Astro.url.pathname + Astro.url.search : undefined;
128
+ const defaultActions: ActionItem[] = serverError && retryHref
129
+ ? [{ label: 'Try again', href: retryHref }, { label: homeLabel, href: homeHref, variant: 'outline' }]
130
+ : [{ label: homeLabel, href: homeHref }];
131
+ const finalActions = actions ?? defaultActions;
132
+ const suggestFrom = (pages ?? links.map(({ label, href }) => ({ label, href }))).filter((p) => p.href && p.href !== homeHref);
133
+
134
+ const err = error as { message?: string; stack?: string; name?: string } | undefined;
135
+ const details = showDetails && err ? [err.name && err.message ? `${err.name}: ${err.message}` : err.message ?? String(error), err.stack].filter(Boolean).join('\n\n') : undefined;
136
+ const hasMedia = Astro.slots.has('media');
137
+ const chevron = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m6 3.5 4.5 4.5L6 12.5"/></svg>';
138
+ const searchIcon = '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="8.5" cy="8.5" r="5.5"/><path d="m13 13 4 4"/></svg>';
139
+ const Wrapper = asDocument ? StandaloneDocument : Fragment;
140
+ const wrapperProps = asDocument ? { title: copy.title, lang, siteName, homeHref } : {};
141
+ ---
142
+
143
+ <Wrapper {...wrapperProps}>
144
+ <BlockShell
145
+ name="error"
146
+ id={sectionId}
147
+ class={className}
148
+ spacing={spacing}
149
+ background={background}
150
+ tone={tone}
151
+ scheme={scheme}
152
+ containerSize={containerSize}
153
+ labelledby={headingId}
154
+ align={align}
155
+ data-sinn-error-page={status}
156
+ data-has-media={hasMedia ? '' : undefined}
157
+ {...rest}
158
+ >
159
+ <div class="sinn-error__layout">
160
+ <div class="sinn-error__content">
161
+ {showCode && <p class="sinn-error__code" aria-hidden="true">{status}</p>}
162
+ {eyebrow && <p class="sinn-block__eyebrow">{eyebrow}</p>}
163
+ <Heading level={1} size="3xl" weight="bold" id={headingId} class="sinn-error__title">{heading ?? copy.heading}</Heading>
164
+ <Text size="l" tone="muted" class="sinn-error__description" measure>{description ?? copy.description}</Text>
165
+ {
166
+ missing && (
167
+ <p class="sinn-error__path" hidden={!requestedPath}>
168
+ Nothing lives at <code data-sinn-error-path>{requestedPath}</code>
169
+ </p>
170
+ )
171
+ }
172
+ {
173
+ missing && suggestFrom.length > 0 && (
174
+ <p class="sinn-error__suggest" data-sinn-error-suggest data-pages={JSON.stringify(suggestFrom)} hidden>
175
+ Did you mean <a href={homeHref}>{homeLabel}</a>?
176
+ </p>
177
+ )
178
+ }
179
+ <slot />
180
+ <Actions actions={finalActions} class="sinn-error__actions">
181
+ {backButton && <Button variant="ghost" size="l" data-sinn-error-back hidden>{backLabel}</Button>}
182
+ {Astro.slots.has('actions') && <slot name="actions" />}
183
+ </Actions>
184
+ {
185
+ search && missing && (
186
+ <form class="sinn-error__search" role="search" action={search.action} method="get">
187
+ <Input type="search" name={search.param ?? 'q'} label={search.label ?? 'Search the site'} data-sinn-error-search autocomplete="off" enterkeyhint="search" class="sinn-error__search-field">
188
+ <span slot="start" class="sinn-error__search-icon" set:html={searchIcon} />
189
+ </Input>
190
+ <Button type="submit" variant="outline">{search.buttonLabel ?? 'Search'}</Button>
191
+ </form>
192
+ )
193
+ }
194
+ {
195
+ contact && (
196
+ <p class="sinn-error__contact">
197
+ {contact.text && <span>{contact.text} </span>}
198
+ <a href={contact.href}>{contact.label}</a>
199
+ </p>
200
+ )
201
+ }
202
+ {
203
+ details && (
204
+ <details class="sinn-error__details">
205
+ <summary>Error details (development only)</summary>
206
+ <pre>{details}</pre>
207
+ </details>
208
+ )
209
+ }
210
+ </div>
211
+ {hasMedia && <div class="sinn-error__media"><slot name="media" /></div>}
212
+ </div>
213
+ {
214
+ links.length > 0 && (
215
+ <nav class="sinn-error__nav" aria-labelledby={navHeadingId}>
216
+ <Heading level={2} size="s" tone="muted" weight="semibold" id={navHeadingId} class="sinn-error__nav-title">{linksHeading}</Heading>
217
+ <ul class="sinn-error__links" role="list">
218
+ {links.map((link) => {
219
+ const icon = link.icon ? icons[link.icon] : undefined;
220
+ return (
221
+ <li>
222
+ <a class="sinn-error__link" href={link.href}>
223
+ {icon && <span class="sinn-error__link-icon" aria-hidden="true" set:html={icon} />}
224
+ <span class="sinn-error__link-text">
225
+ <span class="sinn-error__link-label">{link.label}</span>
226
+ {link.description && <span class="sinn-error__link-description">{link.description}</span>}
227
+ </span>
228
+ <span class="sinn-error__link-arrow" aria-hidden="true" set:html={chevron} />
229
+ </a>
230
+ </li>
231
+ );
232
+ })}
233
+ </ul>
234
+ </nav>
235
+ )
236
+ }
237
+ <script>
238
+ import './scripts/error-page';
239
+ </script>
240
+ </BlockShell>
241
+ </Wrapper>
242
+
@@ -0,0 +1,135 @@
1
+ ---
2
+ /**
3
+ * FAQ: frequently asked questions as an Accordion, with an optional eyebrow, heading, intro
4
+ * and buttons ("Still have questions? Contact us").
5
+ *
6
+ * - Every question is a native `<details>` with the question as a real heading
7
+ * (`itemTitleLevel`, default one below the section heading), so answers work with no
8
+ * JavaScript and screen-reader users can jump between questions.
9
+ * - Each question gets an id from its text, so `/faq#what-does-a-website-cost` opens that answer.
10
+ * Set `id` on an item to keep a link stable when the wording changes.
11
+ * - Answers are rich text or plain text (RichText: safe elements and URLs only).
12
+ * - `layout="split"` puts the header beside the questions on wide containers.
13
+ * - Structured data: pass the same items to `faqStructuredData()` and then to `faqPage()` from
14
+ * `@sinnstack/ui/seo/jsonld`. Use one FAQPage per page, and only for questions the page answers.
15
+ * - Placeholder: no question with an answer → dashed placeholder in dev/CMS preview.
16
+ *
17
+ * @example
18
+ * <FAQ heading="Questions we hear a lot" items={[
19
+ * { question: 'How long does a website take?', answer: 'Most sites launch in four to six weeks.' },
20
+ * ]} actions={[{ label: 'Ask us something else', href: '/contact', variant: 'outline' }]} />
21
+ */
22
+ import Accordion from '../primitives/Accordion.astro';
23
+ import type { HTMLAttributes } from 'astro/types';
24
+ import type { ActionItem, BlockProps, FaqItem, HeadingLevel } from './types';
25
+ import type { ImageResolver } from './cms/types';
26
+ import BlockShell from './internal/BlockShell.astro';
27
+ import BlockHeader from './internal/BlockHeader.astro';
28
+ import Actions from './internal/Actions.astro';
29
+ import Placeholder from './internal/Placeholder.astro';
30
+ import RichText from './RichText.astro';
31
+ import { faqItems } from './lib/faq';
32
+ import { blockIds, PLACEHOLDER_DEFAULT } from './internal/util';
33
+ import { sf, joinField } from './internal/fields';
34
+ import './styles/blocks.css';
35
+ import './styles/faq.css';
36
+
37
+ type Props = Omit<HTMLAttributes<'section'>, 'title'> &
38
+ BlockProps & {
39
+ eyebrow?: string;
40
+ heading?: string;
41
+ description?: string;
42
+ headingLevel?: HeadingLevel;
43
+ /** Heading level of each question. Default: one below the section heading. */
44
+ itemTitleLevel?: Exclude<HeadingLevel, 1>;
45
+ items?: FaqItem[];
46
+ /** `stacked` (header above) or `split` (header beside the questions when there's room). */
47
+ layout?: 'stacked' | 'split';
48
+ /** `divided` (rules between questions) or `card` (each question boxed). */
49
+ variant?: 'divided' | 'card';
50
+ /** `multiple` (default): answers open independently. `single`: one at a time. */
51
+ mode?: 'multiple' | 'single';
52
+ /** Open the first answer on load. */
53
+ openFirst?: boolean;
54
+ actions?: ActionItem[];
55
+ resolveImage?: ImageResolver;
56
+ /** Accordion button text. Translate per site. */
57
+ labels?: { showAll: string; hideAll: string };
58
+ };
59
+
60
+ const {
61
+ eyebrow,
62
+ heading,
63
+ description,
64
+ headingLevel = 2,
65
+ itemTitleLevel,
66
+ items = [],
67
+ layout = 'stacked',
68
+ variant = 'divided',
69
+ mode = 'multiple',
70
+ openFirst = false,
71
+ actions = [],
72
+ resolveImage,
73
+ labels,
74
+ align = 'start',
75
+ anchor,
76
+ spacing = 'l',
77
+ background = 'none',
78
+ tone = 'accent',
79
+ scheme,
80
+ containerSize = 'default',
81
+ placeholder = PLACEHOLDER_DEFAULT,
82
+ fieldPath,
83
+ id,
84
+ class: className,
85
+ ...rest
86
+ } = Astro.props;
87
+
88
+ const faqs = faqItems(items);
89
+ const { sectionId, headingId } = blockIds('faq', anchor, id);
90
+ const hasHeading = Boolean(heading?.trim());
91
+ const questionLevel = (itemTitleLevel ?? Math.min(6, (hasHeading ? headingLevel : 1) + 1)) as Exclude<HeadingLevel, 1>;
92
+ const answerTop = Math.min(6, questionLevel + 1) as 2 | 3 | 4 | 5 | 6;
93
+ const split = layout === 'split' && Boolean(eyebrow || heading || description || actions.length);
94
+ ---
95
+
96
+ {
97
+ faqs.length === 0 ? (
98
+ placeholder && <Placeholder label="FAQ" hint="Add at least one question with an answer." field={joinField(fieldPath, 'items')} />
99
+ ) : (
100
+ <BlockShell
101
+ name="faq"
102
+ id={sectionId}
103
+ class={className}
104
+ spacing={spacing}
105
+ background={background}
106
+ tone={tone}
107
+ scheme={scheme}
108
+ containerSize={containerSize}
109
+ labelledby={hasHeading ? headingId : undefined}
110
+ align={split ? 'start' : align}
111
+ data-layout={split ? 'split' : undefined}
112
+ {...sf(fieldPath)}
113
+ {...rest}
114
+ >
115
+ <div class="sinn-faq__inner">
116
+ <div class="sinn-faq__intro">
117
+ <BlockHeader eyebrow={eyebrow} heading={heading} headingId={headingId} headingLevel={headingLevel} description={description} fieldPath={fieldPath} />
118
+ {split && <Actions actions={actions} size="m" class="sinn-faq__actions" fieldPath={fieldPath} />}
119
+ </div>
120
+ <Accordion
121
+ class="sinn-faq__list"
122
+ items={faqs.map((f, i) => ({ id: f.id, title: f.question, open: openFirst && i === 0 }))}
123
+ headingLevel={questionLevel}
124
+ variant={variant}
125
+ mode={mode}
126
+ labels={labels}
127
+ {...sf(fieldPath, 'items')}
128
+ >
129
+ {(_item: unknown, i: number) => <RichText value={faqs[i].answer} headingLevel={answerTop} resolveImage={resolveImage} class="sinn-faq__answer" {...sf(fieldPath, faqs[i].field, 'answer')} />}
130
+ </Accordion>
131
+ {!split && <Actions actions={actions} size="m" class="sinn-block__footer sinn-faq__actions" fieldPath={fieldPath} />}
132
+ </div>
133
+ </BlockShell>
134
+ )
135
+ }
@@ -0,0 +1,148 @@
1
+ ---
2
+ /**
3
+ * FeatureGrid — features, services or benefits as a grid or list: icon, title, short description.
4
+ *
5
+ * - `items` is plain data (maps 1:1 to the CMS schema). For custom markup put
6
+ * `<li class="sinn-feature">…</li>` children in the default slot (or both).
7
+ * - Icons by name from the built-in set (`blockIcons`: check, heart, shield, clock, phone…) or your
8
+ * own `icons` map, so CMS content never carries raw SVG. `iconSvg` takes trusted markup from code.
9
+ * Unknown names render no icon (and warn in dev).
10
+ * - `variant`: `plain`, `cards` (bordered surfaces) or `divided` (a rule above each item).
11
+ * `layout`: `stacked` (icon above) or `inline` (icon beside). `columns={1}` + `divided` + `inline`
12
+ * reads as a list.
13
+ * - `columns` is the maximum; fewer fit as the container narrows (never narrower than ~16rem).
14
+ * - `size`: s (compact lists) · m · l (big icons, larger titles, for 2–3 headline features).
15
+ * - An item with `href` is one link (its title); the whole item is the click target, and the
16
+ * focus ring wraps the whole item.
17
+ * - Item headings are one level below the section heading (`itemTitleLevel` overrides);
18
+ * level 3 when the block has no heading.
19
+ * - Empty: no items and no slot content → placeholder in dev/CMS preview, nothing in builds.
20
+ *
21
+ * @example
22
+ * <FeatureGrid eyebrow="Services" heading="Everything you need, at home" variant="cards"
23
+ * items={[{ title: 'Astro development', description: 'Fast, static-first pages.', icon: 'code', href: '/services/development' }]} />
24
+ */
25
+ import Heading from '../primitives/Heading.astro';
26
+ import Text from '../primitives/Text.astro';
27
+ import type { HTMLAttributes } from 'astro/types';
28
+ import type { BlockProps, FeatureItem, HeadingLevelNumber } from './types';
29
+ import BlockShell from './internal/BlockShell.astro';
30
+ import BlockHeader from './internal/BlockHeader.astro';
31
+ import Placeholder from './internal/Placeholder.astro';
32
+ import { blockIcons } from './icons';
33
+ import { blockIds, PLACEHOLDER_DEFAULT } from './internal/util';
34
+ import { sf, joinField } from './internal/fields';
35
+ import { renameProp, renameValue } from '../primitives/lib/deprecate';
36
+
37
+ type Props = Omit<HTMLAttributes<'section'>, 'title'> &
38
+ BlockProps & {
39
+ eyebrow?: string;
40
+ heading?: string;
41
+ description?: string;
42
+ headingLevel?: HeadingLevelNumber;
43
+ /** Heading level of each item's title. Default: one below the section heading. */
44
+ itemTitleLevel?: HeadingLevelNumber;
45
+ /** @deprecated Use `itemTitleLevel` (item text is `title`, so its level is `itemTitleLevel`). */
46
+ itemHeadingLevel?: HeadingLevelNumber;
47
+ items?: FeatureItem[];
48
+ columns?: 1 | 2 | 3 | 4;
49
+ /** Item treatment: `plain`, `card` (each item boxed) or `divided` (rules between). `cards` is the deprecated spelling. */
50
+ variant?: 'plain' | 'card' | 'divided' | 'cards';
51
+ layout?: 'stacked' | 'inline';
52
+ size?: 's' | 'm' | 'l';
53
+ /** Tinted rounded square behind each icon (default) or the bare icon. */
54
+ iconStyle?: 'tile' | 'bare';
55
+ /** Icon set: name → trusted SVG markup. Defaults to the built-in `blockIcons`. */
56
+ icons?: Record<string, string>;
57
+ };
58
+
59
+ const {
60
+ eyebrow,
61
+ heading,
62
+ description,
63
+ headingLevel = 2,
64
+ itemTitleLevel: itemTitleLevelProp,
65
+ itemHeadingLevel,
66
+ items = [],
67
+ columns = 3,
68
+ variant: variantProp = 'plain',
69
+ layout = 'stacked',
70
+ size = 'm',
71
+ iconStyle = 'tile',
72
+ icons = blockIcons as Record<string, string>,
73
+ align = 'start',
74
+ anchor,
75
+ spacing = 'l',
76
+ background = 'none',
77
+ tone = 'accent',
78
+ scheme,
79
+ containerSize = 'default',
80
+ placeholder = PLACEHOLDER_DEFAULT,
81
+ fieldPath,
82
+ id,
83
+ class: className,
84
+ ...rest
85
+ } = Astro.props;
86
+ const variant = renameValue('FeatureGrid', 'variant', variantProp, { cards: 'card' });
87
+
88
+ const hasSlot = Astro.slots.has('default');
89
+ const isEmpty = items.length === 0 && !hasSlot;
90
+ const { sectionId, headingId } = blockIds('features', anchor, id);
91
+ const itemTitleLevel = renameProp('FeatureGrid', 'itemTitleLevel', itemTitleLevelProp, 'itemHeadingLevel', itemHeadingLevel);
92
+ const itemLevel = (itemTitleLevel ?? (heading ? Math.min(6, headingLevel + 1) : 3)) as HeadingLevelNumber;
93
+ const titleSize = ({ s: 'm', m: 'l', l: 'xl' } as const)[size];
94
+
95
+ function iconFor(item: FeatureItem): string | undefined {
96
+ if (item.iconSvg) return item.iconSvg;
97
+ if (!item.icon) return undefined;
98
+ const found = icons[item.icon];
99
+ if (!found && import.meta.env?.DEV) console.warn(`[FeatureGrid] Unknown icon "${item.icon}" on "${item.title}".`);
100
+ return found;
101
+ }
102
+ ---
103
+
104
+ {
105
+ isEmpty ? (
106
+ placeholder && <Placeholder label="Feature grid" hint="Add at least one feature." field={joinField(fieldPath, 'items')} />
107
+ ) : (
108
+ <BlockShell
109
+ name="features"
110
+ id={sectionId}
111
+ class={className}
112
+ spacing={spacing}
113
+ background={background}
114
+ tone={tone}
115
+ scheme={scheme}
116
+ size={size}
117
+ containerSize={containerSize}
118
+ labelledby={heading ? headingId : undefined}
119
+ align={align}
120
+ data-variant={variant === 'plain' ? undefined : variant}
121
+ data-layout={layout === 'stacked' ? undefined : layout}
122
+ data-icon={iconStyle === 'tile' ? undefined : iconStyle}
123
+ {...sf(fieldPath)}
124
+ {...rest}
125
+ >
126
+ <BlockHeader eyebrow={eyebrow} heading={heading} headingId={headingId} headingLevel={headingLevel} description={description} fieldPath={fieldPath} />
127
+ <ul class="sinn-block__grid" role="list" data-columns={columns} {...sf(fieldPath, 'items')}>
128
+ {items.map((item, i) => {
129
+ const icon = iconFor(item);
130
+ return (
131
+ <li class="sinn-feature" data-linked={item.href ? '' : undefined} {...sf(fieldPath, item.field)}>
132
+ {icon && <span class="sinn-feature__icon" aria-hidden="true" set:html={icon} />}
133
+ <div class="sinn-feature__body">
134
+ <Heading level={itemLevel} size={titleSize} class="sinn-feature__title">
135
+ {item.href ? <a class="sinn-feature__link" href={item.href}>{item.title}</a> : item.title}
136
+ {item.badge && <span class="sinn-feature__badge">{item.badge}</span>}
137
+ </Heading>
138
+ {item.description && <Text size={size === 'l' ? 'm' : 's'} tone="muted" class="sinn-feature__description">{item.description}</Text>}
139
+ </div>
140
+ </li>
141
+ );
142
+ })}
143
+ <slot />
144
+ </ul>
145
+ {Astro.slots.has('footer') && <div class="sinn-block__footer"><slot name="footer" /></div>}
146
+ </BlockShell>
147
+ )
148
+ }