@sinnstack/ui 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +373 -0
- package/README.md +186 -2
- package/docs/blocks.md +364 -0
- package/docs/data.md +128 -0
- package/docs/motion.md +166 -0
- package/docs/primitives.md +510 -0
- package/docs/seo.md +187 -0
- package/docs/tokens.md +122 -0
- package/package.json +141 -3
- package/scripts/check-contrast.mjs +180 -0
- package/src/blocks/BlockRenderer.astro +54 -0
- package/src/blocks/CTABanner.astro +121 -0
- package/src/blocks/CTAPair.astro +110 -0
- package/src/blocks/CardGrid.astro +167 -0
- package/src/blocks/ConsentEmbed.astro +125 -0
- package/src/blocks/ConsentManager.astro +147 -0
- package/src/blocks/ConsentScript.astro +47 -0
- package/src/blocks/ContactCard.astro +164 -0
- package/src/blocks/ContactForm.astro +224 -0
- package/src/blocks/ErrorPage.astro +242 -0
- package/src/blocks/FAQ.astro +135 -0
- package/src/blocks/FeatureGrid.astro +148 -0
- package/src/blocks/Hero.astro +171 -0
- package/src/blocks/HeroCarousel.astro +220 -0
- package/src/blocks/HighlightCards.astro +107 -0
- package/src/blocks/LocationHours.astro +311 -0
- package/src/blocks/LogoCloud.astro +135 -0
- package/src/blocks/MaintenancePage.astro +168 -0
- package/src/blocks/MediaText.astro +177 -0
- package/src/blocks/PageHeader.astro +126 -0
- package/src/blocks/ProseSection.astro +98 -0
- package/src/blocks/Reviews.astro +194 -0
- package/src/blocks/RichText.astro +57 -0
- package/src/blocks/StatsBand.astro +117 -0
- package/src/blocks/Steps.astro +141 -0
- package/src/blocks/Testimonials.astro +144 -0
- package/src/blocks/Topbar.astro +158 -0
- package/src/blocks/cms/card-grid.ts +80 -0
- package/src/blocks/cms/consent.ts +45 -0
- package/src/blocks/cms/contact-card.ts +88 -0
- package/src/blocks/cms/contact-form.ts +55 -0
- package/src/blocks/cms/cta-banner.ts +48 -0
- package/src/blocks/cms/cta-pair.ts +63 -0
- package/src/blocks/cms/data-base.ts +7 -0
- package/src/blocks/cms/data.ts +257 -0
- package/src/blocks/cms/faq.ts +70 -0
- package/src/blocks/cms/feature-grid.ts +80 -0
- package/src/blocks/cms/fixtures.ts +599 -0
- package/src/blocks/cms/hero-carousel.ts +80 -0
- package/src/blocks/cms/hero.ts +77 -0
- package/src/blocks/cms/highlight-cards.ts +76 -0
- package/src/blocks/cms/images.ts +38 -0
- package/src/blocks/cms/index.ts +87 -0
- package/src/blocks/cms/location-hours.ts +149 -0
- package/src/blocks/cms/logo-cloud.ts +62 -0
- package/src/blocks/cms/media-text.ts +44 -0
- package/src/blocks/cms/page-header.ts +49 -0
- package/src/blocks/cms/pages.ts +81 -0
- package/src/blocks/cms/prose-section.ts +45 -0
- package/src/blocks/cms/reviews.ts +101 -0
- package/src/blocks/cms/shared.ts +115 -0
- package/src/blocks/cms/stats-band.ts +61 -0
- package/src/blocks/cms/steps.ts +67 -0
- package/src/blocks/cms/testimonials.ts +80 -0
- package/src/blocks/cms/topbar.ts +64 -0
- package/src/blocks/cms/types.ts +63 -0
- package/src/blocks/consent.ts +14 -0
- package/src/blocks/icons.ts +47 -0
- package/src/blocks/index.ts +42 -0
- package/src/blocks/internal/Actions.astro +29 -0
- package/src/blocks/internal/BlockHeader.astro +45 -0
- package/src/blocks/internal/BlockShell.astro +58 -0
- package/src/blocks/internal/CarouselScript.astro +7 -0
- package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
- package/src/blocks/internal/ConsentManagerScript.astro +7 -0
- package/src/blocks/internal/HoursScript.astro +7 -0
- package/src/blocks/internal/Placeholder.astro +13 -0
- package/src/blocks/internal/RichTextNode.astro +133 -0
- package/src/blocks/internal/StandaloneDocument.astro +53 -0
- package/src/blocks/internal/tina.ts +19 -0
- package/src/blocks/internal/util.ts +23 -0
- package/src/blocks/lib/consent.ts +96 -0
- package/src/blocks/lib/contact.ts +86 -0
- package/src/blocks/lib/error-pages.ts +119 -0
- package/src/blocks/lib/faq.ts +37 -0
- package/src/blocks/lib/hours.ts +201 -0
- package/src/blocks/lib/maintenance.ts +129 -0
- package/src/blocks/lib/reviews.ts +22 -0
- package/src/blocks/lib/rich-text.ts +143 -0
- package/src/blocks/lib/slug.ts +12 -0
- package/src/blocks/registry.ts +79 -0
- package/src/blocks/scripts/carousel.ts +218 -0
- package/src/blocks/scripts/consent-embed.ts +105 -0
- package/src/blocks/scripts/consent-manager.ts +112 -0
- package/src/blocks/scripts/consent-store.ts +86 -0
- package/src/blocks/scripts/error-page.ts +71 -0
- package/src/blocks/scripts/hours.ts +106 -0
- package/src/blocks/scripts/maintenance.ts +109 -0
- package/src/blocks/styles/blocks.css +1320 -0
- package/src/blocks/styles/consent.css +102 -0
- package/src/blocks/styles/faq.css +28 -0
- package/src/blocks/styles/location.css +92 -0
- package/src/blocks/styles/prose-section.css +13 -0
- package/src/blocks/styles/quotes.css +123 -0
- package/src/blocks/styles/rich-text.css +14 -0
- package/src/blocks/types.ts +283 -0
- package/src/data/ChartAxis.astro +19 -0
- package/src/data/ChartContainer.astro +151 -0
- package/src/data/ChartLegend.astro +25 -0
- package/src/data/ChartSeries.astro +14 -0
- package/src/data/ChartTable.astro +17 -0
- package/src/data/ChartTooltip.astro +20 -0
- package/src/data/Sparkline.astro +55 -0
- package/src/data/cms.ts +190 -0
- package/src/data/index.ts +10 -0
- package/src/data/lib/chart.ts +450 -0
- package/src/data/lib/render.ts +219 -0
- package/src/data/lib/scale.ts +107 -0
- package/src/data/lib/sparkline.ts +117 -0
- package/src/data/scripts/chart.ts +324 -0
- package/src/data/styles/chart.css +392 -0
- package/src/motion/Marquee.astro +90 -0
- package/src/motion/MotionProvider.astro +50 -0
- package/src/motion/PageTransitions.astro +61 -0
- package/src/motion/Parallax.astro +44 -0
- package/src/motion/ParallaxLayer.astro +31 -0
- package/src/motion/RevealOnScroll.astro +59 -0
- package/src/motion/SceneRegistry.astro +38 -0
- package/src/motion/ScrollScene.astro +81 -0
- package/src/motion/index.ts +12 -0
- package/src/motion/integration.ts +48 -0
- package/src/motion/runtime/page-transitions.ts +68 -0
- package/src/motion/runtime/runtime.ts +180 -0
- package/src/motion/runtime/scenes.ts +248 -0
- package/src/motion/runtime/types.ts +103 -0
- package/src/motion/styles/motion.css +332 -0
- package/src/motion/transitions.ts +74 -0
- package/src/motion/virtual.d.ts +4 -0
- package/src/primitives/Accordion.astro +129 -0
- package/src/primitives/Breadcrumbs.astro +50 -0
- package/src/primitives/BulletList.astro +69 -0
- package/src/primitives/Button.astro +73 -0
- package/src/primitives/ButtonGroup.astro +54 -0
- package/src/primitives/Callout.astro +137 -0
- package/src/primitives/Caption.astro +35 -0
- package/src/primitives/Card.astro +72 -0
- package/src/primitives/CardContent.astro +24 -0
- package/src/primitives/CardFooter.astro +36 -0
- package/src/primitives/CardHeader.astro +86 -0
- package/src/primitives/Checkbox.astro +38 -0
- package/src/primitives/ChoiceGroup.astro +23 -0
- package/src/primitives/Cluster.astro +49 -0
- package/src/primitives/Container.astro +44 -0
- package/src/primitives/DescriptionList.astro +83 -0
- package/src/primitives/Dialog.astro +38 -0
- package/src/primitives/Disclosure.astro +67 -0
- package/src/primitives/Divider.astro +93 -0
- package/src/primitives/Drawer.astro +33 -0
- package/src/primitives/Fieldset.astro +80 -0
- package/src/primitives/Flex.astro +64 -0
- package/src/primitives/FocusRing.astro +63 -0
- package/src/primitives/FocusTrap.astro +64 -0
- package/src/primitives/Footer.astro +155 -0
- package/src/primitives/Form.astro +68 -0
- package/src/primitives/FormDescription.astro +26 -0
- package/src/primitives/FormError.astro +106 -0
- package/src/primitives/FormField.astro +72 -0
- package/src/primitives/Grid.astro +64 -0
- package/src/primitives/Heading.astro +45 -0
- package/src/primitives/IconButton.astro +48 -0
- package/src/primitives/Image.astro +125 -0
- package/src/primitives/Input.astro +84 -0
- package/src/primitives/Label.astro +50 -0
- package/src/primitives/Link.astro +81 -0
- package/src/primitives/LinkButton.astro +66 -0
- package/src/primitives/List.astro +39 -0
- package/src/primitives/ListItem.astro +178 -0
- package/src/primitives/MediaObject.astro +66 -0
- package/src/primitives/MetricCard.astro +276 -0
- package/src/primitives/NavLink.astro +81 -0
- package/src/primitives/NavMenu.astro +109 -0
- package/src/primitives/Navbar.astro +197 -0
- package/src/primitives/Panel.astro +153 -0
- package/src/primitives/Picture.astro +167 -0
- package/src/primitives/Popover.astro +95 -0
- package/src/primitives/Prose.astro +45 -0
- package/src/primitives/Radio.astro +21 -0
- package/src/primitives/Rating.astro +135 -0
- package/src/primitives/ReducedMotion.astro +90 -0
- package/src/primitives/SegmentedControl.astro +132 -0
- package/src/primitives/Select.astro +107 -0
- package/src/primitives/Sheet.astro +45 -0
- package/src/primitives/SkipLink.astro +31 -0
- package/src/primitives/Slider.astro +186 -0
- package/src/primitives/Spacer.astro +35 -0
- package/src/primitives/Stack.astro +51 -0
- package/src/primitives/Surface.astro +70 -0
- package/src/primitives/Switch.astro +22 -0
- package/src/primitives/Table.astro +382 -0
- package/src/primitives/Tabs.astro +126 -0
- package/src/primitives/Text.astro +56 -0
- package/src/primitives/Textarea.astro +73 -0
- package/src/primitives/Thumbnail.astro +154 -0
- package/src/primitives/Toggle.astro +99 -0
- package/src/primitives/Tooltip.astro +50 -0
- package/src/primitives/VisuallyHidden.astro +29 -0
- package/src/primitives/index.ts +103 -0
- package/src/primitives/internal/AccordionScript.astro +7 -0
- package/src/primitives/internal/ChoiceField.astro +89 -0
- package/src/primitives/internal/FocusTrapScript.astro +8 -0
- package/src/primitives/internal/FormValidationScript.astro +10 -0
- package/src/primitives/internal/IndeterminateScript.astro +13 -0
- package/src/primitives/internal/ModalPanel.astro +114 -0
- package/src/primitives/internal/OverlayScript.astro +7 -0
- package/src/primitives/internal/ReducedMotionScript.astro +7 -0
- package/src/primitives/internal/SliderScript.astro +7 -0
- package/src/primitives/internal/SparklineScript.astro +7 -0
- package/src/primitives/internal/TableSortScript.astro +7 -0
- package/src/primitives/internal/TabsScript.astro +7 -0
- package/src/primitives/internal/TooltipScript.astro +7 -0
- package/src/primitives/lib/deprecate.ts +47 -0
- package/src/primitives/lib/focus-trap.ts +197 -0
- package/src/primitives/lib/focus.ts +60 -0
- package/src/primitives/lib/image-plan.ts +82 -0
- package/src/primitives/lib/image.ts +129 -0
- package/src/primitives/lib/motion.ts +68 -0
- package/src/primitives/lib/slider.ts +170 -0
- package/src/primitives/scripts/accordion.ts +123 -0
- package/src/primitives/scripts/form-validation.ts +225 -0
- package/src/primitives/scripts/overlay.ts +71 -0
- package/src/primitives/scripts/reduced-motion.ts +59 -0
- package/src/primitives/scripts/slider.ts +150 -0
- package/src/primitives/scripts/sparkline.ts +131 -0
- package/src/primitives/scripts/table-sort.ts +68 -0
- package/src/primitives/scripts/tabs.ts +151 -0
- package/src/primitives/scripts/tooltip.ts +28 -0
- package/src/primitives/styles/a11y.css +104 -0
- package/src/primitives/styles/accordion.css +53 -0
- package/src/primitives/styles/breadcrumbs.css +59 -0
- package/src/primitives/styles/bullet-list.css +89 -0
- package/src/primitives/styles/button.css +237 -0
- package/src/primitives/styles/choice.css +164 -0
- package/src/primitives/styles/cluster.css +24 -0
- package/src/primitives/styles/container.css +19 -0
- package/src/primitives/styles/data.css +849 -0
- package/src/primitives/styles/disclosure.css +140 -0
- package/src/primitives/styles/divider.css +50 -0
- package/src/primitives/styles/flex.css +42 -0
- package/src/primitives/styles/form.css +241 -0
- package/src/primitives/styles/grid.css +36 -0
- package/src/primitives/styles/media.css +247 -0
- package/src/primitives/styles/nav.css +792 -0
- package/src/primitives/styles/overlay.css +362 -0
- package/src/primitives/styles/prose.css +146 -0
- package/src/primitives/styles/scale.css +175 -0
- package/src/primitives/styles/segmented.css +165 -0
- package/src/primitives/styles/slider.css +170 -0
- package/src/primitives/styles/spacer.css +17 -0
- package/src/primitives/styles/stack.css +25 -0
- package/src/primitives/styles/surface.css +403 -0
- package/src/primitives/styles/tabs.css +223 -0
- package/src/primitives/styles/typography.css +144 -0
- package/src/primitives/styles/utilities.css +24 -0
- package/src/primitives/types.ts +385 -0
- package/src/primitives/utils.ts +254 -0
- package/src/seo/JSONLD.astro +35 -0
- package/src/seo/SEOHead.astro +47 -0
- package/src/seo/cms.ts +80 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/integration.ts +231 -0
- package/src/seo/lib/jsonld.ts +334 -0
- package/src/seo/lib/meta.ts +205 -0
- package/src/seo/lib/redirects.ts +283 -0
- package/src/seo/lib/robots.ts +33 -0
- package/src/seo/lib/rss.ts +98 -0
- package/src/seo/lib/sitemap.ts +105 -0
- package/src/seo/lib/url.ts +68 -0
- package/src/tokens/base.css +71 -0
- package/src/tokens/tokens.css +210 -0
package/docs/motion.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# @sinnstack/ui/motion
|
|
2
|
+
|
|
3
|
+
The optional motion group. It has page transitions, scroll-driven reveals and parallax, marquees, and pinned GSAP scroll scenes.
|
|
4
|
+
|
|
5
|
+
It is built in layers so that each page pays only for what it uses:
|
|
6
|
+
|
|
7
|
+
| Layer | Components | JavaScript |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| CSS | `RevealOnScroll`, `Parallax`, `ParallaxLayer`, `Marquee`, and the `ScrollScene` pin | none |
|
|
10
|
+
| Platform | `PageTransitions` (View Transitions API through Astro's `ClientRouter`) | Astro router plus about 1 KB |
|
|
11
|
+
| GSAP island | `MotionProvider`, `SceneRegistry`, `ScrollScene` choreography | GSAP, ScrollTrigger and Lenis load **only** when a scene nears the viewport, or at idle if smooth scrolling is on |
|
|
12
|
+
|
|
13
|
+
Every effect follows the reduced-motion preference. That preference is the OS setting, unless the site overrides it with `<html data-motion="reduce|full">` (`setMotionPreference` from `@sinnstack/ui/primitives/motion`). The CSS effects scale by `--sinn-motion-scale`, and the runtime stops Lenis and rebuilds scenes when the preference changes.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add @sinnstack/ui gsap lenis
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// astro.config.mjs
|
|
23
|
+
import sinnMotion from '@sinnstack/ui/motion/integration';
|
|
24
|
+
export default defineConfig({ integrations: [sinnMotion({ scenes: 'src/scenes' })] });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```astro
|
|
28
|
+
<!-- layout <head>, once -->
|
|
29
|
+
<PageTransitions animation="fade" />
|
|
30
|
+
<MotionProvider plugins={['SplitText']} /> <!-- smooth for Lenis -->
|
|
31
|
+
<SceneRegistry />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Components
|
|
35
|
+
|
|
36
|
+
### RevealOnScroll
|
|
37
|
+
This component uses CSS scroll-driven animations (`animation-timeline: view()`).
|
|
38
|
+
- Effects: `fade`, `rise`, `fall`, `slide-start`, `slide-end` (mirrored in RTL), `scale`, `blur`.
|
|
39
|
+
- `distance` is `s`, `m` or `l`. `range` is `early`, `default` or `late`.
|
|
40
|
+
- `stagger` animates direct children in turn, up to 12 steps. `fade={false}` gives movement only.
|
|
41
|
+
- No timers are involved. Content well inside the first screen is already settled at load. Content in the bottom ~30% of the first screen starts partly revealed and finishes as you scroll.
|
|
42
|
+
- Browsers without scroll-driven animations show the content as normal; it is never hidden while waiting for anything.
|
|
43
|
+
|
|
44
|
+
### Parallax + ParallaxLayer
|
|
45
|
+
- Uses a named view timeline on the section.
|
|
46
|
+
- `speed` ranges from -0.5 to 1. 0 scrolls with the page, 1 looks fixed, and negative values give a foreground layer.
|
|
47
|
+
- `travel` is `s`, `m` or `l`, and `z` sets the stacking order.
|
|
48
|
+
- Layers are oversized by exactly their travel, so no edges ever show.
|
|
49
|
+
- Foreground copy goes in `slot="content"` and never moves.
|
|
50
|
+
- Layers are `aria-hidden` by default.
|
|
51
|
+
|
|
52
|
+
### Marquee
|
|
53
|
+
- Pure CSS. The content is rendered twice, and the copy is `aria-hidden` and `inert`.
|
|
54
|
+
- It pauses when the strip is hovered (`pauseOnHover`) and while a keyboard user is focused inside the strip.
|
|
55
|
+
- A real checkbox labelled "Pause scrolling" provides a pause control for WCAG 2.2.2. It works without JS.
|
|
56
|
+
- RTL-aware, and supports `direction="reverse"`.
|
|
57
|
+
- Reduced motion turns it into a static, wrapped row.
|
|
58
|
+
- The `label` prop is required.
|
|
59
|
+
- Don't put ids inside, since the content is rendered twice.
|
|
60
|
+
|
|
61
|
+
### PageTransitions
|
|
62
|
+
- Wraps `ClientRouter` with presets for the root: `fade`, `slide` (reverses on back navigation and mirrors in RTL), `rise` and `none`.
|
|
63
|
+
- A page without the component inherits the previous preset.
|
|
64
|
+
- Keeps the `<html>` attributes listed in `persist` across swaps. The default list is `data-motion` and `data-theme`; Astro would otherwise drop them.
|
|
65
|
+
- After navigating, focus moves to `<main>` without scrolling, unless the URL has a hash.
|
|
66
|
+
- Reduced motion keeps navigation and drops the animation.
|
|
67
|
+
- For per-element control, use Astro's `transition:animate` with `fade`, `slide` or `rise` from `@sinnstack/ui/motion/transitions`. For shared-element morphs, use `transition:name={morphName('photo', id)}`.
|
|
68
|
+
|
|
69
|
+
### MotionProvider
|
|
70
|
+
Loads GSAP, ScrollTrigger and the listed plugins once. They load lazily, or at idle when `smooth` or `eager` is set.
|
|
71
|
+
- **Smooth scrolling:** `smooth` (Lenis, `lerp` defaults to 0.1).
|
|
72
|
+
- Lenis runs on `gsap.ticker` with `lagSmoothing(0)`, and its scroll events call `ScrollTrigger.update()`.
|
|
73
|
+
- Lenis never runs with reduced motion.
|
|
74
|
+
- **Page transitions:**
|
|
75
|
+
- Before Astro swaps the page, every scene is reverted and Lenis is stopped.
|
|
76
|
+
- After the swap, Lenis restarts. Astro's swap wipes Lenis's `<html>` classes, and restarting re-applies them.
|
|
77
|
+
- Once the new page has loaded, Lenis jumps to the current scroll position and ScrollTrigger refreshes.
|
|
78
|
+
- **Your own scripts:** they can use the same instance:
|
|
79
|
+
```ts
|
|
80
|
+
import { getMotion, onBeforeSwap, onPageLoad, onPreferenceChange } from '@sinnstack/ui/motion/runtime';
|
|
81
|
+
const { gsap, ScrollTrigger, plugins, lenis } = await getMotion();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### SceneRegistry + ScrollScene
|
|
85
|
+
- **Registering scenes:**
|
|
86
|
+
- A scene's name is its file name in `src/scenes/`, provided through the integration as `virtual:sinn-motion/scenes`, with one lazy chunk per scene. Files starting with `_` are ignored.
|
|
87
|
+
- Without the integration, leave `SceneRegistry` out (its script imports the integration's virtual module). Register scenes yourself in a client script with `registerScenes(import.meta.glob('../scenes/*.ts'))` and `startScenes()`.
|
|
88
|
+
- **Loading:** a scene's module, and GSAP the first time, load when the section comes within `rootMargin` of the viewport (half a viewport by default).
|
|
89
|
+
- **Pinning:**
|
|
90
|
+
- `pin` is CSS. The section reserves `100svh + length%` of scroll up front, and the stage is `position: sticky`. Loading a scene never shifts the layout (CLS 0), and the pin works without JS.
|
|
91
|
+
- The scrub trigger runs from `top top` to `bottom bottom` when pinned, and from `top bottom` to `bottom top` otherwise. `start` and `end` override it.
|
|
92
|
+
- **Modes:** `scrub` (follows the scrollbar in both directions, with optional smoothing in seconds) or `play` (plays once at `top 75%`).
|
|
93
|
+
- **Params:** `params={{ accentColor: 'teal' }}` is rendered as `data-param-accent-color` and arrives as `ctx.params.accentColor`.
|
|
94
|
+
- **State:** the section's `data-scene-state` is `loading`, `ready`, `reduced` or `error`, which you can style.
|
|
95
|
+
|
|
96
|
+
Write the markup in its **final, readable state** and animate *from* hidden in the module. That final state is what visitors see without JS, with reduced motion, or before the module arrives.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// src/scenes/care-journey.ts
|
|
100
|
+
import type { gsap } from 'gsap';
|
|
101
|
+
import type { ScrollTrigger } from 'gsap/ScrollTrigger';
|
|
102
|
+
import { defineScene } from '@sinnstack/ui/motion/scenes';
|
|
103
|
+
|
|
104
|
+
export default defineScene<typeof gsap, typeof ScrollTrigger>(({ timeline, q, params, root, stage, reduced, plugins, lenis }) => {
|
|
105
|
+
timeline.from(q('.step'), { autoAlpha: 0, y: 48, stagger: 1 });
|
|
106
|
+
return () => { /* remove listeners you added; GSAP objects are reverted for you */ };
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// With reduced motion: 'end' (default) shows the finished state, 'start' the first frame,
|
|
110
|
+
// 'none' doesn't run the scene at all (the markup stays exactly as authored).
|
|
111
|
+
export const reducedState = 'end';
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Everything a scene creates synchronously inside `setup` is reverted when the page changes and when the motion preference changes, because it runs inside a `gsap.context` scoped to the section. Return a cleanup function for anything else. For example, `stat-count` restores text that its `onUpdate` callback changed.
|
|
115
|
+
|
|
116
|
+
The playground has three scenes to copy: `care-journey` (pinned scrub), `stat-count` (count-up with screen-reader-safe values) and `split-headline` (SplitText).
|
|
117
|
+
|
|
118
|
+
## Notes and limits
|
|
119
|
+
|
|
120
|
+
- **Sticky pinning breaks** if any ancestor of a pinned ScrollScene is a scroll container, such as `overflow: hidden` or `overflow: auto`. A common case is `body { overflow-x: hidden }`; use `overflow-x: clip` instead.
|
|
121
|
+
- **Strict CSP:**
|
|
122
|
+
- The CSS components, the root presets and the runtime add no inline scripts or styles.
|
|
123
|
+
- Astro's `transition:animate` and `transition:name` directives do emit an inline `<style>`. If you use them, enable Astro's CSP hashing (`experimental.csp` in Astro 5.9+). The root presets don't need it.
|
|
124
|
+
- **Toggling reduced motion inside a pinned section** releases its reserved scroll length, so the page gets shorter under the reader. This is expected; the content stays readable.
|
|
125
|
+
- **Budgets:** see `.size-limit.json`.
|
|
126
|
+
- Our runtime is about 3 KB gzipped (minified estimate; about 6.4 KB gzipped unminified).
|
|
127
|
+
- The full cinematic stack (GSAP core, ScrollTrigger, Lenis and the runtime) has a 60 KB budget. Use it only on cinematic scroll sites.
|
|
128
|
+
- Pages without a scene don't download GSAP unless `smooth` or `eager` is set.
|
|
129
|
+
|
|
130
|
+
## What has been verified, and what to test with the real libraries
|
|
131
|
+
|
|
132
|
+
Verified in Chrome 153 against the real CSS and the real runtime code (TypeScript stripped). GSAP, ScrollTrigger, Lenis and Astro's router were replaced by small stand-ins that behave like their documented APIs (102 checks):
|
|
133
|
+
- RevealOnScroll: entry and settle values, stagger order, RTL mirroring, reduced motion (OS and site switch), and the `full` override.
|
|
134
|
+
- Parallax: exact travel (±10svh at speed 0.5), the opposite direction for negative speeds, no edge gaps, content that never moves, and reduced motion.
|
|
135
|
+
- Marquee: a seamless loop (equal copies, the seam equals the gap), pause on hover and on keyboard focus, the Pause checkbox, one Tab stop per item, RTL and reverse, a wrapping static row under reduced motion at 400px, and the ≥24px target.
|
|
136
|
+
- ScrollScene pin geometry: reserved length, sticky hold, release, and no CLS while scrolling the whole page, with or without smooth scrolling.
|
|
137
|
+
- Runtime:
|
|
138
|
+
- Lazy loading: nothing before the look-ahead, one GSAP load, plugins registered, and setup arguments including params.
|
|
139
|
+
- Scrubbing: forward and back.
|
|
140
|
+
- Play-once mode.
|
|
141
|
+
- Warnings and the `error` state.
|
|
142
|
+
- Reduced-motion changes: cleanup, revert, rebuild, no live triggers, and `reducedState` end, start and none.
|
|
143
|
+
- Navigation (Astro's swap semantics replicated):
|
|
144
|
+
- Revert before the swap.
|
|
145
|
+
- `<html>` attributes persisted and the preset taken from the new page.
|
|
146
|
+
- Focus moved to `<main>`, and the hash case.
|
|
147
|
+
- Slide forward and back animation names.
|
|
148
|
+
- No animation under reduced motion.
|
|
149
|
+
- Scenes mount on the new page.
|
|
150
|
+
- Lenis wiring:
|
|
151
|
+
- Options, the ticker driving it, and scroll events calling `ScrollTrigger.update()`.
|
|
152
|
+
- Classes restored before the new view is captured.
|
|
153
|
+
- Destroyed and recreated when the preference changes, with only one instance under rapid toggling.
|
|
154
|
+
- Never created with reduced motion.
|
|
155
|
+
|
|
156
|
+
**Still to test in a real Astro app with GSAP 3.13+ and Lenis 1.3+:**
|
|
157
|
+
- [ ] `pnpm build` passes `astro check`, and the integration's glob emits one chunk per scene. The `gsap/*` dynamic imports should split per plugin.
|
|
158
|
+
- [ ] A real ScrollTrigger scrub on a CSS-sticky pin. There's no `pin: true`, so check `invalidateOnRefresh` after a resize or font load. Check `markers` while developing.
|
|
159
|
+
- [ ] Lenis with Astro's scroll restoration on back and forward navigation. The page should land where you left it with no jump. Also check that anchor links work through Lenis (`anchors: true`).
|
|
160
|
+
- [ ] The order of `astro:after-swap` and `astro:page-load` in Astro 5 matches the replica: Lenis restarts before the new view is captured.
|
|
161
|
+
- [ ] SplitText 3.13 `mask` and `aria` output reverts cleanly on navigation.
|
|
162
|
+
- [ ] Safari and Firefox:
|
|
163
|
+
- Scroll-driven animations (Safari 26+). Older versions fall back to static content.
|
|
164
|
+
- View Transitions in Firefox. Older versions follow the `fallback` behaviour.
|
|
165
|
+
- [ ] Screen readers: VoiceOver and NVDA announce the page title after navigation. The marquee is read once. Count-ups read their final values.
|
|
166
|
+
- [ ] Lighthouse p75 on a cinematic page against its own budget.
|