@su-sws/synthetic-web-team 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 (82) hide show
  1. package/AGENTS.md +149 -0
  2. package/README.md +321 -0
  3. package/package.json +58 -0
  4. package/packages/cli/bin/sws.mjs +722 -0
  5. package/packages/cli/src/axe.mjs +164 -0
  6. package/packages/cli/src/browser.mjs +192 -0
  7. package/packages/cli/src/checks.mjs +1254 -0
  8. package/packages/cli/src/github.mjs +131 -0
  9. package/packages/cli/src/history.mjs +137 -0
  10. package/packages/cli/src/perf.mjs +245 -0
  11. package/packages/cli/src/preflight.mjs +185 -0
  12. package/packages/cli/src/report.mjs +315 -0
  13. package/packages/cli/src/states.mjs +556 -0
  14. package/packages/wizard/bin/wizard.mjs +767 -0
  15. package/packages/wizard/src/detect.mjs +135 -0
  16. package/packages/wizard/src/emit.mjs +553 -0
  17. package/skills/role-accessibility-lead/SKILL.md +183 -0
  18. package/skills/role-api-architect/SKILL.md +65 -0
  19. package/skills/role-backend-developer/SKILL.md +66 -0
  20. package/skills/role-compliance-officer/SKILL.md +73 -0
  21. package/skills/role-content-designer/SKILL.md +145 -0
  22. package/skills/role-devops/SKILL.md +200 -0
  23. package/skills/role-discoverability/SKILL.md +164 -0
  24. package/skills/role-frontend-developer/SKILL.md +167 -0
  25. package/skills/role-fullstack-developer/SKILL.md +56 -0
  26. package/skills/role-identity-engineer/SKILL.md +77 -0
  27. package/skills/role-information-architect/SKILL.md +136 -0
  28. package/skills/role-infrastructure-architect/SKILL.md +60 -0
  29. package/skills/role-qa-engineer/SKILL.md +81 -0
  30. package/skills/role-security-operations/SKILL.md +56 -0
  31. package/skills/role-software-architect/SKILL.md +75 -0
  32. package/skills/role-staff-technical-architect/SKILL.md +73 -0
  33. package/skills/role-strategist/SKILL.md +122 -0
  34. package/skills/role-user-researcher/SKILL.md +66 -0
  35. package/skills/role-ux-designer/SKILL.md +159 -0
  36. package/skills/sws-compliance-check/SKILL.md +153 -0
  37. package/skills/sws-decanter/SKILL.md +191 -0
  38. package/skills/sws-deploy/SKILL.md +162 -0
  39. package/skills/sws-diverge/SKILL.md +131 -0
  40. package/skills/sws-github/SKILL.md +171 -0
  41. package/skills/sws-install/SKILL.md +97 -0
  42. package/skills/sws-netlify/SKILL.md +110 -0
  43. package/skills/sws-onboard/SKILL.md +85 -0
  44. package/skills/sws-preflight/SKILL.md +87 -0
  45. package/skills/sws-prior-art/SKILL.md +137 -0
  46. package/skills/sws-vercel/SKILL.md +117 -0
  47. package/standards/fragments/global-footer.yml +137 -0
  48. package/standards/fragments/identity-bar.yml +180 -0
  49. package/standards/hosting/capabilities.yml +215 -0
  50. package/standards/hosting/github-pages.yml +306 -0
  51. package/standards/hosting/netlify.yml +234 -0
  52. package/standards/hosting/vercel.yml +284 -0
  53. package/standards/patterns/components.md +162 -0
  54. package/standards/patterns/content.md +130 -0
  55. package/standards/patterns/decanter.md +352 -0
  56. package/standards/patterns/discoverability.md +121 -0
  57. package/standards/patterns/forms.md +116 -0
  58. package/standards/patterns/ia.md +126 -0
  59. package/standards/patterns/motion.md +267 -0
  60. package/standards/patterns/sws-conventions.md +225 -0
  61. package/standards/policy/accessibility.md +241 -0
  62. package/standards/policy/brand.md +213 -0
  63. package/standards/policy/escalation.md +53 -0
  64. package/standards/policy/identity.md +96 -0
  65. package/standards/policy/minsec.md +119 -0
  66. package/standards/policy/minweb.md +87 -0
  67. package/standards/policy/privacy.md +114 -0
  68. package/standards/policy/procurement.md +79 -0
  69. package/standards/prior-art/README.md +205 -0
  70. package/standards/prior-art/catalog.yml +409 -0
  71. package/standards/prior-art/patterns/INDEX.md +53 -0
  72. package/standards/prior-art/repos.yml +734 -0
  73. package/standards/recipes/astro-ssr/RECIPE.md +274 -0
  74. package/standards/recipes/astro-ssr/acceptance.yml +168 -0
  75. package/standards/recipes/astro-static/RECIPE.md +468 -0
  76. package/standards/recipes/astro-static/acceptance.yml +800 -0
  77. package/standards/recipes/next-ssr/RECIPE.md +407 -0
  78. package/standards/recipes/next-ssr/acceptance.yml +187 -0
  79. package/standards/scope.md +111 -0
  80. package/standards/stack/performance-budget.yml +95 -0
  81. package/standards/stack/reference-versions.yml +168 -0
  82. package/standards/stack/requirements.yml +154 -0
@@ -0,0 +1,116 @@
1
+ # Forms
2
+
3
+ Where accessibility, usability, and privacy converge hardest. A form is also the
4
+ most common way a `low`-tier site quietly becomes a `moderate`-tier one.
5
+
6
+ ## Before the markup: a form is a tier question
7
+
8
+ **Every field is a MinPriv question about why you need it.**
9
+
10
+ - **Ask for the minimum.** The field nobody can justify is the field to delete.
11
+ - **A transparency notice is required before collection**, saying what is
12
+ collected, why, and what happens to it — in plain language, before the reader
13
+ starts filling it in. See [`../policy/privacy.md`](../policy/privacy.md).
14
+ - **Collecting personal information moves the site to `moderate` tier**, which
15
+ attaches Duo, centralised logging, secure SDLC, backups, and training. See
16
+ [`../policy/minsec.md`](../policy/minsec.md).
17
+ - **A Data Risk Assessment** is required before deploy if personal information is
18
+ collected or a third-party service is introduced. That includes a third-party
19
+ form or survey tool.
20
+
21
+ So "add a contact form" is a scope conversation, not a component request. Say that
22
+ early, once, without lecturing.
23
+
24
+ ## Labels
25
+
26
+ - **Visible labels, above the field.** **Placeholders are not labels** — they
27
+ vanish on focus, fail contrast, and disappear for anyone who needs to check what
28
+ they typed.
29
+ - Every input has a programmatically associated label. `<label for>` or wrapping.
30
+ - **Group related fields** with `fieldset` and `legend`. Radio groups and checkbox
31
+ groups need this or the group's question is never announced.
32
+ - **Mark required fields in text**, not with a colour or a bare asterisk. "Email
33
+ (required)" works for everyone.
34
+
35
+ ## Errors
36
+
37
+ - **Inline, next to the field**, plus a **summary at the top for long forms**.
38
+ - **Say what went wrong and what to do.** "Invalid input" fails WCAG 3.3.3. "Enter
39
+ a date as MM/DD/YYYY" passes and is kinder.
40
+ - **Errors must be announced**, not only shown. A visual-only error is invisible
41
+ to a screen reader user.
42
+ - **Never validate on blur while someone is still typing.** Validate on submit, or
43
+ on blur only after a field has been completed once.
44
+ - **Never clear what the user typed** on a failed submit.
45
+ - **Error recovery is a first-class requirement.** Can someone who makes a mistake
46
+ fix it without starting over? This is on the manual checklist because automation
47
+ cannot see it.
48
+
49
+ ## Inputs
50
+
51
+ - Use the right `type` (`email`, `tel`, `url`, `date`) so mobile keyboards and
52
+ browser validation help rather than fight.
53
+ - Set `autocomplete` attributes. This is WCAG 1.3.5 and it is nearly free.
54
+ - **Target size minimum 24 by 24 CSS pixels.** This is the one WCAG 2.2 criterion
55
+ axe can actually check.
56
+ - Do not disable paste, especially on email and password fields.
57
+ - Do not rely on colour alone to convey required, invalid, or valid state.
58
+
59
+ ## Structure and submission
60
+
61
+ - One `h1`, real headings, logical tab order matching visual order.
62
+ - Keep the submit button visible and its label specific: "Send message," not
63
+ "Submit."
64
+ - Confirm success in text, on a page or region that gets announced. A form that
65
+ silently succeeds gets submitted three times.
66
+ - Say what happens next and when. "We reply within two business days."
67
+
68
+ ## Prior art, with a warning attached
69
+
70
+ **`adapt-online-giving` is the best Decanter form reference at SWS.** Transactional
71
+ form flows, real validation, real error states.
72
+
73
+ **The caveat is not optional:** it is high-risk-tier work with Stripe and
74
+ authentication, almost certainly Moderate-or-higher risk. **Borrow the interaction
75
+ patterns; never the data handling.** Do not treat its architecture as a template
76
+ for a `low`-risk static site.
77
+
78
+ Its era is `decanter-7`, so the CSS is a parallel vocabulary rather than a target.
79
+ See `standards/prior-art/catalog.yml` and the precedence rule in
80
+ `standards/prior-art/README.md`.
81
+
82
+ ## Decanter: forms are opt-in in v8, and forgetting it fails silently
83
+
84
+ **If the site has a form, the entry CSS needs a second import:**
85
+
86
+ ```css
87
+ @import 'decanter';
88
+ @import 'decanter/forms';
89
+ ```
90
+
91
+ Without it you lose `.input`, `.select`, `.textarea`, `.checkbox`, `.radio`,
92
+ `.label`, `.legend`, `.fieldset` **and the global form-element reset**. Nothing
93
+ errors — the form just renders unstyled, so this reaches production with a green
94
+ build. It is the most likely v8 mistake on a Stanford unit site.
95
+
96
+ `decanter/forms` is **not standalone**: import it alongside `decanter` or
97
+ `decanter/minimal`, which supply the theme variables and root font size it needs.
98
+
99
+ In v7 these classes came with the base package, so a v7 project that gains a form
100
+ after upgrading will appear to work until someone looks at it.
101
+
102
+ **Do not install `@tailwindcss/forms` directly.** It is still a declared
103
+ dependency of Decanter 8 and still installs; only its *application* is gated
104
+ behind the entry point above. Read the shipped CSS at
105
+ `node_modules/decanter/src/css/forms.css` rather than guessing class names. See
106
+ [`decanter.md`](decanter.md).
107
+
108
+ ## On a static site, where does the submission go
109
+
110
+ Worth deciding before designing the form, because it constrains everything above:
111
+
112
+ - **GitHub Pages has no server**, so a form needs a third-party endpoint, which is
113
+ a DRA trigger and a third-party service.
114
+ - **Netlify Forms** or a function is the path once the site is on Netlify.
115
+ - **The cheapest compliant answer is often a `mailto:` link or a link to an
116
+ existing central form**, and it is worth offering before building anything.
@@ -0,0 +1,126 @@
1
+ # Information architecture
2
+
3
+ Structure, naming, and findability. The layer where a site becomes usable or does
4
+ not, and where most of the damage is done by organising around the institution
5
+ rather than the reader.
6
+
7
+ ## The org chart is not an IA
8
+
9
+ **The most common failure at a university:** navigation that mirrors internal
10
+ structure. Readers do not know which office owns the thing they need, and should
11
+ not have to.
12
+
13
+ Organise by **task and audience**, then let internal structure show up on an About
14
+ page where it belongs.
15
+
16
+ **The tell** is a top-level item that only makes sense to staff. If a prospective
17
+ student would not use the word, it is not a nav label.
18
+
19
+ ## Navigation
20
+
21
+ **Depth over breadth, but not much depth.** Three levels is usually enough for a
22
+ unit site. A fourth level almost always means either two sites are wearing one
23
+ costume, or a section should be a landing page with real content rather than a
24
+ signpost.
25
+
26
+ **Label with the reader's words.** Test labels against what people search for, not
27
+ what the unit calls itself internally. "Giving" beats "Advancement." "Apply" beats
28
+ "Prospective Student Information."
29
+
30
+ **Seven is not a law.** The advice about seven items comes from working-memory
31
+ research that does not apply to a persistently visible menu. Use as many as the
32
+ content honestly needs — and if that number is large, the problem is the content
33
+ model rather than the menu.
34
+
35
+ **Cross-cutting content needs one home and many paths.** Pick a canonical
36
+ location, then link to it. Duplicating a page for two audiences means two pages
37
+ drifting apart, and it splits your search signal.
38
+
39
+ ## URL design
40
+
41
+ **URLs are a permanent interface. Treat changing one as a migration.**
42
+
43
+ - **Lowercase, hyphenated, no file extensions.** `/graduate-programs`, not
44
+ `/GraduatePrograms` or `/grad_programs.html`.
45
+ - **Short and stable over descriptive and brittle.** `/apply` outlives
46
+ `/how-to-apply-for-autumn-2027-admission`.
47
+ - **No dates in paths** unless the content is genuinely archival. `/news/2026/`
48
+ ages into a graveyard.
49
+ - **Mirror the IA, shallowly.** URL depth should not exceed nav depth.
50
+ - **Never encode the org chart.** `/offices/oue/ugadmit/apply` is the navigation
51
+ mistake made permanent.
52
+ - **Pick a trailing-slash convention and hold it.** Astro's `trailingSlash`
53
+ setting exists for this. Mixed conventions produce duplicate URLs.
54
+
55
+ ## Subdomain naming, which is not yours to approve
56
+
57
+ Per the stanford.edu name assignment policy, a subdomain **must reflect the
58
+ recognised unit name** and is **approved by University Communications**. Vanity
59
+ URLs are not permitted for personal pages.
60
+
61
+ **This has a lead time and it fails projects that leave it late.** Raise it during
62
+ discovery, route per [`../policy/escalation.md`](../policy/escalation.md), and
63
+ record the approval date in `.sws/manifest.yml`.
64
+
65
+ You can advise on a name. You cannot approve one.
66
+
67
+ Also relevant: MinWeb covers Stanford-branded `.org` and `.com` sites too, so
68
+ moving off `stanford.edu` does not shed the standards. `sup.org` is the live
69
+ example. See [`../policy/minweb.md`](../policy/minweb.md).
70
+
71
+ ## Taxonomy
72
+
73
+ **Only build one if something needs filtering or aggregating.** A taxonomy on a
74
+ twelve-page site is overhead pretending to be structure.
75
+
76
+ When you do:
77
+
78
+ - **Flat beats hierarchical** unless the hierarchy is genuinely meaningful.
79
+ - **Closed vocabularies for anything filtered.** Free tags produce
80
+ "Undergraduate," "undergrad," and "Undergraduate " within a month.
81
+ - **One dimension per vocabulary.** Do not mix audience, topic, and format into
82
+ one tag set.
83
+ - **Name the term as a reader would, not as a database would.**
84
+
85
+ ## Migrations and redirects
86
+
87
+ Migrating an existing site is mostly redirect work, and skipping it is how a unit
88
+ loses years of accumulated search equity in an afternoon.
89
+
90
+ 1. **Crawl the existing site** and export every URL with traffic. Siteimprove can
91
+ help, and it is already required.
92
+ 2. **Map old to new, one to one where possible.** A many-to-one map onto the
93
+ homepage is not a redirect strategy, it is a way to hide the problem.
94
+ 3. **301 for permanent moves.** Record the map as `redirects.csv` in the repo so
95
+ it survives the person who made it.
96
+ 4. **Keep an inventory of what you deliberately dropped**, with a reason. "This
97
+ page had four visits in a year and its content is wrong" is a good reason and
98
+ worth writing down.
99
+ 5. **Check inbound links you do not control**: other Stanford sites, Wikipedia,
100
+ syllabi, printed materials. Those cannot be updated, so those URLs must keep
101
+ working.
102
+
103
+ **A hosting constraint that decides architecture:** GitHub Pages is static hosting
104
+ with no server-side redirect layer, so you get meta-refresh or JS shims, both
105
+ worse for accessibility and search. **If a migration involves substantial
106
+ redirects, that is a reason to deploy to Netlify.** Say so early rather than
107
+ discovering it at launch.
108
+
109
+ ## Search, when the site needs it
110
+
111
+ **Below roughly fifty pages, good navigation beats search**, and search becomes a
112
+ crutch for bad IA. Above that, see [`discoverability.md`](discoverability.md) for
113
+ the Algolia and Coveo decision.
114
+
115
+ Either way, **design the empty state and the zero-results case**, because those
116
+ are where search actually gets judged.
117
+
118
+ ## Prior art is unusually valuable here
119
+
120
+ IA is exactly what live exemplars are good for, because a rendered site shows the
121
+ structure that **survived launch**. `standards/prior-art/catalog.yml` has
122
+ seventeen, and the two large school sites are more instructive compared against
123
+ each other than read singly.
124
+
125
+ Remember the precedence rule: **borrow structure freely, never CSS or versions.**
126
+ See `standards/prior-art/README.md`.
@@ -0,0 +1,267 @@
1
+ # Motion
2
+
3
+ **Decanter has no motion guidance.** It ships tokens for colour, type, spacing
4
+ and `transition-duration`, and stops there — so every Stanford site invents its
5
+ own, and most invent badly. This file is the missing layer.
6
+
7
+ Reference implementation: **[sws-astro](https://github.com/SU-SWS/sws-astro)**
8
+ ([live](https://sws-astro.netlify.app/)), whose `AnimateInView` component is the
9
+ house pattern. Design values come from the University Communications homesite
10
+ motion guidelines. Everything measured below was measured on this project's own
11
+ docs site, which is built to this file.
12
+
13
+ ## The shape of good motion here
14
+
15
+ Four properties, and they are not stylistic preferences:
16
+
17
+ 1. **On viewport entry, not on load.** Animating below-fold content at load
18
+ means it finishes before anyone scrolls to it — motion spent where nobody is
19
+ looking, and a page that is already over by the time you arrive.
20
+ 2. **Once.** Replaying every time an element scrolls past turns a page into a
21
+ slideshow and makes re-reading actively unpleasant.
22
+ 3. **Staggered when several things arrive together.** A row of four cards
23
+ appearing simultaneously reads as a flicker. Offset them and it reads as a
24
+ sequence.
25
+ 4. **Short.** 500ms for the movement, 150ms between staggered siblings. Motion
26
+ is the punctuation, not the sentence.
27
+
28
+ ## Do not animate the first screenful
29
+
30
+ The hero is already in the viewport when the page loads, so an entry animation
31
+ there delays the one thing the reader came for — and the `h1` is usually the LCP
32
+ element, so you are animating your own Largest Contentful Paint.
33
+
34
+ Start motion below the fold. This project's docs site has a completely static
35
+ hero and animates from the first section down.
36
+
37
+ ## Values
38
+
39
+ From the homesite motion guidelines. Use these before inventing your own.
40
+
41
+ | Motion | Property | Duration | Easing |
42
+ |---|---|---|---|
43
+ | **Card / block entry** | `scale` 95% → 100% | 500ms | `cubic-bezier(0.80, 0, 0.20, 1)` |
44
+ | Text and image inside it | `opacity` 0 → 100% | 167ms, delayed 500ms | `cubic-bezier(0.33, 0, 0.67, 1)` |
45
+ | Image container reveal | `border-radius` 220px → 0 | 500ms | `cubic-bezier(0.05, 0, 0, 1)` |
46
+ | **Skeleton pulse** | `opacity` 100% → 25% → 100% | 1500ms each way | `cubic-bezier(0.40, 0, 0.20, 1)` |
47
+ | **Sequential reveal** | stagger between siblings | 150ms | — |
48
+
49
+ The reference component simplifies this to one duration (500ms) and `easeOut`,
50
+ which is `cubic-bezier(0, 0, 0.2, 1)`. That is a reasonable default; reach for
51
+ the table when a specific composition needs it.
52
+
53
+ **Stagger increments of 150ms, and cap the total.** Four cards at 150ms means
54
+ the last starts at 450ms, which is fine. Twelve cards means the last starts at
55
+ 1.65s, by which time the reader has scrolled past it. Above roughly six
56
+ siblings, stagger in groups or drop the stagger.
57
+
58
+ ### The variant set
59
+
60
+ Keep the number of distinct motions on a site finite and reviewable. The
61
+ reference implementation ships seven, which is enough:
62
+
63
+ `fadeIn` · `zoomIn` (scale 0.6) · `sharpen` (blur 20px → 0) ·
64
+ `slideInFromLeft` / `slideInFromRight` (x ±100) · `slideUp` / `slideDown`
65
+ (y ±80) · plus `none`.
66
+
67
+ `slideUp` is the default and should stay the default. Distances are modest on
68
+ purpose: 80px reads as arrival, 400px reads as a stunt.
69
+
70
+ ## Only animate `transform` and `opacity`
71
+
72
+ Both are composited, so they do not trigger layout or paint. Animating
73
+ `width`, `height`, `top`, `margin` or `padding` forces reflow on every frame and
74
+ janks on the hardware a lot of campus actually uses.
75
+
76
+ This applies to hover too. `hover:pl-40` on a card reflows its neighbours —
77
+ that is jitter, not feedback. **Hover motion is affordance: a 200ms colour or
78
+ shadow change, and nothing that moves layout.** Avoid `transition: all`, which
79
+ animates properties you did not think about.
80
+
81
+ ## Reduced motion is an exit, not a shorter animation
82
+
83
+ `prefers-reduced-motion: reduce` means *render the static thing*. Not faster,
84
+ not smaller — absent.
85
+
86
+ Two layers, because they cover different failures:
87
+
88
+ ```css
89
+ /* 1. The hidden starting state applies only when motion is welcome. */
90
+ @media (prefers-reduced-motion: no-preference) {
91
+ .js [data-animate] { opacity: 0; transform: translateY(80px); }
92
+ }
93
+
94
+ /* 2. Backstop for CSS transitions and anything third-party that forgets. */
95
+ @media (prefers-reduced-motion: reduce) {
96
+ html { scroll-behavior: auto; }
97
+ *, *::before, *::after {
98
+ animation-duration: 0.01ms !important;
99
+ animation-iteration-count: 1 !important;
100
+ transition-duration: 0.01ms !important;
101
+ }
102
+ }
103
+ ```
104
+
105
+ **Do not forget `scroll-behavior`.** A smooth-scrolled anchor jump is motion,
106
+ and it is the one people most often leave in.
107
+
108
+ In the React component the equivalent is `useReducedMotion()` returning the
109
+ plain element — no motion wrapper, no transform, and no hydration cost for
110
+ someone who asked not to be animated at.
111
+
112
+ ## The failure that matters most: content that never appears
113
+
114
+ **If the hidden state ships in the HTML and the JavaScript does not run, the
115
+ content is gone.** Not degraded — invisible, with no indication anything is
116
+ missing.
117
+
118
+ This is not hypothetical. The React reference component renders its initial
119
+ state server-side, so every animated block ships as
120
+ `style="opacity:0;transform:translateY(80px)"`. Measured on this project's docs
121
+ site before the fix: **13 blocks, including entire sections, permanently
122
+ invisible with JavaScript disabled.**
123
+
124
+ The fix is to make the hidden state conditional on JavaScript being present:
125
+
126
+ ```html
127
+ <!-- In <head>, before first paint, so it cannot flash. -->
128
+ <script>document.documentElement.classList.add('js');</script>
129
+ ```
130
+
131
+ and scope the hidden rule to `.js` as above. If the script never runs, nothing
132
+ is ever hidden.
133
+
134
+ A `<noscript><style>` override also works and is better than nothing, but it
135
+ only covers *disabled* JavaScript. A script error later on the page leaves
136
+ JavaScript enabled and your content hidden, and `<noscript>` will not fire.
137
+ Prefer the class.
138
+
139
+ ## Two implementations, and the cost of each
140
+
141
+ Both use **[`motion`](https://motion.dev)** (formerly framer-motion), which is
142
+ the SWS choice. What differs is whether you pay for React.
143
+
144
+ ### Vanilla — default for an Astro site
145
+
146
+ `motion`'s main entry exports `animate`, `inView`, `stagger`, `scroll` with no
147
+ React at all. One small script, initial state in CSS:
148
+
149
+ ```ts
150
+ import { animate, inView } from 'motion';
151
+
152
+ if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
153
+ for (const el of document.querySelectorAll<HTMLElement>('[data-animate]')) {
154
+ let stop: () => void;
155
+ stop = inView(el, () => {
156
+ animate(el, { opacity: 1, y: 0 }, {
157
+ duration: 0.5,
158
+ ease: [0, 0, 0.2, 1],
159
+ delay: Number(el.dataset.animateDelay ?? 0),
160
+ });
161
+ stop?.(); // once
162
+ }, { amount: 0.15 });
163
+ }
164
+ }
165
+ ```
166
+
167
+ Markup opts in with `data-animate` and `data-animate-delay="0.15"`.
168
+
169
+ ### React — when the project already has React
170
+
171
+ `AnimateInView` from sws-astro: `motion/react` plus `LazyMotion` with
172
+ `domAnimation` so the runtime is code-split, `useInView(ref, { once })`,
173
+ `useReducedMotion()`, and a `variants` map. Used with `client:visible` so the
174
+ island does not hydrate until needed. Read that component rather than
175
+ reimplementing it.
176
+
177
+ ### The measurement
178
+
179
+ Both approaches on the same page, same animations, measured with `sws perf`:
180
+
181
+ | | JavaScript | Verdict |
182
+ |---|---|---|
183
+ | `motion/react` + React 19 island | **266.7 KB** | Breaches the 150 KB js budget |
184
+ | Vanilla `motion` | **60.4 KB** | Within budget |
185
+
186
+ **77% less JavaScript for identical motion.** React accounted for almost all of
187
+ it: 184 KB of runtime plus 8 KB of glue, to fade in some text.
188
+
189
+ So: **if React is already in the project, use the component.** sws-astro is
190
+ React-based and its choice is right for it. If the only reason you would add
191
+ React is the animation, use the vanilla API. A `role-frontend-developer` rule
192
+ applies directly here — *no client-side framework for static content* — and 267
193
+ KB to animate a documentation page is exactly what it is warning about.
194
+
195
+ ## What not to build
196
+
197
+ - **Infinite or looping animation** on anything decorative. Under WCAG 2.2.2,
198
+ motion lasting more than five seconds needs a mechanism to pause, stop or
199
+ hide it. A looping background is a compliance obligation you did not need.
200
+ - **Parallax and scroll-jacking.** Both reliably cause nausea for people with
201
+ vestibular disorders, and scroll-jacking breaks the scrollbar as a position
202
+ indicator.
203
+ - **Animation that delays content.** A spinner in front of text that is already
204
+ in the HTML is a worse experience than the text.
205
+ - **Motion that moves focus.** If an element animates away from where it was
206
+ when focused, keyboard users lose their place.
207
+ - **Animating a hash target.** Landing on `#install` should put you at
208
+ `#install`, not somewhere en route to it.
209
+ - **Autoplaying video as decoration.** Different problem, same instinct.
210
+ Captions and audio description are required on new video regardless — see
211
+ [`../policy/accessibility.md`](../policy/accessibility.md).
212
+
213
+ ## Skeleton loading
214
+
215
+ A skeleton is a placeholder for content that genuinely cannot arrive quickly —
216
+ a large dataset, a slow upstream API. It reduces *perceived* load time by
217
+ showing the shape of what is coming.
218
+
219
+ Pulse `opacity` 100% → 25% → 100%, 1500ms each direction,
220
+ `cubic-bezier(0.40, 0, 0.20, 1)`.
221
+
222
+ **Do not use one for content you already have.** On a static Stanford site the
223
+ HTML arrives with the content in it, so a skeleton is a fake delay. And a
224
+ looping pulse is exactly the >5s motion WCAG 2.2.2 asks you to be able to stop,
225
+ so if it can run indefinitely, it needs a way out.
226
+
227
+ Mark it `aria-hidden="true"` and give the live region a real status, or a screen
228
+ reader announces a wall of nothing.
229
+
230
+ ## Testing: two things automation gets wrong
231
+
232
+ Both were found building this file's own reference site, and both are handled by
233
+ `sws a11y` and `sws perf`. If you write your own harness, handle them.
234
+
235
+ **1. axe skips invisible content, so entry motion creates a blind spot.**
236
+ Below-fold elements sit at `opacity: 0` until scrolled to, and axe correctly
237
+ treats an invisible element as not applicable — so it audits nothing inside
238
+ them. Measured here: **116 rule-nodes unscrolled versus 145 scrolled.** Thirteen
239
+ blocks silently unaudited, reported as a clean pass. A false negative in an
240
+ accessibility check is worse than a false positive, because a false positive
241
+ gets investigated.
242
+
243
+ **2. Mid-animation elements produce false contrast failures.** axe reads
244
+ *computed* colour, so an element captured part-way through a fade reports the
245
+ blend against its backdrop. This site once produced four `color-contrast`
246
+ violations at ratios of 1.05 to 1.55 — foregrounds like `#f9f9f9` on white — all
247
+ false, all caused by measuring at 2% opacity.
248
+
249
+ So the order is: **scroll the whole page, then wait for animations to settle,
250
+ then audit.** Scrolling is what starts the animations that then need to finish.
251
+
252
+ A related trap for performance measurement: lazily hydrated islands do not
253
+ request their JavaScript until they approach the viewport, so measuring only the
254
+ initial load reports the page as if that code did not exist. Here that was 52.9
255
+ KB reported against 319.6 KB actual.
256
+
257
+ ## The manual check
258
+
259
+ Automation cannot tell you whether motion is *good*, only whether it is present.
260
+ On the pre-launch checklist:
261
+
262
+ - Set `prefers-reduced-motion` in the OS and reload. Is everything readable,
263
+ with no movement?
264
+ - Disable JavaScript and reload. Is all content visible?
265
+ - Tab through the page. Does anything animate away from a focused element?
266
+ - Read the page twice. Does the motion get annoying the second time?
267
+ - Watch it on a slow device, not a development machine.