Files
the-sunken-reach/frontend/src/components/Toasts.tsx
T
joshuaandClaude Opus 5.5 c3f2b0dfa7 V1.25.0: the DM approves a level, each player takes their own
- "Level up..." beside Rest approves a level for any of the party at once;
  with XP tracked, those who have the XP start ticked
- Each player is told with a notice and picks for themselves in the checklist:
  class (multiclass), subclass, Boon, spells within the level's allowance,
  the weapon upgrade; a waiting level shows on the sheet and campaign page
- The DM sees who still has picks to make, and can finish or take back any
- Hit points on a level up can be rolled (campaign setting): by the site, or
  at the table and typed in with physical dice
- Toasts: notices that slide in over any page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 08:30:31 +02:00

28 lines
1.0 KiB
TypeScript

import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { dismissToast, subscribeToasts, type Toast } from '../lib/toasts';
// The stack of toasts (lib/toasts.ts), mounted once in the layout.
export function Toasts() {
const [toasts, setToasts] = useState<Toast[]>([]);
useEffect(() => subscribeToasts(setToasts), []);
if (toasts.length === 0) return null;
return (
<div className="toasts" role="status" aria-live="polite">
{toasts.map((toast) => (
<div key={toast.id} className={`toast${toast.tone ? ` toast-${toast.tone}` : ''}`}>
<span className="toast-text">{toast.text}</span>
{toast.action && (
<Link to={toast.action.to} className="btn btn-primary btn-sm" onClick={() => dismissToast(toast.id)}>
{toast.action.label}
</Link>
)}
<button className="btn btn-ghost btn-sm" aria-label="Dismiss" onClick={() => dismissToast(toast.id)}>
✕
</button>
</div>
))}
</div>
);
}