@ericrisco/rsc 1.0.27 → 1.0.28
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/README.md +22 -4
- package/manifest.json +230 -2
- package/package.json +1 -1
- package/scripts/detect-repo.js +27 -1
- package/scripts/lib/domains.js +3 -2
- package/skills/animate/SKILL.md +228 -0
- package/skills/animate/evals/cases.yaml +36 -0
- package/skills/animate/references/recipes.md +324 -0
- package/skills/animate-expo/SKILL.md +281 -0
- package/skills/animate-expo/evals/cases.yaml +36 -0
- package/skills/animate-expo/references/recipes.md +385 -0
- package/skills/animation-vocabulary/SKILL.md +189 -0
- package/skills/animation-vocabulary/evals/cases.yaml +31 -0
- package/skills/apple-design/SKILL.md +301 -0
- package/skills/apple-design/evals/cases.yaml +33 -0
- package/skills/ask-sonner/SKILL.md +104 -0
- package/skills/ask-sonner/evals/cases.yaml +33 -0
- package/skills/ask-sonner/references/api.md +64 -0
- package/skills/design/SKILL.md +8 -0
- package/skills/design/references/motion-and-interaction.md +14 -3
- package/skills/design/references/visual-system.md +4 -3
- package/skills/design-eng/SKILL.md +724 -0
- package/skills/design-eng/evals/cases.yaml +36 -0
- package/skills/expo/SKILL.md +6 -0
- package/skills/find-animation-opportunities/SKILL.md +150 -0
- package/skills/find-animation-opportunities/evals/cases.yaml +31 -0
- package/skills/improve-animations/SKILL.md +126 -0
- package/skills/improve-animations/evals/cases.yaml +31 -0
- package/skills/improve-animations/references/audit.md +115 -0
- package/skills/improve-animations/references/plan-template.md +73 -0
- package/skills/pick-ui-library/SKILL.md +100 -0
- package/skills/pick-ui-library/evals/cases.yaml +33 -0
- package/skills/prototype/SKILL.md +113 -0
- package/skills/prototype/evals/cases.yaml +31 -0
- package/skills/prototype/references/picker.md +197 -0
- package/skills/react/SKILL.md +6 -0
- package/skills/react-native/SKILL.md +5 -0
- package/skills/review-animations/SKILL.md +137 -0
- package/skills/review-animations/evals/cases.yaml +34 -0
- package/skills/review-animations/references/standards.md +187 -0
- package/skills/review-animations/scripts/verify.sh +164 -0
- package/skills/swift-ios/SKILL.md +7 -0
- package/skills/write-swift/SKILL.md +413 -0
- package/skills/write-swift/evals/cases.yaml +36 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
skill: review-animations
|
|
2
|
+
|
|
3
|
+
should_trigger:
|
|
4
|
+
- prompt: "Review the animations in this pull request and tell me what's wrong with them."
|
|
5
|
+
why: "Reviewing motion in a diff: the skill's core object."
|
|
6
|
+
- prompt: "Is the easing and duration on this modal transition right?"
|
|
7
|
+
why: "A judgement call against the easing and duration standards."
|
|
8
|
+
- prompt: "Check this component's motion against a strict craft bar before I merge it."
|
|
9
|
+
why: "The bar and the merge gate are what this skill provides."
|
|
10
|
+
- prompt: "Critique the transitions I just wrote — be harsh."
|
|
11
|
+
why: "Default-to-flagging posture; approval is earned."
|
|
12
|
+
- prompt: "Did I get the transform-origin and the reduced-motion handling right on this popover?"
|
|
13
|
+
why: "Two of the ten non-negotiable standards, named directly."
|
|
14
|
+
|
|
15
|
+
should_not_trigger:
|
|
16
|
+
- prompt: "Audit the animations across the whole app and give me a prioritized roadmap of fixes."
|
|
17
|
+
route_to: "improve-animations"
|
|
18
|
+
why: "Whole-codebase audit producing plans, not a verdict on one diff."
|
|
19
|
+
- prompt: "Animate this dropdown for me with the right curve and duration."
|
|
20
|
+
route_to: "animate"
|
|
21
|
+
why: "Building the animation, not reviewing one."
|
|
22
|
+
- prompt: "Review this pull request for SQL injection and missing authorization checks."
|
|
23
|
+
route_to: "code-review"
|
|
24
|
+
why: "Non-motion code review; this skill declines and points there."
|
|
25
|
+
- prompt: "What could be animated in this settings page that isn't animated today?"
|
|
26
|
+
route_to: "find-animation-opportunities"
|
|
27
|
+
why: "Looking for absent motion, not judging present motion."
|
|
28
|
+
- prompt: "Pick a library for the command palette instead of the div-based one we have."
|
|
29
|
+
route_to: "pick-ui-library"
|
|
30
|
+
why: "A dependency choice, not a motion review."
|
|
31
|
+
|
|
32
|
+
capability:
|
|
33
|
+
- scenario: "A diff adds `transition: all 400ms ease-in` and a `transform: scale(0)` entrance to a popover with `transform-origin: center`, and no reduced-motion handling anywhere in the project."
|
|
34
|
+
expect: "Runs scripts/verify.sh first so the countable findings come from the checker (transition-all, ease-in-ui, scale-zero-entrance, origin-center-popover, reduced-motion-missing) and spends judgement on frequency, purpose and cohesion. Blocks rather than approves, and every finding carries the exact replacement value."
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Animation Standards Reference
|
|
2
|
+
|
|
3
|
+
The precise values, curves, and rules behind the review. Cite these in findings instead of approximating. Distilled from Emil Kowalski's design engineering philosophy.
|
|
4
|
+
|
|
5
|
+
## Should it animate? (frequency table)
|
|
6
|
+
|
|
7
|
+
| Frequency | Decision |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 100+ times/day (keyboard shortcuts, command palette toggle) | No animation. Ever. |
|
|
10
|
+
| Tens of times/day (hover effects, list navigation) | Remove or drastically reduce |
|
|
11
|
+
| Occasional (modals, drawers, toasts) | Standard animation |
|
|
12
|
+
| Rare / first-time (onboarding, feedback, celebrations) | Can add delight |
|
|
13
|
+
|
|
14
|
+
**Never animate keyboard-initiated actions** — they repeat hundreds of times daily; animation makes them feel slow and disconnected. (Raycast has no open/close animation — correct for something used hundreds of times a day.)
|
|
15
|
+
|
|
16
|
+
Valid purposes for motion: spatial consistency, state indication, explanation, feedback, preventing jarring change. "It looks cool" on a frequently-seen element is not valid.
|
|
17
|
+
|
|
18
|
+
## Easing
|
|
19
|
+
|
|
20
|
+
Decision order:
|
|
21
|
+
- Entering or exiting → **`ease-out`** (starts fast, feels responsive)
|
|
22
|
+
- Moving / morphing on screen → **`ease-in-out`**
|
|
23
|
+
- Hover / color change → **`ease`**
|
|
24
|
+
- Constant motion (marquee, progress) → **`linear`**
|
|
25
|
+
- Default → **`ease-out`**
|
|
26
|
+
|
|
27
|
+
**Never `ease-in` on UI.** It starts slow, delaying the exact moment the user is watching. `ease-out` at 200ms *feels* faster than `ease-in` at 200ms.
|
|
28
|
+
|
|
29
|
+
Built-in CSS easings are too weak. Use strong custom curves:
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
--ease-out: cubic-bezier(0.23, 1, 0.32, 1); /* strong ease-out for UI */
|
|
33
|
+
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); /* strong ease-in-out for on-screen movement */
|
|
34
|
+
--ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); /* iOS-like drawer curve (Ionic) */
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Find curves at [easing.dev](https://easing.dev/) or [easings.co](https://easings.co/) — don't hand-roll from scratch.
|
|
38
|
+
|
|
39
|
+
## Duration
|
|
40
|
+
|
|
41
|
+
| Element | Duration |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| Button press feedback | 100–160ms |
|
|
44
|
+
| Tooltips, small popovers | 125–200ms |
|
|
45
|
+
| Dropdowns, selects | 150–250ms |
|
|
46
|
+
| Modals, drawers | 200–500ms |
|
|
47
|
+
| Marketing / explanatory | Can be longer |
|
|
48
|
+
|
|
49
|
+
**Rule: UI animations stay under 300ms.** A 180ms dropdown feels more responsive than a 400ms one. Faster spinners make load feel faster (same actual time). Instant tooltips after the first (skip delay + animation) make a toolbar feel faster.
|
|
50
|
+
|
|
51
|
+
## Physicality
|
|
52
|
+
|
|
53
|
+
- **Never `scale(0)`.** Start from `scale(0.9–0.97)` + `opacity: 0`. Nothing in the real world appears from nothing.
|
|
54
|
+
- **Origin-aware popovers.** Scale from the trigger, not center:
|
|
55
|
+
```css
|
|
56
|
+
.popover { transform-origin: var(--transform-origin); } /* Base UI */
|
|
57
|
+
```
|
|
58
|
+
**Modals are exempt** — they appear centered in the viewport, keep `transform-origin: center`.
|
|
59
|
+
- **Button press feedback.** `transform: scale(0.97)` on `:active`, `transition: transform 160ms ease-out`. Subtle (0.95–0.98). Applies to any pressable element.
|
|
60
|
+
|
|
61
|
+
## Springs
|
|
62
|
+
|
|
63
|
+
Feel natural because they simulate physics; no fixed duration — they settle on parameters. Use for: drag with momentum, "alive" elements (Dynamic Island), interruptible gestures, decorative mouse-tracking.
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
// Apple-style (easier to reason about) — recommended
|
|
67
|
+
{ type: "spring", duration: 0.5, bounce: 0.2 }
|
|
68
|
+
|
|
69
|
+
// Traditional physics (more control)
|
|
70
|
+
{ type: "spring", mass: 1, stiffness: 100, damping: 10 }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Keep bounce subtle (0.1–0.3); avoid bounce in most UI — reserve for drag-to-dismiss and playful interactions. Springs maintain velocity when interrupted (keyframes restart from zero), so they're ideal for gestures users may reverse mid-motion.
|
|
74
|
+
|
|
75
|
+
Mouse interactions: interpolate with `useSpring` rather than tying value directly to mouse position (direct = artificial, no momentum). Only do this when the motion is decorative.
|
|
76
|
+
|
|
77
|
+
## Interruptibility
|
|
78
|
+
|
|
79
|
+
CSS **transitions** can be interrupted and retargeted mid-animation; **keyframes** restart from zero. For anything triggered rapidly (toasts being added, toggles), transitions are smoother.
|
|
80
|
+
|
|
81
|
+
```css
|
|
82
|
+
/* Interruptible — good for dynamic UI */
|
|
83
|
+
.toast { transition: transform 400ms ease; }
|
|
84
|
+
|
|
85
|
+
/* Not interruptible — avoid for dynamic UI */
|
|
86
|
+
@keyframes slideIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `@starting-style` for entry without JS:
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
.toast {
|
|
93
|
+
opacity: 1; transform: translateY(0);
|
|
94
|
+
transition: opacity 400ms ease, transform 400ms ease;
|
|
95
|
+
@starting-style { opacity: 0; transform: translateY(100%); }
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Legacy fallback: `useEffect(() => setMounted(true), [])` + `data-mounted` attribute.
|
|
100
|
+
|
|
101
|
+
## Asymmetric timing
|
|
102
|
+
|
|
103
|
+
Slow where the user is deciding, fast where the system responds.
|
|
104
|
+
|
|
105
|
+
```css
|
|
106
|
+
.overlay { transition: clip-path 200ms ease-out; } /* release: fast */
|
|
107
|
+
.button:active .overlay { transition: clip-path 2s linear; } /* press: slow, deliberate */
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Performance
|
|
111
|
+
|
|
112
|
+
- **Only animate `transform` and `opacity`** — they skip layout/paint and run on the GPU. `padding`/`margin`/`height`/`width`/`top`/`left` trigger all three rendering steps.
|
|
113
|
+
- **Don't drive child transforms via a CSS variable on the parent** — it recalcs styles for all children. Set `transform` directly on the element.
|
|
114
|
+
```js
|
|
115
|
+
element.style.setProperty('--swipe-amount', `${d}px`); // bad: recalc on all children
|
|
116
|
+
element.style.transform = `translateY(${d}px)`; // good: only this element
|
|
117
|
+
```
|
|
118
|
+
- **Framer Motion shorthands are NOT hardware-accelerated.** `x`/`y`/`scale` run on the main thread via rAF and drop frames under load. Use the full transform string:
|
|
119
|
+
```jsx
|
|
120
|
+
<motion.div animate={{ x: 100 }} /> // drops frames under load
|
|
121
|
+
<motion.div animate={{ transform: "translateX(100px)" }} /> // hardware accelerated
|
|
122
|
+
```
|
|
123
|
+
- **CSS animations beat JS under load** — they run off the main thread; rAF-based animations stutter while the browser loads/scripts/paints. Use CSS for predetermined motion, JS for dynamic/interruptible.
|
|
124
|
+
- **WAAPI** gives JS control with CSS performance (hardware-accelerated, interruptible, no library):
|
|
125
|
+
```js
|
|
126
|
+
element.animate([{ clipPath: 'inset(0 0 100% 0)' }, { clipPath: 'inset(0 0 0 0)' }],
|
|
127
|
+
{ duration: 1000, fill: 'forwards', easing: 'cubic-bezier(0.77, 0, 0.175, 1)' });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Transforms & clip-path
|
|
131
|
+
|
|
132
|
+
- **`translate` percentages** are relative to the element's own size — `translateY(100%)` moves by the element's height regardless of dimensions (how Sonner/Vaul position toasts/drawers). Prefer over hardcoded px.
|
|
133
|
+
- **`scale()` scales children too** (font, icons, content) — a feature for press feedback.
|
|
134
|
+
- **3D**: `rotateX/Y` + `transform-style: preserve-3d` for depth/orbit/flip without JS.
|
|
135
|
+
- **`clip-path: inset(t r b l)`** is a powerful animation tool: each value eats in from that side. Uses: reveal-on-scroll (`inset(0 0 100% 0)` → `inset(0 0 0 0)`), hold-to-delete overlay, seamless tab color transitions (duplicate + clip the active copy), comparison sliders.
|
|
136
|
+
|
|
137
|
+
## Gestures & drag
|
|
138
|
+
|
|
139
|
+
- **Momentum dismissal**: don't require crossing a distance threshold — compute velocity (`Math.abs(distance)/elapsedMs`); dismiss if `> ~0.11`. A flick should be enough.
|
|
140
|
+
- **Damping at boundaries**: dragging past a natural edge moves less the further you go (real things slow before stopping).
|
|
141
|
+
- **Pointer capture** once dragging starts, so it continues when the pointer leaves bounds.
|
|
142
|
+
- **Multi-touch protection**: ignore extra touch points after the drag begins (`if (isDragging) return`) — prevents jumps.
|
|
143
|
+
- **Friction over hard stops** — allow over-drag with rising resistance rather than an invisible wall.
|
|
144
|
+
|
|
145
|
+
## Masking imperfect crossfades
|
|
146
|
+
|
|
147
|
+
When a crossfade shows two overlapping states despite tuning easing/duration, add subtle `filter: blur(2px)` during the transition to blend them into one perceived transformation. Keep blur < 20px (heavy blur is expensive, especially Safari).
|
|
148
|
+
|
|
149
|
+
## Stagger
|
|
150
|
+
|
|
151
|
+
Stagger group entrances; 30–80ms between items. Longer delays feel slow. Stagger is decorative — never block interaction while it plays.
|
|
152
|
+
|
|
153
|
+
```css
|
|
154
|
+
.item { opacity: 0; transform: translateY(8px); animation: fadeIn 300ms ease-out forwards; }
|
|
155
|
+
.item:nth-child(2) { animation-delay: 50ms; }
|
|
156
|
+
.item:nth-child(3) { animation-delay: 100ms; }
|
|
157
|
+
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Accessibility
|
|
161
|
+
|
|
162
|
+
```css
|
|
163
|
+
@media (prefers-reduced-motion: reduce) {
|
|
164
|
+
.element { animation: fade 0.2s ease; } /* keep opacity/color, drop transform-based motion */
|
|
165
|
+
}
|
|
166
|
+
@media (hover: hover) and (pointer: fine) {
|
|
167
|
+
.element:hover { transform: scale(1.05); } /* gate hover motion — touch fires false hovers on tap */
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```jsx
|
|
172
|
+
const reduce = useReducedMotion();
|
|
173
|
+
const closedX = reduce ? 0 : '-100%';
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Reduced motion means fewer and gentler animations, not zero — keep transitions that aid comprehension, remove movement/position changes.
|
|
177
|
+
|
|
178
|
+
## Debugging (recommend in reviews when feel is uncertain)
|
|
179
|
+
|
|
180
|
+
- **Slow motion**: bump duration 2–5× or use DevTools animation inspector. Check colors crossfade cleanly, easing doesn't stop abruptly, `transform-origin` is right, coordinated properties stay in sync.
|
|
181
|
+
- **Frame-by-frame**: Chrome DevTools Animations panel reveals timing drift between coordinated properties.
|
|
182
|
+
- **Real devices** for gestures (drawers, swipe) — connect a phone, hit the dev server by IP, use Safari remote devtools.
|
|
183
|
+
- **Fresh eyes next day** — imperfections invisible during development surface later.
|
|
184
|
+
|
|
185
|
+
## Cohesion
|
|
186
|
+
|
|
187
|
+
Match motion to the component's personality: playful can be bouncier; a professional dashboard should be crisp and fast. Sonner feels right partly because easing, duration, design, and even the name are in harmony — slightly slower, `ease` rather than `ease-out`, to feel elegant. Opacity + height in entering/exiting lists is trial and error; there's no formula — adjust until it feels right.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# verify.sh — the checkable half of the motion craft bar.
|
|
4
|
+
#
|
|
5
|
+
# WHAT THIS IS
|
|
6
|
+
# The source material for these skills (emilkowalski/skills, MIT) ships its "Never Ship" bar as
|
|
7
|
+
# a markdown table: prose an agent may or may not honor. Part of that bar is a plain pattern in
|
|
8
|
+
# the code — `transition: all`, an entrance from `scale(0)`, `ease-in` on a UI transition — and
|
|
9
|
+
# anything that is a pattern belongs in a binary, not in a paragraph (constitution P1).
|
|
10
|
+
#
|
|
11
|
+
# So this script owns the countable half, and the SKILL.md bodies own the half that needs
|
|
12
|
+
# judgement (is the frequency tier right? does the motion have a purpose? does it feel right?).
|
|
13
|
+
# Nothing here can tell you whether an animation feels good. It tells you when it is definitely
|
|
14
|
+
# wrong.
|
|
15
|
+
#
|
|
16
|
+
# WHAT IT CHECKS
|
|
17
|
+
# - the tell registry: one row per checkable motion defect, iterated generically — see
|
|
18
|
+
# motion_tell_table(). Every row has a fixture in tests/fixtures/motion-tells/ and is driven
|
|
19
|
+
# from tests/motion-tells.test.js; a row without a fixture fails the suite.
|
|
20
|
+
# - one counter that cannot be a row: motion present with no prefers-reduced-motion guard
|
|
21
|
+
# anywhere. Absence of a guard is not a pattern match, so it gets its own check and its own
|
|
22
|
+
# named test.
|
|
23
|
+
#
|
|
24
|
+
# HOW TO RUN (inside YOUR project, not the skills repo)
|
|
25
|
+
# bash verify.sh # fail-severity rows break the build; warns are advisory
|
|
26
|
+
# bash verify.sh --strict # treat warnings as failures too
|
|
27
|
+
#
|
|
28
|
+
# EXIT CODES
|
|
29
|
+
# 0 no fail-severity finding (and no warning, under --strict)
|
|
30
|
+
# 1 a fail-severity finding, or --strict with any warning
|
|
31
|
+
# 2 bad usage
|
|
32
|
+
#
|
|
33
|
+
# Missing tools are SKIPPED with a notice, never failed.
|
|
34
|
+
|
|
35
|
+
set -euo pipefail
|
|
36
|
+
|
|
37
|
+
# --- portability: runs on stock macOS bash 3.2 ------------------------------
|
|
38
|
+
# No mapfile, no associative arrays, no `${arr[@]}` under set -u — same constraint as design's
|
|
39
|
+
# verify.sh, for the same reason: the default /bin/bash on macOS is 3.2.
|
|
40
|
+
if [ -z "${BASH_VERSION:-}" ]; then
|
|
41
|
+
printf 'This script requires bash (any version >= 3.2). Run: bash %s\n' "$0" >&2
|
|
42
|
+
exit 2
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
STRICT=0
|
|
46
|
+
while [ "$#" -gt 0 ]; do
|
|
47
|
+
case "$1" in
|
|
48
|
+
--strict) STRICT=1; shift ;;
|
|
49
|
+
-h|--help) sed -n '2,32p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
50
|
+
*) printf 'unknown argument: %s\n' "$1" >&2; exit 2 ;;
|
|
51
|
+
esac
|
|
52
|
+
done
|
|
53
|
+
|
|
54
|
+
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
|
|
55
|
+
RED=$'\033[31m'; GREEN=$'\033[32m'; YELLOW=$'\033[33m'; NC=$'\033[0m'
|
|
56
|
+
else
|
|
57
|
+
RED=''; GREEN=''; YELLOW=''; NC=''
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
ok_count=0; skip_count=0; warn_count=0; fail_count=0
|
|
61
|
+
SELF_NAME="$(basename "$0")"
|
|
62
|
+
|
|
63
|
+
ok() { printf '%s ok %s %s\n' "$GREEN" "$NC" "$1"; ok_count=$((ok_count + 1)); }
|
|
64
|
+
skip() { printf '%sskip %s %s\n' "$YELLOW" "$NC" "$1"; skip_count=$((skip_count + 1)); }
|
|
65
|
+
warn() { printf '%swarn %s %s\n' "$YELLOW" "$NC" "$1"; warn_count=$((warn_count + 1)); }
|
|
66
|
+
fail() { printf '%sfail %s %s\n' "$RED" "$NC" "$1"; fail_count=$((fail_count + 1)); }
|
|
67
|
+
|
|
68
|
+
have() { command -v "$1" >/dev/null 2>&1; }
|
|
69
|
+
|
|
70
|
+
search() {
|
|
71
|
+
[ "$#" -gt 0 ] || return 1
|
|
72
|
+
# VERIFY_FORCE_GREP=1 pins the grep branch so the suite can prove both engines agree, instead
|
|
73
|
+
# of only exercising whichever one happens to be installed.
|
|
74
|
+
if have rg && [ -z "${VERIFY_FORCE_GREP:-}" ]; then
|
|
75
|
+
rg -n --no-heading --glob "!$SELF_NAME" "$@"
|
|
76
|
+
else
|
|
77
|
+
local pattern="${*: -1}"
|
|
78
|
+
grep -rnE \
|
|
79
|
+
--exclude="$SELF_NAME" \
|
|
80
|
+
--exclude-dir=node_modules --exclude-dir=.git --exclude-dir=.next \
|
|
81
|
+
--exclude-dir=dist --exclude-dir=build \
|
|
82
|
+
"$pattern" . 2>/dev/null
|
|
83
|
+
fi
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# --- the tell registry ------------------------------------------------------
|
|
87
|
+
# Columns, delimited by %% (the pattern column needs `|` for ERE alternation):
|
|
88
|
+
# id %% sev %% extensions %% POSIX-ERE pattern %% what to do instead / the legit exception
|
|
89
|
+
#
|
|
90
|
+
# Patterns are POSIX ERE: no lookahead, no \b, no \s — they must behave identically under rg and
|
|
91
|
+
# under grep -E. The bar they encode is adapted from emilkowalski/skills (MIT).
|
|
92
|
+
#
|
|
93
|
+
# Severity is load-bearing, not decoration. `fail` is for a defect with no legitimate reading;
|
|
94
|
+
# `warn` is for a pattern whose exception is real and cannot be seen from one line (a centered
|
|
95
|
+
# modal, an accordion animating height). A table where everything fails gets switched off (P7).
|
|
96
|
+
motion_tell_table() {
|
|
97
|
+
cat <<'TELLS'
|
|
98
|
+
transition-all%%fail%%tsx,jsx,ts,js,css,scss,html,vue,svelte%%transition:[[:space:]]*all|transition-all%%transition: all animates every property that ever changes, including layout ones, and janks. Name the exact properties instead: transition-property: transform, opacity
|
|
99
|
+
scale-zero-entrance%%fail%%tsx,jsx,ts,js,css,scss,html,vue,svelte%%scale\(0\)|scale3d\(0,|scale:[[:space:]]*0[,;}[:space:]]%%nothing in the real world appears from nothing, so an entrance from zero scale reads as broken. Start from scale(0.9)-scale(0.97) plus opacity: 0
|
|
100
|
+
ease-in-ui%%fail%%tsx,jsx,ts,js,css,scss,html,vue,svelte%%(^|[^a-zA-Z])ease-in([^-]|$)%%ease-in starts slow, delaying the exact moment the user is watching, so the interface feels sluggish. Use ease-out, or the stronger cubic-bezier(0.23, 1, 0.32, 1). Legitimate exception: an exit that must accelerate off-screen
|
|
101
|
+
origin-center-popover%%warn%%tsx,jsx,ts,js,css,scss,html,vue,svelte%%transform-origin:[[:space:]]*center%%a popover, dropdown, menu or tooltip should grow out of the trigger that opened it, not out of its own middle. Use transform-origin: var(--transform-origin). Legitimate exception: a modal, which is not anchored to a trigger and stays centered
|
|
102
|
+
layout-property-animation%%warn%%css,scss%%transition-property:[[:space:]]*(width|height|margin|padding|top|left)|transition:[[:space:]]*(width|height|margin|padding|top|left)[[:space:]]%%animating a layout property triggers layout, paint and composite every frame. Animate transform and opacity instead. Legitimate exception: an accordion height, which has no transform equivalent
|
|
103
|
+
motion-shorthand-under-load%%warn%%tsx,jsx,ts,js%%animate=\{\{[[:space:]]*(x|y|scale):%%the Motion x/y/scale shorthands are not hardware-accelerated: they run on the main thread and drop frames while the page is busy. Use the full transform string: animate={{ transform: "translateX(100px)" }}
|
|
104
|
+
TELLS
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
run_motion_tell_table() {
|
|
108
|
+
local line id sev globs pat msg hits exts rest
|
|
109
|
+
# NOT `IFS='%%'`: IFS is a set of characters, so it would split on a single `%`. Parameter
|
|
110
|
+
# expansion splits on the two-character delimiter exactly, which the pattern column needs to
|
|
111
|
+
# keep its ERE `|`.
|
|
112
|
+
while IFS= read -r line; do
|
|
113
|
+
case "$line" in ''|'#'*) continue ;; esac
|
|
114
|
+
id="${line%%"%%"*}"; rest="${line#*"%%"}"
|
|
115
|
+
sev="${rest%%"%%"*}"; rest="${rest#*"%%"}"
|
|
116
|
+
globs="${rest%%"%%"*}"; rest="${rest#*"%%"}"
|
|
117
|
+
pat="${rest%%"%%"*}"; msg="${rest#*"%%"}"
|
|
118
|
+
exts="${globs//,/|}"
|
|
119
|
+
# Two post-filters, both taken from design/scripts/verify.sh where they were learned from a
|
|
120
|
+
# real run: keep only the extensions the row declares (anchored before the first colon, so it
|
|
121
|
+
# behaves the same under rg and grep and never matches content that merely names a file), and
|
|
122
|
+
# drop matches that sit inside a code comment. `ease-in` in `/* not ease-in */` is not code,
|
|
123
|
+
# and flagging it trains the reader to ignore the tool.
|
|
124
|
+
hits="$(search "$pat" 2>/dev/null \
|
|
125
|
+
| grep -E "^[^:]*\.($exts):" \
|
|
126
|
+
| grep -vE "^[^:]*:[0-9]+:[[:space:]]*(//|/\*|\*[^a-zA-Z]|#|<!--|\{/\*)" || true)"
|
|
127
|
+
if [ -n "$hits" ]; then
|
|
128
|
+
case "$sev" in
|
|
129
|
+
warn) warn "$id: $msg" ;;
|
|
130
|
+
*) fail "$id: $msg" ;;
|
|
131
|
+
esac
|
|
132
|
+
printf '%s\n' "$hits" | head -n 5
|
|
133
|
+
fi
|
|
134
|
+
done <<EOF
|
|
135
|
+
$(motion_tell_table)
|
|
136
|
+
EOF
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# --- the counter that cannot be a row ---------------------------------------
|
|
140
|
+
# Absence of a guard has no line to match, so it cannot ride the generic mechanism. It carries its
|
|
141
|
+
# own named test instead of pretending to be a row.
|
|
142
|
+
reduced_motion_counter() {
|
|
143
|
+
# Only meaningful where motion actually exists: telling a backend repo to add a reduced-motion
|
|
144
|
+
# guard is the noise that gets a checker switched off.
|
|
145
|
+
if search 'transition:|transition-property|@keyframes|animation:|animate=\{|useSpring|animate-\[' >/dev/null 2>&1; then
|
|
146
|
+
if search 'prefers-reduced-motion|useReducedMotion|motion-safe:|motion-reduce:' >/dev/null 2>&1; then
|
|
147
|
+
ok "reduced-motion-missing: motion is present and a reduced-motion guard was found"
|
|
148
|
+
else
|
|
149
|
+
fail "reduced-motion-missing: this project animates but no prefers-reduced-motion guard was found anywhere. Reduced motion means fewer and gentler animations, not zero: keep opacity and color transitions that aid comprehension, drop movement and position changes"
|
|
150
|
+
fi
|
|
151
|
+
else
|
|
152
|
+
skip "reduced-motion-missing: no motion found in this project, nothing to guard"
|
|
153
|
+
fi
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# --- run --------------------------------------------------------------------
|
|
157
|
+
run_motion_tell_table
|
|
158
|
+
reduced_motion_counter
|
|
159
|
+
|
|
160
|
+
printf '\nok=%d skip=%d warn=%d fail=%d\n' "$ok_count" "$skip_count" "$warn_count" "$fail_count"
|
|
161
|
+
|
|
162
|
+
if [ "$fail_count" -gt 0 ]; then exit 1; fi
|
|
163
|
+
if [ "$STRICT" -eq 1 ] && [ "$warn_count" -gt 0 ]; then exit 1; fi
|
|
164
|
+
exit 0
|
|
@@ -9,6 +9,13 @@ origin: risco
|
|
|
9
9
|
|
|
10
10
|
# swift-ios
|
|
11
11
|
|
|
12
|
+
**Hand-off — the language vs the platform.** This skill owns the **platform**: SwiftUI/UIKit views,
|
|
13
|
+
app lifecycle, Xcode, iOS APIs, App Store shipping. Language-level Swift — Swift 6 data-race safety
|
|
14
|
+
and approachable concurrency, actors and task groups, `some` vs `any`, ARC and performance, Swift
|
|
15
|
+
Testing, macros — is `../write-swift/SKILL.md`'s. A concurrency error, a hang, a data race or a
|
|
16
|
+
retain cycle goes there, not here. Interface feel, springs and materials: `../apple-design/SKILL.md`.
|
|
17
|
+
|
|
18
|
+
|
|
12
19
|
Native Apple-platform apps: the code is `.swift`, the UI is SwiftUI, and the compiler enforces actor isolation. If the answer is a `@MainActor`, `@Observable`, `async let`, `#expect`, `NavigationStack`, or `@Model`, you are in the right place.
|
|
13
20
|
|
|
14
21
|
## First move: match the project before you write a line
|