@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.
- package/CHANGELOG.md +89 -0
- package/LICENSE +373 -0
- package/README.md +188 -2
- package/docs/blocks.md +373 -0
- package/docs/data.md +128 -0
- package/docs/finishes.md +165 -0
- package/docs/motion.md +166 -0
- package/docs/primitives.md +510 -0
- package/docs/seo.md +191 -0
- package/docs/tokens.md +122 -0
- package/package.json +132 -3
- package/scripts/check-contrast.mjs +180 -0
- package/src/blocks/BlockRenderer.astro +60 -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 +173 -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 +58 -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 +48 -0
- package/src/blocks/cms/consent.ts +16 -0
- package/src/blocks/cms/contact-card.ts +46 -0
- package/src/blocks/cms/contact-form.ts +37 -0
- package/src/blocks/cms/cta-banner.ts +27 -0
- package/src/blocks/cms/cta-pair.ts +30 -0
- package/src/blocks/cms/data-base.ts +5 -0
- package/src/blocks/cms/data.ts +257 -0
- package/src/blocks/cms/faq.ts +38 -0
- package/src/blocks/cms/feature-grid.ts +47 -0
- package/src/blocks/cms/fixtures.ts +591 -0
- package/src/blocks/cms/hero-carousel.ts +36 -0
- package/src/blocks/cms/hero.ts +33 -0
- package/src/blocks/cms/highlight-cards.ts +41 -0
- package/src/blocks/cms/images.ts +37 -0
- package/src/blocks/cms/index.ts +59 -0
- package/src/blocks/cms/location-hours.ts +67 -0
- package/src/blocks/cms/logo-cloud.ts +36 -0
- package/src/blocks/cms/media-text.ts +26 -0
- package/src/blocks/cms/page-header.ts +27 -0
- package/src/blocks/cms/pages.ts +35 -0
- package/src/blocks/cms/prose-section.ts +25 -0
- package/src/blocks/cms/reviews.ts +50 -0
- package/src/blocks/cms/schema-dsl.ts +134 -0
- package/src/blocks/cms/schema.ts +794 -0
- package/src/blocks/cms/shared.ts +63 -0
- package/src/blocks/cms/stats-band.ts +35 -0
- package/src/blocks/cms/steps.ts +40 -0
- package/src/blocks/cms/testimonials.ts +46 -0
- package/src/blocks/cms/topbar.ts +27 -0
- package/src/blocks/cms/types.ts +27 -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 +35 -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/consent.ts +96 -0
- package/src/blocks/internal/fields.ts +18 -0
- package/src/blocks/internal/registry-contract.ts +67 -0
- package/src/blocks/internal/reviews.ts +22 -0
- package/src/blocks/internal/slug.ts +12 -0
- package/src/blocks/internal/util.ts +23 -0
- package/src/blocks/lib/contact.ts +92 -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/markdown.ts +350 -0
- package/src/blocks/lib/rich-text.ts +132 -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 +107 -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 +293 -0
- package/src/data/ChartAxis.astro +19 -0
- package/src/data/ChartContainer.astro +152 -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 +130 -0
- package/src/data/index.ts +10 -0
- package/src/data/internal/scale.ts +107 -0
- package/src/data/lib/chart.ts +459 -0
- package/src/data/lib/render.ts +219 -0
- package/src/data/lib/sparkline.ts +117 -0
- package/src/data/schema.ts +65 -0
- package/src/data/scripts/chart.ts +324 -0
- package/src/data/styles/chart.css +392 -0
- package/src/finishes/aurora.css +75 -0
- package/src/finishes/autumn.css +87 -0
- package/src/finishes/blueprint.css +69 -0
- package/src/finishes/brutalist.css +55 -0
- package/src/finishes/clay.css +48 -0
- package/src/finishes/day-cycle.css +46 -0
- package/src/finishes/fog.css +71 -0
- package/src/finishes/glass.css +149 -0
- package/src/finishes/holographic.css +91 -0
- package/src/finishes/night.css +77 -0
- package/src/finishes/paper.css +58 -0
- package/src/finishes/polished-glass.css +159 -0
- package/src/finishes/rain.css +84 -0
- package/src/finishes/scripts/day-cycle.ts +30 -0
- package/src/finishes/scripts/holographic.ts +37 -0
- package/src/finishes/scripts/spotlight.ts +30 -0
- package/src/finishes/spotlight.css +41 -0
- package/src/finishes/spring.css +80 -0
- package/src/finishes/terminal.css +49 -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 +86 -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 +278 -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 +109 -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 +75 -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 +91 -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/internal/image-plan.ts +82 -0
- package/src/primitives/internal/image.ts +129 -0
- package/src/primitives/internal/slider.ts +170 -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/motion.ts +68 -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 +59 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/integration.ts +268 -0
- package/src/seo/internal/url.ts +68 -0
- package/src/seo/lib/jsonld.ts +342 -0
- package/src/seo/lib/meta.ts +205 -0
- package/src/seo/lib/redirects.ts +293 -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/schema.ts +43 -0
- package/src/tokens/base.css +71 -0
- package/src/tokens/tokens.css +210 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene registry: maps scene names to choreography modules and mounts each one only when its
|
|
3
|
+
* section nears the viewport. GSAP itself is only downloaded when the first scene mounts.
|
|
4
|
+
*
|
|
5
|
+
* Mounting a scene:
|
|
6
|
+
* 1. load its module and the shared GSAP setup (getMotion) in parallel;
|
|
7
|
+
* 2. inside gsap.context(…, root), build the scene's timeline (scrubbed or play-once, driven by
|
|
8
|
+
* a ScrollTrigger on the section) and call the module's setup with it;
|
|
9
|
+
* 3. keep the context so everything can be reverted.
|
|
10
|
+
* Everything is reverted before Astro swaps the page, and rebuilt when reduced motion changes.
|
|
11
|
+
*/
|
|
12
|
+
import { prefersReducedMotion } from '../../primitives/lib/motion';
|
|
13
|
+
import { getMotion, onBeforeSwap, onPageLoad, onPreferenceChange } from './runtime';
|
|
14
|
+
import type { ContextLike, GsapLike, Motion, SceneContext, SceneLoader, SceneModule, SceneSetup, ScrollTriggerLike, TimelineLike } from './types';
|
|
15
|
+
|
|
16
|
+
export type { SceneContext, SceneModule, SceneSetup } from './types';
|
|
17
|
+
|
|
18
|
+
/** Typed helper for writing a scene module's default export. */
|
|
19
|
+
export function defineScene<G = GsapLike, ST = ScrollTriggerLike>(setup: SceneSetup<G, ST>): SceneSetup<G, ST> {
|
|
20
|
+
return setup;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Scene name from a module path: '/src/scenes/project-journey.ts' → 'project-journey'. */
|
|
24
|
+
export function sceneNameFromPath(path: string): string {
|
|
25
|
+
const file = path.split('/').pop() ?? path;
|
|
26
|
+
return file.replace(/\.(m?[jt]s|[jt]sx)$/, '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Normalizes an import.meta.glob() result or a plain { name: () => import(...) } map.
|
|
31
|
+
* registerScenes(defineScenes(import.meta.glob('../scenes/*.ts')))
|
|
32
|
+
*/
|
|
33
|
+
export function defineScenes(map: Record<string, SceneLoader>): Record<string, SceneLoader> {
|
|
34
|
+
const out: Record<string, SceneLoader> = {};
|
|
35
|
+
for (const [key, loader] of Object.entries(map)) out[key.includes('/') ? sceneNameFromPath(key) : key] = loader;
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Mounted {
|
|
40
|
+
ctx: ContextLike;
|
|
41
|
+
cleanup?: () => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const registry = new Map<string, SceneLoader>();
|
|
45
|
+
const mounted = new Map<HTMLElement, Mounted>();
|
|
46
|
+
const pending = new Set<HTMLElement>();
|
|
47
|
+
let observer: IntersectionObserver | null = null;
|
|
48
|
+
let rootMargin = '50% 0px';
|
|
49
|
+
let generation = 0;
|
|
50
|
+
|
|
51
|
+
export function registerScenes(map: Record<string, SceneLoader>): void {
|
|
52
|
+
for (const [name, loader] of Object.entries(defineScenes(map))) registry.set(name, loader);
|
|
53
|
+
if (typeof window !== 'undefined' && observer) scan();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Names currently registered (useful for debugging). */
|
|
57
|
+
export function registeredScenes(): string[] {
|
|
58
|
+
return [...registry.keys()];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function paramsOf(el: HTMLElement): Record<string, string> {
|
|
62
|
+
const out: Record<string, string> = {};
|
|
63
|
+
for (const [key, value] of Object.entries(el.dataset)) {
|
|
64
|
+
if (key.startsWith('param') && key.length > 5 && value !== undefined) {
|
|
65
|
+
out[key[5].toLowerCase() + key.slice(6)] = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function scrubValue(raw: string | undefined): boolean | number {
|
|
72
|
+
if (raw === undefined || raw === 'true' || raw === '') return true;
|
|
73
|
+
const n = Number(raw);
|
|
74
|
+
return Number.isFinite(n) && n > 0 ? n : true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Applies the start state of every tween in the timeline, then parks the playhead at `progress`.
|
|
79
|
+
* A from() with a stagger (or any tween placed later in the timeline) otherwise keeps the
|
|
80
|
+
* authored final state until the playhead first reaches it: later items show, then vanish and
|
|
81
|
+
* animate in. Jumping to the end and back renders every child without firing callbacks.
|
|
82
|
+
*/
|
|
83
|
+
function primeStartStates(timeline: TimelineLike | undefined, progress: number): void {
|
|
84
|
+
if (!timeline) return;
|
|
85
|
+
timeline.progress(1, true);
|
|
86
|
+
timeline.progress(progress, true);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function mount(el: HTMLElement): Promise<void> {
|
|
90
|
+
const name = el.dataset.sinnScene ?? '';
|
|
91
|
+
const loader = registry.get(name);
|
|
92
|
+
if (!loader) {
|
|
93
|
+
console.warn(`[sinn-motion] No scene registered as "${name}". Registered: ${registeredScenes().join(', ') || '(none)'}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
pending.add(el);
|
|
97
|
+
el.dataset.sceneState = 'loading';
|
|
98
|
+
const gen = generation;
|
|
99
|
+
let mod: SceneModule;
|
|
100
|
+
let m: Motion<GsapLike, ScrollTriggerLike>;
|
|
101
|
+
try {
|
|
102
|
+
[mod, m] = await Promise.all([loader() as Promise<SceneModule>, getMotion<GsapLike, ScrollTriggerLike>()]);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
pending.delete(el);
|
|
105
|
+
el.dataset.sceneState = 'error';
|
|
106
|
+
console.error(`[sinn-motion] Scene "${name}" failed to load`, error);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
pending.delete(el);
|
|
110
|
+
// Page changed (or preference flipped) while loading: drop this mount.
|
|
111
|
+
if (gen !== generation || !el.isConnected || mounted.has(el)) return;
|
|
112
|
+
|
|
113
|
+
const reduced = prefersReducedMotion();
|
|
114
|
+
const reducedState = mod.reducedState ?? 'end';
|
|
115
|
+
if (reduced && reducedState === 'none') {
|
|
116
|
+
// Leave the markup exactly as authored: don't run the scene at all.
|
|
117
|
+
mounted.set(el, { ctx: { revert() {} } });
|
|
118
|
+
el.dataset.sceneState = 'reduced';
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const stage = el.querySelector<HTMLElement>(':scope > [data-scene-stage]') ?? el;
|
|
122
|
+
const pinned = el.hasAttribute('data-scene-pin');
|
|
123
|
+
const mode = el.dataset.sceneMode === 'play' ? 'play' : 'scrub';
|
|
124
|
+
const setup = typeof mod.default === 'function' ? mod.default : (mod as unknown as SceneSetup);
|
|
125
|
+
// Assigned inside the (synchronous) gsap.context callback.
|
|
126
|
+
let cleanup: (() => void) | void = undefined;
|
|
127
|
+
let timeline!: TimelineLike;
|
|
128
|
+
|
|
129
|
+
const ctx = m.gsap.context(() => {
|
|
130
|
+
if (reduced) {
|
|
131
|
+
timeline = m.gsap.timeline({ paused: true });
|
|
132
|
+
} else if (mode === 'scrub') {
|
|
133
|
+
timeline = m.gsap.timeline({
|
|
134
|
+
defaults: { ease: 'none' },
|
|
135
|
+
scrollTrigger: {
|
|
136
|
+
trigger: el,
|
|
137
|
+
// Pinned: the stage is sticky for the section's whole reserved length.
|
|
138
|
+
start: el.dataset.sceneStart ?? (pinned ? 'top top' : 'top bottom'),
|
|
139
|
+
end: el.dataset.sceneEnd ?? (pinned ? 'bottom bottom' : 'bottom top'),
|
|
140
|
+
scrub: scrubValue(el.dataset.sceneScrub),
|
|
141
|
+
markers: el.hasAttribute('data-scene-markers'),
|
|
142
|
+
invalidateOnRefresh: true,
|
|
143
|
+
// invalidateOnRefresh clears recorded start values, so re-apply them after every
|
|
144
|
+
// refresh (mount, resize, fonts), then return to the scroll position's progress.
|
|
145
|
+
onRefresh: (self: { progress: number }) => primeStartStates(timeline, self.progress),
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
timeline = m.gsap.timeline({
|
|
150
|
+
scrollTrigger: {
|
|
151
|
+
trigger: el,
|
|
152
|
+
start: el.dataset.sceneStart ?? 'top 75%',
|
|
153
|
+
end: el.dataset.sceneEnd,
|
|
154
|
+
once: true,
|
|
155
|
+
markers: el.hasAttribute('data-scene-markers'),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const sceneCtx: SceneContext = {
|
|
161
|
+
...m,
|
|
162
|
+
root: el,
|
|
163
|
+
stage,
|
|
164
|
+
timeline,
|
|
165
|
+
q: m.gsap.utils.selector(el),
|
|
166
|
+
params: paramsOf(el),
|
|
167
|
+
reduced,
|
|
168
|
+
};
|
|
169
|
+
cleanup = setup(sceneCtx as never);
|
|
170
|
+
|
|
171
|
+
if (reduced) timeline.progress(reducedState === 'end' ? 1 : 0);
|
|
172
|
+
else primeStartStates(timeline, 0);
|
|
173
|
+
}, el);
|
|
174
|
+
|
|
175
|
+
mounted.set(el, { ctx, cleanup: typeof cleanup === 'function' ? cleanup : undefined });
|
|
176
|
+
el.dataset.sceneState = reduced ? 'reduced' : 'ready';
|
|
177
|
+
m.ScrollTrigger.refresh();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function unmountAll(): void {
|
|
181
|
+
generation++;
|
|
182
|
+
for (const [el, entry] of mounted) {
|
|
183
|
+
try {
|
|
184
|
+
entry.cleanup?.();
|
|
185
|
+
} finally {
|
|
186
|
+
entry.ctx.revert();
|
|
187
|
+
delete el.dataset.sceneState;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
mounted.clear();
|
|
191
|
+
pending.clear();
|
|
192
|
+
observer?.disconnect();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Observe every [data-sinn-scene] not yet mounted. Called on each page load. */
|
|
196
|
+
export function scan(root: ParentNode = document): void {
|
|
197
|
+
if (typeof window === 'undefined') return;
|
|
198
|
+
observer ??= new IntersectionObserver(
|
|
199
|
+
(entries) => {
|
|
200
|
+
for (const entry of entries) {
|
|
201
|
+
if (!entry.isIntersecting) continue;
|
|
202
|
+
const el = entry.target as HTMLElement;
|
|
203
|
+
observer?.unobserve(el);
|
|
204
|
+
if (!mounted.has(el) && !pending.has(el)) void mount(el);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{ rootMargin },
|
|
208
|
+
);
|
|
209
|
+
for (const el of root.querySelectorAll<HTMLElement>('[data-sinn-scene]')) {
|
|
210
|
+
if (!mounted.has(el) && !pending.has(el)) observer.observe(el);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Starts scene loading. `rootMargin` controls how early a scene loads before it's visible
|
|
216
|
+
* (default: half a viewport ahead). Safe to call more than once.
|
|
217
|
+
*/
|
|
218
|
+
export function startScenes(options: { rootMargin?: string } = {}): void {
|
|
219
|
+
if (typeof window === 'undefined') return;
|
|
220
|
+
const w = window as unknown as Record<string, boolean>;
|
|
221
|
+
if (options.rootMargin && options.rootMargin !== rootMargin) {
|
|
222
|
+
rootMargin = options.rootMargin;
|
|
223
|
+
observer?.disconnect();
|
|
224
|
+
observer = null;
|
|
225
|
+
}
|
|
226
|
+
if (w.__sinnScenes) return void scan();
|
|
227
|
+
w.__sinnScenes = true;
|
|
228
|
+
|
|
229
|
+
onBeforeSwap(unmountAll);
|
|
230
|
+
onPageLoad(() => scan());
|
|
231
|
+
onPreferenceChange(() => {
|
|
232
|
+
// Rebuild in the new mode; scenes in view re-mount immediately (the observer fires on observe).
|
|
233
|
+
unmountAll();
|
|
234
|
+
observer = null;
|
|
235
|
+
scan();
|
|
236
|
+
});
|
|
237
|
+
scan();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Revert one element's scene (e.g. before removing it yourself). */
|
|
241
|
+
export function unmountScene(el: HTMLElement): void {
|
|
242
|
+
const entry = mounted.get(el);
|
|
243
|
+
if (!entry) return;
|
|
244
|
+
entry.cleanup?.();
|
|
245
|
+
entry.ctx.revert();
|
|
246
|
+
mounted.delete(el);
|
|
247
|
+
delete el.dataset.sceneState;
|
|
248
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for scene modules. GSAP types are generic parameters so this package type-checks
|
|
3
|
+
* without GSAP installed; in your scenes, pass the real ones:
|
|
4
|
+
*
|
|
5
|
+
* import type { gsap } from 'gsap';
|
|
6
|
+
* import type { ScrollTrigger } from 'gsap/ScrollTrigger';
|
|
7
|
+
* import { defineScene } from '@sinnstack/ui/motion/scenes';
|
|
8
|
+
* export default defineScene<typeof gsap, typeof ScrollTrigger>(({ gsap, timeline, q }) => { … });
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Plugins MotionProvider can load (GSAP's plugins are free to use as of GSAP 3.13). */
|
|
12
|
+
export type PluginName =
|
|
13
|
+
| 'ScrollTrigger'
|
|
14
|
+
| 'ScrollToPlugin'
|
|
15
|
+
| 'SplitText'
|
|
16
|
+
| 'Flip'
|
|
17
|
+
| 'Observer'
|
|
18
|
+
| 'Draggable'
|
|
19
|
+
| 'DrawSVGPlugin'
|
|
20
|
+
| 'MorphSVGPlugin'
|
|
21
|
+
| 'MotionPathPlugin'
|
|
22
|
+
| 'TextPlugin'
|
|
23
|
+
| 'CustomEase';
|
|
24
|
+
|
|
25
|
+
// Minimal structural shapes the runtime relies on. The real GSAP objects satisfy them.
|
|
26
|
+
export interface TimelineLike {
|
|
27
|
+
progress(value?: number, suppressEvents?: boolean): number | TimelineLike;
|
|
28
|
+
kill(): void;
|
|
29
|
+
scrollTrigger?: { kill(): void } | null;
|
|
30
|
+
}
|
|
31
|
+
export interface ContextLike {
|
|
32
|
+
revert(): void;
|
|
33
|
+
add?(fn: () => void): void;
|
|
34
|
+
}
|
|
35
|
+
export interface GsapLike {
|
|
36
|
+
registerPlugin(...plugins: unknown[]): void;
|
|
37
|
+
context(fn: (self: ContextLike) => void, scope?: Element | string): ContextLike;
|
|
38
|
+
timeline(vars?: Record<string, unknown>): TimelineLike;
|
|
39
|
+
ticker: { add(fn: (time: number) => void): void; remove(fn: (time: number) => void): void; lagSmoothing(threshold: number, adjusted?: number): void };
|
|
40
|
+
utils: { selector(scope: Element): (selector: string) => Element[] };
|
|
41
|
+
}
|
|
42
|
+
export interface ScrollTriggerLike {
|
|
43
|
+
refresh(safe?: boolean): void;
|
|
44
|
+
update(): void;
|
|
45
|
+
getAll(): Array<{ kill(): void }>;
|
|
46
|
+
}
|
|
47
|
+
export interface LenisLike {
|
|
48
|
+
on(event: 'scroll', cb: (...args: unknown[]) => void): void;
|
|
49
|
+
raf(time: number): void;
|
|
50
|
+
scrollTo(target: number | string | Element, options?: Record<string, unknown>): void;
|
|
51
|
+
start(): void;
|
|
52
|
+
stop(): void;
|
|
53
|
+
resize(): void;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface Motion<G = GsapLike, ST = ScrollTriggerLike> {
|
|
58
|
+
gsap: G;
|
|
59
|
+
ScrollTrigger: ST;
|
|
60
|
+
/** Loaded optional plugins, by name. */
|
|
61
|
+
plugins: Partial<Record<PluginName, unknown>>;
|
|
62
|
+
/** The smooth-scroll instance, when enabled and motion isn't reduced. */
|
|
63
|
+
lenis: LenisLike | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The timeline type of a GSAP-like object (`any` stays `any`). */
|
|
67
|
+
export type TimelineOf<G> = 0 extends 1 & G ? any : G extends { timeline(...args: never[]): infer T } ? T : TimelineLike;
|
|
68
|
+
|
|
69
|
+
export interface SceneContext<G = GsapLike, ST = ScrollTriggerLike> extends Motion<G, ST> {
|
|
70
|
+
/** The ScrollScene section (or any element with data-sinn-scene). */
|
|
71
|
+
root: HTMLElement;
|
|
72
|
+
/** The pinned stage (or root when there is none). */
|
|
73
|
+
stage: HTMLElement;
|
|
74
|
+
/**
|
|
75
|
+
* Timeline driven by the scene's ScrollTrigger (scrubbed or played on entry). Add tweens to it.
|
|
76
|
+
* With reduced motion it's paused and settled to `reducedState` after setup.
|
|
77
|
+
*/
|
|
78
|
+
timeline: TimelineOf<G>;
|
|
79
|
+
/** Scoped selector: q('.title') finds elements inside root. */
|
|
80
|
+
q: (selector: string) => Element[];
|
|
81
|
+
/** data-param-* values from the ScrollScene `params` prop. */
|
|
82
|
+
params: Record<string, string>;
|
|
83
|
+
/** True when motion is reduced (OS setting or site override). */
|
|
84
|
+
reduced: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A scene's choreography. Build tweens synchronously (everything created here is reverted
|
|
89
|
+
* automatically on navigation or when the preference changes). Optionally return a cleanup
|
|
90
|
+
* function for anything else (listeners, observers).
|
|
91
|
+
*/
|
|
92
|
+
export type SceneSetup<G = GsapLike, ST = ScrollTriggerLike> = (ctx: SceneContext<G, ST>) => void | (() => void);
|
|
93
|
+
|
|
94
|
+
export interface SceneModule {
|
|
95
|
+
default: SceneSetup<any, any>;
|
|
96
|
+
/**
|
|
97
|
+
* With reduced motion: show the timeline's `end` state (default), its `start`, or `none`
|
|
98
|
+
* (the scene doesn't run at all; the markup stays exactly as authored).
|
|
99
|
+
*/
|
|
100
|
+
reducedState?: 'end' | 'start' | 'none';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export type SceneLoader = () => Promise<unknown>;
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/* GENERATED by scripts/generate-css.mjs — edit the generator, not this file. */
|
|
2
|
+
/*
|
|
3
|
+
* @sinnstack/ui/motion styles. Everything moves through --sinn-motion-scale (1 full, 0 reduced;
|
|
4
|
+
* see @sinnstack/ui), so reduced motion and the site's <html data-motion> switch apply
|
|
5
|
+
* without extra code. Scroll-driven effects are progressive enhancement: without
|
|
6
|
+
* animation-timeline support the content is simply shown, never hidden.
|
|
7
|
+
*/
|
|
8
|
+
/* Same order as tokens.css: whichever stylesheet loads first fixes the layer order. */
|
|
9
|
+
@layer sinn.reset, sinn.tokens, sinn.primitives, sinn.data, sinn.motion, sinn.blocks, sinn.overrides;
|
|
10
|
+
|
|
11
|
+
@layer sinn.motion {
|
|
12
|
+
/* ================= RevealOnScroll ================= */
|
|
13
|
+
:where(.sinn-reveal) {
|
|
14
|
+
--sinn-p-reveal-distance: 2rem;
|
|
15
|
+
--sinn-p-reveal-x: 0px;
|
|
16
|
+
--sinn-p-reveal-y: 0px;
|
|
17
|
+
--sinn-p-reveal-scale: 1;
|
|
18
|
+
--sinn-p-reveal-blur: 0px;
|
|
19
|
+
--sinn-p-reveal-opacity: 0;
|
|
20
|
+
--sinn-p-reveal-step: 6%;
|
|
21
|
+
}
|
|
22
|
+
:where(.sinn-reveal[data-distance='s']) { --sinn-p-reveal-distance: 1rem; }
|
|
23
|
+
:where(.sinn-reveal[data-distance='l']) { --sinn-p-reveal-distance: 4rem; }
|
|
24
|
+
:where(.sinn-reveal[data-effect='rise']) { --sinn-p-reveal-y: var(--sinn-p-reveal-distance); }
|
|
25
|
+
:where(.sinn-reveal[data-effect='fall']) { --sinn-p-reveal-y: calc(var(--sinn-p-reveal-distance) * -1); }
|
|
26
|
+
:where(.sinn-reveal[data-effect='slide-start']) { --sinn-p-reveal-x: calc(var(--sinn-p-reveal-distance) * -1); }
|
|
27
|
+
:where(.sinn-reveal[data-effect='slide-end']) { --sinn-p-reveal-x: var(--sinn-p-reveal-distance); }
|
|
28
|
+
:where(.sinn-reveal[data-effect='slide-start']:dir(rtl)) { --sinn-p-reveal-x: var(--sinn-p-reveal-distance); }
|
|
29
|
+
:where(.sinn-reveal[data-effect='slide-end']:dir(rtl)) { --sinn-p-reveal-x: calc(var(--sinn-p-reveal-distance) * -1); }
|
|
30
|
+
:where(.sinn-reveal[data-effect='scale']) { --sinn-p-reveal-scale: 0.92; }
|
|
31
|
+
:where(.sinn-reveal[data-effect='blur']) { --sinn-p-reveal-blur: 10px; }
|
|
32
|
+
:where(.sinn-reveal[data-effect='fade']) { --sinn-p-reveal-opacity: 0; }
|
|
33
|
+
:where(.sinn-reveal[data-fade='false']) { --sinn-p-reveal-opacity: 1; }
|
|
34
|
+
|
|
35
|
+
@supports (animation-timeline: view()) {
|
|
36
|
+
:where(.sinn-reveal:not([data-stagger])),
|
|
37
|
+
:where(.sinn-reveal[data-stagger]) > :where(*) {
|
|
38
|
+
--sinn-p-i: 0;
|
|
39
|
+
animation: sinn-reveal linear both;
|
|
40
|
+
animation-timeline: view();
|
|
41
|
+
animation-range: entry calc(var(--sinn-p-i) * var(--sinn-p-reveal-step)) cover calc(30% + var(--sinn-p-i) * var(--sinn-p-reveal-step));
|
|
42
|
+
}
|
|
43
|
+
:where(.sinn-reveal[data-range='early']:not([data-stagger])),
|
|
44
|
+
:where(.sinn-reveal[data-range='early'][data-stagger]) > :where(*) {
|
|
45
|
+
animation-range: entry calc(var(--sinn-p-i) * var(--sinn-p-reveal-step)) entry calc(100% + var(--sinn-p-i) * var(--sinn-p-reveal-step));
|
|
46
|
+
}
|
|
47
|
+
:where(.sinn-reveal[data-range='late']:not([data-stagger])),
|
|
48
|
+
:where(.sinn-reveal[data-range='late'][data-stagger]) > :where(*) {
|
|
49
|
+
animation-range: cover calc(10% + var(--sinn-p-i) * var(--sinn-p-reveal-step)) cover calc(45% + var(--sinn-p-i) * var(--sinn-p-reveal-step));
|
|
50
|
+
}
|
|
51
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(2)) { --sinn-p-i: 1; }
|
|
52
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(3)) { --sinn-p-i: 2; }
|
|
53
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(4)) { --sinn-p-i: 3; }
|
|
54
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(5)) { --sinn-p-i: 4; }
|
|
55
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(6)) { --sinn-p-i: 5; }
|
|
56
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(7)) { --sinn-p-i: 6; }
|
|
57
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(8)) { --sinn-p-i: 7; }
|
|
58
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(9)) { --sinn-p-i: 8; }
|
|
59
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(10)) { --sinn-p-i: 9; }
|
|
60
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(11)) { --sinn-p-i: 10; }
|
|
61
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(12)) { --sinn-p-i: 11; }
|
|
62
|
+
:where(.sinn-reveal[data-stagger]) > :where(:nth-child(n + 13)) { --sinn-p-i: 12; }
|
|
63
|
+
}
|
|
64
|
+
@media print {
|
|
65
|
+
:where(.sinn-reveal, .sinn-reveal > *) { animation: none !important; }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* ================= Parallax ================= */
|
|
69
|
+
:where(.sinn-parallax) {
|
|
70
|
+
--sinn-p-travel: 20svh;
|
|
71
|
+
position: relative;
|
|
72
|
+
display: grid;
|
|
73
|
+
isolation: isolate;
|
|
74
|
+
overflow: clip;
|
|
75
|
+
view-timeline: --sinn-parallax block;
|
|
76
|
+
}
|
|
77
|
+
:where(.sinn-parallax[data-travel='s']) { --sinn-p-travel: 10svh; }
|
|
78
|
+
:where(.sinn-parallax[data-travel='l']) { --sinn-p-travel: 35svh; }
|
|
79
|
+
:where(.sinn-parallax[data-height='s']) { min-block-size: 40svh; }
|
|
80
|
+
:where(.sinn-parallax[data-height='m']) { min-block-size: 60svh; }
|
|
81
|
+
:where(.sinn-parallax[data-height='l']) { min-block-size: 80svh; }
|
|
82
|
+
:where(.sinn-parallax[data-height='screen']) { min-block-size: 100svh; }
|
|
83
|
+
:where(.sinn-parallax[data-radius='l']) { border-radius: var(--sinn-radius-l); }
|
|
84
|
+
|
|
85
|
+
/* Foreground content sits in normal flow above the layers. */
|
|
86
|
+
:where(.sinn-parallax__content) {
|
|
87
|
+
position: relative;
|
|
88
|
+
z-index: 10;
|
|
89
|
+
grid-area: 1 / 1;
|
|
90
|
+
align-self: center;
|
|
91
|
+
}
|
|
92
|
+
:where(.sinn-parallax__layer) {
|
|
93
|
+
--sinn-p-speed: 0;
|
|
94
|
+
/* Oversize by the farthest the layer can travel, so no edge ever shows. */
|
|
95
|
+
--sinn-p-bleed: calc(max(var(--sinn-p-speed), var(--sinn-p-speed) * -1) * var(--sinn-p-travel));
|
|
96
|
+
position: absolute;
|
|
97
|
+
inset: calc(var(--sinn-p-bleed) * -1) 0;
|
|
98
|
+
z-index: var(--sinn-p-z, 0);
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
will-change: translate;
|
|
101
|
+
}
|
|
102
|
+
:where(.sinn-parallax__layer) > :where(img, picture, video, svg, .sinn-picture) {
|
|
103
|
+
display: block;
|
|
104
|
+
inline-size: 100%;
|
|
105
|
+
block-size: 100%;
|
|
106
|
+
object-fit: cover;
|
|
107
|
+
}
|
|
108
|
+
:where(.sinn-parallax__layer) > :where(.sinn-picture) > :where(img) { inline-size: 100%; block-size: 100%; object-fit: cover; }
|
|
109
|
+
:where(.sinn-parallax__layer[data-speed='-0.5']) { --sinn-p-speed: -0.5; }
|
|
110
|
+
:where(.sinn-parallax__layer[data-speed='-0.25']) { --sinn-p-speed: -0.25; }
|
|
111
|
+
:where(.sinn-parallax__layer[data-speed='0']) { --sinn-p-speed: 0; }
|
|
112
|
+
:where(.sinn-parallax__layer[data-speed='0.25']) { --sinn-p-speed: 0.25; }
|
|
113
|
+
:where(.sinn-parallax__layer[data-speed='0.5']) { --sinn-p-speed: 0.5; }
|
|
114
|
+
:where(.sinn-parallax__layer[data-speed='0.75']) { --sinn-p-speed: 0.75; }
|
|
115
|
+
:where(.sinn-parallax__layer[data-speed='1']) { --sinn-p-speed: 1; }
|
|
116
|
+
:where(.sinn-parallax__layer[data-z='1']) { --sinn-p-z: 1; }
|
|
117
|
+
:where(.sinn-parallax__layer[data-z='2']) { --sinn-p-z: 2; }
|
|
118
|
+
:where(.sinn-parallax__layer[data-z='3']) { --sinn-p-z: 3; }
|
|
119
|
+
:where(.sinn-parallax__layer[data-z='4']) { --sinn-p-z: 4; }
|
|
120
|
+
:where(.sinn-parallax__layer[data-z='5']) { --sinn-p-z: 5; }
|
|
121
|
+
@supports (animation-timeline: view()) {
|
|
122
|
+
:where(.sinn-parallax__layer) {
|
|
123
|
+
animation: sinn-parallax linear both;
|
|
124
|
+
animation-timeline: --sinn-parallax;
|
|
125
|
+
animation-range: cover;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* ================= Marquee ================= */
|
|
130
|
+
:where(.sinn-marquee) {
|
|
131
|
+
--sinn-p-marquee-gap: var(--sinn-space-l);
|
|
132
|
+
--sinn-p-marquee-duration: 40s;
|
|
133
|
+
position: relative;
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
gap: var(--sinn-space-2xs);
|
|
137
|
+
}
|
|
138
|
+
:where(.sinn-marquee[data-gap='s']) { --sinn-p-marquee-gap: var(--sinn-space-s); }
|
|
139
|
+
:where(.sinn-marquee[data-gap='xl']) { --sinn-p-marquee-gap: var(--sinn-space-xl); }
|
|
140
|
+
:where(.sinn-marquee[data-speed='slow']) { --sinn-p-marquee-duration: 70s; }
|
|
141
|
+
:where(.sinn-marquee[data-speed='fast']) { --sinn-p-marquee-duration: 22s; }
|
|
142
|
+
:where(.sinn-marquee__viewport) {
|
|
143
|
+
display: flex;
|
|
144
|
+
overflow: clip;
|
|
145
|
+
}
|
|
146
|
+
:where(.sinn-marquee[data-fade]) :where(.sinn-marquee__viewport) {
|
|
147
|
+
mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
|
|
148
|
+
}
|
|
149
|
+
:where(.sinn-marquee__group) {
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-shrink: 0;
|
|
152
|
+
align-items: center;
|
|
153
|
+
justify-content: space-around;
|
|
154
|
+
gap: var(--sinn-p-marquee-gap);
|
|
155
|
+
/* At least as wide as the viewport, so short content still loops without a hole. */
|
|
156
|
+
min-inline-size: 100%;
|
|
157
|
+
margin: 0;
|
|
158
|
+
/* The trailing gap makes the seam between the two copies identical to the gaps inside. */
|
|
159
|
+
padding: 0 var(--sinn-p-marquee-gap) 0 0;
|
|
160
|
+
list-style: none;
|
|
161
|
+
animation: sinn-marquee var(--sinn-p-marquee-duration) linear infinite;
|
|
162
|
+
}
|
|
163
|
+
:where(.sinn-marquee[data-direction='reverse']) :where(.sinn-marquee__group) { animation-direction: reverse; }
|
|
164
|
+
:where(.sinn-marquee:dir(rtl)) :where(.sinn-marquee__group) { animation-name: sinn-marquee-rtl; padding: 0 0 0 var(--sinn-p-marquee-gap); }
|
|
165
|
+
:where(.sinn-marquee__group) > :where(*) { flex-shrink: 0; }
|
|
166
|
+
:where(.sinn-marquee__group) :where(img, svg) { display: block; block-size: var(--sinn-p-marquee-item-h, 2.5rem); inline-size: auto; }
|
|
167
|
+
/* Hover/focus pause is scoped to the moving content, so the Pause control's own focus
|
|
168
|
+
doesn't mask its state (toggling it while focused must visibly resume/pause). */
|
|
169
|
+
:where(.sinn-marquee[data-pause-on-hover]) > :where(.sinn-marquee__viewport:hover) > :where(.sinn-marquee__group),
|
|
170
|
+
:where(.sinn-marquee__viewport:focus-within) > :where(.sinn-marquee__group),
|
|
171
|
+
:where(.sinn-marquee:has(.sinn-marquee__toggle-input:checked)) :where(.sinn-marquee__group) {
|
|
172
|
+
animation-play-state: paused;
|
|
173
|
+
}
|
|
174
|
+
/* Pause control: a real checkbox ("Pause scrolling", checked = paused), styled as a button. No JS. */
|
|
175
|
+
:where(.sinn-marquee__toggle) {
|
|
176
|
+
position: relative;
|
|
177
|
+
display: inline-flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
align-self: flex-end;
|
|
180
|
+
gap: 0.35em;
|
|
181
|
+
padding: 0.25rem 0.6rem;
|
|
182
|
+
border-radius: var(--sinn-radius-full);
|
|
183
|
+
background-color: var(--sinn-color-neutral-soft);
|
|
184
|
+
color: var(--sinn-color-text);
|
|
185
|
+
font-size: var(--sinn-text-xs);
|
|
186
|
+
font-weight: var(--sinn-weight-semibold);
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
user-select: none;
|
|
189
|
+
}
|
|
190
|
+
:where(.sinn-marquee__toggle:has(:focus-visible)) {
|
|
191
|
+
outline: var(--sinn-focus-width) solid var(--sinn-color-focus);
|
|
192
|
+
outline-offset: var(--sinn-focus-offset);
|
|
193
|
+
}
|
|
194
|
+
:where(.sinn-marquee__toggle-input) {
|
|
195
|
+
position: absolute;
|
|
196
|
+
inset: 0;
|
|
197
|
+
margin: 0;
|
|
198
|
+
opacity: 0;
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
}
|
|
201
|
+
:where(.sinn-marquee__toggle) :where(svg) { inline-size: 0.9em; block-size: 0.9em; }
|
|
202
|
+
:where(.sinn-marquee__icon-play) { display: none; }
|
|
203
|
+
:where(.sinn-marquee__toggle:has(:checked)) :where(.sinn-marquee__icon-play) { display: inline; }
|
|
204
|
+
:where(.sinn-marquee__toggle:has(:checked)) :where(.sinn-marquee__icon-pause) { display: none; }
|
|
205
|
+
|
|
206
|
+
/* ================= ScrollScene ================= */
|
|
207
|
+
:where(.sinn-scene) {
|
|
208
|
+
--sinn-p-scene-length: 0svh;
|
|
209
|
+
position: relative;
|
|
210
|
+
}
|
|
211
|
+
:where(.sinn-scene[data-scene-length='50']) { --sinn-p-scene-length: 50svh; }
|
|
212
|
+
:where(.sinn-scene[data-scene-length='100']) { --sinn-p-scene-length: 100svh; }
|
|
213
|
+
:where(.sinn-scene[data-scene-length='150']) { --sinn-p-scene-length: 150svh; }
|
|
214
|
+
:where(.sinn-scene[data-scene-length='200']) { --sinn-p-scene-length: 200svh; }
|
|
215
|
+
:where(.sinn-scene[data-scene-length='250']) { --sinn-p-scene-length: 250svh; }
|
|
216
|
+
:where(.sinn-scene[data-scene-length='300']) { --sinn-p-scene-length: 300svh; }
|
|
217
|
+
:where(.sinn-scene[data-scene-length='400']) { --sinn-p-scene-length: 400svh; }
|
|
218
|
+
:where(.sinn-scene[data-scene-length='500']) { --sinn-p-scene-length: 500svh; }
|
|
219
|
+
/*
|
|
220
|
+
* Pinning is CSS: the section reserves its whole scroll length up front (100svh + length)
|
|
221
|
+
* and the stage is position: sticky inside it. No pin spacer is inserted when the scene
|
|
222
|
+
* loads (CLS 0), it works with smooth scrolling, and without JS the stage still pins and
|
|
223
|
+
* shows its final, readable state.
|
|
224
|
+
*/
|
|
225
|
+
:where(.sinn-scene[data-scene-pin]) {
|
|
226
|
+
block-size: calc(100svh + var(--sinn-p-scene-length) * var(--sinn-motion-scale, 1));
|
|
227
|
+
}
|
|
228
|
+
:where(.sinn-scene[data-scene-pin]) > :where(.sinn-scene__stage) {
|
|
229
|
+
position: sticky;
|
|
230
|
+
inset-block-start: 0;
|
|
231
|
+
block-size: 100svh;
|
|
232
|
+
overflow: clip;
|
|
233
|
+
}
|
|
234
|
+
:where(.sinn-scene__stage) {
|
|
235
|
+
display: grid;
|
|
236
|
+
box-sizing: border-box;
|
|
237
|
+
}
|
|
238
|
+
:where(.sinn-scene[data-scene-align='center']) > :where(.sinn-scene__stage) { place-items: center; }
|
|
239
|
+
|
|
240
|
+
@media (prefers-reduced-motion: reduce) {
|
|
241
|
+
:where(:root:not([data-motion='full'])) :where(.sinn-scene[data-scene-pin]) { block-size: auto; }
|
|
242
|
+
:where(:root:not([data-motion='full'])) :where(.sinn-scene[data-scene-pin]) > :where(.sinn-scene__stage) {
|
|
243
|
+
position: relative;
|
|
244
|
+
block-size: auto;
|
|
245
|
+
min-block-size: 100svh;
|
|
246
|
+
overflow: visible;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
:where(:root[data-motion='reduce']) :where(.sinn-scene[data-scene-pin]) { block-size: auto; }
|
|
250
|
+
:where(:root[data-motion='reduce']) :where(.sinn-scene[data-scene-pin]) > :where(.sinn-scene__stage) {
|
|
251
|
+
position: relative;
|
|
252
|
+
block-size: auto;
|
|
253
|
+
min-block-size: 100svh;
|
|
254
|
+
overflow: visible;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* ================= Marquee: reduced motion ================= */
|
|
258
|
+
|
|
259
|
+
@media (prefers-reduced-motion: reduce) {
|
|
260
|
+
:where(:root:not([data-motion='full'])) :where(.sinn-marquee__group) { animation: none; flex: 1 1 100%; min-inline-size: 0; flex-wrap: wrap; justify-content: center; padding: 0; row-gap: var(--sinn-space-s); }
|
|
261
|
+
:where(:root:not([data-motion='full'])) :where(.sinn-marquee__group[aria-hidden='true']) { display: none; }
|
|
262
|
+
:where(:root:not([data-motion='full'])) :where(.sinn-marquee__viewport) { mask-image: none; }
|
|
263
|
+
:where(:root:not([data-motion='full'])) :where(.sinn-marquee__toggle) { display: none; }
|
|
264
|
+
}
|
|
265
|
+
:where(:root[data-motion='reduce']) :where(.sinn-marquee__group) { animation: none; flex: 1 1 100%; min-inline-size: 0; flex-wrap: wrap; justify-content: center; padding: 0; row-gap: var(--sinn-space-s); }
|
|
266
|
+
:where(:root[data-motion='reduce']) :where(.sinn-marquee__group[aria-hidden='true']) { display: none; }
|
|
267
|
+
:where(:root[data-motion='reduce']) :where(.sinn-marquee__viewport) { mask-image: none; }
|
|
268
|
+
:where(:root[data-motion='reduce']) :where(.sinn-marquee__toggle) { display: none; }
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* Keyframes are global. Distances are multiplied by --sinn-motion-scale (custom properties
|
|
272
|
+
in keyframes resolve per element), so reduced motion yields no movement. */
|
|
273
|
+
@keyframes sinn-reveal {
|
|
274
|
+
from {
|
|
275
|
+
opacity: calc(var(--sinn-p-reveal-opacity) + (1 - var(--sinn-p-reveal-opacity)) * (1 - var(--sinn-motion-scale, 1)));
|
|
276
|
+
translate: calc(var(--sinn-p-reveal-x) * var(--sinn-motion-scale, 1)) calc(var(--sinn-p-reveal-y) * var(--sinn-motion-scale, 1));
|
|
277
|
+
scale: calc(1 - (1 - var(--sinn-p-reveal-scale)) * var(--sinn-motion-scale, 1));
|
|
278
|
+
filter: blur(calc(var(--sinn-p-reveal-blur) * var(--sinn-motion-scale, 1)));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
@keyframes sinn-parallax {
|
|
282
|
+
from { translate: 0 calc(var(--sinn-p-speed) * var(--sinn-p-travel) * -1 * var(--sinn-motion-scale, 1)); }
|
|
283
|
+
to { translate: 0 calc(var(--sinn-p-speed) * var(--sinn-p-travel) * var(--sinn-motion-scale, 1)); }
|
|
284
|
+
}
|
|
285
|
+
@keyframes sinn-marquee { to { translate: -100% 0; } }
|
|
286
|
+
@keyframes sinn-marquee-rtl { to { translate: 100% 0; } }
|
|
287
|
+
|
|
288
|
+
/* ================= Page transitions =================
|
|
289
|
+
* Unlayered on purpose: it must win over the browser's default root crossfade and any
|
|
290
|
+
* framework layer. Active preset comes from <html data-page-transition>; direction from
|
|
291
|
+
* Astro's <html data-astro-transition="forward|back">.
|
|
292
|
+
*/
|
|
293
|
+
@keyframes sinn-vt-fade-in { from { opacity: 0; } }
|
|
294
|
+
@keyframes sinn-vt-fade-out { to { opacity: 0; } }
|
|
295
|
+
@keyframes sinn-vt-slide-from-end { from { opacity: 0; translate: 2.5rem 0; } }
|
|
296
|
+
@keyframes sinn-vt-slide-to-start { to { opacity: 0; translate: -2.5rem 0; } }
|
|
297
|
+
@keyframes sinn-vt-slide-from-start { from { opacity: 0; translate: -2.5rem 0; } }
|
|
298
|
+
@keyframes sinn-vt-slide-to-end { to { opacity: 0; translate: 2.5rem 0; } }
|
|
299
|
+
@keyframes sinn-vt-rise-in { from { opacity: 0; translate: 0 1rem; } }
|
|
300
|
+
|
|
301
|
+
:root[data-page-transition='fade']::view-transition-old(root) { animation: 160ms cubic-bezier(0.4, 0, 1, 1) both sinn-vt-fade-out; }
|
|
302
|
+
:root[data-page-transition='fade']::view-transition-new(root) { animation: 220ms cubic-bezier(0, 0, 0.2, 1) 60ms both sinn-vt-fade-in; }
|
|
303
|
+
|
|
304
|
+
:root[data-page-transition='slide']::view-transition-old(root) { animation: 180ms cubic-bezier(0.4, 0, 1, 1) both sinn-vt-slide-to-start; }
|
|
305
|
+
:root[data-page-transition='slide']::view-transition-new(root) { animation: 260ms cubic-bezier(0, 0, 0.2, 1) 60ms both sinn-vt-slide-from-end; }
|
|
306
|
+
:root[data-page-transition='slide'][data-astro-transition='back']::view-transition-old(root) { animation-name: sinn-vt-slide-to-end; }
|
|
307
|
+
:root[data-page-transition='slide'][data-astro-transition='back']::view-transition-new(root) { animation-name: sinn-vt-slide-from-start; }
|
|
308
|
+
:root[data-page-transition='slide']:dir(rtl)::view-transition-old(root) { animation-name: sinn-vt-slide-to-end; }
|
|
309
|
+
:root[data-page-transition='slide']:dir(rtl)::view-transition-new(root) { animation-name: sinn-vt-slide-from-start; }
|
|
310
|
+
|
|
311
|
+
:root[data-page-transition='rise']::view-transition-old(root) { animation: 160ms cubic-bezier(0.4, 0, 1, 1) both sinn-vt-fade-out; }
|
|
312
|
+
:root[data-page-transition='rise']::view-transition-new(root) { animation: 280ms cubic-bezier(0, 0, 0.2, 1) 40ms both sinn-vt-rise-in; }
|
|
313
|
+
|
|
314
|
+
:root[data-page-transition='none']::view-transition-old(root),
|
|
315
|
+
:root[data-page-transition='none']::view-transition-new(root) { animation: none; }
|
|
316
|
+
|
|
317
|
+
/* Reduced motion (OS, or the site override): no page animation at all. */
|
|
318
|
+
@media (prefers-reduced-motion: reduce) {
|
|
319
|
+
:root:not([data-motion='full'])::view-transition-group(*),
|
|
320
|
+
:root:not([data-motion='full'])::view-transition-old(*),
|
|
321
|
+
:root:not([data-motion='full'])::view-transition-new(*) { animation: none !important; }
|
|
322
|
+
}
|
|
323
|
+
:root[data-motion='reduce']::view-transition-group(*),
|
|
324
|
+
:root[data-motion='reduce']::view-transition-old(*),
|
|
325
|
+
:root[data-motion='reduce']::view-transition-new(*) { animation: none !important; }
|
|
326
|
+
|
|
327
|
+
/* ================= Lenis smooth scrolling (required by Lenis) ================= */
|
|
328
|
+
html.lenis, html.lenis body { block-size: auto; }
|
|
329
|
+
.lenis.lenis-smooth { scroll-behavior: auto !important; }
|
|
330
|
+
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
|
|
331
|
+
.lenis.lenis-stopped { overflow: clip; }
|
|
332
|
+
.lenis.lenis-smooth iframe { pointer-events: none; }
|