- "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>
78 lines
2.7 KiB
TypeScript
78 lines
2.7 KiB
TypeScript
import { Suspense } from 'react';
|
|
import { Link, NavLink, Outlet, useMatch } from 'react-router-dom';
|
|
import { useAuth } from '../auth/useAuth';
|
|
import { useLastCampaignId, useRememberCampaign } from '../lib/lastCampaign';
|
|
import { DiceRoller } from './DiceRoller';
|
|
import { CharacterPanel } from './CharacterPanel';
|
|
import { Toasts } from './Toasts';
|
|
|
|
export function Layout() {
|
|
const { user, logout } = useAuth();
|
|
|
|
// The campaign pages say which campaign they are in their address; sheets
|
|
// and encounters report theirs themselves (useRememberCampaign).
|
|
const onCampaign = useMatch('/campaigns/:campaignId/*');
|
|
useRememberCampaign(onCampaign?.params.campaignId);
|
|
const campaignId = useLastCampaignId();
|
|
|
|
// The same destinations twice: along the top bar on a wide screen, and as a
|
|
// bar along the bottom, in reach of a thumb, on a phone.
|
|
const destinations = [
|
|
{ to: '/campaigns', end: true, icon: '🗺', label: 'Campaigns' },
|
|
...(campaignId
|
|
? [
|
|
{ to: `/campaigns/${campaignId}`, end: true, icon: '🏰', label: 'Campaign' },
|
|
{ to: `/campaigns/${campaignId}/party`, end: true, icon: '👥', label: 'Party' },
|
|
]
|
|
: []),
|
|
{ to: '/account', end: true, icon: '👤', label: 'Account' },
|
|
];
|
|
const links = (className: string) =>
|
|
destinations.map((d) => (
|
|
<NavLink key={d.to} to={d.to} end={d.end} className={({ isActive }) => `${className}${isActive ? ' is-active' : ''}`}>
|
|
<span className="nav-icon" aria-hidden>
|
|
{d.icon}
|
|
</span>
|
|
<span>{d.label}</span>
|
|
</NavLink>
|
|
));
|
|
|
|
return (
|
|
<div className="app-shell">
|
|
<header className="topbar">
|
|
<Link to="/campaigns" className="topbar-brand">
|
|
<span className="die" aria-hidden>
|
|
⚄
|
|
</span>
|
|
The Sunken Reach
|
|
</Link>
|
|
{user && (
|
|
<nav className="topbar-nav" aria-label="Main">
|
|
<div className="topbar-links">{links('topbar-link')}</div>
|
|
<div className="topbar-user">
|
|
<span className="topbar-name">{user.displayName}</span>
|
|
<button className="btn btn-ghost" onClick={logout}>
|
|
Log out
|
|
</button>
|
|
</div>
|
|
</nav>
|
|
)}
|
|
</header>
|
|
<main className="page">
|
|
{/* The bars stay put while a page that has not been opened before downloads. */}
|
|
<Suspense fallback={null}>
|
|
<Outlet />
|
|
</Suspense>
|
|
</main>
|
|
{user && (
|
|
<nav className="bottom-nav" aria-label="Main">
|
|
{links('bottom-nav-link')}
|
|
</nav>
|
|
)}
|
|
<DiceRoller />
|
|
{user && <CharacterPanel />}
|
|
<Toasts />
|
|
</div>
|
|
);
|
|
}
|