Full-site nav: one auth-aware nav bar on every page
- SiteHeader: a single consistent main nav (Home, News, Screenshots, Five on Friday, Newsletter, Wiki, Shard, About) with active-state highlighting, plus an auth-aware entry on the right — Sign in when logged out, My Account (player) or Admin (staff) when logged in. - Portal (landing) now renders the site header too, so the nav is present across the entire site, not just interior pages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qPmpmVH1xGCiZoz9m9vW3
This commit is contained in:
@@ -1,27 +1,37 @@
|
|||||||
import { Link } from 'react-router-dom'
|
import { Link, NavLink } from 'react-router-dom'
|
||||||
import MoonDot from './MoonDot.jsx'
|
import MoonDot from './MoonDot.jsx'
|
||||||
|
import { useAuth } from '../contexts/AuthContext.jsx'
|
||||||
|
|
||||||
const NAV = {
|
// One consistent top nav for the whole public site. Every page gets the same
|
||||||
website: [
|
// main links plus an auth-aware entry on the right (Sign in / My Account / Admin).
|
||||||
{ label: 'Shard', to: '/site/shard' },
|
const NAV = [
|
||||||
|
{ label: 'Home', to: '/', end: true },
|
||||||
{ label: 'News', to: '/site/news' },
|
{ label: 'News', to: '/site/news' },
|
||||||
{ label: 'Screenshots', to: '/site/screenshots' },
|
{ label: 'Screenshots', to: '/site/screenshots' },
|
||||||
{ label: 'Five on Friday', to: '/site/five-on-friday' },
|
{ label: 'Five on Friday', to: '/site/five-on-friday' },
|
||||||
{ label: 'Newsletter', to: '/site/newsletter' },
|
{ label: 'Newsletter', to: '/site/newsletter' },
|
||||||
{ label: 'About', to: '/site/about' },
|
|
||||||
{ label: 'Wiki', to: '/wiki' },
|
{ label: 'Wiki', to: '/wiki' },
|
||||||
],
|
{ label: 'Shard', to: '/site/shard' },
|
||||||
wiki: [
|
{ label: 'About', to: '/site/about' },
|
||||||
{ label: 'Website', to: '/site' },
|
]
|
||||||
{ label: 'New Player Guide', to: '/wiki/new-player-guide' },
|
|
||||||
{ label: 'Maps & Atlas', to: '/wiki/maps-atlas' },
|
const linkStyle = ({ isActive }) => ({
|
||||||
{ label: 'Systems', to: '/wiki/systems' },
|
background: isActive ? 'var(--accent)' : undefined,
|
||||||
{ label: 'Rules', to: '/wiki/rules' },
|
color: isActive ? 'var(--bg-deep)' : undefined,
|
||||||
],
|
borderColor: isActive ? 'var(--accent)' : undefined,
|
||||||
}
|
})
|
||||||
|
|
||||||
|
export default function SiteHeader() {
|
||||||
|
const { user, loading } = useAuth()
|
||||||
|
|
||||||
|
// Where the auth entry points: staff → admin, player → portal, else sign in.
|
||||||
|
const account =
|
||||||
|
user && user.role && user.role !== 'player'
|
||||||
|
? { label: 'Admin', to: '/admin' }
|
||||||
|
: user
|
||||||
|
? { label: 'My Account', to: '/player' }
|
||||||
|
: { label: 'Sign in', to: '/account/login' }
|
||||||
|
|
||||||
export default function SiteHeader({ section = 'website' }) {
|
|
||||||
const links = NAV[section] || NAV.website
|
|
||||||
return (
|
return (
|
||||||
<header
|
<header
|
||||||
style={{
|
style={{
|
||||||
@@ -35,38 +45,31 @@ export default function SiteHeader({ section = 'website' }) {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="shell"
|
className="shell"
|
||||||
style={{
|
style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 20, padding: '14px 0', flexWrap: 'wrap' }}
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
gap: 20,
|
|
||||||
padding: '14px 0',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
to="/"
|
to="/"
|
||||||
className="display"
|
className="display"
|
||||||
style={{
|
style={{ display: 'flex', alignItems: 'center', gap: 10, fontSize: '1.2rem', letterSpacing: '0.05em', color: 'var(--accent-bright)', textDecoration: 'none', fontWeight: 600 }}
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: 10,
|
|
||||||
fontSize: '1.2rem',
|
|
||||||
letterSpacing: '0.05em',
|
|
||||||
color: 'var(--accent-bright)',
|
|
||||||
textDecoration: 'none',
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<MoonDot />
|
<MoonDot />
|
||||||
UOMysticmoon
|
UOMysticmoon
|
||||||
</Link>
|
</Link>
|
||||||
<nav style={{ display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>
|
<nav style={{ display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>
|
||||||
{links.map((l) => (
|
{NAV.map((l) => (
|
||||||
<Link key={l.to + l.label} to={l.to} className="pill">
|
<NavLink key={l.to} to={l.to} end={l.end} className="pill" style={linkStyle}>
|
||||||
{l.label}
|
{l.label}
|
||||||
</Link>
|
</NavLink>
|
||||||
))}
|
))}
|
||||||
|
{!loading && (
|
||||||
|
<NavLink
|
||||||
|
to={account.to}
|
||||||
|
className="pill"
|
||||||
|
style={{ marginLeft: 6, borderColor: 'var(--accent)', color: 'var(--accent-bright)' }}
|
||||||
|
>
|
||||||
|
{account.label}
|
||||||
|
</NavLink>
|
||||||
|
)}
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export default function Portal() {
|
|||||||
const elements = [...layout.elements].sort((a, b) => (a.z || 0) - (b.z || 0))
|
const elements = [...layout.elements].sort((a, b) => (a.z || 0) - (b.z || 0))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PublicLayout header={false}>
|
<PublicLayout>
|
||||||
<main style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
|
<main style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
|
||||||
{PREVIEW && draft && (
|
{PREVIEW && draft && (
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user