@samline/skills 0.0.0-stage → 0.4.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/LICENSE.md +21 -0
- package/README.md +113 -2
- package/bin/skills.mjs +344 -0
- package/package.json +26 -4
- package/skills/samline-catalog/SKILL.md +80 -0
- package/skills/samline-components/SKILL.md +133 -0
- package/skills/samline-debugging/SKILL.md +85 -0
- package/skills/samline-frontend/SKILL.md +144 -0
- package/skills/samline-i18n/SKILL.md +96 -0
- package/skills/samline-kickoff/SKILL.md +150 -0
- package/skills/samline-library/SKILL.md +136 -0
- package/skills/samline-library/references/dom-traps.md +54 -0
- package/skills/samline-motion/SKILL.md +124 -0
- package/skills/samline-motion/references/reveal-recipe.md +205 -0
- package/skills/samline-qa/SKILL.md +119 -0
- package/skills/samline-tasks/SKILL.md +157 -0
- package/skills/samline-voice/SKILL.md +70 -0
- package/skills/samline-workflow/SKILL.md +187 -0
- package/skills/samline-workflow/references/evidence-and-qa.md +57 -0
- package/skills/samline-workflow/references/lessons-and-memory.md +57 -0
- package/skills/samline-workflow/references/web-traps.md +56 -0
- package/skills/silence/SKILL.md +226 -0
- package/skills-index.json +132 -0
- package/skills.json +129 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: samline-library
|
|
3
|
+
description: Design and release rules for any JavaScript or TypeScript library with a DOM or browser surface. Closures and a DOM-free core, SSR-safe imports, idempotent destroy, attributes over options, named IIFE exports, tests against built artifacts in three browsers, ARIA as API, bfcache, rollback, size budgets, changelog, pack manifest and a CI that never publishes. Use when creating, changing, testing or releasing a library. In @samline/* repositories samline-package and the repo AGENTS.md (with its synced family block) are authoritative and this skill never overrides them. Project AGENTS.md wins.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# JavaScript library rules
|
|
8
|
+
|
|
9
|
+
Precedence: the user's current instructions, then the project's `AGENTS.md`,
|
|
10
|
+
`DESIGN.md` and `.agents/memory`, then the stack skill (and `samline-package`
|
|
11
|
+
in @samline/* repositories), then this skill. When this skill disagrees with
|
|
12
|
+
them, follow them and mention the conflict once.
|
|
13
|
+
|
|
14
|
+
In a @samline/* repository, `samline-package` and the repo's `AGENTS.md` (with
|
|
15
|
+
its synced family block) are authoritative. This skill is the generic baseline
|
|
16
|
+
and never overrides them. On a conflict, follow `samline-package`, then ask the
|
|
17
|
+
maintainer. Never use this skill as the checklist for a @samline package.
|
|
18
|
+
|
|
19
|
+
Generic rules for any library. Event and DOM traps live in
|
|
20
|
+
[dom-traps.md](references/dom-traps.md).
|
|
21
|
+
|
|
22
|
+
## Design
|
|
23
|
+
|
|
24
|
+
- Use arrow functions and closures; no classes, no `this`. Reason: closures
|
|
25
|
+
keep state private and survive being passed around as callbacks. Only
|
|
26
|
+
TypeScript overload sets and wrappers that forward the caller's `this` keep
|
|
27
|
+
`function`.
|
|
28
|
+
- Keep the core DOM-free (`src/core`): types, defaults and pure helpers. DOM
|
|
29
|
+
controllers live in their own folder. Reason: the core is testable without a
|
|
30
|
+
DOM and safe on the server.
|
|
31
|
+
- Be SSR-safe: no DOM access at import time, no global registration in the root
|
|
32
|
+
entry, and without a DOM every call is a no-op. Mark only the browser bundle
|
|
33
|
+
in `sideEffects`.
|
|
34
|
+
- A controller returns a cleanup or `{ refresh, destroy }`. `destroy` is
|
|
35
|
+
idempotent, restores the original markup, removes every attribute it wrote
|
|
36
|
+
and ignores late async work (timers, promises, observers) that fires after it.
|
|
37
|
+
Calling the factory again on an element that already has a controller returns
|
|
38
|
+
the same controller (new options go through `update()`); never wrap twice.
|
|
39
|
+
A content factory that re-runs disposes the previous render's listeners.
|
|
40
|
+
- Define behavior for empty, zero-size or unmeasurable input: report not ready,
|
|
41
|
+
create no clones, and recover on `refresh()`, instead of throwing or looping.
|
|
42
|
+
- Declarative API: `data-<name>` on the element and `data-<name>-<option>` per
|
|
43
|
+
option. Attributes win over options. Expose state as `data-<name>-state`.
|
|
44
|
+
Reason: it works without JavaScript glue and is inspectable in the DOM.
|
|
45
|
+
- `update()` is partial: only the options passed change; the rest keep their
|
|
46
|
+
values.
|
|
47
|
+
- Content stays usable without JavaScript. Respect `prefers-reduced-motion`.
|
|
48
|
+
- Accessibility is API. Follow the WAI-ARIA pattern for the widget (a combobox
|
|
49
|
+
keeps its roles, states and keyboard model), and test it.
|
|
50
|
+
- Never use `innerHTML`, `outerHTML` or `insertAdjacentHTML` with external or
|
|
51
|
+
user content. Use `textContent` or DOM nodes, or consumer-owned render
|
|
52
|
+
callbacks. A library never ships its own sanitizer; any HTML a consumer
|
|
53
|
+
passes is the consumer's responsibility and is documented as such.
|
|
54
|
+
- Keep numeric and string IDs distinct. Never expose live nodes in snapshots
|
|
55
|
+
handed to consumers. Keep lifecycle callbacks in shared state so every path
|
|
56
|
+
reads the same ones.
|
|
57
|
+
- Timers store a deadline and subtract elapsed time on pause and resume; they
|
|
58
|
+
never restart the full duration.
|
|
59
|
+
- bfcache: a `pagehide` event with `persisted` set must keep controllers alive
|
|
60
|
+
(do not destroy them), and the page may resume with stale state.
|
|
61
|
+
- Re-check that your instance is still current after every consumer callback:
|
|
62
|
+
the callback may have destroyed or replaced it.
|
|
63
|
+
- Roll back partial DOM and listeners when a factory throws midway, so a failed
|
|
64
|
+
call leaves the page as it was.
|
|
65
|
+
- Dependencies: zero runtime dependencies unless the job demands one. Bundle
|
|
66
|
+
build-time helpers instead of publishing them as dependencies.
|
|
67
|
+
|
|
68
|
+
## Browser global (IIFE)
|
|
69
|
+
|
|
70
|
+
- Export named members only. A default export leaks `window.<Name>.default`.
|
|
71
|
+
- Never prefix a vendor brand (Samline or any other) in a global, event,
|
|
72
|
+
attribute, cookie, storage key or CSS identifier; the npm scope is the only
|
|
73
|
+
place the brand appears. If the natural name collides with a built-in global
|
|
74
|
+
(`String`, `Text`, `Map`, `Image`), use the plural or another plain word;
|
|
75
|
+
check `'<Name>' in window` in a browser.
|
|
76
|
+
- Auto-init on load, skipping elements already handled and picking up elements
|
|
77
|
+
added later. Provide an opt-out (for example `data-manual` on the script tag).
|
|
78
|
+
|
|
79
|
+
## Tests
|
|
80
|
+
|
|
81
|
+
- Unit tests (Vitest and jsdom or equivalent) cover every public function,
|
|
82
|
+
option and attribute, the no-DOM path, and `destroy` restoring markup.
|
|
83
|
+
Thresholds: 90 branches, 95 functions, 95 lines, 95 statements (the browser
|
|
84
|
+
entry and CSS are excluded from coverage; the project's check, such as
|
|
85
|
+
`bun run check`, must pass).
|
|
86
|
+
- Browser tests (Playwright in Chromium, Firefox and WebKit) cover anything that
|
|
87
|
+
depends on real layout, scrolling, frames or focus. Run them against the
|
|
88
|
+
built artifacts, not the source.
|
|
89
|
+
- Test the built output: ESM and CJS parity, the IIFE loaded as a classic
|
|
90
|
+
script, and the contents of the packed archive. Source tests pass while a
|
|
91
|
+
build config drops an export.
|
|
92
|
+
- Every example a reader can copy (README, docs, site) runs against the built
|
|
93
|
+
bundle, so documented code never drifts from what ships.
|
|
94
|
+
- A hybrid CSS and JS library tests both paths with the mode forced.
|
|
95
|
+
- A regression test fails first (see `samline-qa`).
|
|
96
|
+
|
|
97
|
+
## Size and manifest
|
|
98
|
+
|
|
99
|
+
- Every public entry has a gzip size budget in `package.json`, checked in CI.
|
|
100
|
+
- `type: module`, ESM and CJS with `.d.ts` for each entry, `exports` with
|
|
101
|
+
`types` first, `./package.json` exported, `sideEffects` set.
|
|
102
|
+
- `files` is an allowlist: built output, changelog and license only. Tests,
|
|
103
|
+
sites and agent files never ship. Test the pack manifest (`npm pack --dry-run`) so a missing or extra file fails CI.
|
|
104
|
+
- `engines` states the consumer runtime, not the maintainer's tooling: for
|
|
105
|
+
example `node >=20`; Bun never appears in `engines`.
|
|
106
|
+
|
|
107
|
+
## Release
|
|
108
|
+
|
|
109
|
+
- Keep a Changelog: every user-facing change adds an entry under `Unreleased`
|
|
110
|
+
(Breaking, Added, Changed, Fixed, Removed) and the semver bump follows the
|
|
111
|
+
entries; breaking or behavior changes are explicit.
|
|
112
|
+
- A public API change updates source, tests, README, docs, examples and any
|
|
113
|
+
integration skill in the same change.
|
|
114
|
+
- Validate the lockfile with an empty cache: a fresh
|
|
115
|
+
`pnpm install --frozen-lockfile` (use the project's install tool; in
|
|
116
|
+
@samline repos pnpm installs and `bun run` runs scripts), so the release does
|
|
117
|
+
not depend on a warm local store.
|
|
118
|
+
- Pin every CDN URL in the README, docs and examples to a version already
|
|
119
|
+
published on npm; a version in Git does not prove it is published. In
|
|
120
|
+
@samline repos follow the family `conventions/release.md` (version bump in
|
|
121
|
+
every pinned location, `chore(release): x.y.z` commit, `vx.y.z` tag).
|
|
122
|
+
- Run the full check (format, typecheck, coverage, build, size, browser tests)
|
|
123
|
+
before tagging. Tags are annotated, and a published tag is immutable.
|
|
124
|
+
- CI never publishes and never adds provenance; the maintainer publishes
|
|
125
|
+
locally. Check the registry before treating a version as published.
|
|
126
|
+
- Commit and tag, push, and publish are three separate approvals (see
|
|
127
|
+
`samline-workflow` when installed).
|
|
128
|
+
- Retire a library with `npm deprecate`, never `npm unpublish`: projects that
|
|
129
|
+
already depend on it must keep installing.
|
|
130
|
+
|
|
131
|
+
## Packages and dependencies
|
|
132
|
+
|
|
133
|
+
- A library that uses another installs the published version, pinned by semver
|
|
134
|
+
and lockfile. Never link, alias or import a sibling checkout (`link:`,
|
|
135
|
+
`file:`, workspace paths, relative imports into another repository).
|
|
136
|
+
Publish the dependency first, then upgrade the consumer.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Event and DOM traps for libraries
|
|
2
|
+
|
|
3
|
+
Each item is a rule and the reason behind it.
|
|
4
|
+
|
|
5
|
+
## Forms
|
|
6
|
+
|
|
7
|
+
- `requestSubmit()` dispatches the submit event synchronously. Code after it
|
|
8
|
+
runs after every handler; do not assume an async gap.
|
|
9
|
+
- A `reset` event fires before the form restores its default values. Defer
|
|
10
|
+
(a microtask or a frame) before reading values after a reset.
|
|
11
|
+
- Listen to `input` only. Listening to both `input` and `change` for the same
|
|
12
|
+
edit runs your logic twice.
|
|
13
|
+
- Re-enable a disabled control before waiting on it or moving focus: a
|
|
14
|
+
disabled element cannot take focus, so the focus call silently fails.
|
|
15
|
+
- `aria-invalid` follows what the user can see and fix: set it only on a
|
|
16
|
+
visible error, and clear it when the error is corrected.
|
|
17
|
+
|
|
18
|
+
## Observers and state
|
|
19
|
+
|
|
20
|
+
- Filter MutationObserver records. A callback that writes to the observed
|
|
21
|
+
subtree triggers itself; ignore records caused by your own attributes and
|
|
22
|
+
nodes.
|
|
23
|
+
- In a state `subscribe` callback, write derived text only when it changed.
|
|
24
|
+
Unconditional writes create a mutation feedback loop.
|
|
25
|
+
- Content cloned from a `<template>` needs its own initialization and cleanup;
|
|
26
|
+
cloning does not run your setup.
|
|
27
|
+
- Render initial choices as server `checked` or `selected` values. A late
|
|
28
|
+
prefill overwrote quick user edits.
|
|
29
|
+
|
|
30
|
+
## Overlays and focus
|
|
31
|
+
|
|
32
|
+
- Dismiss on outside press only when both press and release land on the
|
|
33
|
+
overlay; a drag that starts inside and ends outside must not close it.
|
|
34
|
+
- Ignore Escape while `isComposing`: it cancels the IME composition, not the
|
|
35
|
+
overlay.
|
|
36
|
+
- Restore focus with `focus({ preventScroll: true })` so closing does not jump
|
|
37
|
+
the page.
|
|
38
|
+
- Exiting or hidden items are `inert`, so they leave the tab order and the
|
|
39
|
+
accessibility tree while their exit runs.
|
|
40
|
+
- The trigger's `aria-expanded` and `aria-haspopup` persist across rebuilds;
|
|
41
|
+
a re-render must not drop them.
|
|
42
|
+
|
|
43
|
+
## Accessibility
|
|
44
|
+
|
|
45
|
+
- Never put `aria-label` on a toast or notification item that has visible text:
|
|
46
|
+
the label replaces the description assistive technology reads.
|
|
47
|
+
- Do not build a custom widget without its ARIA pattern and keyboard model; they
|
|
48
|
+
are part of the API and are tested.
|
|
49
|
+
|
|
50
|
+
## Looping tracks and motion
|
|
51
|
+
|
|
52
|
+
- Test the last-to-first seam of looping tracks; share the gap variable between
|
|
53
|
+
the source and the generated track.
|
|
54
|
+
- Entrance motion for visible blocks: see `samline-motion`.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: samline-motion
|
|
3
|
+
description: "Motion rules for any site, in vanilla CSS and JavaScript: never animate layout properties (prefer opacity and transform), one owner per animated property, scroll reveal that never hides visible content, no animation on initial state, reduced-motion fallbacks, cleanup. Use when adding or reviewing transitions, entrances, scroll reveals, hover or open/close motion. Defers to the project's AGENTS.md, DESIGN.md and stack skill; reveal details are in references/reveal-recipe.md."
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Motion the samline way
|
|
8
|
+
|
|
9
|
+
Precedence: the user's current instructions, then the project's `AGENTS.md`,
|
|
10
|
+
`DESIGN.md` and `.agents/memory`, then the stack skill (and `samline-package`
|
|
11
|
+
in @samline/* repositories), then this skill. When this skill disagrees with
|
|
12
|
+
them, follow them and mention the conflict once. An absolute "never" below
|
|
13
|
+
defers to `DESIGN.md` or a recorded owner decision.
|
|
14
|
+
|
|
15
|
+
Scope: these rules govern how a site or app uses motion. A package that owns
|
|
16
|
+
the element (drawer panel, toast, ticker track) animates its own nodes; its
|
|
17
|
+
exit and closed states are not hidden start states, as long as content is not
|
|
18
|
+
hidden without JavaScript. The package ships its own `prefers-reduced-motion`
|
|
19
|
+
handling in its stylesheet.
|
|
20
|
+
|
|
21
|
+
Motion is a tool for orientation and feedback, not decoration. These rules are
|
|
22
|
+
vanilla CSS and JavaScript with no animation library and no framework
|
|
23
|
+
dependency. The stack skill defines where scripts and styles live. Before CSS or
|
|
24
|
+
JavaScript work, search `modern-web-guidance` (scroll-driven animations, view
|
|
25
|
+
transitions and `animation-timeline` may replace script). Git, tooling and
|
|
26
|
+
evidence rules live in `samline-workflow`; markup rules in `samline-frontend`.
|
|
27
|
+
|
|
28
|
+
## Rules
|
|
29
|
+
|
|
30
|
+
- **Never animate layout properties** (`width`, `height`, `top`/`left`,
|
|
31
|
+
`margin`, `padding`): they trigger layout every frame and drop frames. Prefer
|
|
32
|
+
`opacity` and `transform` (the individual `translate`, `scale`, `rotate`
|
|
33
|
+
properties are fine). Short paint-only feedback (color, background, shadow,
|
|
34
|
+
filter, `clip-path`) is allowed when measured; `DESIGN.md` decides.
|
|
35
|
+
- **Never `transition: all`**; list the properties. `all` animates properties
|
|
36
|
+
you did not intend, including ones added later.
|
|
37
|
+
- **No persistent `will-change`.** Set it just before an animation and remove
|
|
38
|
+
it after; a permanent layer wastes memory and can blur text.
|
|
39
|
+
- **One owner per animated property.** From a site, never animate a node that a
|
|
40
|
+
package controls (a marquee track, a drawer panel, a parallax target), and
|
|
41
|
+
never nest reveals that compete for one transform. Animate a wrapper instead.
|
|
42
|
+
- **The initial state or selection never animates.** On load, a restored
|
|
43
|
+
tab or a preselected option is simply there; animation marks change.
|
|
44
|
+
- **Never hide visible content to replay an entrance.** Content already on
|
|
45
|
+
screen at first observation stays natural. A block that disappears and
|
|
46
|
+
returns reads as a bug.
|
|
47
|
+
- **No hidden start state without JavaScript.** Content stays readable with
|
|
48
|
+
JavaScript off or an API missing (`samline-frontend` when installed). The reveal recipe's
|
|
49
|
+
script-applied `pending` marker is the only permitted hidden state for scroll reveals (script-applied hidden regions: samline-frontend), applied
|
|
50
|
+
only to targets still offscreen at first observation (see
|
|
51
|
+
`references/reveal-recipe.md`).
|
|
52
|
+
- **`prefers-reduced-motion` gets a static fallback.** The content is shown
|
|
53
|
+
immediately and any running effect is cancelled, including when the setting
|
|
54
|
+
changes mid-animation.
|
|
55
|
+
- **Prefer one purposeful motion moment** over identical entrances on every
|
|
56
|
+
section, unless `DESIGN.md` or the owner fixes a motion language; then follow
|
|
57
|
+
it. Uniform fade-ins on every block make the page feel slow and hide the
|
|
58
|
+
hierarchy.
|
|
59
|
+
- **Auto-moving content longer than 5 seconds needs a pause or stop control**
|
|
60
|
+
(carousels, marquees, tickers), or an owner exception documented in
|
|
61
|
+
`DESIGN.md`. Never suppress a package's own reduced-motion policy.
|
|
62
|
+
- **Get geometry from observers** (`IntersectionObserver`, `ResizeObserver`),
|
|
63
|
+
not from per-item scroll listeners, because listeners run on every scroll
|
|
64
|
+
frame.
|
|
65
|
+
- **Clean up.** Every controller returns an idempotent cleanup that disconnects
|
|
66
|
+
observers, aborts listeners and cancels animations, and runs on navigation
|
|
67
|
+
and hot reload. A persisted `pagehide` keeps controllers alive and `pageshow` reuses
|
|
68
|
+
them; dispose only on real departures.
|
|
69
|
+
|
|
70
|
+
## Craft principles (adapted, not APIs)
|
|
71
|
+
|
|
72
|
+
Take the principles from motion-craft sources (such as the emilkowalski
|
|
73
|
+
skills) and write them in plain CSS and JavaScript:
|
|
74
|
+
|
|
75
|
+
- Keep durations short: fast for feedback and small state changes, longer only
|
|
76
|
+
for an entrance; slow motion reads as lag.
|
|
77
|
+
- Ease-out (decelerate) for entrances and short exits by default; continuous
|
|
78
|
+
loops (marquees, tickers) are linear; follow the project's effect dictionary
|
|
79
|
+
for page transitions (exits may use ease-in there). Make the easing explicit
|
|
80
|
+
and let the project set its own curve.
|
|
81
|
+
- Derive distances and speeds a library needs from `rem` at the API boundary,
|
|
82
|
+
never hardcoded `px`.
|
|
83
|
+
- Animation must be interruptible: a new input mid-animation continues from
|
|
84
|
+
the current state without a jump or a queue.
|
|
85
|
+
- Animate from where the element is (origin-aware), by a small distance; do
|
|
86
|
+
not travel full-screen for a small change.
|
|
87
|
+
- Their examples assume React, a motion library and Tailwind: do not install
|
|
88
|
+
any of them for these principles.
|
|
89
|
+
|
|
90
|
+
## Scroll reveal
|
|
91
|
+
|
|
92
|
+
If the project already has a reveal owner (a local runtime or a recipe), extend
|
|
93
|
+
it and never add a second one. Only when there is no reveal, use
|
|
94
|
+
`@samline/reveal` if the project already depends on it or `samline-catalog`
|
|
95
|
+
(when installed) recommends it, and record the choice in the project's
|
|
96
|
+
decisions. Otherwise follow
|
|
97
|
+
[references/reveal-recipe.md](references/reveal-recipe.md): states, first
|
|
98
|
+
observation rule, focus and hash handling, reduced motion, cleanup and the
|
|
99
|
+
acceptance matrix. A reveal that hides visible content (for example fading in
|
|
100
|
+
every block unconditionally) is retired, not extended.
|
|
101
|
+
|
|
102
|
+
## Check before "done"
|
|
103
|
+
|
|
104
|
+
- Reload while scrolled midway and with a hash: nothing visible disappears.
|
|
105
|
+
- Enable reduced motion before load and while an animation runs.
|
|
106
|
+
- Disable JavaScript: content is fully readable.
|
|
107
|
+
- Navigate away and back (and use back/forward): no duplicate controllers.
|
|
108
|
+
- Check the frame in a real browser; a throttled preview pane can misrepresent
|
|
109
|
+
frames, so scrub the animations or record in a headless browser.
|
|
110
|
+
|
|
111
|
+
## Known traps
|
|
112
|
+
|
|
113
|
+
- Do not restore playback on a drag when a package emits the same event for
|
|
114
|
+
drag and navigation.
|
|
115
|
+
- Do not clear a sticky header's revealed state on every small scroll; clear it
|
|
116
|
+
only at the top, or its offset changes and it jumps.
|
|
117
|
+
- Keep a presentation frame (a counter's intro, a flip) separate from the
|
|
118
|
+
logical value, accessible label and stored value.
|
|
119
|
+
- A loop seam needs one shared gap: test the last-to-first boundary.
|
|
120
|
+
- Updating options (theme, speed) must not restart running timers or
|
|
121
|
+
animations: pass only what changed.
|
|
122
|
+
- A package's stylesheet carries its own reduced-motion handling; do not
|
|
123
|
+
duplicate or override it from a site.
|
|
124
|
+
- View transitions: use the stack's view-transitions skill when installed.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Scroll reveal recipe (vanilla JS and CSS)
|
|
2
|
+
|
|
3
|
+
Use this only when the project has no reveal owner and `@samline/reveal` is not
|
|
4
|
+
installed or recommended. If a reveal owner exists, extend it instead. It is a
|
|
5
|
+
recipe to adapt inside the section that owns the targets, not a global
|
|
6
|
+
animation system. Reuse the project's lifecycle owner if it has one. No library
|
|
7
|
+
is needed.
|
|
8
|
+
|
|
9
|
+
## States
|
|
10
|
+
|
|
11
|
+
Each target moves through, once:
|
|
12
|
+
|
|
13
|
+
`natural` -> `pending` (offscreen only) -> `playing` -> `revealed`
|
|
14
|
+
|
|
15
|
+
- **natural**: ordinary visible HTML. The default, and the end state.
|
|
16
|
+
- **pending**: the only hidden state. Applied after the first observation, and
|
|
17
|
+
only to targets that are below the viewport. Marked with a data attribute
|
|
18
|
+
(for example `data-reveal-pending`) that the section's CSS styles.
|
|
19
|
+
- **playing**: an animation of `opacity` and `translate`, once. The animation
|
|
20
|
+
owns those two properties while it runs.
|
|
21
|
+
- **revealed**: natural styles restored, marker `data-reveal-done`, observers
|
|
22
|
+
disconnected. No replay when scrolling back.
|
|
23
|
+
|
|
24
|
+
A restrained start: opacity from 0 and a small translate (about 0.75rem) over
|
|
25
|
+
about 600 ms with ease-out, triggered a little before the target intersects
|
|
26
|
+
(a root margin of about 4rem, computed from the root font size). No default
|
|
27
|
+
delay and no stagger.
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
|
|
31
|
+
1. **First observation decides.** On the first observer report, a target that is
|
|
32
|
+
intersecting or already above the viewport bottom is `natural` and finishes
|
|
33
|
+
immediately. Never hide something the visitor could already have seen.
|
|
34
|
+
2. **Fast scrolling.** If a later report shows the target is already passed
|
|
35
|
+
(its bottom is above the viewport), finish without animating.
|
|
36
|
+
3. **No JavaScript, no support.** Missing `IntersectionObserver` or
|
|
37
|
+
`Element.animate`: stay natural. The pending style exists only while the
|
|
38
|
+
script is active.
|
|
39
|
+
4. **Reduced motion.** At load: finish immediately. When it turns on while
|
|
40
|
+
pending or playing: finish immediately and cancel the animation. Add a CSS
|
|
41
|
+
override of the pending style under `prefers-reduced-motion: reduce`.
|
|
42
|
+
5. **Focus and hash.** Focus moving into a target, or a hash that points inside
|
|
43
|
+
it, reveals it immediately and cancels the effect.
|
|
44
|
+
6. **One owner per property.** Never reveal a node another package transforms
|
|
45
|
+
(marquee track, drawer panel, parallax target) and never nest reveals.
|
|
46
|
+
7. **Cleanup.** Setup is idempotent per element (a `WeakMap` of element to
|
|
47
|
+
cleanup). The cleanup is safe to call twice: it finishes the target, aborts
|
|
48
|
+
listeners and disconnects the observer. Run it on navigation and hot reload.
|
|
49
|
+
8. **bfcache.** A persisted `pagehide` keeps controllers alive; `pageshow`
|
|
50
|
+
reuses them without replay. Only a real back/forward navigation proves it;
|
|
51
|
+
synthetic events only exercise listener branches.
|
|
52
|
+
9. **Animation promises.** Cancelling rejects `animation.finished`; handle or
|
|
53
|
+
avoid awaiting it so cancel never throws an unhandled rejection.
|
|
54
|
+
10. **No layered fill.** `fill: forwards` keeps the effect layered over later
|
|
55
|
+
styles; finish by restoring natural styles instead.
|
|
56
|
+
11. **Silent for assistive technology.** Decorative opacity must not create
|
|
57
|
+
`aria-live` announcements; keep targets out of live regions.
|
|
58
|
+
12. **Group markers.** A group marker (a wrapper that only tags its children)
|
|
59
|
+
never wraps children at runtime; mark each target instead.
|
|
60
|
+
13. **Explicit easing.** Ease-out by default; the project can set its own curve.
|
|
61
|
+
14. **Dynamic content** (deferred or client-rendered) needs an explicit owner
|
|
62
|
+
that calls setup after inserting the real wrapper and cleanup before
|
|
63
|
+
removing it. A placeholder is never a target. Do not add a global
|
|
64
|
+
mutation observer.
|
|
65
|
+
|
|
66
|
+
## Controller sketch
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
const mounted = new WeakMap();
|
|
70
|
+
|
|
71
|
+
export const setupReveal = (element) => {
|
|
72
|
+
const existing = mounted.get(element);
|
|
73
|
+
if (existing) return existing;
|
|
74
|
+
const events = new AbortController();
|
|
75
|
+
const motion = matchMedia("(prefers-reduced-motion: reduce)");
|
|
76
|
+
let observer;
|
|
77
|
+
let animation;
|
|
78
|
+
let initial = true;
|
|
79
|
+
let disposed = false;
|
|
80
|
+
|
|
81
|
+
const finish = () => {
|
|
82
|
+
element.dataset.revealDone = "true";
|
|
83
|
+
delete element.dataset.revealPending;
|
|
84
|
+
observer?.disconnect();
|
|
85
|
+
animation?.cancel();
|
|
86
|
+
animation = undefined;
|
|
87
|
+
};
|
|
88
|
+
const exposeHash = () => {
|
|
89
|
+
let id;
|
|
90
|
+
try {
|
|
91
|
+
id = decodeURIComponent(location.hash.slice(1));
|
|
92
|
+
} catch {
|
|
93
|
+
return; // A malformed hash cannot point inside the target.
|
|
94
|
+
}
|
|
95
|
+
const target = document.getElementById(id);
|
|
96
|
+
if (target && element.contains(target)) finish();
|
|
97
|
+
};
|
|
98
|
+
const cleanup = () => {
|
|
99
|
+
if (disposed) return;
|
|
100
|
+
disposed = true;
|
|
101
|
+
finish();
|
|
102
|
+
events.abort();
|
|
103
|
+
mounted.delete(element);
|
|
104
|
+
};
|
|
105
|
+
mounted.set(element, cleanup);
|
|
106
|
+
element.addEventListener("focusin", finish, { signal: events.signal });
|
|
107
|
+
window.addEventListener("hashchange", exposeHash, { signal: events.signal });
|
|
108
|
+
motion.addEventListener("change", () => motion.matches && finish(), {
|
|
109
|
+
signal: events.signal,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (
|
|
113
|
+
element.dataset.revealDone ||
|
|
114
|
+
motion.matches ||
|
|
115
|
+
!("IntersectionObserver" in window) ||
|
|
116
|
+
!element.animate ||
|
|
117
|
+
element.contains(document.activeElement)
|
|
118
|
+
) {
|
|
119
|
+
finish();
|
|
120
|
+
return cleanup;
|
|
121
|
+
}
|
|
122
|
+
// Initial hash check: a deep link into the target must never hide it.
|
|
123
|
+
exposeHash();
|
|
124
|
+
if (element.dataset.revealDone) return cleanup;
|
|
125
|
+
|
|
126
|
+
observer = new IntersectionObserver(
|
|
127
|
+
(entries) => {
|
|
128
|
+
if (disposed || element.dataset.revealDone) return;
|
|
129
|
+
for (const entry of entries) {
|
|
130
|
+
const visible =
|
|
131
|
+
entry.isIntersecting || entry.boundingClientRect.top < innerHeight;
|
|
132
|
+
if (initial) {
|
|
133
|
+
initial = false;
|
|
134
|
+
// Never hide content the visitor could already have seen.
|
|
135
|
+
if (visible) return finish();
|
|
136
|
+
element.dataset.revealPending = "true";
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
// Fast scrolling can pass a target between reports.
|
|
140
|
+
if (entry.boundingClientRect.bottom <= 0) return finish();
|
|
141
|
+
if (visible) {
|
|
142
|
+
observer.disconnect();
|
|
143
|
+
delete element.dataset.revealPending;
|
|
144
|
+
animation = element.animate(
|
|
145
|
+
[
|
|
146
|
+
{ opacity: 0, translate: "0 0.75rem" },
|
|
147
|
+
{ opacity: 1, translate: "0 0" },
|
|
148
|
+
],
|
|
149
|
+
{ duration: 600, easing: "ease-out" },
|
|
150
|
+
);
|
|
151
|
+
animation.onfinish = finish;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
threshold: 0,
|
|
158
|
+
rootMargin: `0px 0px ${4 * parseFloat(getComputedStyle(document.documentElement).fontSize)}px 0px`,
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
observer.observe(element);
|
|
162
|
+
return cleanup;
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
```css
|
|
167
|
+
[data-reveal][data-reveal-pending] {
|
|
168
|
+
opacity: 0;
|
|
169
|
+
translate: 0 0.75rem;
|
|
170
|
+
}
|
|
171
|
+
@media (prefers-reduced-motion: reduce) {
|
|
172
|
+
[data-reveal][data-reveal-pending] {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
translate: none;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Only the pending state hides content, and only while the script runs. The Web
|
|
180
|
+
Animations API owns opacity and `translate` during playback, so no competing
|
|
181
|
+
CSS transition, transform or delay may exist on the target.
|
|
182
|
+
|
|
183
|
+
## Mounting
|
|
184
|
+
|
|
185
|
+
Call `setupReveal` once per wrapper from the section that owns it. With
|
|
186
|
+
client-side navigation, clear every cleanup before the page swaps and mount
|
|
187
|
+
again after it; on hot reload, clear and abort. Without a router, a normal page
|
|
188
|
+
load is enough. The stack skill defines the navigation lifecycle events.
|
|
189
|
+
|
|
190
|
+
## Acceptance matrix
|
|
191
|
+
|
|
192
|
+
Check at narrow and wide widths, in both themes and with enlarged text:
|
|
193
|
+
|
|
194
|
+
| Situation | Expected result |
|
|
195
|
+
| ---------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
196
|
+
| Initial viewport, initial deep scroll, direct hash | Visible immediately; never hidden by the first report. |
|
|
197
|
+
| Below the viewport, slow and fast downward scrolling | Only unseen offscreen targets become pending; passed targets stay natural. |
|
|
198
|
+
| Animation completion and reverse scroll | Natural styles, no retained animation, no replay. |
|
|
199
|
+
| Keyboard focus or hash into a pending or playing target | Immediately visible; the active effect is cancelled. |
|
|
200
|
+
| No JS, missing observer or animation support | Natural readable HTML. |
|
|
201
|
+
| Reduced motion at load or enabled while pending or playing | Readable immediately; no effect, no replay after disabling. |
|
|
202
|
+
| Multiple instances, repeated setup, cleanup twice, remount | One controller per target; no duplicated observers or listeners. |
|
|
203
|
+
| Client navigation and hot reload | Old effects, observers and listeners released; fresh targets mount. |
|
|
204
|
+
| Real back/forward restoration from bfcache | Retained state; completed targets visible; no duplicate setup. |
|
|
205
|
+
| Deferred or dynamic insertion and removal | An explicit owner mounts real content and releases it before removal. |
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: samline-qa
|
|
3
|
+
description: Proof before saying "done" for web work. Rendered evidence matrix (320px, breakpoints, 200% text, both themes, every state, long copy), real-browser QA, SSR-before-hydration and real-input checks, regression tests that fail first, Lighthouse protocol, and test policy for client sites versus libraries. Use before reporting UI, form, layout or performance work as finished, when asked to QA, test or audit a page, or when choosing what tests a project needs. Project AGENTS.md wins.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# QA: proof before "done"
|
|
8
|
+
|
|
9
|
+
Extends the evidence bar in `samline-workflow` (see its `evidence-and-qa.md`); it
|
|
10
|
+
never replaces it.
|
|
11
|
+
|
|
12
|
+
Precedence: the user's current instructions, then the project's `AGENTS.md`,
|
|
13
|
+
`DESIGN.md` and `.agents/memory`, then the stack skill (and `samline-package` in
|
|
14
|
+
@samline/* repositories), then this skill. When this skill disagrees with them,
|
|
15
|
+
follow them and mention the conflict once. In a @samline/* repository,
|
|
16
|
+
`samline-package` and the repository's `AGENTS.md` are authoritative and this
|
|
17
|
+
skill never relaxes them.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- A build, typecheck or green test is not proof of what the user sees. Look at
|
|
22
|
+
the rendered result in a real browser; say which checks you did not run.
|
|
23
|
+
- Run the QA yourself and close with evidence. Never hand the user a checklist
|
|
24
|
+
to run: that moves the work, not the risk.
|
|
25
|
+
- Prefer the user's own browser through the browser extension when it is
|
|
26
|
+
available; a simulated or headless one hides real rendering, fonts and
|
|
27
|
+
autofill. A local browser cannot prove another OS's rendering (for example a
|
|
28
|
+
native select on Windows): say so instead of guessing.
|
|
29
|
+
- Confirm a viewport change by reading the DOM or taking a screenshot. A resize
|
|
30
|
+
API call that returned success does not prove the width changed.
|
|
31
|
+
- Review the whole composition, not only the changed part: green checks do not
|
|
32
|
+
prove visual quality.
|
|
33
|
+
|
|
34
|
+
## Evidence matrix (UI and layout)
|
|
35
|
+
|
|
36
|
+
Check each row on the rendered page, not in the code:
|
|
37
|
+
|
|
38
|
+
| Axis | What to cover |
|
|
39
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| Width | 320, 390, 768 and 1440px, every breakpoint the project configures (both sides), the user's real width. Never invent breakpoints |
|
|
41
|
+
| Text size | 200% browser text: nothing clips, overlaps or hides behind a fixed element |
|
|
42
|
+
| Theme | Light and dark, including focus rings, borders and disabled states |
|
|
43
|
+
| State | Hover, focus, pressed, current, disabled, empty, loading, error, success. Open every transient UI (toast, drawer, popover, dialog) in each variant and both themes: check contrast and usable width inside it, and scroll position and focus return after closing |
|
|
44
|
+
| Copy | The longest real label and a long translation, not placeholder text |
|
|
45
|
+
| Text width | Usable line length. No horizontal overflow is not enough: a column squeezed to a few characters still fails |
|
|
46
|
+
| No JS | Content and navigation still work when scripts do not run |
|
|
47
|
+
|
|
48
|
+
Reason for the width rule: bugs live at boundaries, and the project's own
|
|
49
|
+
breakpoints are the only ones its CSS reacts to.
|
|
50
|
+
|
|
51
|
+
## Captures, journeys and verdicts
|
|
52
|
+
|
|
53
|
+
- Journeys: visit states in sequence, not only one by one: switch mode and come
|
|
54
|
+
back, repeat an action, close and reopen, correct an input. Then confirm
|
|
55
|
+
controls, results and links still agree.
|
|
56
|
+
- Label every capture (viewport, scroll position, mode, state), open the file
|
|
57
|
+
before sending it, and clear focus (the skip link) before a composition
|
|
58
|
+
capture. A capture artifact is not automatically a design defect.
|
|
59
|
+
- A verdict states its scope: fidelity to a reference, working behavior and
|
|
60
|
+
editorial quality are separate judgments. Without a quality reference, say the
|
|
61
|
+
verdict covers fidelity and behavior only.
|
|
62
|
+
- An automated accessibility pass is scoped evidence, not WCAG certification.
|
|
63
|
+
- Triage findings in order: broken tasks and inaccessible paths, missing
|
|
64
|
+
states, hierarchy and responsive drift, visual details, cleanup.
|
|
65
|
+
|
|
66
|
+
## Behavior checks
|
|
67
|
+
|
|
68
|
+
- SSR before hydration: read the initial HTML (view source or disable JS). A
|
|
69
|
+
control that JavaScript disables later (`:disabled` from a framework) is
|
|
70
|
+
active until hydration, so protect it in the markup.
|
|
71
|
+
- Real input: test paste, browser autofill and the real keyboard in a real
|
|
72
|
+
browser. A synthetic `beforeinput` or `input` event misses paste and autofill.
|
|
73
|
+
- Keyboard: tab order, visible focus, Escape and Enter, focus return after an
|
|
74
|
+
overlay closes.
|
|
75
|
+
- Scroll: reload while scrolled and test anchors with fixed headers.
|
|
76
|
+
- A mock is not a live provider; localhost is not the deployed site. Name the
|
|
77
|
+
environment each result comes from.
|
|
78
|
+
|
|
79
|
+
## Regression tests
|
|
80
|
+
|
|
81
|
+
- Write the test, run it against the previous artifact (or with the fix
|
|
82
|
+
reverted) and see it fail. A test that never failed proves nothing.
|
|
83
|
+
- Then fix and see it pass. Report both runs.
|
|
84
|
+
- A test filter (Playwright `--grep`) also matches project and file names: check
|
|
85
|
+
that the intended tests actually ran, not zero or too many.
|
|
86
|
+
|
|
87
|
+
## Lighthouse and performance
|
|
88
|
+
|
|
89
|
+
- Measure a production build, never the dev server.
|
|
90
|
+
- Run three cold mobile runs and report the median; a single run is noise.
|
|
91
|
+
- Label lab data as lab and field data as field; never mix them.
|
|
92
|
+
- A failed or crashed run is "unverified", not a pass.
|
|
93
|
+
- Keep performance work inside the agreed boundary: do not trade visual or
|
|
94
|
+
content decisions for a score.
|
|
95
|
+
- Stop only the measurement servers you started; the project's managed dev
|
|
96
|
+
server stays under its manager (see `samline-workflow`, Dev servers and
|
|
97
|
+
processes).
|
|
98
|
+
|
|
99
|
+
## Test policy by project type
|
|
100
|
+
|
|
101
|
+
- Client site: one check command (lint, format, typecheck), browser evidence
|
|
102
|
+
from the matrix above, and Playwright e2e only for critical flows (forms,
|
|
103
|
+
checkout, login). No coverage target; add unit tests where logic warrants them.
|
|
104
|
+
- Library: unit tests with coverage thresholds of 90 branches, 95 functions, 95
|
|
105
|
+
lines and 95 statements (browser entry and CSS excluded from coverage; the
|
|
106
|
+
project's check script must pass); browser tests against the built artifacts
|
|
107
|
+
in Chromium, Firefox and WebKit; every copyable README example runs as a test.
|
|
108
|
+
See `samline-library` when installed.
|
|
109
|
+
- Pin one Playwright version per repository and install its browsers with the
|
|
110
|
+
repository's own Playwright (`pnpm exec playwright install <browsers>`), so
|
|
111
|
+
every run uses the same builds. In @samline/* repos the version is the
|
|
112
|
+
template's exact pin, changed only in the template and then synced; never
|
|
113
|
+
change it locally.
|
|
114
|
+
- Test naming: see `samline-workflow` `references/evidence-and-qa.md`.
|
|
115
|
+
|
|
116
|
+
## Report
|
|
117
|
+
|
|
118
|
+
State what was verified and how, what was not and why, and what remains open.
|
|
119
|
+
Never write "should work".
|