Communitygithub.com

503496348-ops/mischief-production(モーション基盤)

モーショントークン、スプリングプリセット、パフォーマンスルール、デバイス適応、アクセシビリティ強制、React / Next.js 向け SSR 安全性を提供します。`motion/react` を使用し、他のすべてのモーションスキルの基本基盤となります。

mischief-production(モーション基盤) とは?

このスキルは、React / Next.js プロジェクトにおけるアニメーションシステムの基盤層を定義します。`motionTokens` オブジェクト(duration, easing, distance, scale)や `springs` プリセットマップ(snappy, gentle, bouncy, instant, release の5つ)といった共有トークンを提供し、すべてのコンポーネントで一貫したアニメーションパラメータを使用できるようにします。また、アクセシビリティを強制するための `useReducedMotion` フックや `shouldAnimate()` ゲートを実装し、`prefers-reduced-motion` 設定やローエンドデバイス検出に応じてアニメーションを無効化します。さらに、SSR 環境でのハイドレーション不一致を防ぐための安全な初期状態の設定方法をガイドします。このスキルは `motion/react` のみを使用し、`framer-motion` との混在を禁止するなど、厳格なルールを適用することで、パフォーマンスとアクセシビリティを両立した堅牢なアニメーション基盤を提供します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/503496348-ops/mischief-production/tree/HEAD/skills/ecc-motion-foundations

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

モーション基盤

モーションシステムの基本レイヤー。ダウンストリームスキル(motion-patterns、motion-advanced)が継承するすべての値、制約、ルールを定義します。このスキルは、アニメーション作業を開始する前にロードしてください。

いつ有効にするか

  • アニメーションコンポーネントをゼロから作成する場合
  • トークン、スプリングプリセット、イージング値を設定する場合
  • prefers-reduced-motion サポートを実装する場合
  • アニメーションの初期状態によるハイドレーションの不一致をデバッグする場合
  • アニメーションをそもそも存在させるべきか評価する場合

成果物

このスキルは以下を生成します:

  • 共有の motionTokens オブジェクト(duration、easing、distance、scale)
  • 共有の springs プリセットマップ(5つの名前付き設定)
  • すべてのコンポーネントで使用される shouldAnimate() ゲート
  • useReducedMotion によるアクセシビリティ準拠のアニメーション初期値
  • ハイドレーション警告がゼロの SSR 安全な初期状態

原則

モーションは、以下の少なくとも1つを実現しなければなりません。そうでない場合は削除する必要があります。

  • 注意を誘導する
  • 状態を伝える
  • 空間の連続性を維持する

応答性は常に滑らかさよりも優先されます。入力遅延を引き起こす 60 fps のアニメーションは、アニメーションがないよりも悪いです。

ルール

これらは交渉の余地がありません。システム内のすべてのコンポーネントに適用されます。

  1. motion/react のみを使用すること。 framer-motion からインポートしないでください。同じツリー内でこれら2つを混在させないでください。
  2. initial はサーバーの出力と一致する必要があります。 サーバーが opacity: 1 をレンダリングする場合、initial プロパティも opacity: 1 でなければなりません。例外はありません。
  3. モーション削減設定はすべてをオーバーライドします。 useReducedMotion() が true を返すか、prefersReduced が true の場合、すべてのトランスフォームは無効になります。許容されるフォールバックは、0.2秒以下の opacity のみのフェードのみです。
  4. レイアウトプロパティをアニメーション化しないでください。 width、height、top、left、margin、padding を animate で使用することは禁止されています。transform と opacity のみを使用してください。
  5. すべてのトークン値は motionTokens から取得します。 コンポーネントファイルでの duration や easing のハードコードは禁止されています。
  6. すべてのスプリング設定は springs マップから取得します。 インラインの stiffness/damping 値は禁止されています。
  7. motion/react からインポートするすべてのファイルに "use client" が必要です。
  8. モジュールレベルで window や navigator を読み取らないでください。 常に typeof window !== "undefined" でガードしてください。

決定ガイド

Duration の選択

トークン使用場面
instantツールチップの表示/非表示、フォーカスリング、バッジ更新
fastボタンフィードバック、アイコン交換、チップトグル
normalモーダルオープン、カード展開、ページ要素の出現
slowヒーローエントランス、全画面トランジション
crawl意図的なストーリーテリング;控えめに使用

Spring の選択

プリセット使用場面
snappyデフォルトUI — ボタン、チップ、ナビゲーションアイテム
gentleカード、モーダル、パネルがソフトに着地する場合
bouncy遊び心のある瞬間 — 空の状態、オンボーディング
instantツールチップ、ポップオーバー、ドロップダウン
releaseドラッグリリース — 自然な物理感覚

アニメーションを完全に無効にする場合

以下の場合に shouldAnimate() が false を返すようにします:

  • prefersReduced が true の場合
  • isLowEnd が true で、アニメーションが必須でない場合
  • 要素が画面外にあり、ビューポートに入ることがない場合
  • アニメーションが純粋に装飾的で、UX 上の目的がない場合

コアコンセプト

トークンシステム

// 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 },
  instant: { type: "spring", stiffness: 600, damping: 35 },
  release: { type: "spring", stiffness: 200, damping: 20, restDelta: 0.001 },
}

ランタイムフラグ

// lib/motion-config.ts
export const motionConfig = {
  isLowEnd() {
    return (
      typeof navigator !== "undefined" &&
      navigator.hardwareConcurrency <= 4
    )
  },

  prefersReduced() {
    return (
      typeof window !== "undefined" &&
      window.matchMedia("(prefers-reduced-motion: reduce)").matches
    )
  },

  shouldAnimate({ essential = false } = {}) {
    if (this.prefersReduced()) return false
    if (!essential && this.isLowEnd()) return false
    return true
  },

  duration() {
    return this.isLowEnd() || this.prefersReduced()
      ? motionTokens.duration.instant
      : motionTokens.duration.normal
  },
}

アクセシビリティ

優先順位(高いものから低いものへ):

  1. prefers-reduced-motion: reduce — すべてのトランスフォームを無効にし、opacity トランジションを 0.2 秒以下に制限する
  2. ローエンドデバイス検出 — duration を短縮し、必須でないアニメーションを削除する
  3. デザインの好み — その他すべて

モーションは段階的に低下する必要があります。レイアウトシフトを引き起こしたり、方向感覚を混乱させたりするような突然の消失があってはなりません。

// hooks/use-reduced-motion.tsx
"use client"
import { useReducedMotion } from "motion/react"

export function useSafeMotion(fullY: number = 16) {
  const reduce = useReducedMotion()
  return {
    initial: { opacity: 0, y: reduce ? 0 : fullY },
    animate: { opacity: 1, y: 0 },
    exit:    { opacity: 0, y: reduce ? 0 : -fullY },
  }
}
/* globals.css */
@media (prefers-reduced-motion: reduce) {
  .motion-safe-transition  { transition: opacity 0.15s; }
  .motion-reduce-transform { transform: none !important; }
}
<!-- Tailwind -->
<div class="motion-safe:animate-fade motion-reduce:opacity-100"></div>

SSR / ハイドレーション安全性

ルール:initial は常にサーバーがレンダリングするものと一致しなければなりません。

// 間違い — サーバーは opacity:1 をレンダリングするが、initial は 0 を指定 → ハイドレーション不一致
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} />

// 正しい — AnimatePresence を使用するか、クライアントマウントまで延期する
"use client"
const [mounted, setMounted] = useState(false)
useEffect(() => setMounted(true), [])

<motion.div
  initial={{ opacity: mounted ? 0 : 1 }}
  animate={{ opacity: 1 }}
/>

コード例

エンドツーエンド:トークン + スプリング + アクセシビリティ + SSR ガード

// components/fade-in-card.tsx
"use client"

import { useState, useEffect } from "react"
import { motion } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"
import { useSafeMotion } from "@/hooks/use-reduced-motion"
import { motionConfig } from "@/lib/motion-config"

interface FadeInCardProps {
  children: React.ReactNode
  delay?: number
}

export function FadeInCard({ children, delay = 0 }: FadeInCardProps) {
  // SSR ガード — initial はサーバー出力(opacity: 1)と一致しなければならない
  const [mounted, setMounted] = useState(false)
  useEffect(() => setMounted(true), [])

  // アクセシビリティ — モーション削減設定が優先される場合、トランスフォームを無効にする
  const safeMotion = useSafeMotion(motionTokens.distance.md)

  // デバイスゲート — ローエンドハードウェアではアニメーションをスキップ
  if (!motionConfig.shouldAnimate() || !mounted) {
    return <div>{children}</div>
  }

  return (
    <motion.div
      initial={safeMotion.initial}
      animate={safeMotion.animate}
      exit={safeMotion.exit}
      transition={{
        ...springs.gentle,
        delay,
      }}
      whileHover={{ scale: motionTokens.scale.pop }}
      whileTap={{ scale: motionTokens.scale.press }}
    >
      {children}
    </motion.div>
  )
}

制約 / 非対象

このスキルは以下をカバー しません:

  • UIコンポーネントパターン(ボタン、モーダル、スタッガー) → motion-patterns を参照
  • ドラッグ、ジェスチャー、SVG、テキストアニメーション、カスタムフック → motion-advanced を参照
  • CSS のみのアニメーションや、motion/react を使用しない Tailwind animate-* クラス
  • サードパーティのアニメーションライブラリ(GSAP、anime.js など)
  • モーションデザインの決定(いつアニメーションするか、何を強調するか)— それはコードの制約ではなく、デザインの関心事です

アンチパターン

アンチパターン違反ルール修正方法
import { motion } from "framer-motion"ルール1motion/react を使用
SSR コンポーネントで initial={{ opacity: 0 }}ルール2マウントガードを追加
useReducedMotion チェックの省略ルール3useSafeMotion フックを使用
animate={{ width: "100%" }}ルール4代わりに scaleX トランスフォームを使用
インラインで transition={{ duration: 0.4 }}ルール5motionTokens.duration.normal を使用
インラインで { stiffness: 300, damping: 30 }ルール6springs.snappy を使用
"use client" ディレクティブの欠落ルール7ファイルの先頭に追加
モジュールレベルでの navigator.hardwareConcurrencyルール8typeof navigator !== "undefined" でラップ

関連スキル

  • motion-patterns — ここで定義されたトークンとスプリングを消費して、ボタン、モーダル、スタッガー、ページトランジション、スクロールパターンを構築します。値を再定義することはありません。
  • motion-advanced — ここで定義されたトークンとスプリングを消費して、ドラッグ、SVG、テキスト、ジェスチャーパターンを構築します。この基盤の上に useAnimate シーケンスとカスタムフックを追加します。

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

503496348-ops/mischief-production

Use this skill when inspecting Blender characters, rigs, poses, animation retargeting, ground contact, facing direction, or model-vs-motion alignment where screenshots alone are not enough.

503496348-ops/mischief-production

Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider HCP video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.

503496348-ops/mischief-production

Advanced motion patterns for React / Next.js — drag & drop, gestures, text animations, SVG path drawing, custom hooks, imperative sequences (useAnimate), loaders, and the full API decision tree. Requires motion-foundations.

503496348-ops/mischief-production

Production-ready animation patterns for React / Next.js — button, modal, toast, stagger, page transitions, exit animations, scroll, and layout — built on motion-foundations tokens and springs.

503496348-ops/mischief-production

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

503496348-ops/mischief-production

Best practices for Remotion - Video creation in React. 29 domain-specific rules covering 3D, animations, audio, captions, charts, transitions, and more.

503496348-ops/mischief-production

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

関連スキル