@shavin/skills 0.0.0-stage → 0.1.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 (80) hide show
  1. package/AGENTS.md +193 -0
  2. package/CHANGELOG.md +27 -0
  3. package/LICENSE +21 -0
  4. package/README.md +48 -2
  5. package/bin/hex-policy.mjs +157 -0
  6. package/bin/install.mjs +219 -0
  7. package/bin/lint-tokens.mjs +178 -0
  8. package/build.mjs +540 -0
  9. package/commands/add-composition.md +14 -0
  10. package/commands/apply-theme.md +59 -0
  11. package/commands/audit-layout.md +15 -0
  12. package/commands/audit-ui.md +42 -0
  13. package/commands/compose-page.md +16 -0
  14. package/commands/create-block.md +79 -0
  15. package/commands/create-primitive.md +40 -0
  16. package/commands/create-screen.md +45 -0
  17. package/commands/create-theme.md +41 -0
  18. package/cursor/shavin.mdc +14 -0
  19. package/package.json +66 -4
  20. package/posix-path.mjs +7 -0
  21. package/skills/core-rules.md +294 -0
  22. package/skills/layout-choreography/SKILL.md +102 -0
  23. package/skills/layout-choreography/references/fallbacks-and-accessibility.md +76 -0
  24. package/skills/layout-choreography/references/scenes.md +113 -0
  25. package/skills/layout-choreography/references/shavin-timelines.md +100 -0
  26. package/skills/layout-choreography/references/tech-and-performance.md +147 -0
  27. package/skills/layout-compositions/SKILL.md +149 -0
  28. package/skills/layout-compositions/references/adapters/shavin-ui.md +122 -0
  29. package/skills/layout-compositions/references/adapters/tailwind-html.md +100 -0
  30. package/skills/layout-compositions/references/component-language.md +105 -0
  31. package/skills/layout-compositions/references/compositions/conversion.md +286 -0
  32. package/skills/layout-compositions/references/compositions/documentation.md +125 -0
  33. package/skills/layout-compositions/references/compositions/editorial.md +126 -0
  34. package/skills/layout-compositions/references/compositions/expressive.md +151 -0
  35. package/skills/layout-compositions/references/compositions/features.md +262 -0
  36. package/skills/layout-compositions/references/compositions/gallery.md +172 -0
  37. package/skills/layout-compositions/references/compositions/hero.md +184 -0
  38. package/skills/layout-compositions/references/compositions/proof.md +194 -0
  39. package/skills/layout-compositions/references/compositions/structural.md +173 -0
  40. package/skills/layout-compositions/references/distinctiveness.md +65 -0
  41. package/skills/layout-compositions/references/foundations.md +119 -0
  42. package/skills/layout-compositions/references/metadata-schema.md +64 -0
  43. package/skills/layout-compositions/references/page-recipes.md +143 -0
  44. package/skills/layout-compositions/references/selection-guide.md +207 -0
  45. package/skills/layout-compositions/references/treatments.md +60 -0
  46. package/skills/layout-compositions/references/unsection-source-examples.md +92 -0
  47. package/skills/layout-compositions/references/visual-review.md +40 -0
  48. package/skills/layout-compositions/scripts/render_wireframes.py +138 -0
  49. package/skills/layout-compositions/scripts/validate_library.py +165 -0
  50. package/skills/layout-motion/SKILL.md +83 -0
  51. package/skills/layout-motion/references/composition-motion-map.md +69 -0
  52. package/skills/layout-motion/references/presets.md +209 -0
  53. package/skills/layout-motion/references/tokens.md +100 -0
  54. package/skills/shavin-app/SKILL.md +242 -0
  55. package/skills/shavin-app/patterns.md +35 -0
  56. package/skills/shavin-studio/SKILL.md +97 -0
  57. package/skills/shavin-webpage/SKILL.md +210 -0
  58. package/skills/shavin-webpage/editorial-craft.md +117 -0
  59. package/skills/shavin-webpage/page-architecture.md +137 -0
  60. package/skills/shavin-webpage/style-recipes.md +107 -0
  61. package/skills/visual-compositor/SKILL.md +200 -0
  62. package/skills/visual-compositor/anti-patterns.md +109 -0
  63. package/skills/visual-compositor/audit-checklist.md +162 -0
  64. package/skills/visual-compositor/cognitive-layer.md +287 -0
  65. package/skills/visual-compositor/composition-motion-map.md +167 -0
  66. package/skills/visual-compositor/concentric-laws.md +147 -0
  67. package/skills/visual-compositor/docs-mode.md +32 -0
  68. package/skills/visual-compositor/editorial-mode.md +48 -0
  69. package/skills/visual-compositor/font-pairings.md +224 -0
  70. package/skills/visual-compositor/graphics-and-assets.md +128 -0
  71. package/skills/visual-compositor/interface-polish.md +125 -0
  72. package/skills/visual-compositor/layout-restraint.md +80 -0
  73. package/skills/visual-compositor/motion-and-physics.md +257 -0
  74. package/skills/visual-compositor/page-motion-presets.md +246 -0
  75. package/skills/visual-compositor/references/EDITORIAL_EXPRESSIVE.md +163 -0
  76. package/skills/visual-compositor/spacing-core.md +386 -0
  77. package/skills/visual-compositor/spacing-dense.md +63 -0
  78. package/skills/visual-compositor/spacing-marketing.md +192 -0
  79. package/skills/visual-compositor/typography-rules.md +114 -0
  80. package/token-budget.json +86 -0
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: layout-choreography
3
+ description: >
4
+ Scene-based, awwwards-style choreographed motion for web pages (Tier 2) — pinned
5
+ scrollytelling, scroll-scrubbed timelines, horizontal-scroll sections, split-text and mask
6
+ reveals, stacked-card scenes, cursor-follow and magnetic effects, page and shared-element
7
+ transitions, preloader/intro sequences, WebGL/canvas heroes, smooth-scroll integration —
8
+ specified as scenes with triggers, timelines, fallbacks and performance budgets, built with
9
+ GSAP/ScrollTrigger, Lenis, CSS scroll-driven animations, View Transitions or three.js. Use
10
+ whenever the user asks for awwards-style, cinematic, immersive, scroll-driven, scrollytelling,
11
+ "fancy", GSAP, Lenis, pinned, parallax-heavy or timeline-based animation, or wants a signature
12
+ motion moment on a hero, portfolio or story page. Requires a finished static layout first
13
+ (layout-compositions); for simple reveals, hovers and count-ups use layout-motion instead.
14
+ sections:
15
+ - id: scenes
16
+ file: references/scenes.md
17
+ description: "12 scene recipes mapped to compositions — pinned scrollytelling, scroll-scrubbed timelines, horizontal scroll, split-text, stacked cards, cursor effects, page transitions, preloader, WebGL hero (~2.5K tokens)"
18
+ - id: tech-and-performance
19
+ file: references/tech-and-performance.md
20
+ description: "Stack choices, code patterns, budgets, cleanup — CSS scroll-driven, GSAP+ScrollTrigger, Lenis, Motion, View Transitions, three.js (~2K tokens)"
21
+ - id: fallbacks-and-accessibility
22
+ file: references/fallbacks-and-accessibility.md
23
+ description: "Reduced motion, keyboard, focus, scroll-jacking rules, test matrix (~1.5K tokens)"
24
+ - id: shavin-timelines
25
+ file: references/shavin-timelines.md
26
+ description: "Native sequenced motion via data-motion-tl-* — zero-setup load/scroll/click timelines the Studio Timelines tab emits; prefer over hand-rolled GSAP for sequenced reveals (~1.5K tokens)"
27
+ ---
28
+
29
+ - **Token-efficient usage:** This skill is modular. For specific rules, call:
30
+ > - `get_skill({ name: "layout-choreography", section: "scenes" })` — 12 scene recipes
31
+ > - `get_skill({ name: "layout-choreography", section: "tech-and-performance" })` — stack choices and budgets
32
+ > - `get_skill({ name: "layout-choreography", section: "fallbacks-and-accessibility" })` — accessibility and fallback rules
33
+ > - `get_skill({ name: "layout-choreography", section: "shavin-timelines" })` — native `data-motion-tl-*` sequenced motion (zero-setup; prefer for load/scroll/click sequences)
34
+ >
35
+ > **This is the cinematic brain partner.** It is deliberately separate from standard composition
36
+ > guidelines (`layout-compositions`) and restrained motion (`layout-motion`). It only activates
37
+ > when the brief asks for scroll-linked, pinned, or timeline-driven motion.
38
+ >
39
+ > **Motion tokens:** Already defined in `@shavin/ui` `global.css` (`--dur-*`, `--dist-*`, `--stagger`).
40
+ > See `visual-compositor/motion-and-physics.md` for the canonical reference.
41
+
42
+ # Layout Choreography (Tier 2)
43
+
44
+ Choreography is motion as **composition over time**. Where a layout arranges a section in space, a scene arranges elements in time, often tied to scroll position. It is a separate discipline from layout because its unit is the **scene** (a trigger, a timeline, a length of scroll), its failures are different (jank, scroll-jacking, inaccessibility), and its cost is much higher (JS weight, testing, fallbacks).
45
+
46
+ ## Preconditions
47
+
48
+ 1. **A finished static layout exists** (Tier 0) built from `layout-compositions`, with `data-slot` attributes on the parts that will move. A scene targets slots and never restructures the layout.
49
+ 2. **The composition allows it.** Its metadata says `motion: choreography-ok`. If it says `tier0` or `tier1`, use `layout-motion` or leave it static, or discuss changing the composition.
50
+ 3. **There is a reason.** Choreography earns its cost when motion explains, guides or creates a memorable moment. It does not earn it as decoration. For award-level or brand-led briefs, one signature scene is expected, not optional: plan it with the page, not after.
51
+
52
+ If the static layout is missing, build that first.
53
+
54
+ ## Scene budget
55
+
56
+ Per page: **one signature scene** (the memorable moment) and at most **two supporting scenes**. Everything else stays at Tier 0 or Tier 1. A page where every section is choreographed is exhausting, slow, and hard to make accessible.
57
+
58
+ ## Workflow
59
+
60
+ 1. **Clarify** with the user, briefly: which single moment matters most; target devices and performance floor; the stack (React? existing GSAP or Lenis?); brand tone (restrained, playful, cinematic); any license constraints on libraries.
61
+ 2. **Choose scenes** from `references/scenes.md` (12 scene recipes, each mapped to compositions).
62
+ 3. **Write a scene spec** for each, using the template below, and show it before coding. The spec forces the fallback and budget decisions early.
63
+ 4. **Choose the tech** with `references/tech-and-performance.md`. Prefer the lightest tool that does the job: CSS first, then a small library, then a full timeline library.
64
+ 5. **Implement** as isolated modules: one init function and one teardown per scene; every scene wrapped in a `matchMedia` branch that handles reduced motion and small screens.
65
+ 6. **Verify** with the checks in `references/fallbacks-and-accessibility.md` and the performance budgets in `references/tech-and-performance.md`.
66
+
67
+ ## Scene spec template
68
+
69
+ Copy this into the response (or a `scenes/<name>.md` file) and fill every field. A blank field means the decision hasn't been made.
70
+
71
+ ```markdown
72
+ ### Scene: <name>
73
+ - **Targets:** composition ID(s) and the slots animated (e.g. H5: headline lines, sub, cta)
74
+ - **Goal:** one sentence: what should the viewer understand or feel?
75
+ - **Trigger:** load | in-view | scroll-scrub | pointer | route change
76
+ - **Scroll length:** pin/scrub duration in viewport heights (scroll scenes), or total duration in ms
77
+ - **Timeline:** beats table (time or scroll progress → slot → property → ease)
78
+ - **Tech:** CSS scroll-driven | GSAP+ScrollTrigger | Lenis | Motion | View Transitions | WebGL (+ why)
79
+ - **Static baseline:** what Tier 0 shows (must be complete and correct on its own)
80
+ - **Reduced motion:** what happens (usually: final state, no movement)
81
+ - **Mobile / short viewport:** what happens (usually: simplified or static)
82
+ - **Budget:** JS added (kB), max long task, target frame rate, assets
83
+ - **Accessibility:** keyboard, focus, screen-reader order, anchors, find-in-page
84
+ - **Teardown:** how listeners, triggers, and tickers are cleaned up
85
+ ```
86
+
87
+ ## Rules that keep it good
88
+
89
+ - **Scroll belongs to the user.** Don't change scroll speed, direction or position in ways that trap them. If a smooth-scroll library is used, it is disabled under reduced motion and never blocks keyboard, anchors, or find-in-page.
90
+ - **Pin lengths are bounded.** Each pinned scene ≤ ~3–4 viewport heights; total choreographed scroll stays a small fraction of the page.
91
+ - **Static first.** Every scene has a complete non-animated state; reduced motion and no-JS users get it.
92
+ - **Load lazily.** Animation libraries load after first paint, or only when the scene is near the viewport.
93
+ - **Refresh after layout changes.** Fonts, images and route changes shift positions: refresh triggers when they settle.
94
+ - **Test on the floor device.** Mid-range Android and a 4× CPU throttle, not just a fast laptop.
95
+
96
+ ## Reference map
97
+
98
+ | Need | Read |
99
+ |---|---|
100
+ | Scene recipes and which compositions they fit | `references/scenes.md` |
101
+ | Stack choices, code patterns, budgets, cleanup | `references/tech-and-performance.md` |
102
+ | Reduced motion, keyboard, focus, scroll-jacking rules, test matrix | `references/fallbacks-and-accessibility.md` |
@@ -0,0 +1,76 @@
1
+ # Fallbacks and accessibility for choreographed scenes
2
+
3
+ Choreography fails people in specific ways: trapped scrolling, hidden content, dizziness, lost focus. Every scene needs answers to the questions below before it ships.
4
+
5
+ Contents: 1 The static baseline contract · 2 Reduced motion · 3 Scroll ownership · 4 Keyboard, focus and anchors · 5 Screen readers and content order · 6 Flashing and vestibular safety · 7 Small screens and short viewports · 8 Test matrix
6
+
7
+ ---
8
+
9
+ ## 1. The static baseline contract
10
+
11
+ - With JS disabled, with the animation library failing to load, and with reduced motion on, the page shows every piece of content in a sensible, complete layout.
12
+ - Never start content hidden in CSS and rely on JS to reveal it, unless the hiding rule is scoped to a class added by the same script that will reveal it and only when motion is allowed.
13
+ - Text, links and CTAs live in the DOM as real elements, never only inside a canvas or image.
14
+
15
+ ## 2. Reduced motion
16
+
17
+ `prefers-reduced-motion: reduce` means the scene resolves to its **final state** immediately: no movement, no scrubbing, no parallax, no autoplaying loops, no smooth-scroll library. Crossfades of short duration can remain if they are not spatial. Provide an in-page motion toggle when the site is animation-heavy.
18
+
19
+ ## 3. Scroll ownership
20
+
21
+ - Don't change scroll speed or direction except through a smooth-scroll library that is off under reduced motion.
22
+ - A pinned or scrubbed section always releases: the user can reach the content after it by continuing to scroll normally.
23
+ - Horizontal-by-vertical scenes keep a native alternative and never capture scroll at the ends.
24
+ - Total choreographed scroll length stays a small part of the page. Each pinned scene ≲ 3–4 viewport heights.
25
+ - Back/forward navigation restores scroll position sensibly.
26
+
27
+ ## 4. Keyboard, focus and anchors
28
+
29
+ - Tab reaches every interactive element inside pinned/scrubbed scenes; focusing an element scrolls it into view and the scene updates coherently.
30
+ - Space, PageUp/PageDown, Home/End and arrow keys work as normal.
31
+ - Anchor links land on the right position despite pin spacers (offset for header height; refresh triggers).
32
+ - Browser find-in-page can find text that is currently offscreen or in an inactive step.
33
+ - `:focus-visible` remains visible over media, masks and overlays.
34
+ - Page transitions move focus to the new page's `<h1>` (or a labelled main region) and announce the route change if the framework doesn't.
35
+
36
+ ## 5. Screen readers and content order
37
+
38
+ - DOM order equals reading order; visual choreography never reorders it.
39
+ - Split-text animation keeps the sentence intact for assistive tech: `aria-label` on the container and `aria-hidden="true"` on split spans (or visually-hidden real text plus hidden animated copy).
40
+ - Decorative motion elements are `aria-hidden`. Meaningful content isn't hidden by an animation state (`visibility: hidden` or `inert` must be undone when it becomes relevant).
41
+ - Progress indicators that convey position have text or ARIA equivalents.
42
+
43
+ ## 6. Flashing and vestibular safety
44
+
45
+ - Nothing flashes more than three times per second (WCAG 2.3.1).
46
+ - Avoid large-area parallax at different speeds, big zooms and spinning full-screen motion; these trigger vestibular symptoms. Keep travel modest, or off under reduced motion.
47
+ - Video or canvas backgrounds that run longer than 5 seconds offer a pause control (WCAG 2.2.2).
48
+
49
+ ## 6b. Battery and data
50
+
51
+ Lazy-load heavy scenes, respect `prefers-reduced-data` where supported, and fall back to posters on save-data connections or low-power modes when detectable.
52
+
53
+ ## 7. Small screens and short viewports
54
+
55
+ - Pinning and scrubbing require adequate size: enable only for `min-width: 1024px` and `min-height: 600px` (tune per scene).
56
+ - Below that, the scene becomes the static baseline or a lighter reveal.
57
+ - Test at 200% zoom and with large text sizes: pinned blocks that no longer fit must unpin.
58
+ - Touch devices don't get hover-only or cursor-follow behaviour.
59
+
60
+ ## 8. Test matrix
61
+
62
+ Run each scene through these before delivery, and record results in the scene spec.
63
+
64
+ | Condition | Expected |
65
+ |---|---|
66
+ | JS disabled | Full static page, no missing content |
67
+ | Animation library blocked | Same as above |
68
+ | Reduced motion on | Final state, no movement |
69
+ | Keyboard only | Every control reachable; scene stays coherent |
70
+ | Screen reader pass | Correct reading order; no repeated/hidden text noise |
71
+ | 200% zoom / short viewport (≈ 600px tall) | Pins release; nothing clipped |
72
+ | Phone (360–430px), mid-range device | Simplified or static; smooth |
73
+ | 4× CPU throttle | No long tasks during scroll; no visible jank |
74
+ | Slow 4G | Static content usable before animation code arrives |
75
+ | Back button and reload mid-scene | Scroll restored; scene state correct |
76
+ | Font load delay | Text splits and pin lengths recalculated correctly |
@@ -0,0 +1,113 @@
1
+ # Scene recipes
2
+
3
+ Twelve recurring choreography scenes. Each names the compositions it fits, what the static baseline must already provide, the trigger and beats, and the main risk. Use them as starting specs (see the template in `SKILL.md`), then tune for the brief.
4
+
5
+ Compositions must allow choreography (`motion: choreography-ok`). Those currently: H3, H4, H5, F6, X1, X2, X3, X4, X5. Other compositions can adopt a scene only after their metadata is changed deliberately.
6
+
7
+ Contents: 1 Hero intro · 2 Split-text reveal · 3 Pinned scrollytelling · 4 Horizontal scroll section · 5 Stacked cards · 6 Mask / clip reveal · 7 Frame-sequence scrub · 8 Scroll-velocity marquee · 9 Cursor-follow and magnetic · 10 Page and shared-element transitions · 11 Preloader / intro gate · 12 WebGL hero
8
+
9
+ ---
10
+
11
+ ## 1. Hero intro
12
+
13
+ - **Fits:** H3, H4, H5 (slots: overline (optional), headline, sub, cta, visual)
14
+ - **Trigger:** load (after fonts and the LCP image are ready)
15
+ - **Beats:** headline lines rise/unmask (0–600ms, staggered 70ms) → sub fades (300–700ms) → CTA (450–850ms) → visual settles (0–900ms, transform only). Total ≤ 1.2s.
16
+ - **Static baseline:** everything visible and in place.
17
+ - **Risk:** hiding the LCP element delays LCP. Animate transforms and masks, not the LCP element's opacity from 0. Skip or shorten on repeat visits.
18
+
19
+ ## 2. Split-text reveal
20
+
21
+ - **Fits:** H5, X2 (slots: headline, line)
22
+ - **Trigger:** load or in-view
23
+ - **Beats:** split into lines (not letters) inside overflow-hidden wrappers; each line translates up from 100% (staggered 60–90ms). Words only for very short text.
24
+ - **Static baseline:** the real, unsplit text.
25
+ - **Risk:** splitting before fonts load breaks line detection: wait for `document.fonts.ready`, and re-split on resize. Keep the original sentence readable by assistive tech (`aria-label` on the container, `aria-hidden` on split spans).
26
+
27
+ ## 3. Pinned scrollytelling
28
+
29
+ - **Fits:** F6, X3 (slots: step-title, step-desc, pinned-visual / pinned, scroller)
30
+ - **Trigger:** scroll-scrub
31
+ - **Length:** 3–4 viewports max per scene.
32
+ - **Beats:** pin the visual; progress 0→1 across N steps; each step crossfades/morphs the visual to its state and highlights its text. Progress markers optional.
33
+ - **Static baseline:** F6/X3 as laid out: steps stacked with each state's visual visible.
34
+ - **Mobile:** no pin; steps become a plain stack.
35
+ - **Risk:** pinned content taller than the viewport at zoom or short heights. Only pin when height ≥ 600px and width ≥ 1024px.
36
+
37
+ ## 4. Horizontal scroll section
38
+
39
+ - **Fits:** X4 (slots: track, card, caption, progress)
40
+ - **Trigger:** scroll-scrub with pin
41
+ - **Length:** track overflow width, capped at ~3 viewports of scroll.
42
+ - **Beats:** pin the section; translate the track on X by scroll progress; progress bar tracks it; cards may scale/parallax lightly.
43
+ - **Static baseline:** the native horizontal scroller from X4, which already works with trackpad, touch and keyboard.
44
+ - **Mobile:** keep the native scroller.
45
+ - **Risk:** classic scroll-jacking. Never trap vertical scroll: the pin releases at the end, and Tab/arrow keys still reach every card.
46
+
47
+ ## 5. Stacked cards
48
+
49
+ - **Fits:** F6, X3, or a card list in an X* section
50
+ - **Trigger:** scroll-scrub
51
+ - **Beats:** each card is `position: sticky` at a staggered `top`; as the next card arrives, the previous scales to ~0.94 and dims slightly.
52
+ - **Static baseline:** a normal vertical list.
53
+ - **Tech:** sticky + CSS scroll-driven animation where supported (progressive enhancement) or a light ScrollTrigger.
54
+ - **Risk:** sticky broken by an ancestor's `overflow`.
55
+
56
+ ## 6. Mask / clip reveal
57
+
58
+ - **Fits:** H3, X1 (slots: visual, primary)
59
+ - **Trigger:** in-view
60
+ - **Beats:** the frame opens via `clip-path: inset()` (600–900ms, `--ease-out`) while the inner image scales from 1.15 to 1.
61
+ - **Static baseline:** image fully visible.
62
+ - **Risk:** large clip-path animations can be costly on big images: test with CPU throttling; keep image dimensions sensible.
63
+
64
+ ## 7. Frame-sequence scrub
65
+
66
+ - **Fits:** H4 (slots: background, scroll-cue)
67
+ - **Trigger:** scroll-scrub
68
+ - **Beats:** a canvas draws pre-rendered frames tied to scroll progress.
69
+ - **Static baseline:** poster image plus short text.
70
+ - **Budget:** very heavy. Cap frame count and resolution, load progressively, don't start until the section is near the viewport. Use only for a product reveal that genuinely needs it.
71
+ - **Risk:** memory and bandwidth. Provide a low-data fallback (poster only).
72
+
73
+ ## 8. Scroll-velocity marquee
74
+
75
+ - **Fits:** X2 (type marquee), or a marquee strip in an X* section
76
+ - **Trigger:** scroll (speed and direction modulated by scroll velocity)
77
+ - **Beats:** base drift plus velocity-based boost; direction flips with scroll direction.
78
+ - **Static baseline:** the static wrapped text or logo grid.
79
+ - **Risk:** must still be pausable and stop under reduced motion (WCAG 2.2.2).
80
+
81
+ ## 9. Cursor-follow and magnetic
82
+
83
+ - **Fits:** X5 (preview follows the pointer), buttons in H3/H5
84
+ - **Trigger:** pointer (fine pointers only: `(hover: hover) and (pointer: fine)`)
85
+ - **Beats:** target eases toward the pointer using a lerp (factor ~0.15); magnetic buttons pull ≤ 8–12px.
86
+ - **Static baseline:** fixed-position preview on hover *and* focus; normal buttons.
87
+ - **Risk:** input lag and covering text. Never rely on it for meaning; keyboard users get the same information.
88
+
89
+ ## 10. Page and shared-element transitions
90
+
91
+ - **Fits:** X5 → detail pages, G4 → case studies (with X* styling)
92
+ - **Trigger:** route change
93
+ - **Beats:** outgoing content fades/slides ≤ 250ms; a shared element (thumbnail) morphs into the destination's hero; incoming content rises.
94
+ - **Tech:** View Transitions API where supported (progressive enhancement), or router-level transitions.
95
+ - **Static baseline:** instant navigation with no animation.
96
+ - **Risk:** focus and scroll position. Move focus to the new page's `<h1>`, restore scroll on back, and never delay navigation beyond ~300ms.
97
+
98
+ ## 11. Preloader / intro gate
99
+
100
+ - **Fits:** H4, H5
101
+ - **Trigger:** first visit only
102
+ - **Beats:** short branded sequence (≤ 1.5s) that overlaps real loading; skip on repeat visits (remembered per viewer) and under reduced motion.
103
+ - **Static baseline:** the page itself, immediately.
104
+ - **Risk:** blocking content, harming LCP, frustrating repeat visitors. If the page is ready earlier than the sequence, cut it short.
105
+
106
+ ## 12. WebGL hero
107
+
108
+ - **Fits:** H4
109
+ - **Trigger:** load (lazy, after first paint), pointer or scroll
110
+ - **Beats:** a shader/3D scene reacts subtly to the pointer or scroll; idle state is calm.
111
+ - **Static baseline:** a poster image with the real text and CTA in the DOM.
112
+ - **Budget:** lazy-load the 3D library, cap device pixel ratio at 2, pause when offscreen or the tab is hidden, cap frame work.
113
+ - **Risk:** battery, thermal throttling, old devices. Detect capability and fall back to the poster. Text and CTA are never drawn in the canvas.
@@ -0,0 +1,100 @@
1
+ # Shavin Timelines — native sequenced motion (`data-motion-tl-*`)
2
+
3
+ For **sequenced, multi-element choreography** (hero load sequences, scroll-scrubbed reveals, click-to-play
4
+ sequences), prefer Shavin's native **Timelines** over hand-written GSAP. They are **zero-setup**: emit
5
+ `data-motion-tl-*` attributes and the `@shavin/ui` motion runtime (self-booting, GSAP lazy-loaded)
6
+ drives them — no `<MotionRuntime>`, no `useEffect`, no ScrollTrigger wiring, no imports. They round-trip
7
+ losslessly through Studio and are what the Studio **Timelines** tab produces, so code and the visual
8
+ editor stay identical.
9
+
10
+ Use hand-rolled GSAP (the `scenes` / `tech-and-performance` references) only for what Timelines don't
11
+ cover: split-text, horizontal-scroll sections, cursor/magnetic effects, WebGL, page transitions.
12
+
13
+ ## The contract
14
+
15
+ A timeline is **distributed over the nodes it touches** — no wrapper, no config object.
16
+
17
+ **Scope-root** (the common ancestor it plays within — a Section/Container):
18
+
19
+ | Attribute | Values |
20
+ |---|---|
21
+ | `data-motion-tl` | timeline id, document-unique (`t1`, `t2`, …) |
22
+ | `data-motion-tl-label` | human label ("Hero intro") |
23
+ | `data-motion-tl-trigger` | `load` · `scroll` · `click` |
24
+ | `data-motion-tl-mode` | scroll only: `reveal` (play once on enter) · `scrub` (tie progress to scroll) |
25
+ | `data-motion-tl-start` / `-end` | scroll only: ScrollTrigger offsets (e.g. `top top` / `+=150%`) |
26
+ | `data-motion-tl-pin` | scroll+scrub only: `"1"` pins the root while scrubbing |
27
+
28
+ **Member** (each element the timeline animates — a descendant of the root):
29
+
30
+ | Attribute | Values |
31
+ |---|---|
32
+ | `data-motion-tl-member` | the owning timeline id (`t1`) |
33
+ | `data-motion-tl-at` | position on the clock — **ms** for load/click, **0–100 (%)** for scrub |
34
+ | `data-motion-tl-effect` | `fade` · `fade-up` · `fade-down` · `scale-in` · `blur-in` · `mask-up` |
35
+ | `data-motion-tl-dist` / `-dur` / `-ease` | token selectors (`xs…lg` / `instant…enter` / `standard`,`out`,`in`,`overshoot`) |
36
+ | `data-motion-tl-stagger` | **container members** — ms between each direct child's entry (fans the children; `0`/absent = the whole element moves as one). Works on any container with 2+ children, repeat-grids included |
37
+ | `data-motion-tl-stagger-order` | fan order — `forward` (DOM order / rows, default) · `reverse` · `cols` (column-major, from a grid's columns) |
38
+ | `data-motion-tl-split` | **text members** — split the text and stagger the pieces (by `-stagger`): `words` · `chars` · `lines`. Needs GSAP SplitText at runtime; without it (or under reduced motion) the whole node reveals |
39
+
40
+ **Click trigger:** mark the control that replays it with `data-motion-tl-play` on a descendant (a
41
+ `<Button>`); clicking it, or Enter/Space when focused, restarts the sequence. With no marked control the
42
+ whole root is the trigger — prefer a real button for accessibility.
43
+
44
+ ```tsx
45
+ // Hero load sequence — three lines on their own beats, zero setup.
46
+ <Section data-motion-tl="t1" data-motion-tl-label="Hero intro" data-motion-tl-trigger="load">
47
+ <Heading data-motion-tl-member="t1" data-motion-tl-at="0" data-motion-tl-effect="fade-up" data-motion-tl-dist="md" />
48
+ <Text data-motion-tl-member="t1" data-motion-tl-at="120" data-motion-tl-effect="fade-up" data-motion-tl-dist="sm" />
49
+ <Button data-motion-tl-member="t1" data-motion-tl-at="240" data-motion-tl-effect="scale-in" />
50
+ </Section>
51
+
52
+ // Pinned scroll-scrubbed scene — positions are 0–100% of the scroll range.
53
+ <Section data-motion-tl="t2" data-motion-tl-trigger="scroll" data-motion-tl-mode="scrub"
54
+ data-motion-tl-start="top top" data-motion-tl-end="+=150%" data-motion-tl-pin="1">
55
+ <Heading data-motion-tl-member="t2" data-motion-tl-at="0" data-motion-tl-effect="fade-up" data-motion-tl-dist="lg" />
56
+ <Text data-motion-tl-member="t2" data-motion-tl-at="50" data-motion-tl-effect="blur-in" />
57
+ <Text data-motion-tl-member="t2" data-motion-tl-at="100" data-motion-tl-effect="mask-up" />
58
+ </Section>
59
+
60
+ // Any container fans its children — each 80ms after the last, column by column.
61
+ <RepeatGrid data-motion-tl-member="t3" data-motion-tl-at="0" data-motion-tl-effect="fade-up"
62
+ data-motion-tl-stagger="80" data-motion-tl-stagger-order="cols" />
63
+
64
+ // Split a heading into words and stagger them — "Know / where / every …" 60ms apart.
65
+ <Heading data-motion-tl-member="t4" data-motion-tl-at="0" data-motion-tl-effect="fade-up"
66
+ data-motion-tl-split="words" data-motion-tl-stagger="60">
67
+ Know where every dollar stands
68
+ </Heading>
69
+ ```
70
+
71
+ **Container stagger.** On a container member (a `RepeatGrid`, any `display:grid`/`flex`, or any element with
72
+ >1 child), `-stagger` ms fans the direct children from the member's `-at` instead of moving the element as
73
+ one; `-stagger-order` sweeps `forward` (rows, default), `reverse`, or `cols` (column-major). No `-stagger` →
74
+ the element animates as a single block.
75
+
76
+ **Split text.** On a text member, `-split="words|chars|lines"` breaks the text into pieces and `-stagger` fans
77
+ them. Uses GSAP SplitText at runtime; without it, or under `prefers-reduced-motion`, the whole node reveals.
78
+
79
+ ## Rules (enforced by `validate_code`)
80
+
81
+ - **One root per member.** Every `data-motion-tl-member="X"` needs an ancestor `data-motion-tl="X"`, or
82
+ nothing drives it (`timeline-orphan-member`).
83
+ - **No dead timelines.** A root with no members is flagged (`timeline-no-members`).
84
+ - **Member opt-out.** A timeline member must **not** also carry its own `data-motion-entry` /
85
+ `data-motion-scroll` — the timeline drives it; the runtime suppresses standalone entry for members, and
86
+ double-declaring is flagged (`timeline-member-standalone`).
87
+ - **One subtree per timeline.** All members descend from the single root; scattered-member and nested
88
+ timelines are not supported.
89
+ - **Scrub roots are block-level** and tall/pinnable; `at` is ms for time triggers, 0–100 for scrub.
90
+
91
+ ## Accessibility & fallbacks
92
+
93
+ - **Reduced motion** is automatic: `prefers-reduced-motion: reduce` reveals every member at its final
94
+ state with no travel — never build a timeline that hides content the reader can't get to otherwise.
95
+ - Members are hidden before the clock reveals them **only when the runtime booted** (`html.shavin-motion-js`);
96
+ with no JS, reduced motion, or inside Studio's paused canvas, they stay visible. Keep content correct in
97
+ all three.
98
+ - GSAP is **optional and lazy** — if absent, members are revealed (no animation) and the page still works;
99
+ the one-flag kill switch is `motionConfig.gsap`.
100
+ - Timelines play on the live page / `/preview`, not Studio's editing canvas (it is intentionally paused).
@@ -0,0 +1,147 @@
1
+ # Tech choices, patterns and budgets
2
+
3
+ Contents: 1 Choosing the tool · 2 GSAP + ScrollTrigger pattern · 3 Lenis smooth scroll · 4 CSS scroll-driven animations · 5 View Transitions · 6 React and cleanup · 7 Performance budgets · 8 Loading strategy
4
+
5
+ Check current documentation and browser support for anything version-sensitive before relying on it; APIs and support tables change.
6
+
7
+ ---
8
+
9
+ ## 1. Choosing the tool
10
+
11
+ Use the lightest tool that does the job.
12
+
13
+ | Need | First choice | Escalate to |
14
+ |---|---|---|
15
+ | Simple scroll-linked transform/opacity | CSS scroll-driven animations (`animation-timeline`) as progressive enhancement | GSAP ScrollTrigger |
16
+ | Pinning, scrubbed multi-element timelines | GSAP + ScrollTrigger | |
17
+ | Smooth (inertial) scrolling | None: native scroll. Only if the brief demands it, Lenis | |
18
+ | React component-level animation | Motion (formerly Framer Motion) | GSAP via a React hook |
19
+ | Route / shared-element transitions | View Transitions API | Router-level transitions |
20
+ | 3D / shader hero | three.js or a lighter WebGL wrapper | |
21
+ | Vector illustration animation | Lottie or Rive | |
22
+
23
+ Licensing and versions change: confirm the current terms of any library before choosing it for a commercial project.
24
+
25
+ ## 2. GSAP + ScrollTrigger pattern
26
+
27
+ Every scene is a function that returns a cleanup, wrapped in `matchMedia` so reduced motion and small screens get the right behaviour.
28
+
29
+ ```js
30
+ import gsap from "gsap";
31
+ import { ScrollTrigger } from "gsap/ScrollTrigger";
32
+ gsap.registerPlugin(ScrollTrigger);
33
+
34
+ const mm = gsap.matchMedia();
35
+
36
+ mm.add(
37
+ {
38
+ motionOk: "(prefers-reduced-motion: no-preference)",
39
+ wide: "(min-width: 1024px) and (min-height: 600px)",
40
+ },
41
+ (ctx) => {
42
+ const { motionOk, wide } = ctx.conditions;
43
+ if (!motionOk) return; // static baseline stays as-is
44
+
45
+ if (wide) {
46
+ // pinned scrollytelling (scene 3)
47
+ const tl = gsap.timeline({
48
+ scrollTrigger: {
49
+ trigger: "[data-scene='steps']",
50
+ start: "top top",
51
+ end: "+=300%", // ≈ 3 viewports
52
+ pin: true,
53
+ scrub: true,
54
+ anticipatePin: 1,
55
+ },
56
+ });
57
+ tl.to("[data-slot='pinned-visual'] [data-state='2']", { opacity: 1 }, 0.33)
58
+ .to("[data-slot='pinned-visual'] [data-state='3']", { opacity: 1 }, 0.66);
59
+ }
60
+ // everything registered here is reverted automatically when conditions change
61
+ }
62
+ );
63
+ ```
64
+
65
+ Guidelines:
66
+
67
+ - Target `data-slot` and `data-scene` attributes, not generated class names.
68
+ - Keep timelines declarative: positions as fractions of the scene, easing chosen from the token set where possible.
69
+ - Call `ScrollTrigger.refresh()` after fonts and images settle, and after layout-changing route updates.
70
+ - Use `scrub: true` (or a small smoothing value) for direct scroll-linking; use `toggleActions` for one-shot scenes.
71
+
72
+ ## 3. Lenis smooth scroll
73
+
74
+ Use only when the design depends on it. Requirements:
75
+
76
+ ```js
77
+ import Lenis from "lenis";
78
+
79
+ if (!matchMedia("(prefers-reduced-motion: reduce)").matches) {
80
+ const lenis = new Lenis();
81
+ lenis.on("scroll", ScrollTrigger.update); // keep ScrollTrigger in sync
82
+ gsap.ticker.add((time) => lenis.raf(time * 1000)); // one shared ticker
83
+ gsap.ticker.lagSmoothing(0);
84
+ }
85
+ ```
86
+
87
+ - Disabled under reduced motion.
88
+ - Anchor links, keyboard scrolling (Space, PageUp/Down, arrows), focus-into-view and find-in-page must still land correctly: test them.
89
+ - Nested scroll containers (modals, code blocks) need the library's prevent/ignore attribute so they scroll natively.
90
+
91
+ ## 4. CSS scroll-driven animations
92
+
93
+ ```css
94
+ @supports (animation-timeline: scroll()) {
95
+ @media (prefers-reduced-motion: no-preference) {
96
+ .progress-bar { animation: grow linear both; animation-timeline: scroll(root); transform-origin: left; }
97
+ @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
98
+ }
99
+ }
100
+ ```
101
+
102
+ Good for progress bars, light parallax and simple reveals with no JS. No pinning, no complex sequencing. Verify browser support for your audience and always leave the static state as the fallback.
103
+
104
+ ## 5. View Transitions
105
+
106
+ ```js
107
+ function go(update) {
108
+ if (!document.startViewTransition || matchMedia("(prefers-reduced-motion: reduce)").matches) {
109
+ update(); // no animation, same result
110
+ return;
111
+ }
112
+ document.startViewTransition(update);
113
+ }
114
+ ```
115
+
116
+ Give shared elements a `view-transition-name` unique per page. After a transition, move focus to the new `<h1>` and restore scroll on back navigation. Frameworks may provide their own integration: prefer it.
117
+
118
+ ## 6. React and cleanup
119
+
120
+ - Use the library's React hook or a `useLayoutEffect` with a context/`matchMedia` scope, and return the cleanup so triggers revert on unmount and on hot reload.
121
+ - In development strict mode, effects run twice: make setup idempotent.
122
+ - Don't animate React-controlled `style` values that state re-renders will overwrite; animate refs or data attributes.
123
+ - Route changes: kill or refresh triggers, then re-run scene setup after the new DOM paints.
124
+
125
+ ## 7. Performance budgets
126
+
127
+ | Metric | Target | Notes |
128
+ |---|---|---|
129
+ | LCP | ≤ 2.5s | Scenes must not delay the LCP element |
130
+ | INP | ≤ 200ms | Keep scroll handlers off the main thread; use rAF/tickers |
131
+ | CLS | ≤ 0.1 | Pinned sections reserve their space; use `anticipatePin` |
132
+ | Long tasks during scroll | none over ~50ms | Profile with CPU throttling |
133
+ | Frame rate while scrolling | 60fps target; 30fps floor on the floor device | |
134
+ | Added JS (animation libs) | as small as possible; lazy-loaded | Report the kB in the scene spec |
135
+
136
+ - Animate `transform`, `opacity`, and (sparingly) `clip-path`. Avoid animating `filter: blur`, box-shadows, or layout properties.
137
+ - Use `will-change` only on elements about to animate, and remove it afterwards.
138
+ - Cap canvas device pixel ratio at 2. Pause canvas, video and tickers when offscreen (`IntersectionObserver`) or the tab is hidden.
139
+ - Limit concurrent scroll-linked timelines; combine where possible.
140
+
141
+ ## 8. Loading strategy
142
+
143
+ 1. Render the static page first. Text, CTA and media are in the DOM and readable.
144
+ 2. Load animation code with dynamic `import()` after first paint, or when the scene approaches the viewport (`IntersectionObserver` with a generous `rootMargin`).
145
+ 3. Wait for `document.fonts.ready` before measuring text or setting pin lengths.
146
+ 4. Feature-detect (`startViewTransition`, `animation-timeline`, WebGL) and fall back to the static baseline.
147
+ 5. Remember "already seen" intros per viewer and skip them on return visits.