Lumen & Gesso / website · lumengesso.com / app / components / SiteHeader.tsx
| 1 | import { getCustomerUser } from '@/app/lib/lumen-auth'; |
| 2 | import { isAdmin } from '@/app/lib/admin'; |
| 3 | import ButtonIcon from './ButtonIcon'; |
| 4 | |
| 5 | // Shared dark title bar — brand wordmark + nav. Rendered on every page |
| 6 | // via the root layout. Reads the Supabase session server-side so the |
| 7 | // Sign in / Sign out link reflects current state without a client-side |
| 8 | // flash. Admin users also get a quick "Admin" link to /admin. |
| 9 | // |
| 10 | // Two navs are rendered from the same server data: |
| 11 | // • .sitebar__nav — the inline desktop row (unchanged; hidden ≤768px) |
| 12 | // • .sitebar__menu — a pure-CSS <details> disclosure for mobile, so the |
| 13 | // links collapse behind a hamburger instead of |
| 14 | // wrapping. No client JS / hydration. |
| 15 | export async function SiteHeader() { |
| 16 | const user = await getCustomerUser(); |
| 17 | const signedIn = !!user; |
| 18 | const admin = signedIn && isAdmin(user.email); |
| 19 | |
| 20 | const accountHref = admin ? '/admin' : '/orders'; |
| 21 | const accountLabel = admin ? 'Admin' : 'My orders'; |
| 22 | |
| 23 | return ( |
| 24 | <header className="sitebar"> |
| 25 | <a className="sitebar__brand" href="/"> |
| 26 | Lumen <span className="amp">&</span> Gesso |
| 27 | </a> |
| 28 | |
| 29 | <nav className="sitebar__nav" aria-label="Main navigation"> |
| 30 | <a className="sitebar__link sitebar__link--cta" href="/studio"><ButtonIcon name="palette" size={15} />Free Studio</a> |
| 31 | <a className="sitebar__link sitebar__link--outline" href="/gallery"><ButtonIcon name="image" size={15} />Gallery</a> |
| 32 | <a className="sitebar__link" href="/reviews">Reviews</a> |
| 33 | <a className="sitebar__link" href="/careers">Careers</a> |
| 34 | {signedIn && ( |
| 35 | <a className="sitebar__link" href={accountHref}>{accountLabel}</a> |
| 36 | )} |
| 37 | {signedIn ? ( |
| 38 | <a className="sitebar__link" href="/auth/signout?next=/login">Sign out</a> |
| 39 | ) : ( |
| 40 | <a className="sitebar__link" href="/login">Sign in</a> |
| 41 | )} |
| 42 | </nav> |
| 43 | |
| 44 | <details className="sitebar__menu"> |
| 45 | <summary className="sitebar__menu-toggle" aria-label="Menu"> |
| 46 | <span className="sitebar__menu-bars" aria-hidden="true"> |
| 47 | <span /><span /> |
| 48 | </span> |
| 49 | </summary> |
| 50 | <div className="sitebar__menu-panel"> |
| 51 | <a className="sitebar__menu-link" href="/studio">Free Studio</a> |
| 52 | <a className="sitebar__menu-link" href="/gallery">Gallery</a> |
| 53 | <a className="sitebar__menu-link" href="/reviews">Reviews</a> |
| 54 | <a className="sitebar__menu-link" href="/careers">Careers</a> |
| 55 | <span className="sitebar__menu-divider" aria-hidden="true" /> |
| 56 | {signedIn && ( |
| 57 | <a className="sitebar__menu-link" href={accountHref}>{accountLabel}</a> |
| 58 | )} |
| 59 | {signedIn ? ( |
| 60 | <a className="sitebar__menu-link" href="/auth/signout?next=/login">Sign out</a> |
| 61 | ) : ( |
| 62 | <a className="sitebar__menu-link" href="/login">Sign in</a> |
| 63 | )} |
| 64 | </div> |
| 65 | </details> |
| 66 | </header> |
| 67 | ); |
| 68 | } |