为 React/Next.js 动效系统建立规范基座,统一令牌、弹簧预设、性能与无障碍规则。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "motion-foundations" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/motion-foundations/SKILL.md 2. 保存为 ~/.claude/skills/motion-foundations/SKILL.md 3. 装好后重载技能,告诉我可以用了
请为 React/Next.js 项目设计一套 motion foundation,使用 motion/react,包含 motion tokens、spring presets、性能约束、响应式设备适配、reduced motion 无障碍支持,以及 SSR 安全注意事项。请输出可复用的配置结构与实施建议。
一套可复用的动效基础层方案,含配置建议、规则说明与工程落地要点。
请审查下面的 React 动效实现是否符合基础规范:检查动画属性选择、弹簧参数是否合理、是否会引发重排、是否支持 prefers-reduced-motion、在 SSR/水合阶段是否安全,并给出修改建议。
一份问题清单与优化建议,指出性能、无障碍和 SSR 风险及对应修复方式。
请基于 motion/react 为我生成一个基础层代码示例:包含动效令牌定义、通用 spring presets、设备分级策略、reduced motion 处理、SSR 安全封装,以及组件调用示例。代码风格适合 Next.js 项目直接集成。
一组可直接集成的基础代码模板,展示统一动效配置与组件用法。
The base layer of the motion system. Defines every value, constraint, and
rule that downstream skills (motion-patterns, motion-advanced) inherit.
Load this skill before any animation work begins.
prefers-reduced-motion supportThis skill produces:
motionTokens object (duration, easing, distance, scale)springs preset map (5 named configs)shouldAnimate() gate used by all componentsuseReducedMotionMotion must do at least one of the following or it must be removed:
Responsiveness always outranks smoothness. A 60 fps animation that causes input delay is worse than no animation.
These are non-negotiable. They apply to every component in the system.
motion/react only. Never import from framer-motion. Never mix the two in the same tree.initial must match server output. If the server renders opacity: 1, the initial prop must also be opacity: 1. No exceptions.useReducedMotion() returns true or prefersReduced is true, all transforms are disabled. Opacity-only fades at ≤ 0.2s are the only permitted fallback.width, height, top, left, margin, padding are banned from animate. Use transform and opacity only.motionTokens. Hardcoded durations and easings in component files are forbidden.springs map. Inline stiffness/damping values are forbidden."use client" is required on every file that imports from motion/react.window or navigator at module level. Always guard with typeof window !== "undefined".| Token | Use when |
|---|---|
instant | Tooltip show/hide, focus ring, badge update |
fast | Button feedback, icon swap, chip toggle |
normal | Modal open, card expand, page element enter |
slow | Hero entrance, full-page transition |
crawl | Deliberate storytelling; use sparingly |
| Preset | Use when |
|---|---|
snappy | Default UI — buttons, chips, nav items |
gentle | Cards, modals, panels landing softly |
bouncy | Playful moments — empty states, onboarding |
instant | Tooltips, popovers, dropdowns |
release | Drag release — natural physics feel |
Disable (make shouldAnimate() return false) when:
prefersReduced is trueisLowEnd is true and the animation is non-essential// lib/motion-tokens.ts
export const motionTokens = {
duration: {
instant: 0.08,
fast: 0.18,
normal: 0.35,
slow: 0.6,
crawl: 1.0,
},
easing: {
smooth: [0.22, 1, 0.36, 1],
sharp: [0.4, 0, 0.2, 1],
bounce: [0.34, 1.56, 0.64, 1],
linear: [0, 0, 1, 1],
},
distance: {
xs: 4,
sm: 8,
md: 16,
lg: 24,
xl: 48,
},
scale: {
subtle: 0.98,
press: 0.95,
pop: 1.04,
},
}
export const springs = {
snappy: { type: "spring", stiffness: 300, damping: 30 },
gentle: { type: "spring", stiffness: 120, damping: 14 },
bouncy: { type: "spring", stiffness: 400, damping: 10 },
…
为 TypeScript、JavaScript、React 与 Node.js 提供统一编码规范与最佳实践建议
帮助开发者掌握 Ktor 服务端常用模式、认证依赖注入与测试实践。
帮助开发者为代码代理配置性能优化、安全防护与研究优先工作流。
为 Windows 原生桌面应用生成并执行端到端自动化测试流程。
帮助 Swift 开发者实现基于 Actor 的线程安全内存与文件持久化方案
帮助团队编排多代理协作流程,管理任务归属、看板流转与交接控制。
帮助你为 React/Next.js 产品实现可复用的界面动效与过渡方案。
帮助你在 React/Next.js 中实现高级动效、手势交互与动画编排。
提供适用于 React/Next.js 的高质量动画模式,快速实现常见交互动效。
帮助用户将动效设计原则转化为适用于界面与 AI 代理的可执行规范
帮助你在编写、审查或重构 React/Next.js 代码时系统优化性能。
帮助用户将 motion-foundations 相关内容准确翻译并本地化为日语。