Communitygithub.com

Cody-W-Tucker/skills

React/Next.js 向けのプロダクションレディなアニメーションパターン集。ボタン、モーダル、トースト、スタッガー、ページトランジション、退場アニメーション、スクロール、レイアウトを、motion-foundations のトークンとスプリング上に構築。

skills とは?

このスキルは、React および Next.js アプリケーションにおける最も一般的な UI アニメーションのニーズに対応する、コピー&ペースト可能なパターンを提供します。すべてのパターンは `motion-foundations` ライブラリが提供するデザイントークンとスプリング値に基づいており、生の数値やインラインでの duration/easing 定義を禁止することで、プロジェクト全体のアニメーションの一貫性とメンテナンス性を高めます。具体的には、`AnimatePresence` を用いた条件付きレンダリングの適切な退場アニメーション、Next.js App Router 向けのページトランジションラッパー、`useScroll` + `useTransform` を活用したスクロール連動アニメーション、`layout` / `layoutId` による要素の変形・クロスフェードなどをカバーします。アクセシビリティ(フォーカストラップ、Escape キー、aria 属性)や SSR 対応も考慮されており、`motion-foundations` の `useSafeMotion` フックを通じてユーザーの動きの抑制設定にも配慮します。アンチパターン集も付属しており、`key` の欠如、退場アニメーションの省略、不適切な `layout` 使用などを防止します。

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

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

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

ドキュメント

Motion Patterns

最も一般的な UI アニメーションのニーズに対応する、コピー&ペースト可能なパターン集。 ここにあるすべてのパターンは motion-foundations のトークンとスプリングに基づいています。 新たな duration や easing の値を定義せず、それらをインポートしてください。

いつアクティブにするか

  • ボタン、カード、モーダル、トースト通知をアニメーションさせる時
  • スタッガーを使ったリストの進入アニメーションを構築する時
  • Next.js App Router でページトランジションを設定する時
  • 条件付きコンテンツに進入・退場アニメーションを追加する時
  • スクロール表示、スクロール連動プログレス、スティッキーストーリーセクションを実装する時
  • 展開カード、アコーディオン、共有要素トランジションを構築する時

アウトプット

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

  • アクセシブルで SSR 安全な、すべての標準 UI コンポーネント向けアニメーション
  • 正しい退場動作を持つ AnimatePresence でラップされた条件付きレンダリング
  • Next.js App Router 向けのページトランジションラッパーコンポーネント
  • useScroll + useTransform を使用したスクロール表示・スクロール連動パターン
  • 展開やクロスフェード要素のためのレイアウトアニメーションパターン(layout、layoutId)

原則

  • すべてのパターンは motion-foundations からインポートします。生の数値は使用しません。
  • 条件付きレンダリングはすべて key とともに AnimatePresence でラップします。
  • 退場アニメーションは常に進入アニメーションと一緒に定義します。後付けにしてはいけません。
  • layout は小さく孤立した変化にのみ使用します。大きなサブツリーには明示的なトランスフォームを使用します。

ルール

  1. 条件付きレンダリングは常に、直接の子要素に key を付けて AnimatePresence でラップします。 key がないと退場アニメーションは決して発火しません。
  2. initial + animate を定義するときは常に exit も定義します。 退場アニメーションがないアニメーションは不完全です。
  3. ページトランジションには mode="wait" を使用します。 退場が完了するまで進入を開始してはいけません。
  4. 子要素が約 5 個以上ある、または深くネストされた DOM のサブツリーには layout を使用しないでください。 代わりに明示的な x/y トランスフォームを使用します。
  5. スタッガー間隔は 0.05s から 0.10s の間に保ちます。 これより短いと機械的に、長いと動作が鈍く感じられます。
  6. モーダルには常に以下を含める必要があります: フォーカストラップ、Escape キーで閉じる、スクロールロック、role="dialog"、aria-modal="true"。
  7. スクロール表示には viewport={{ once: true }} を使用します。 スクロールアウト時に繰り返すと、情報提供ではなく気が散ります。
  8. すべてのトークン値は motion-foundations からインポートします。 インラインでの数値使用は禁止です。

判断ガイド

適切なパターンの選択

状況パターン
要素が表示/非表示になるAnimatePresence
アイテムのリストが順に読み込まれるスタッガーバリアント
ルート間を移動するページトランジションラッパー
要素がその場でサイズ変更するlayout プロパティ
同じ要素がページコンテキスト間を移動するlayoutId
要素がスクロールでビューに入ったときwhileInView
値をスクロール位置に紐づけるuseScroll + useTransform

mode="wait" と mode="sync" の使い分け

モード使用する場面
waitページトランジション、コンテンツの入れ替え(一度にひとつ)
sync積み重なる通知、リストアイテム(重複しても問題ない)
popLayoutアイテムがリフローリストから削除される場合

コアコンセプト

AnimatePresence の契約

以下の 3 点が常に真である必要があります:

  1. AnimatePresence が条件付きレンダリングをラップしている
  2. 直接の子要素に key がある
  3. 子要素に exit プロパティがある

これらのいずれかが欠けると、退場アニメーションは警告なしに失敗します。

layout と layoutId の違い

  • layout — その場での要素自身のサイズ/位置の変化をアニメーション化する
  • layoutId — 2 つの別々の要素をリンクし、レンダリング間でクロスフェードさせる

展開コンテナ内のテキストには layout="position" を使用して、テキストのリフローがアニメーション化されるのを防ぎます。

コード例

ボタンフィードバック

"use client"
import { motion } from "motion/react"
import { springs, motionTokens } from "@/lib/motion-tokens"

<motion.button
  whileHover={{ scale: motionTokens.scale.pop }}
  whileTap={{ scale: motionTokens.scale.press }}
  transition={springs.snappy}
/>

スタッガーリスト

"use client"
import { motion } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

const container = {
  hidden: {},
  visible: {
    transition: {
      staggerChildren: 0.08,   // 0.05–0.10 ルール内
      delayChildren: 0.1,
    },
  },
}

const item = {
  hidden:  { opacity: 0, y: motionTokens.distance.md },
  visible: { opacity: 1, y: 0, transition: springs.gentle },
}

<motion.ul variants={container} initial="hidden" animate="visible">
  {items.map((i) => (
    <motion.li key={i.id} variants={item} />
  ))}
</motion.ul>

モーダル

"use client"
import { motion, AnimatePresence } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

// 呼び出し側でラップ:
// <AnimatePresence>{isOpen && <Modal key="modal" />}</AnimatePresence>

export function Modal({ onClose }: { onClose: () => void }) {
  return (
    <>
      {/* オーバーレイ */}
      <motion.div
        className="fixed inset-0 bg-black/50"
        initial={{ opacity: 0 }}
        animate={{ opacity: 1 }}
        exit={{ opacity: 0 }}
        onClick={onClose}
      />

      {/* パネル — アクセシビリティ要件: フォーカストラップ、Escape で閉じる、
          スクロールロック、role="dialog"、aria-modal="true" */}
      <motion.div
        role="dialog"
        aria-modal="true"
        className="fixed inset-x-4 top-1/2 -translate-y-1/2 rounded-xl bg-white p-6"
        initial={{
          opacity: 0,
          scale: motionTokens.scale.press,
          y: motionTokens.distance.sm,
        }}
        animate={{ opacity: 1, scale: 1, y: 0 }}
        exit={{
          opacity: 0,
          scale: motionTokens.scale.press,
          y: motionTokens.distance.sm,
        }}
        transition={springs.gentle}
      />
    </>
  )
}

トーストスタック

"use client"
import { motion, AnimatePresence } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

<AnimatePresence mode="sync">
  {toasts.map((t) => (
    <motion.div
      key={t.id}
      layout
      initial={{
        opacity: 0,
        x: motionTokens.distance.xl,
        scale: motionTokens.scale.subtle,
      }}
      animate={{ opacity: 1, x: 0, scale: 1 }}
      exit={{
        opacity: 0,
        x: motionTokens.distance.xl,
        scale: motionTokens.scale.subtle,
      }}
      transition={springs.snappy}
    />
  ))}
</AnimatePresence>

ページトランジション (Next.js App Router)

// components/page-transition.tsx
"use client"
import { motion, AnimatePresence } from "motion/react"
import { usePathname } from "next/navigation"
import { motionTokens } from "@/lib/motion-tokens"

const variants = {
  initial: { opacity: 0, y: motionTokens.distance.sm },
  enter:   { opacity: 1, y: 0 },
  exit:    { opacity: 0, y: -motionTokens.distance.sm },
}

export function PageTransition({ children }: { children: React.ReactNode }) {
  const pathname = usePathname()
  return (
    <AnimatePresence mode="wait">
      <motion.div
        key={pathname}
        variants={variants}
        initial="initial"
        animate="enter"
        exit="exit"
        transition={{
          duration: motionTokens.duration.normal,
          ease: motionTokens.easing.smooth,
        }}
      >
        {children}
      </motion.div>
    </AnimatePresence>
  )
}

スクロール表示

"use client"
import { motion } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

<motion.div
  initial={{ opacity: 0, y: motionTokens.distance.lg }}
  whileInView={{ opacity: 1, y: 0 }}
  viewport={{ once: true, margin: "-80px" }}   // once: true — ルール 7
  transition={{ duration: motionTokens.duration.slow, ease: motionTokens.easing.smooth }}
/>

スクロールプログレスバー

"use client"
import { motion, useScroll } from "motion/react"

export function ScrollProgress() {
  const { scrollYProgress } = useScroll()
  return (
    <motion.div
      className="fixed top-0 left-0 h-1 bg-indigo-500 origin-left w-full"
      style={{ scaleX: scrollYProgress }}
    />
  )
}

展開カード

"use client"
import { useState } from "react"
import { motion, AnimatePresence } from "motion/react"
import { springs, motionTokens } from "@/lib/motion-tokens"

export function ExpandingCard({ title, body }: { title: string; body: string }) {
  const [expanded, setExpanded] = useState(false)

  return (
    <motion.div layout onClick={() => setExpanded(!expanded)} className="cursor-pointer">
      {/* layout="position" によりテキストのリフローがアニメーション化されるのを防ぐ */}
      <motion.h2 layout="position" className="font-semibold">
        {title}
      </motion.h2>

      <AnimatePresence>
        {expanded && (
          <motion.p
            key="body"
            initial={{ opacity: 0 }}
            animate={{ opacity: 1 }}
            exit={{ opacity: 0 }}
            transition={{ duration: motionTokens.duration.fast }}
          >
            {body}
          </motion.p>
        )}
      </AnimatePresence>
    </motion.div>
  )
}

共有要素クロスフェード

// ソースコンテキスト
<motion.img layoutId="hero-image" src={src} className="w-16 h-16 rounded" />

// 宛先コンテキスト(同じ layoutId — motion がトランジションを処理)
<motion.img layoutId="hero-image" src={src} className="w-full rounded-xl" />

アコーディオン

<motion.div
  initial={false}
  animate={{ opacity: open ? 1 : 0, scaleY: open ? 1 : 0 }}
  style={{ transformOrigin: "top", overflow: "hidden" }}
  transition={{
    duration: motionTokens.duration.normal,
    ease: motionTokens.easing.smooth,
  }}
>
  {children}
</motion.div>

エンドツーエンドの例

マウント時に進入するスタッガーリストで、条件付きの存在を処理し、動きの抑制設定を尊重します。トークン、スプリング、AnimatePresence、および motion-foundations のアクセシビリティフックを組み合わせています:

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

const containerVariants = {
  hidden: {},
  visible: {
    transition: { staggerChildren: 0.08, delayChildren: 0.1 },
  },
}

function ListItem({ label, onRemove }: { label: string; onRemove: () => void }) {
  const safe = useSafeMotion(motionTokens.distance.sm)
  return (
    <motion.li
      variants={{
        hidden:  safe.initial,
        visible: safe.animate,
      }}
      exit={safe.exit}
      transition={springs.gentle}
      className="flex items-center justify-between p-3 rounded-lg bg-white shadow-sm"
    >
      <span>{label}</span>
      <button onClick={onRemove}>Remove</button>
    </motion.li>
  )
}

export function AnimatedList({ items, onRemove }: {
  items: { id: string; label: string }[]
  onRemove: (id: string) => void
}) {
  return (
    <motion.ul
      variants={containerVariants}
      initial="hidden"
      animate="visible"
      className="space-y-2"
    >
      <AnimatePresence mode="popLayout">
        {items.map((item) => (
          <ListItem
            key={item.id}
            label={item.label}
            onRemove={() => onRemove(item.id)}
          />
        ))}
      </AnimatePresence>
    </motion.ul>
  )
}

制約 / 非対象

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

  • トークンとスプリングの定義 → motion-foundations を参照
  • ドラッグ操作、スワイプジェスチャー、並べ替え可能リスト → motion-advanced を参照
  • テキストアニメーション(単語/文字の表示、カウンター) → motion-advanced を参照
  • SVG パスの描画またはモーフィング → motion-advanced を参照
  • カスタムアニメーションフック → motion-advanced を参照
  • motion/react を使用しない CSS のみのトランジション

アンチパターン

アンチパターン違反したルール修正方法
AnimatePresence の子要素に key がないルール 1直接の子要素に安定した key を追加する
initial + animate に exit がないルール 2常に 3 つすべてを一緒に定義する
mode="wait" なしのページトランジションルール 3AnimatePresence に mode="wait" を追加する
50 アイテムのリストに layout を使用ルール 4mode="popLayout" または明示的なトランスフォームを使用する
10 アイテムのリストで staggerChildren: 0.2ルール 50.08–0.10 に制限する
フォーカストラップなしのモーダルルール 6focus-trap-react または Radix Dialog を追加する
viewport={{ once: true }} なしの whileInViewルール 7繰り返す進入は情報提供ではなく気が散る
インラインで transition={{ duration: 0.3 }}ルール 8motionTokens.duration.normal を使用する

関連スキル

  • motion-foundations — ここにあるすべてのパターンがインポートする、すべてのトークン、スプリング、useSafeMotion フック、SSR ガードを定義します。最初にセットアップする必要があります。
  • motion-advanced — これらのパターンをドラッグ、ジェスチャー、SVG、テキスト、カスタムフック、命令型シーケンスで拡張します。このスキルのパターンを再定義することはありません。

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

Motion tokens, spring presets, performance rules, device adaptation, accessibility enforcement, and SSR safety for React / Next.js using motion/react. Foundation layer — all other motion skills depend on this.

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 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.

関連スキル