@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,61 @@
1
+ ---
2
+ /**
3
+ * PageTransitions — animated navigation between pages with Astro View Transitions
4
+ * (ClientRouter). Put it in the <head> of your layout.
5
+ *
6
+ * - `animation`: page-level preset for the root: `fade` (default), `slide` (direction-aware:
7
+ * back navigation slides the other way; mirrored in right-to-left pages), `rise`, or `none`.
8
+ * For element-level control use Astro's `transition:animate` with the presets from
9
+ * `@sinnstack/ui/motion/transitions`, and `transition:name` (see `morphName()`) for shared
10
+ * elements, e.g. a card image that morphs into the detail page's hero.
11
+ * - Reduced motion (OS or <html data-motion="reduce">): navigation still works, with no animation.
12
+ * - Keeps `<html>` attributes listed in `persist` across navigations (Astro would otherwise drop
13
+ * client-set ones like the site's motion or theme switch).
14
+ * - After a navigation, focus moves to <main> (without scrolling) so keyboard and screen-reader
15
+ * users start at the new content; Astro announces the new page title.
16
+ * - `fallback`: what browsers without the View Transitions API do (`animate` simulates, `swap`
17
+ * just swaps, `none` does full page loads).
18
+ *
19
+ * Scripts on client-routed sites run once: re-run per-page setup on `astro:page-load`.
20
+ * MotionProvider does this for scenes.
21
+ *
22
+ * @example
23
+ * <head>
24
+ * <PageTransitions animation="slide" />
25
+ * </head>
26
+ */
27
+ import { ClientRouter } from 'astro:transitions';
28
+ import './styles/motion.css';
29
+
30
+ type Props = {
31
+ animation?: 'fade' | 'slide' | 'rise' | 'none';
32
+ fallback?: 'animate' | 'swap' | 'none';
33
+ /** <html> attributes to carry over between pages. */
34
+ persist?: string[];
35
+ /** Move focus to the main landmark after navigating. */
36
+ focusMain?: boolean;
37
+ focusTarget?: string;
38
+ };
39
+
40
+ const {
41
+ animation = 'fade',
42
+ fallback = 'animate',
43
+ persist = ['data-motion', 'data-theme'],
44
+ focusMain = true,
45
+ focusTarget = 'main, [role="main"], #main',
46
+ } = Astro.props;
47
+
48
+ const metaAttrs = {
49
+ 'data-animation': animation,
50
+ 'data-persist': persist.join(','),
51
+ 'data-focus': focusMain ? 'true' : 'false',
52
+ 'data-focus-target': focusTarget,
53
+ };
54
+ ---
55
+
56
+ <meta name="sinn-page-transitions" content="" {...metaAttrs} />
57
+ <ClientRouter fallback={fallback} />
58
+ <script>
59
+ import { setupPageTransitions } from './runtime/page-transitions';
60
+ setupPageTransitions();
61
+ </script>
@@ -0,0 +1,44 @@
1
+ ---
2
+ /**
3
+ * Parallax — layers that move at different speeds while the section scrolls past, for depth.
4
+ * CSS scroll-driven animations (a view timeline on the section); no JavaScript.
5
+ *
6
+ * - Put background layers in ParallaxLayer children (with a `speed`) and the readable
7
+ * foreground in the `content` slot. Content stays in normal flow and never moves, so text
8
+ * is always legible and selectable.
9
+ * - Layers are oversized by exactly how far they can travel, so edges never show.
10
+ * - Reduced motion (OS or site override): layers stay still. Unsupported browsers: still too.
11
+ * - Layers are decorative (aria-hidden) by default; put meaningful images in `content`.
12
+ *
13
+ * @example
14
+ * <Parallax height="l" travel="m">
15
+ * <ParallaxLayer speed={0.5}><Image src={sky} alt="" layout="full" /></ParallaxLayer>
16
+ * <ParallaxLayer speed={0.25} z={1}><Image src={hills} alt="" layout="full" /></ParallaxLayer>
17
+ * <Container slot="content"><Heading level={2}>Built in Fort Worth, shipped everywhere</Heading></Container>
18
+ * </Parallax>
19
+ */
20
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
21
+ import './styles/motion.css';
22
+
23
+ type Props = HTMLAttributes<'section'> & {
24
+ as?: HTMLTag;
25
+ /** Minimum height: s 40svh · m 60svh · l 80svh · screen 100svh. */
26
+ height?: 's' | 'm' | 'l' | 'screen';
27
+ /** How far layers travel at speed 1: s 10svh · m 20svh · l 35svh. */
28
+ travel?: 's' | 'm' | 'l';
29
+ radius?: 'none' | 'l';
30
+ };
31
+
32
+ const { as: Tag = 'section', height = 'm', travel = 'm', radius = 'none', class: className, ...rest } = Astro.props;
33
+ ---
34
+
35
+ <Tag
36
+ class:list={['sinn-parallax', className]}
37
+ data-height={height}
38
+ data-travel={travel === 'm' ? undefined : travel}
39
+ data-radius={radius === 'none' ? undefined : radius}
40
+ {...rest}
41
+ >
42
+ <slot />
43
+ {Astro.slots.has('content') && <div class="sinn-parallax__content"><slot name="content" /></div>}
44
+ </Tag>
@@ -0,0 +1,31 @@
1
+ ---
2
+ /**
3
+ * ParallaxLayer — one moving layer inside Parallax.
4
+ *
5
+ * `speed` is depth relative to the page: 0 scrolls with the page, 0.5 drifts at half speed
6
+ * (far background), 1 appears fixed; negative values move faster than the page (foreground).
7
+ * `z` stacks layers (content sits above all of them).
8
+ */
9
+ import type { HTMLAttributes } from 'astro/types';
10
+ import './styles/motion.css';
11
+
12
+ type Props = HTMLAttributes<'div'> & {
13
+ speed?: -0.5 | -0.25 | 0 | 0.25 | 0.5 | 0.75 | 1;
14
+ z?: 0 | 1 | 2 | 3 | 4 | 5;
15
+ /** Hide from assistive tech (default). Set false if the layer carries meaning. */
16
+ decorative?: boolean;
17
+ };
18
+
19
+ const { speed = 0.5, z = 0, decorative = true, class: className, ...rest } = Astro.props;
20
+ // The z index is a small fixed set, mapped in CSS (no inline styles).
21
+ ---
22
+
23
+ <div
24
+ class:list={['sinn-parallax__layer', className]}
25
+ data-speed={String(speed)}
26
+ data-z={z || undefined}
27
+ aria-hidden={decorative ? 'true' : undefined}
28
+ {...rest}
29
+ >
30
+ <slot />
31
+ </div>
@@ -0,0 +1,59 @@
1
+ ---
2
+ /**
3
+ * RevealOnScroll — fades or slides content in as it enters the viewport, using CSS
4
+ * scroll-driven animations (`animation-timeline: view()`). No JavaScript.
5
+ *
6
+ * - The animation is tied to scroll position, so it plays as the element enters and settles
7
+ * when it's ~30% into the viewport. Nothing runs on a timer, so there's no flash at load:
8
+ * content well inside the first screen is already settled; anything in the bottom ~30% of
9
+ * the first screen starts partly revealed and finishes as you scroll.
10
+ * - Progressive enhancement: browsers without scroll-driven animations just show the content.
11
+ * Content is never hidden waiting for a script.
12
+ * - Reduced motion (OS or <html data-motion="reduce">): no movement, no fade.
13
+ * - `stagger`: animates direct children one after another (up to 12 steps).
14
+ *
15
+ * Use it sparingly: on section intros, card grids, feature lists. Not on body text, and
16
+ * never on content people need to read immediately (prices, errors, form fields).
17
+ *
18
+ * @example
19
+ * <RevealOnScroll effect="rise"><Heading level={2}>Websites that ship fast</Heading></RevealOnScroll>
20
+ * <RevealOnScroll as="ul" effect="rise" stagger class="sinn-grid" data-min="s">…cards…</RevealOnScroll>
21
+ */
22
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
23
+ import './styles/motion.css';
24
+
25
+ type Props = HTMLAttributes<'div'> & {
26
+ as?: HTMLTag;
27
+ effect?: 'fade' | 'rise' | 'fall' | 'slide-start' | 'slide-end' | 'scale' | 'blur';
28
+ distance?: 's' | 'm' | 'l';
29
+ /** When it plays: `early` (as it enters), `default` (done ~30% in), `late` (around mid-screen). */
30
+ range?: 'early' | 'default' | 'late';
31
+ /** Animate direct children in sequence instead of the wrapper as a whole. */
32
+ stagger?: boolean;
33
+ /** Also fade (default true). Set false for movement only. */
34
+ fade?: boolean;
35
+ };
36
+
37
+ const {
38
+ as: Tag = 'div',
39
+ effect = 'rise',
40
+ distance = 'm',
41
+ range = 'default',
42
+ stagger = false,
43
+ fade = true,
44
+ class: className,
45
+ ...rest
46
+ } = Astro.props;
47
+ ---
48
+
49
+ <Tag
50
+ class:list={['sinn-reveal', className]}
51
+ data-effect={effect}
52
+ data-distance={distance === 'm' ? undefined : distance}
53
+ data-range={range === 'default' ? undefined : range}
54
+ data-stagger={stagger ? '' : undefined}
55
+ data-fade={fade ? undefined : 'false'}
56
+ {...rest}
57
+ >
58
+ <slot />
59
+ </Tag>
@@ -0,0 +1,38 @@
1
+ ---
2
+ /**
3
+ * SceneRegistry — maps scene names to choreography modules and loads each one only when its
4
+ * section nears the viewport. Requires the integration (it provides your src/scenes files)
5
+ * and MotionProvider. Put it once in your layout, after MotionProvider.
6
+ *
7
+ * A scene module (src/scenes/project-journey.ts):
8
+ *
9
+ * import { defineScene } from '@sinnstack/ui/motion/scenes';
10
+ * export default defineScene(({ timeline, q, params }) => {
11
+ * timeline.from(q('.step'), { autoAlpha: 0, y: 60, stagger: 0.3 })
12
+ * .from(q('.line'), { scaleY: 0, transformOrigin: 'top' }, 0);
13
+ * });
14
+ * export const reducedState = 'end';
15
+ *
16
+ * Without the integration, don't use this component (its script imports the integration's
17
+ * virtual module); register scenes yourself in a client script instead:
18
+ * import { registerScenes, startScenes } from '@sinnstack/ui/motion/scenes';
19
+ * registerScenes(import.meta.glob('../scenes/*.ts'));
20
+ * startScenes();
21
+ */
22
+ type Props = {
23
+ /** How far ahead of the viewport scenes start loading (IntersectionObserver rootMargin). */
24
+ rootMargin?: string;
25
+ };
26
+
27
+ const { rootMargin = '50% 0px' } = Astro.props;
28
+ const metaAttrs = { 'data-root-margin': rootMargin };
29
+ ---
30
+
31
+ <meta name="sinn-scenes" content="" {...metaAttrs} />
32
+ <script>
33
+ import scenes from 'virtual:sinn-motion/scenes';
34
+ import { registerScenes, startScenes } from './runtime/scenes';
35
+ const meta = document.querySelector<HTMLMetaElement>('meta[name="sinn-scenes"]');
36
+ registerScenes(scenes);
37
+ startScenes({ rootMargin: meta?.dataset.rootMargin });
38
+ </script>
@@ -0,0 +1,81 @@
1
+ ---
2
+ /**
3
+ * ScrollScene — a section whose animation is choreographed by a named scene module (GSAP),
4
+ * scrubbed by scroll. Requires MotionProvider and SceneRegistry on the page.
5
+ *
6
+ * - `scene` names a module in src/scenes/ (via the integration) or registered with registerScenes().
7
+ * It's loaded only when the section nears the viewport.
8
+ * - `pin`: the stage stays on screen while the section scrolls `length`% of a viewport past it.
9
+ * Pinning is CSS (position: sticky) and the scroll length is reserved up front, so loading
10
+ * the scene never shifts the page, and without JS the stage still pins.
11
+ * - `mode`: `scrub` (timeline follows the scroll, both ways) or `play` (plays once on entry).
12
+ * - `params`: small string values passed to the module (`ctx.params`), rendered as data-param-*.
13
+ * - Author the markup in its *final*, readable state and animate *from* hidden in the module.
14
+ * That's what no-JS, reduced-motion and slow-network users see.
15
+ * - Reduced motion: no pin length, no scrubbing; the module's `reducedState` decides what's shown
16
+ * (default: the timeline's end state).
17
+ *
18
+ * @example
19
+ * <ScrollScene scene="project-journey" pin length={300} align="center" params={{ steps: '4' }}>
20
+ * <ol class="journey">…</ol>
21
+ * </ScrollScene>
22
+ */
23
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
24
+ import './styles/motion.css';
25
+
26
+ type Props = HTMLAttributes<'section'> & {
27
+ as?: HTMLTag;
28
+ scene: string;
29
+ pin?: boolean;
30
+ /** Extra scroll distance while pinned, in % of the viewport height. */
31
+ length?: 50 | 100 | 150 | 200 | 250 | 300 | 400 | 500;
32
+ mode?: 'scrub' | 'play';
33
+ /** Scrub smoothing in seconds (true = locked to the scrollbar). */
34
+ scrub?: true | 0.25 | 0.5 | 1 | 2;
35
+ /** ScrollTrigger start/end overrides, e.g. "top 60%". */
36
+ start?: string;
37
+ end?: string;
38
+ params?: Record<string, string | number | boolean>;
39
+ align?: 'stretch' | 'center';
40
+ /** Show ScrollTrigger markers (development). */
41
+ markers?: boolean;
42
+ };
43
+
44
+ const {
45
+ as: Tag = 'section',
46
+ scene,
47
+ pin = false,
48
+ length = 200,
49
+ mode = 'scrub',
50
+ scrub = true,
51
+ start,
52
+ end,
53
+ params = {},
54
+ align = 'stretch',
55
+ markers = false,
56
+ class: className,
57
+ ...rest
58
+ } = Astro.props;
59
+
60
+ const toKebab = (s: string) => s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/[^a-z0-9-]/g, '-');
61
+ const paramAttrs = Object.fromEntries(Object.entries(params).map(([k, v]) => [`data-param-${toKebab(k)}`, String(v)]));
62
+ ---
63
+
64
+ <Tag
65
+ class:list={['sinn-scene', className]}
66
+ data-sinn-scene={scene}
67
+ data-scene-mode={mode}
68
+ data-scene-pin={pin ? '' : undefined}
69
+ data-scene-length={pin ? String(length) : undefined}
70
+ data-scene-scrub={mode === 'scrub' ? String(scrub) : undefined}
71
+ data-scene-start={start}
72
+ data-scene-end={end}
73
+ data-scene-markers={markers ? '' : undefined}
74
+ data-scene-align={align === 'center' ? 'center' : undefined}
75
+ {...paramAttrs}
76
+ {...rest}
77
+ >
78
+ <div class="sinn-scene__stage" data-scene-stage>
79
+ <slot />
80
+ </div>
81
+ </Tag>
@@ -0,0 +1,12 @@
1
+ // @sinnstack/ui/motion — optional motion group.
2
+ export { default as PageTransitions } from './PageTransitions.astro';
3
+ export { default as RevealOnScroll } from './RevealOnScroll.astro';
4
+ export { default as Parallax } from './Parallax.astro';
5
+ export { default as ParallaxLayer } from './ParallaxLayer.astro';
6
+ export { default as Marquee } from './Marquee.astro';
7
+ export { default as MotionProvider } from './MotionProvider.astro';
8
+ export { default as SceneRegistry } from './SceneRegistry.astro';
9
+ export { default as ScrollScene } from './ScrollScene.astro';
10
+
11
+ export type * from './runtime/types';
12
+ export { fade, slide, rise, morphName } from './transitions';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Astro integration for @sinnstack/ui/motion. Exposes your scene modules to SceneRegistry
3
+ * as the virtual module `virtual:sinn-motion/scenes`, so each scene is its own lazily
4
+ * loaded chunk and nothing has to be registered by hand.
5
+ *
6
+ * // astro.config.mjs
7
+ * import sinnMotion from '@sinnstack/ui/motion/integration';
8
+ * export default defineConfig({ integrations: [sinnMotion({ scenes: 'src/scenes' })] });
9
+ *
10
+ * A scene's name is its file name: src/scenes/project-journey.ts → scene="project-journey".
11
+ */
12
+ import type { AstroIntegration } from 'astro';
13
+
14
+ export interface SinnMotionOptions {
15
+ /** Folder (relative to the project root) holding scene modules. Default: src/scenes */
16
+ scenes?: string;
17
+ }
18
+
19
+ const VIRTUAL = 'virtual:sinn-motion/scenes';
20
+ const RESOLVED = `\0${VIRTUAL}`;
21
+
22
+ export default function sinnMotion(options: SinnMotionOptions = {}): AstroIntegration {
23
+ const dir = (options.scenes ?? 'src/scenes').replace(/^\.?\/+/, '').replace(/\/+$/, '');
24
+ return {
25
+ name: '@sinnstack/ui/motion',
26
+ hooks: {
27
+ 'astro:config:setup': ({ updateConfig }) => {
28
+ updateConfig({
29
+ vite: {
30
+ plugins: [
31
+ {
32
+ name: 'sinn-motion-scenes',
33
+ resolveId(id: string) {
34
+ return id === VIRTUAL ? RESOLVED : undefined;
35
+ },
36
+ load(id: string) {
37
+ if (id !== RESOLVED) return undefined;
38
+ // Root-relative glob: one lazy chunk per scene file.
39
+ return `export default import.meta.glob(['/${dir}/*.{ts,js,mjs}', '!/${dir}/*.d.ts', '!/${dir}/_*']);`;
40
+ },
41
+ },
42
+ ],
43
+ },
44
+ });
45
+ },
46
+ },
47
+ };
48
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Client side of PageTransitions (Astro ClientRouter lifecycle):
3
+ * - keeps chosen <html> attributes (data-motion, data-theme, data-page-transition, …) across
4
+ * navigations: Astro replaces <html> attributes with the new page's on every swap;
5
+ * - after a client-side navigation, moves focus to the main landmark (without scrolling) so
6
+ * keyboard and screen-reader users start at the new content, unless the URL targets an anchor.
7
+ *
8
+ * Reads its settings from <meta name="sinn-page-transitions"> written by the component.
9
+ */
10
+
11
+ interface Settings {
12
+ animation: string;
13
+ persist: string[];
14
+ focus: boolean;
15
+ focusTarget: string;
16
+ }
17
+
18
+ function read(doc: Document = document): Settings {
19
+ const meta = doc.querySelector<HTMLMetaElement>('meta[name="sinn-page-transitions"]');
20
+ const d = meta?.dataset ?? {};
21
+ return {
22
+ animation: d.animation ?? 'fade',
23
+ persist: (d.persist ?? 'data-motion,data-theme').split(',').map((s) => s.trim()).filter(Boolean),
24
+ focus: d.focus !== 'false',
25
+ focusTarget: d.focusTarget ?? 'main, [role="main"], #main',
26
+ };
27
+ }
28
+
29
+ export function setupPageTransitions(): void {
30
+ if (typeof window === 'undefined') return;
31
+ const w = window as unknown as Record<string, boolean>;
32
+ if (w.__sinnPageTransitions) return;
33
+ w.__sinnPageTransitions = true;
34
+
35
+ const root = document.documentElement;
36
+ root.dataset.pageTransition = read().animation;
37
+ let navigated = false;
38
+
39
+ document.addEventListener('astro:before-swap', (event) => {
40
+ const e = event as Event & { newDocument?: Document };
41
+ const next = e.newDocument?.documentElement;
42
+ if (!next) return;
43
+ const settings = read();
44
+ for (const attr of settings.persist) {
45
+ const value = root.getAttribute(attr);
46
+ if (value !== null && !next.hasAttribute(attr)) next.setAttribute(attr, value);
47
+ }
48
+ // The incoming page decides its own preset; a page without PageTransitions inherits ours.
49
+ const hasOwn = e.newDocument?.querySelector('meta[name="sinn-page-transitions"]');
50
+ const preset = hasOwn ? read(e.newDocument).animation : root.dataset.pageTransition;
51
+ if (preset) next.dataset.pageTransition = preset;
52
+ });
53
+
54
+ document.addEventListener('astro:after-swap', () => {
55
+ navigated = true;
56
+ });
57
+
58
+ document.addEventListener('astro:page-load', () => {
59
+ if (!navigated) return;
60
+ navigated = false;
61
+ const settings = read();
62
+ if (!settings.focus || location.hash) return;
63
+ const target = document.querySelector<HTMLElement>(settings.focusTarget);
64
+ if (!target) return;
65
+ if (!target.hasAttribute('tabindex')) target.setAttribute('tabindex', '-1');
66
+ target.focus({ preventScroll: true });
67
+ });
68
+ }
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Motion runtime: loads GSAP, ScrollTrigger and requested plugins once per page lifetime,
3
+ * runs Lenis smooth scrolling in sync with ScrollTrigger, and keeps everything correct across
4
+ * Astro client-side navigations and reduced-motion changes.
5
+ *
6
+ * Config comes from <meta name="sinn-motion"> written by MotionProvider. Everything is lazy:
7
+ * nothing is downloaded until a scene needs it, unless smooth scrolling is on (then it loads
8
+ * at idle, because scrolling should feel the same from the first wheel tick).
9
+ *
10
+ * SSR-safe: no DOM access at import time.
11
+ */
12
+ import { onReducedMotionChange, prefersReducedMotion } from '../../primitives/lib/motion';
13
+ import type { GsapLike, LenisLike, Motion, PluginName, ScrollTriggerLike } from './types';
14
+
15
+ export interface MotionConfig {
16
+ smooth: boolean;
17
+ /** Lenis lerp (0–1, lower = smoother/slower). */
18
+ lerp: number;
19
+ plugins: PluginName[];
20
+ /** Load at idle even without smooth scrolling or scenes (e.g. for your own scripts). */
21
+ eager: boolean;
22
+ }
23
+
24
+ export function readConfig(doc: Document = document): MotionConfig {
25
+ const d = doc.querySelector<HTMLMetaElement>('meta[name="sinn-motion"]')?.dataset ?? {};
26
+ return {
27
+ smooth: d.smooth === 'true',
28
+ lerp: Number(d.lerp) > 0 ? Number(d.lerp) : 0.1,
29
+ plugins: (d.plugins ?? '').split(',').map((s) => s.trim()).filter(Boolean) as PluginName[],
30
+ eager: d.eager === 'true',
31
+ };
32
+ }
33
+
34
+ // Static importers, so bundlers can code-split each plugin and load only what's requested.
35
+ const PLUGINS: Record<PluginName, () => Promise<unknown>> = {
36
+ ScrollTrigger: () => import('gsap/ScrollTrigger').then((m) => m.ScrollTrigger),
37
+ ScrollToPlugin: () => import('gsap/ScrollToPlugin').then((m) => m.ScrollToPlugin),
38
+ SplitText: () => import('gsap/SplitText').then((m) => m.SplitText),
39
+ Flip: () => import('gsap/Flip').then((m) => m.Flip),
40
+ Observer: () => import('gsap/Observer').then((m) => m.Observer),
41
+ Draggable: () => import('gsap/Draggable').then((m) => m.Draggable),
42
+ DrawSVGPlugin: () => import('gsap/DrawSVGPlugin').then((m) => m.DrawSVGPlugin),
43
+ MorphSVGPlugin: () => import('gsap/MorphSVGPlugin').then((m) => m.MorphSVGPlugin),
44
+ MotionPathPlugin: () => import('gsap/MotionPathPlugin').then((m) => m.MotionPathPlugin),
45
+ TextPlugin: () => import('gsap/TextPlugin').then((m) => m.TextPlugin),
46
+ CustomEase: () => import('gsap/CustomEase').then((m) => m.CustomEase),
47
+ };
48
+
49
+ type Listener = () => void;
50
+ const swapListeners = new Set<Listener>();
51
+ const loadListeners = new Set<Listener>();
52
+ const preferenceListeners = new Set<(reduced: boolean) => void>();
53
+
54
+ let motion: Promise<Motion> | null = null;
55
+ let current: Motion | null = null;
56
+ let config: MotionConfig | null = null;
57
+ let rafFn: ((time: number) => void) | null = null;
58
+ let lenisStarting: Promise<void> | null = null;
59
+
60
+ function startLenis(m: Motion): Promise<void> {
61
+ lenisStarting ??= createLenis(m).finally(() => (lenisStarting = null));
62
+ return lenisStarting;
63
+ }
64
+
65
+ async function createLenis(m: Motion): Promise<void> {
66
+ if (m.lenis || !config?.smooth || prefersReducedMotion()) return;
67
+ const { default: Lenis } = await import('lenis');
68
+ // The preference may have flipped while Lenis was downloading.
69
+ if (m.lenis || prefersReducedMotion()) return;
70
+ const lenis = new Lenis({ lerp: config.lerp, anchors: true, autoRaf: false }) as unknown as LenisLike;
71
+ const ST = m.ScrollTrigger;
72
+ lenis.on('scroll', () => ST.update());
73
+ rafFn = (time: number) => lenis.raf(time * 1000);
74
+ m.gsap.ticker.add(rafFn);
75
+ m.gsap.ticker.lagSmoothing(0);
76
+ m.lenis = lenis;
77
+ }
78
+
79
+ function stopLenis(m: Motion): void {
80
+ if (!m.lenis) return;
81
+ if (rafFn) m.gsap.ticker.remove(rafFn);
82
+ rafFn = null;
83
+ m.lenis.destroy();
84
+ m.lenis = null;
85
+ }
86
+
87
+ /**
88
+ * The shared GSAP setup. First call downloads GSAP, ScrollTrigger, the configured plugins and
89
+ * (if enabled) Lenis; later calls return the same instance.
90
+ */
91
+ export function getMotion<G = GsapLike, ST = ScrollTriggerLike>(): Promise<Motion<G, ST>> {
92
+ if (typeof window === 'undefined') return Promise.reject(new Error('getMotion() is browser-only'));
93
+ motion ??= (async () => {
94
+ config ??= readConfig();
95
+ const [{ gsap }, ScrollTrigger] = await Promise.all([
96
+ import('gsap') as unknown as Promise<{ gsap: GsapLike }>, // structural: real GSAP satisfies GsapLike
97
+ PLUGINS.ScrollTrigger() as Promise<ScrollTriggerLike>,
98
+ ]);
99
+ const extra = config.plugins.filter((p) => p !== 'ScrollTrigger' && p in PLUGINS);
100
+ const loaded = await Promise.all(extra.map((p) => PLUGINS[p]()));
101
+ gsap.registerPlugin(ScrollTrigger, ...loaded);
102
+ const plugins: Motion['plugins'] = { ScrollTrigger };
103
+ extra.forEach((name, i) => (plugins[name] = loaded[i]));
104
+
105
+ const m: Motion = { gsap, ScrollTrigger, plugins, lenis: null };
106
+ current = m;
107
+ await startLenis(m);
108
+ return m;
109
+ })();
110
+ return motion as Promise<Motion<G, ST>>;
111
+ }
112
+
113
+ /** The instance if it's already loaded (no download). */
114
+ export function peekMotion(): Motion | null {
115
+ return current;
116
+ }
117
+
118
+ /** Run before Astro swaps the page (revert animations you created). Returns an unsubscribe. */
119
+ export function onBeforeSwap(fn: Listener): () => void {
120
+ swapListeners.add(fn);
121
+ return () => swapListeners.delete(fn);
122
+ }
123
+ /** Run after every page load, including the first (set animations up). Returns an unsubscribe. */
124
+ export function onPageLoad(fn: Listener): () => void {
125
+ loadListeners.add(fn);
126
+ return () => loadListeners.delete(fn);
127
+ }
128
+ /** Run when reduced motion turns on/off (OS or site switch), after Lenis is updated. */
129
+ export function onPreferenceChange(fn: (reduced: boolean) => void): () => void {
130
+ preferenceListeners.add(fn);
131
+ return () => preferenceListeners.delete(fn);
132
+ }
133
+
134
+ function idle(fn: () => void) {
135
+ const ric = (window as Window & { requestIdleCallback?: (cb: () => void, o?: { timeout: number }) => void }).requestIdleCallback;
136
+ if (ric) ric(fn, { timeout: 2000 });
137
+ else setTimeout(fn, 200);
138
+ }
139
+
140
+ /** Installs lifecycle handling. Called by MotionProvider; safe to call more than once. */
141
+ export function startMotionRuntime(): void {
142
+ if (typeof window === 'undefined') return;
143
+ const w = window as unknown as Record<string, boolean>;
144
+ if (w.__sinnMotionRuntime) return;
145
+ w.__sinnMotionRuntime = true;
146
+
147
+ config = readConfig();
148
+ if (config.smooth || config.eager) idle(() => void getMotion());
149
+
150
+ // Stop Lenis during the swap so it can't animate the incoming page toward the old target.
151
+ document.addEventListener('astro:before-swap', () => {
152
+ for (const fn of swapListeners) fn();
153
+ current?.lenis?.stop();
154
+ });
155
+
156
+ // Astro replaces <html>'s attributes with the new page's on swap, which wipes Lenis's
157
+ // classes (lenis, lenis-smooth). Restarting re-applies them, before the new view is captured.
158
+ document.addEventListener('astro:after-swap', () => {
159
+ current?.lenis?.resize();
160
+ current?.lenis?.start();
161
+ });
162
+
163
+ // Fires on the first load too; on later loads, resync scroll measurements with the new DOM.
164
+ document.addEventListener('astro:page-load', () => {
165
+ if (current) {
166
+ current.lenis?.scrollTo(window.scrollY, { immediate: true, force: true });
167
+ current.ScrollTrigger.refresh();
168
+ }
169
+ for (const fn of loadListeners) fn();
170
+ });
171
+
172
+ onReducedMotionChange(async (reduced) => {
173
+ if (current) {
174
+ if (reduced) stopLenis(current);
175
+ else await startLenis(current);
176
+ }
177
+ for (const fn of preferenceListeners) fn(reduced);
178
+ current?.ScrollTrigger.refresh();
179
+ });
180
+ }