mcpField
G
goey-toast

goey-toast

github.com/anl331デザイン・UI1.3k125 回インストール8 週間前に更新
リポジトリ

goey-toast について

goey-toastは、Reactアプリにアニメーション付き通知を追加するスキルです。SonnerとFramer Motionを基盤に、トーストをピル型とブロブ型の間で変形させ、通知状態やキュー、操作項目も備えています。

主な機能

  1. 01ピル型とブロブ型の変形アニメーション
  2. 02成功・エラー・警告・情報トースト
  3. 03Promiseの処理中・結果通知
  4. 04トーストの更新・絞り込み・消去
  5. 05進捗表示・タイムスタンプ・キュー設定

活用シーン

  1. 01Reactアプリへの通知UI追加
  2. 02非同期保存の処理中と結果の表示
  3. 03通知へのクリック操作の追加
  4. 04トーストキューと消去動作の管理

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/anl331/goey-toast --skill goey-toast

インストール後、Claude Code で/goey-toastを入力して読み込まれたか確認します。

詳細

goey-toast

Framer Motion のアニメーション(ピル → ブロブ → ピル)を使用し、Sonner をベースに構築された、形状が変化する React トーストコンポーネントです。このスキルを使ってパッケージをインストールし、任意の React プロジェクトで正しい使用コードを記述できます。

使用する場面

  • React アプリ(React >= 18)にトースト/通知 UI を追加する場合。
  • ユーザーが「goey-toast」や「gooey toast」と言及した場合、またはアニメーション付き/形状が変化するトーストを求めている場合。
  • 標準の sonner トーストを gooey 版に置き換える場合。

インストール

npm install goey-toast react react-dom framer-motion

ピア依存関係(ホストアプリに存在する必要があります):

パッケージバージョン
react>= 18.0.0
react-dom>= 18.0.0
framer-motion>= 10.0.0
shadcn/ui プロジェクト
npx shadcn@latest add https://goey-toast.vercel.app/r/goey-toaster.json

components/ui/goey-toaster.tsx にラッパーをインストールし、依存関係も自動でインストールします。

トーストを表示するために必要な2つの手順

  1. <GooeyToaster /> をアプリのルート付近に一度だけマウントします。
  2. エントリーポイントでスタイルシートを一度だけインポートします。 インポートしない場合、トーストはスタイルなしで表示されます。
import { GooeyToaster, gooeyToast } from 'goey-toast'
import 'goey-toast/styles.css' // REQUIRED — import once at app entry

function App() {
  return (
    <>
      <GooeyToaster position="bottom-right" />
      <button onClick={() => gooeyToast.success('Saved!')}>Save</button>
    </>
  )
}

API:gooeyToast

gooeyToast(title, options?)         // default (neutral)
gooeyToast.success(title, options?) // green
gooeyToast.error(title, options?)   // red
gooeyToast.warning(title, options?) // yellow
gooeyToast.info(title, options?)    // blue
gooeyToast.promise(promise, data)   // loading → success/error
gooeyToast.update(id, options)      // update an existing toast in-place
gooeyToast.dismiss(idOrFilter?)     // dismiss one, by type, or all
共通オプション(第2引数)
オプション型説明
descriptionReactNode文字列またはコンポーネントの本文
actionGooeyToastAction{ label, onClick, successLabel? }
iconReactNodeカスタムアイコン(update で null を指定するとクリア)
durationnumberミリ秒
idstring | number固定 ID(update に必要)
fillColor / borderColor / borderWidth色 / pxブロブのスタイル設定
spring / bounceboolean / numberバウンスは 0.05~0.8、デフォルトは 0.4
preset'smooth' | 'bouncy' | 'subtle' | 'snappy'アニメーションのプリセット
showProgressbooleanカウントダウンバー
showTimestampbooleanデフォルトは true
onDismiss / onAutoClose(id) => void閉じる際のコールバック
<GooeyToaster /> の主な props

position('top-left'|'top-center'|'top-right'|'bottom-left'|'bottom-center'|'bottom-right'、デフォルトは 'bottom-right')、 theme('light'|'dark')、closeButton、showProgress、closeOnEscape、 maxQueue、queueOverflow('drop-oldest'|'drop-newest')、dir('ltr'|'rtl')、 spring、bounce、preset、swipeToDismiss、showTimestamp、gap、offset。

使用例

説明とアクションボタン
gooeyToast.info('Share link ready', {
  description: 'Your link has been generated.',
  action: {
    label: 'Copy',
    onClick: () => navigator.clipboard.writeText(url),
    successLabel: 'Copied!', // morphs back to pill after click
  },
})
Promise トースト
gooeyToast.promise(saveData(), {
  loading: 'Saving...',
  success: (data) => `Saved ${data.count} items`,
  error: (e) => `Failed: ${String(e)}`,
  description: { success: 'All changes synced.', error: 'Try again later.' },
  action: { error: { label: 'Retry', onClick: () => retry() } },
})
その場で更新
const id = gooeyToast('Uploading...', { icon: <Spinner /> })
gooeyToast.update(id, { title: 'Done', type: 'success', icon: null })
フィルターで閉じる
gooeyToast.dismiss(id)                       // one
gooeyToast.dismiss({ type: 'error' })        // all errors
gooeyToast.dismiss({ type: ['error','warning'] })
gooeyToast.dismiss()                         // all

注意点

  • import 'goey-toast/styles.css' を忘れると、トーストはスタイルなしで表示されます。最もよくある不具合です。
  • <GooeyToaster /> はルート付近に一度だけマウントする必要があります。
  • update() には、作成時の呼び出しで返されたものと同じ id が必要です。
  • framer-motion はピア依存関係です。明示的にインストールしてください。
  • v0.2.x との後方互換エイリアス(GoeyToaster、goeyToast)もありますが、二重の o を使う名前(GooeyToaster、gooeyToast)を推奨します。

参考資料

コメント