Communitygithub.com

モーション基礎 (Motion Foundations)

モーショントークン、スプリングプリセット、パフォーマンスルール、デバイス適応、アクセシビリティの強制、React/Next.js(motion/react使用)のSSR安全性を定義します。基礎レイヤーであり、他のすべてのモーションスキルはこれに依存します。

モーション基礎 (Motion Foundations) とは?

このスキルは、React および Next.js アプリケーションにおけるアニメーションシステムの基盤レイヤーを提供します。`motion/react` ライブラリを使用し、すべてのアニメーションで共有されるトークン(`motionTokens`)、スプリングプリセット(`springs`)、アクセシビリティゲート(`shouldAnimate()`)、SSR安全な初期状態を定義します。これにより、アニメーションの一貫性、パフォーマンス、アクセシビリティ準拠が保証されます。特に、`prefers-reduced-motion` 対応、低スペックデバイスでのアニメーション制限、`initial` プロパティのサーバー出力との一致を強制するため、ハイドレーションの不一致やユーザー体験の低下を防ぎます。下流のスキル(`motion-patterns`、`motion-advanced`)はこのスキルで定義された値とルールを継承するため、アニメーション作業を開始する前に必ずロードする必要があります。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Cody-W-Tucker/skills/tree/HEAD/skills/motion-foundations

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

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

ドキュメント

モーション基礎 (Motion Foundations) は何をしますか?

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

いつアクティブにするか

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

出力

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

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

原則

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

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

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

ルール

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

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

判断の指針

長さの選択

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

スプリングの選択

プリセット使用場面
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 — すべてのトランスフォームを無効にし、不透明度のトランジションを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 20 individual skills — each has its own dedicated page.

Cody-W-Tucker/skills

Landing page quality assessment for paid advertising campaigns. Evaluates message match, page speed, mobile experience, trust signals, form optimization, and conversion rate potential. Use when user says landing page, post-click experience, landing page audit, conversion rate, or landing page optimization.

Cody-W-Tucker/skills

TikTok Ads deep analysis covering creative quality, tracking, bidding, campaign structure, and TikTok Shop. Evaluates 28 checks with emphasis on creative-first strategy, safe zone compliance, and Smart+ campaigns. Use when user says TikTok Ads, TikTok marketing, TikTok Shop, Spark Ads, Smart+, or TikTok campaign.

Cody-W-Tucker/skills

YouTube Ads specific analysis covering campaign types, creative quality, audience targeting, and measurement. Evaluates video ad performance across skippable, non-skippable, bumper, Shorts, Demand Gen, and Connected TV formats. Covers VAC→Demand Gen migration, Shorts creative requirements, and CTV shoppable ads. Use when user says YouTube Ads, video ads, pre-roll, bumper ads, YouTube campaign, Shorts ads, or CTV ads.

Cody-W-Tucker/skills

Craft the story that makes investors say \"I want in.\" Master the narrative structure that Reid Hoffman, Sequoia, and top founders use to raise capital. Use when: **Preparing to fundraise** to develop your story before the deck; **Investor meetings** to structure conversations that convert; **Pitch practice** to refine your narrative arc; **Cold outreach** to write compelling investor emails; **Pivoting** to reframe your story after a change

Cody-W-Tucker/skills

Identify the best GTM motions and tools across 7 motion types: Inbound, Outbound, Paid Digital, Community, Partners, ABM, and PLG. Use when selecting marketing channels, choosing between inbound and outbound strategy, or planning cross-channel campaigns.

Cody-W-Tucker/skills

Produce a print-grade single-page kami (紙 / 纸) document — warm parchment canvas, ink-blue accent, serif at one weight, no italic, no cool grays. The output reads like a professional white paper or studio one-pager, not an app UI. Multilingual by design (EN · zh-CN · ja). One self-contained HTML file, zero dependencies.

Cody-W-Tucker/skills

Optimize landing pages for maximum conversions using proven frameworks from Unbounce and Oli Gardner—apply the \"one goal, one message, one action\" principle with data-driven design, copy, and CTA best practices. Use when: **Create a new landing page** for a campaign; **Optimize an existing landing page** that isn't converting; **Review landing page design** before launch; **Improve form conversion rates** on lead gen pages; **A/B test landing page elements** systematically

Cody-W-Tucker/skills

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.

Cody-W-Tucker/skills

A single-frame motion-design composition with looping CSS animations — rotating type ring, animated globe, ticking timer, parallax labels. Renders as a hero video poster you can hand straight to HyperFrames or any keyframe-based exporter. Use when the brief asks for "motion design", "animated hero", "loop", "video poster", "title card", or pairs Open Claude Design with HyperFrames for a kinetic export.

Cody-W-Tucker/skills

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.

Cody-W-Tucker/skills

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

Cody-W-Tucker/skills

Produce a single-file slide deck in the Atelier Zero visual language (warm-paper background, italic-serif emphasis spans, coral terminating dots, surreal collage plates) — Open Design's brand deck recipe. The deck uses **horizontal magazine-style swipe pagination** (←/→, wheel, swipe), a per-slide chrome strip with brand mark and slide counter, an ESC overview grid, a coral progress bar, and inherits the canonical stylesheet + 16-slot image library from the sister `open-design-landing` skill.

Cody-W-Tucker/skills

Produce a world-class single-page editorial landing site in the Atelier Zero visual language (Monocle / Apartamento / Études editorial collage) — the same aesthetic Open Design uses for its own marketing surface. The agent fills a typed `inputs.json` from a brand brief, optionally generates 16 collage assets via gpt-image-2, then runs a pure-function composer that emits a self-contained HTML file; a separate path can mirror the Astro marketing site in `apps/landing-page/`. Drop-in scroll-reveal motion and a Headroom-style sticky nav are wired automatically.

Cody-W-Tucker/skills

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

Cody-W-Tucker/skills

Single-page SaaS landing with hero, features, social proof, pricing, and CTA. Respects the active DESIGN.md color/typography/layout tokens. Trigger keywords: "saas landing", "marketing page", "product landing".

Cody-W-Tucker/skills

Single-page SaaS landing with hero, features, social proof, pricing, and CTA. Respects the active DESIGN.md color/typography/layout tokens. Trigger keywords: "saas landing", "marketing page", "product landing".

Cody-W-Tucker/skills

Master April Dunford's 8-step sales narrative from \"Sales Pitch\" (2023). Transform your positioning into a compelling story that wins enterprise deals. Use when: Structuring B2B sales presentations and demos; Creating pitch decks for complex products; Training sales teams on narrative-driven selling; Converting positioning strategy into sales conversations; Winning against entrenched competitors

Cody-W-Tucker/skills

Swiss-style user-research narrative template in warm-paper editorial aesthetics. Use when users ask for a premium research deck or story-first live artifact with minimalist typography, high-clarity layout, subtle motion, donut breakdowns, and keyboard/click navigation across slides in a single HTML file.

Cody-W-Tucker/skills

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.

Cody-W-Tucker/skills

Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.

関連スキル