Skip to content

✨ feat(tooltip): 開閉のアニメーションをモーショントークンで動かす - #382

Merged
touyou merged 2 commits into
motion-component-modal-1102from
motion-component-tooltip-1102
Nov 18, 2026
Merged

touyou merged 2 commits into
motion-component-modal-1102from
motion-component-tooltip-1102

Conversation

@harukosugimoto

@harukosugimoto harukosugimoto commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

概要

Tooltip のアニメーションを、tw-animate-css の animate-in / zoom-in-95 などからモーショントークン(--motion-*)に置き換えます。設計ガイドラインでは Tooltip は Small(移動距離 40px 以下)なので、移動と退場の時間に *-small(0.75 倍)を使います。

要素 開くとき 閉じるとき
箱 animate-motion-pop-in-small:フェードと、アンカーの側からの移動・拡大 animate-motion-pop-out-small
文字 animate-motion-content-in-tooltip:箱より少し遅れてフェードイン(移動時間の 10%) 箱と一緒に消える

出る方向は表示する側(data-side)で決めます。上に出るときは下から上へ(ガイドラインの「下から上へ/アンカー側」)、下に出るときは上から下へ、左右も同じくアンカーの側から出ます。

スタックでの位置

この PR は Stacked PRs の stack #394 の 3 / 8 段目です(goodpatch/sparkle-design-internal#403)。

#380 Dialog → #381 Modal → #382 Tooltip → #383 Select → #385 Switch → #386 Tabs → #387 InlineMessage → #388 Toast

すぐ下は #381 です。差分はこの PR の分だけになっています。モーショントークンを含む CSS の生成し直しは、一番下の #380 に入っています。

下の PR がマージされたら、gh stack rebase && gh stack push で積み直します。2026-11-05 に main の最新の上へ積み直し、各段で型チェック・lint・テストが通ることを確認しました。

依存関係とマージの順番は #380 と同じです。

プレビュー(Storybook)

⚠️ #380 と同じく、Vercel のプレビューデプロイが権限エラーで失敗する見込みです。Vercel チームのメンバーがデプロイを承認すると、このリンクで開けるようになります。

レビューしてほしい点

  • 拡大の支点の不具合も直している:今の origin-[--radix-tooltip-content-transform-origin] は Tailwind v3 の書き方で、v4 では transform-origin: --radix-tooltip-content-transform-origin という無効な CSS になります(Tailwind でコンパイルして確認)。このため、拡大が中央から始まっていました。origin-(--radix-tooltip-content-transform-origin) に直し、アンカー側から拡大するようにしています
  • 文字を要素で包むようにした:文字だけを遅らせるため、children を <span data-slot="tooltip-text" class="block"> で包んでいます。Tooltip の本体(data-slot="tooltip-content")の直下に文字がある前提で書かれたコードやテストは影響を受けます。このリポジトリでは Tooltip のテスト 4 か所が該当したので、closest('[data-slot="tooltip-content"]') で本体を探すように直しました
  • 閉じるまでの待ち(原則20)は入れていない:ガイドラインの原則20(ホバーで開くものは閉じるのを 150ms 待つ)は、この PR では実装していません。Radix の Tooltip は閉じる遅延の props を持たないためです

変更点

  • src/components/ui/tooltip/index.tsx:アニメーションのクラスの置き換え、data-side ごとの --motion-pop-from-x / -y、origin-(...) への修正、文字の包み
  • src/components/ui/tooltip/index.test.tsx:文字の包みに合わせた修正と、アニメーションのクラス・時間を直書きしていないことのテスト
  • CHANGELOG.md:Unreleased の Changed と Fixed に追記

検証

  • pnpm test:818 件成功(skip 10・todo 18 は既存)
  • pnpm type-check:成功
  • pnpm lint:新しい警告なし(既存の 2 件のみ)
  • Storybook の Tooltip を Chrome(Playwright)で開閉し、計算値を確認しました(重さは middle)
    • 開くとき:フェード 220ms と移動 225ms(300ms × 0.75)が並んで動き、文字は 22.5ms(300ms × 0.75 × 0.1)遅れて出る
    • 拡大の支点がアンカー側(上に出るときは箱の下端)になっている
    • 閉じるとき:退場 120ms(160ms × 0.75)のあとで要素が外れる

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

Deployment failed for project sparkle-design with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: sparkle-design.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8014abb8-6f85-49d3-aa29-347432c77adf
Commits

Reviewing files that changed from the base of the PR and between 4a13168 and 5b6fc47.

Files selected for processing: 3

  • CHANGELOG.md
  • src/components/ui/tooltip/index.test.tsx
  • src/components/ui/tooltip/index.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@touyou touyou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

表示する側に応じて方向を変える指定と、origin-(--radix-…) への書き換え(Tailwind v4 で無効だった不具合の修正)が良いと思います。止める指摘はないので Approve します。

メモ: 文字を span[data-slot="tooltip-text"](block)で包むようになったので、利用側が TooltipContent の子に直接スタイルを当てている場合は 1 段深くなります。CHANGELOG に書いてもらっているので、このままで大丈夫です。


Generated by Claude Code

- 箱を animate-motion-pop-in-small / -out-small で動かし、表示する側に応じてアンカーの側から出す(--motion-pop-from-x / -y)
- 文字を data-slot="tooltip-text" の要素で包み、animate-motion-content-in-tooltip で箱より遅れてフェードインさせる
- origin-[--radix-…](Tailwind v4 では無効な CSS になる)を origin-(--radix-tooltip-content-transform-origin) に直し、拡大の支点をアンカー側にする
- テストを文字の包みに合わせ、アニメーションのクラスと時間を直書きしていないことのテストを追加
- CHANGELOG に追記

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sparkle-design Ready Ready Preview Nov 18, 2026 1:24am UTC

Request Review

@touyou
touyou merged commit 10bed56 into main Nov 18, 2026
4 checks passed
@touyou
touyou deleted the motion-component-tooltip-1102 branch November 18, 2026 01:25

This branch was successfully deployed

1 active deployment
Preview — 572e7bae Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants