@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,33 @@
1
+ ---
2
+ /**
3
+ * Drawer — a full-height panel that slides in from the start or end edge: filters, a cart,
4
+ * secondary navigation, record details. Modal, like Dialog (same opening and closing rules),
5
+ * and it slides from the correct side in right-to-left pages.
6
+ *
7
+ * @example
8
+ * <Button commandfor="filters" command="show-modal" variant="outline">Filters</Button>
9
+ * <Drawer id="filters" title="Filter providers" side="end">
10
+ * <ChoiceGroup legend="Specialty">…</ChoiceGroup>
11
+ * <Fragment slot="footer">
12
+ * <Button variant="ghost" tone="neutral" commandfor="filters" command="close">Cancel</Button>
13
+ * <Button type="submit" form="filter-form">Show results</Button>
14
+ * </Fragment>
15
+ * </Drawer>
16
+ */
17
+ import type { ModalPanelProps } from './types';
18
+ import ModalPanel from './internal/ModalPanel.astro';
19
+
20
+ type Props = Omit<ModalPanelProps, 'size'> & {
21
+ side?: 'start' | 'end';
22
+ /** Width: s 24rem · m 32rem · l 48rem (always leaves a sliver of page visible). */
23
+ size?: 's' | 'm' | 'l';
24
+ };
25
+
26
+ const { side = 'end', size = 's', ...rest } = Astro.props;
27
+ ---
28
+
29
+ <ModalPanel {...rest} size={size} placement={side} kindClass="sinn-drawer">
30
+ <slot name="header" slot="header" />
31
+ <slot />
32
+ <slot name="footer" slot="footer" />
33
+ </ModalPanel>
@@ -0,0 +1,80 @@
1
+ ---
2
+ /**
3
+ * Fieldset — groups related controls under a shared legend: a set of radios or
4
+ * checkboxes, an address, a date split into day/month/year.
5
+ *
6
+ * The legend names the group; description and error are linked with aria-describedby,
7
+ * so they're read when focus enters the group. Group-level errors ("Select a contact
8
+ * method") go here, not on each control; Form's inline validation writes radio errors here.
9
+ *
10
+ * Use `legendSize="l"` when the fieldset is the only question on the page
11
+ * (the legend acts as the page's question heading).
12
+ *
13
+ * @example
14
+ * <Fieldset legend="Your address">
15
+ * <Input name="line1" label="Address line 1" autocomplete="address-line1" />
16
+ * <Input name="city" label="Town or city" autocomplete="address-level2" />
17
+ * </Fieldset>
18
+ */
19
+ import type { HTMLAttributes } from 'astro/types';
20
+ import type { Space } from './types';
21
+ import { idList, uid } from './utils';
22
+ import FormDescription from './FormDescription.astro';
23
+ import FormError from './FormError.astro';
24
+ import './styles/scale.css';
25
+ import './styles/utilities.css';
26
+ import './styles/typography.css';
27
+ import './styles/form.css';
28
+
29
+ type Props = HTMLAttributes<'fieldset'> & {
30
+ legend: string;
31
+ description?: string;
32
+ error?: string;
33
+ /** Visual required marker on the legend. Also set `required` on the controls. */
34
+ required?: boolean;
35
+ /** Keep the legend for screen readers but hide it visually. */
36
+ hideLegend?: boolean;
37
+ legendSize?: 's' | 'm' | 'l';
38
+ orientation?: 'vertical' | 'horizontal';
39
+ /** Space between the grouped controls. */
40
+ gap?: Space;
41
+ };
42
+
43
+ const {
44
+ legend,
45
+ description,
46
+ error,
47
+ required = false,
48
+ hideLegend = false,
49
+ legendSize = 's',
50
+ orientation = 'vertical',
51
+ gap = 'm',
52
+ id = uid('sinn-fieldset'),
53
+ class: className,
54
+ 'aria-describedby': describedBy,
55
+ ...rest
56
+ } = Astro.props;
57
+
58
+ const descId = description ? `${id}-desc` : undefined;
59
+ const errorId = `${id}-error`;
60
+ ---
61
+
62
+ <fieldset
63
+ id={id}
64
+ class:list={['sinn-fieldset', className]}
65
+ data-orientation={orientation}
66
+ aria-describedby={idList(describedBy as string | undefined, descId, error ? errorId : undefined)}
67
+ {...rest}
68
+ >
69
+ <legend
70
+ class:list={['sinn-type', 'sinn-label', 'sinn-fieldset__legend', { 'sinn-sr-only': hideLegend }]}
71
+ data-size={legendSize}
72
+ >
73
+ {legend}{required && <span class="sinn-label__required" aria-hidden="true">*</span>}
74
+ </legend>
75
+ {description && <FormDescription id={descId} class="sinn-fieldset__description">{description}</FormDescription>}
76
+ <div class="sinn-fieldset__items" data-gap={gap}>
77
+ <slot />
78
+ </div>
79
+ <FormError id={errorId} message={error} />
80
+ </fieldset>
@@ -0,0 +1,64 @@
1
+ ---
2
+ /**
3
+ * Flex — general flexbox alignment and distribution.
4
+ * Reach for Stack or Cluster first; use Flex when you need direction, reverse or switching.
5
+ *
6
+ * `switchAt` turns it into a "switcher": a row while the Flex is wider than the
7
+ * measure, a column once narrower. Based on its own width, so it works in any slot.
8
+ *
9
+ * Give a child `data-flex-grow` to make it take the remaining space.
10
+ *
11
+ * @example
12
+ * <Flex justify="between" align="center"><Logo /><Nav /></Flex>
13
+ * <Flex switchAt="l" gap="l"><Media /><div data-flex-grow>…</div></Flex>
14
+ */
15
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
16
+ import type { Align, Justify, Measure, Space } from './types';
17
+ import './styles/utilities.css';
18
+ import './styles/scale.css';
19
+ import './styles/flex.css';
20
+
21
+ type Props = HTMLAttributes<'div'> & {
22
+ as?: HTMLTag;
23
+ direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
24
+ wrap?: boolean;
25
+ gap?: Space;
26
+ /** Gap between wrapped lines. Defaults to `gap`. */
27
+ rowGap?: Space;
28
+ justify?: Justify;
29
+ align?: Align;
30
+ /** Render as `inline-flex`. */
31
+ inline?: boolean;
32
+ /** Stack children when the Flex itself is narrower than this measure. Ignores `direction`. */
33
+ switchAt?: Measure;
34
+ };
35
+
36
+ const {
37
+ as: Tag = 'div',
38
+ direction = 'row',
39
+ wrap = false,
40
+ gap = 's',
41
+ rowGap,
42
+ justify = 'start',
43
+ align = 'stretch',
44
+ inline = false,
45
+ switchAt,
46
+ class: className,
47
+ ...rest
48
+ } = Astro.props;
49
+ ---
50
+
51
+ <Tag
52
+ class:list={['sinn-flex', className]}
53
+ data-direction={switchAt ? undefined : direction}
54
+ data-wrap={wrap ? '' : undefined}
55
+ data-gap={gap}
56
+ data-row-gap={rowGap ?? gap}
57
+ data-justify={justify}
58
+ data-align={align}
59
+ data-inline={inline ? '' : undefined}
60
+ data-switch={switchAt}
61
+ {...rest}
62
+ >
63
+ <slot />
64
+ </Tag>
@@ -0,0 +1,63 @@
1
+ ---
2
+ /**
3
+ * FocusRing — applies the library's keyboard-focus treatment to content you don't control
4
+ * (CMS rich text, embeds, third-party widgets) or adjusts it for a special case.
5
+ *
6
+ * Every library component already has a focus ring, and `@sinnstack/ui/base.css` gives
7
+ * one to everything else on the page. Reach for FocusRing when:
8
+ * - `within`: the ring should wrap a group while anything inside has focus (a search field
9
+ * with its button, a composite control, a custom card).
10
+ * - `tone="contrast"`: the element sits on a photo, gradient or colored fill; a halo in the
11
+ * surface color keeps the ring visible against anything.
12
+ * - `offset` / `weight`: tight corners (`inset`) or a heavier ring.
13
+ *
14
+ * Only `:focus-visible` (keyboard and programmatic focus) shows a ring; mouse clicks don't.
15
+ * Colors and widths come from tokens (--sinn-color-focus, --sinn-focus-width, --sinn-focus-offset),
16
+ * and the focus color is contrast-checked (≥ 3:1) in both themes.
17
+ *
18
+ * @example
19
+ * <FocusRing within radius="full"><form role="search">…<input/><button/>…</form></FocusRing>
20
+ * <FocusRing tone="contrast"><a href="/tour"><img …/></a></FocusRing>
21
+ * <FocusRing><RichText value={cmsBody} /></FocusRing> (RichText from @sinnstack/ui/blocks; never set:html CMS content)
22
+ */
23
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
24
+ import './styles/a11y.css';
25
+
26
+ type Props = HTMLAttributes<'div'> & {
27
+ as?: HTMLTag;
28
+ /** Ring the wrapper while anything inside has keyboard focus. */
29
+ within?: boolean;
30
+ /** For `within`: lay the wrapper out inline-block instead of block. */
31
+ inline?: boolean;
32
+ offset?: 'inset' | 'tight' | 'default' | 'loose';
33
+ weight?: 'default' | 'thick';
34
+ tone?: 'default' | 'contrast';
35
+ /** For `within`: corner radius of the ring. */
36
+ radius?: 's' | 'm' | 'l' | 'full';
37
+ };
38
+
39
+ const {
40
+ as: Tag = 'div',
41
+ within = false,
42
+ inline = false,
43
+ offset = 'default',
44
+ weight = 'default',
45
+ tone = 'default',
46
+ radius = 'm',
47
+ class: className,
48
+ ...rest
49
+ } = Astro.props;
50
+ ---
51
+
52
+ <Tag
53
+ class:list={['sinn-focus-ring', className]}
54
+ data-within={within ? '' : undefined}
55
+ data-display={within && inline ? 'inline' : undefined}
56
+ data-offset={offset === 'default' ? undefined : offset}
57
+ data-weight={weight === 'default' ? undefined : weight}
58
+ data-tone={tone === 'default' ? undefined : tone}
59
+ data-radius={within && radius !== 'm' ? radius : undefined}
60
+ {...rest}
61
+ >
62
+ <slot />
63
+ </Tag>
@@ -0,0 +1,64 @@
1
+ ---
2
+ /**
3
+ * FocusTrap — keeps keyboard focus inside a region while active. Renders <sinn-focus-trap>,
4
+ * a small custom element (no framework), so it works in plain pages and inside Lit islands.
5
+ *
6
+ * Prefer the platform first: Dialog, Drawer and Sheet (native modal <dialog>) and Popover
7
+ * already handle focus. Use FocusTrap for custom, non-dialog widgets: an inline editing
8
+ * panel, a full-screen search built from other parts, a kiosk/checkout step.
9
+ *
10
+ * Every trap needs a way out that keyboard users can find: a visible close or done button,
11
+ * and/or `escapeDeactivates`.
12
+ *
13
+ * Toggle it with the `active` attribute, or element.activate() / element.deactivate():
14
+ *
15
+ * @example
16
+ * <Button id="edit" aria-controls="editor">Edit address</Button>
17
+ * <FocusTrap id="editor" mode="tab" escapeDeactivates initialFocus="input" hidden>…</FocusTrap>
18
+ * <script>
19
+ * import type { SinnFocusTrapElement } from '@sinnstack/ui/primitives/focus-trap';
20
+ * const trap = document.getElementById('editor') as SinnFocusTrapElement;
21
+ * document.getElementById('edit')!.addEventListener('click', () => { trap.hidden = false; trap.activate(); });
22
+ * trap.addEventListener('sinn-focus-trap-deactivate', () => (trap.hidden = true));
23
+ * </script>
24
+ */
25
+ import type { HTMLAttributes } from 'astro/types';
26
+ import FocusTrapScript from './internal/FocusTrapScript.astro';
27
+ import './styles/a11y.css';
28
+
29
+ type Props = HTMLAttributes<'div'> & {
30
+ active?: boolean;
31
+ /** `tab`: wrap Tab inside (page stays readable). `inert`: make everything else inert (modal). */
32
+ mode?: 'tab' | 'inert';
33
+ /** Selector for the element to focus on activate. */
34
+ initialFocus?: string;
35
+ /** Return focus to where it was on deactivate. Default true. */
36
+ returnFocus?: boolean;
37
+ escapeDeactivates?: boolean;
38
+ /** Lay out with display: contents (no box of its own). */
39
+ contents?: boolean;
40
+ };
41
+
42
+ const {
43
+ active = false,
44
+ mode = 'tab',
45
+ initialFocus,
46
+ returnFocus = true,
47
+ escapeDeactivates = false,
48
+ contents = false,
49
+ ...rest
50
+ } = Astro.props;
51
+
52
+ // Custom-element attributes go through a spread: Astro's DOM typings don't know them.
53
+ const attrs = {
54
+ active: active ? '' : undefined,
55
+ mode,
56
+ 'initial-focus': initialFocus,
57
+ 'return-focus': returnFocus ? undefined : 'false',
58
+ 'escape-deactivates': escapeDeactivates ? '' : undefined,
59
+ 'data-display': contents ? 'contents' : undefined,
60
+ };
61
+ ---
62
+
63
+ <sinn-focus-trap {...attrs} {...rest}><slot /></sinn-focus-trap>
64
+ <FocusTrapScript />
@@ -0,0 +1,155 @@
1
+ ---
2
+ /**
3
+ * Footer — site-wide footer: brand and blurb, columns of links, then a bottom row with
4
+ * copyright, legal links and social links. Renders `<footer>` (the page's contentinfo
5
+ * landmark when it isn't inside an article/section) with one labelled `<nav>` for the columns.
6
+ *
7
+ * Slots:
8
+ * - `brand`: logo. Falls back to `name` as text.
9
+ * - default: content under the blurb (address, hours, click-to-call, a "not legal advice" note).
10
+ * - `social`: icon links in the bottom row (IconButton with `href` + `label`).
11
+ * - `bottom`: replaces the default copyright text.
12
+ *
13
+ * The year is taken at build/render time. For static sites, the next deploy after
14
+ * New Year updates it; pass `year` to pin it.
15
+ *
16
+ * @example
17
+ * <Footer name="Sinnstack" description="Web design and development in Fort Worth."
18
+ * sections={[{ title: 'Services', links: [{ href: '/services/web-design', label: 'Website design' }] }]}
19
+ * legal={[{ href: '/privacy', label: 'Privacy' }, { href: '/accessibility', label: 'Accessibility' }]}>
20
+ * <Text size="s">Call <Link href="tel:+18175550100">(817) 555-0100</Link></Text>
21
+ * </Footer>
22
+ */
23
+ import type { HTMLAttributes } from 'astro/types';
24
+ import type { FooterSection, HeadingLevel, NavItem } from './types';
25
+ import { currentFor } from './utils';
26
+ import Container from './Container.astro';
27
+ import './styles/utilities.css';
28
+ import './styles/typography.css';
29
+ import './styles/nav.css';
30
+ import { renameProp } from './lib/deprecate';
31
+
32
+ type Props = HTMLAttributes<'footer'> & {
33
+ /** Organization name: brand fallback and copyright line. */
34
+ name?: string;
35
+ brandHref?: string;
36
+ description?: string;
37
+ sections?: FooterSection[];
38
+ legal?: NavItem[];
39
+ /** aria-label of the link columns' <nav>. */
40
+ label?: string;
41
+ /** aria-label of the legal links list. Translate per site. */
42
+ legalLabel?: string;
43
+ /** Level of the column headings. */
44
+ headingLevel?: HeadingLevel;
45
+ year?: number;
46
+ /** Width of the inner Container (`containerSize` on the blocks too; `size` means s/m/l elsewhere). */
47
+ containerSize?: 'narrow' | 'default' | 'wide' | 'full';
48
+ /** @deprecated Use `containerSize`. */
49
+ size?: 'narrow' | 'default' | 'wide' | 'full';
50
+ };
51
+
52
+ const {
53
+ name,
54
+ brandHref = '/',
55
+ description,
56
+ sections = [],
57
+ legal = [],
58
+ label = 'Footer',
59
+ legalLabel = 'Legal',
60
+ headingLevel = 2,
61
+ year = new Date().getFullYear(),
62
+ containerSize: containerSizeProp,
63
+ size,
64
+ class: className,
65
+ ...rest
66
+ } = Astro.props;
67
+ const containerSize = renameProp('Footer', 'containerSize', containerSizeProp, 'size', size) ?? 'default';
68
+
69
+ const H = `h${headingLevel}` as 'h2';
70
+ const hasBrandSlot = Astro.slots.has('brand');
71
+ const hasAbout = hasBrandSlot || Boolean(name) || Boolean(description) || Astro.slots.has('default');
72
+ const hasSocial = Astro.slots.has('social');
73
+ const hasBottomSlot = Astro.slots.has('bottom');
74
+ const cur = (l: NavItem) => currentFor(l.href, Astro.url, l.match);
75
+ ---
76
+
77
+ <footer class:list={['sinn-footer', className]} {...rest}>
78
+ <Container size={containerSize} class="sinn-footer__inner">
79
+ {
80
+ (hasAbout || sections.length > 0) && (
81
+ <div class="sinn-footer__top">
82
+ {hasAbout && (
83
+ <div class="sinn-footer__about">
84
+ {(hasBrandSlot || name) && (
85
+ <a href={brandHref} class="sinn-footer__brand">
86
+ {hasBrandSlot ? <slot name="brand" /> : name}
87
+ </a>
88
+ )}
89
+ {description && (
90
+ <p class="sinn-type sinn-text" data-size="s" data-tone="muted">
91
+ {description}
92
+ </p>
93
+ )}
94
+ <slot />
95
+ </div>
96
+ )}
97
+ {sections.length > 0 && (
98
+ <nav aria-label={label} class="sinn-footer__nav">
99
+ {sections.map((section) => (
100
+ <div class="sinn-footer__section">
101
+ <H class="sinn-footer__heading">{section.title}</H>
102
+ <ul role="list" class="sinn-footer__links">
103
+ {section.links.map((l) => (
104
+ <li>
105
+ <a
106
+ href={l.href}
107
+ aria-current={cur(l)}
108
+ target={l.newTab ? '_blank' : undefined}
109
+ rel={l.newTab ? 'noopener' : undefined}
110
+ >
111
+ {l.label}
112
+ {l.newTab && <span class="sinn-sr-only"> (opens in a new tab)</span>}
113
+ </a>
114
+ </li>
115
+ ))}
116
+ </ul>
117
+ </div>
118
+ ))}
119
+ </nav>
120
+ )}
121
+ </div>
122
+ )
123
+ }
124
+
125
+ <div class="sinn-footer__bottom">
126
+ {
127
+ hasBottomSlot ? (
128
+ <slot name="bottom" />
129
+ ) : (
130
+ <p class="sinn-footer__copyright">{`© ${year} ${name ?? ''}`.trim()}</p>
131
+ )
132
+ }
133
+ {
134
+ legal.length > 0 && (
135
+ <ul role="list" class="sinn-footer__legal" aria-label={legalLabel}>
136
+ {legal.map((l) => (
137
+ <li>
138
+ <a href={l.href} aria-current={cur(l)}>
139
+ {l.label}
140
+ </a>
141
+ </li>
142
+ ))}
143
+ </ul>
144
+ )
145
+ }
146
+ {
147
+ hasSocial && (
148
+ <div class="sinn-footer__social">
149
+ <slot name="social" />
150
+ </div>
151
+ )
152
+ }
153
+ </div>
154
+ </Container>
155
+ </footer>
@@ -0,0 +1,68 @@
1
+ ---
2
+ /**
3
+ * Form — groups controls, lays them out, and handles submission feedback.
4
+ *
5
+ * Submission works without JavaScript: a normal POST to `action` (a URL or an Astro Action).
6
+ * After a failed server-side check, re-render the page with `errors` (shown as a focused
7
+ * summary at the top) plus each field's own `error` and submitted value.
8
+ *
9
+ * `validate`:
10
+ * - `"native"` (default, 0 KB JS): browser validation bubbles.
11
+ * - `"inline"` (~1.5 KB gzipped, loaded once per page that uses it): messages appear in each field's
12
+ * FormError, on blur and on submit; focus moves to the first problem; double submits are
13
+ * blocked; fires `sinn-form-invalid`. Without JS it falls back to native.
14
+ * - `"none"`: `novalidate`; the server is the only check.
15
+ *
16
+ * @example
17
+ * <Form action={actions.contact} validate="inline" errors={result?.errors}>
18
+ * <Input name="email" type="email" label="Email" autocomplete="email" required
19
+ * messages={{ valueMissing: 'Enter your email address' }} />
20
+ * <Button type="submit">Send</Button>
21
+ * </Form>
22
+ */
23
+ import type { HTMLAttributes } from 'astro/types';
24
+ import type { FormErrorItem, Space } from './types';
25
+ import FormError from './FormError.astro';
26
+ import FormValidationScript from './internal/FormValidationScript.astro';
27
+ import './styles/scale.css';
28
+ import './styles/utilities.css';
29
+ import './styles/form.css';
30
+
31
+ type Props = HTMLAttributes<'form'> & {
32
+ validate?: 'native' | 'inline' | 'none';
33
+ /** Summary of problems after a failed submit; each `field` is the control's id. */
34
+ errors?: FormErrorItem[];
35
+ /** Heading of the error summary. */
36
+ errorTitle?: string;
37
+ /** Message for a failure not tied to a field ("We couldn't send your message"). */
38
+ submitError?: string;
39
+ /** Space between direct children. */
40
+ gap?: Space;
41
+ };
42
+
43
+ const {
44
+ validate = 'native',
45
+ errors = [],
46
+ errorTitle = 'There is a problem',
47
+ submitError,
48
+ gap = 'm',
49
+ method = 'post',
50
+ class: className,
51
+ ...rest
52
+ } = Astro.props;
53
+
54
+ const showSummary = errors.length > 0 || Boolean(submitError);
55
+ ---
56
+
57
+ <form
58
+ class:list={['sinn-form', className]}
59
+ method={method}
60
+ data-gap={gap}
61
+ data-sinn-validate={validate}
62
+ novalidate={validate === 'none'}
63
+ {...rest}
64
+ >
65
+ {showSummary && <FormError variant="form" title={errorTitle} message={submitError} errors={errors} />}
66
+ <slot />
67
+ </form>
68
+ {validate === 'inline' && <FormValidationScript />}
@@ -0,0 +1,26 @@
1
+ ---
2
+ /**
3
+ * FormDescription — instructions for a field ("Use the email on your invoice").
4
+ * FormField, Fieldset and the controls render this for you from their `description` prop;
5
+ * use it directly in custom layouts and reference its `id` from the control's aria-describedby.
6
+ *
7
+ * Keep it short and put it before the control so people read it before typing.
8
+ *
9
+ * @example
10
+ * <FormDescription id="dob-desc">For example, 27 3 1985</FormDescription>
11
+ */
12
+ import type { HTMLAttributes } from 'astro/types';
13
+ import './styles/utilities.css';
14
+ import './styles/typography.css';
15
+ import './styles/form.css';
16
+
17
+ type Props = HTMLAttributes<'p'> & {
18
+ as?: 'p' | 'div' | 'span';
19
+ };
20
+
21
+ const { as: Tag = 'p', class: className, ...rest } = Astro.props;
22
+ ---
23
+
24
+ <Tag class:list={['sinn-type', 'sinn-caption', 'sinn-form-description', className]} data-size="s" {...rest}>
25
+ <slot />
26
+ </Tag>
@@ -0,0 +1,106 @@
1
+ ---
2
+ /**
3
+ * FormError — a validation or submission error.
4
+ *
5
+ * `variant="field"` (default): the message under one control. Rendered `hidden` while
6
+ * empty so Form's inline validation can fill it in later. Prefixed with a visually
7
+ * hidden "Error:" and an icon, so it isn't conveyed by color alone.
8
+ *
9
+ * `variant="form"`: a summary at the top of a form after a failed submit. Lists each
10
+ * problem as a link to its field, uses role="alert", and takes focus on page load
11
+ * (`autofocus`) so keyboard and screen-reader users land on it. Form renders this for
12
+ * you from its `errors` prop.
13
+ *
14
+ * @example
15
+ * <FormError id="email-error">Enter an email address in the correct format</FormError>
16
+ * <FormError variant="form" title="There is a problem" errors={[{ field: 'email', message: 'Enter your email' }]} />
17
+ * <FormError variant="form" title="We couldn't send your message">Please try again in a few minutes.</FormError>
18
+ */
19
+ import type { HTMLAttributes } from 'astro/types';
20
+ import type { FormErrorItem } from './types';
21
+ import { uid } from './utils';
22
+ import './styles/utilities.css';
23
+ import './styles/form.css';
24
+
25
+ type Props = HTMLAttributes<'div'> & {
26
+ variant?: 'field' | 'form';
27
+ /** Message text. Or use the default slot. */
28
+ message?: string;
29
+ /** Form variant: heading. */
30
+ title?: string;
31
+ /** Form variant: list of field problems, each linking to its control. */
32
+ errors?: FormErrorItem[];
33
+ /** Form variant: move focus here on page load. Default true. */
34
+ focus?: boolean;
35
+ /** Screen-reader prefix for field errors. Translate per site. */
36
+ prefix?: string;
37
+ };
38
+
39
+ const {
40
+ variant = 'field',
41
+ message,
42
+ title = 'There is a problem',
43
+ errors = [],
44
+ focus = true,
45
+ prefix = 'Error',
46
+ id,
47
+ class: className,
48
+ ...rest
49
+ } = Astro.props;
50
+
51
+ const hasSlot = Astro.slots.has('default');
52
+ const isEmpty = !message && !hasSlot;
53
+ const titleId = variant === 'form' ? `${id ?? uid('sinn-form-error')}-title` : undefined;
54
+ ---
55
+
56
+ {
57
+ variant === 'field' ? (
58
+ <p id={id} class:list={['sinn-form-error', className]} data-sinn-error hidden={isEmpty} {...rest}>
59
+ <svg class="sinn-form-error__icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
60
+ <circle cx="10" cy="10" r="8.25" fill="none" stroke="currentColor" stroke-width="1.5" />
61
+ <path d="M10 5.75v5" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
62
+ <circle cx="10" cy="13.75" r="1" fill="currentColor" />
63
+ </svg>
64
+ <span>
65
+ <span class="sinn-sr-only">{prefix}: </span>
66
+ <span data-sinn-error-text>
67
+ {message}
68
+ <slot />
69
+ </span>
70
+ </span>
71
+ </p>
72
+ ) : (
73
+ <div
74
+ id={id}
75
+ class:list={['sinn-form-error', className]}
76
+ data-variant="form"
77
+ role="alert"
78
+ aria-labelledby={titleId}
79
+ tabindex={focus ? -1 : undefined}
80
+ autofocus={focus}
81
+ {...rest}
82
+ >
83
+ <p id={titleId} class="sinn-form-error__title">
84
+ <svg class="sinn-form-error__icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
85
+ <circle cx="10" cy="10" r="8.25" fill="none" stroke="currentColor" stroke-width="1.5" />
86
+ <path d="M10 5.75v5" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
87
+ <circle cx="10" cy="13.75" r="1" fill="currentColor" />
88
+ </svg>
89
+ {title}
90
+ </p>
91
+ {(message || hasSlot) && (
92
+ <p class="sinn-form-error__body">
93
+ {message}
94
+ <slot />
95
+ </p>
96
+ )}
97
+ {errors.length > 0 && (
98
+ <ul class="sinn-form-error__list">
99
+ {errors.map((e) => (
100
+ <li>{e.field ? <a href={`#${e.field}`}>{e.message}</a> : e.message}</li>
101
+ ))}
102
+ </ul>
103
+ )}
104
+ </div>
105
+ )
106
+ }