mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
Add a warm charcoal dark mode ("Night Ops") using CSS variable swapping
under [data-theme="dark"]. All 23 desert palette variables are overridden
with dark-mode counterparts, and ~313 generic Tailwind classes (bg-white,
text-gray-*, border-gray-*) are replaced with semantic tokens.
Infrastructure:
- CSS variable overrides in app.css for both themes
- ThemeProvider + useTheme hook (localStorage + KV store sync)
- ThemeToggle component (moon/sun icons, "Night Ops"/"Day Ops" labels)
- FOUC prevention script in inertia_layout.edge
- Toggle placed in StyledSidebar and Footer for access on every page
Color replacements across 50 files:
- bg-white → bg-surface-primary
- bg-gray-50/100 → bg-surface-secondary
- text-gray-900/800 → text-text-primary
- text-gray-600/500 → text-text-secondary/text-text-muted
- border-gray-200/300 → border-border-subtle/border-border-default
- text-desert-white → text-white (fixes invisible text on colored bg)
- Button hover/active states use dedicated btn-green-hover/active vars
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
133 lines
4.5 KiB
TypeScript
133 lines
4.5 KiB
TypeScript
import { useMemo, useState } from 'react'
|
|
import { Dialog, DialogBackdrop, DialogPanel, TransitionChild } from '@headlessui/react'
|
|
import classNames from '~/lib/classNames'
|
|
import { IconArrowLeft } from '@tabler/icons-react'
|
|
import { usePage } from '@inertiajs/react'
|
|
import { UsePageProps } from '../../types/system'
|
|
import { IconMenu2, IconX } from '@tabler/icons-react'
|
|
import ThemeToggle from '~/components/ThemeToggle'
|
|
|
|
type SidebarItem = {
|
|
name: string
|
|
href: string
|
|
icon?: React.ElementType
|
|
current: boolean
|
|
target?: string
|
|
}
|
|
|
|
interface StyledSidebarProps {
|
|
title: string
|
|
items: SidebarItem[]
|
|
}
|
|
|
|
const StyledSidebar: React.FC<StyledSidebarProps> = ({ title, items }) => {
|
|
const [sidebarOpen, setSidebarOpen] = useState(false)
|
|
const { appVersion } = usePage().props as unknown as UsePageProps
|
|
|
|
const currentPath = useMemo(() => {
|
|
if (typeof window === 'undefined') return ''
|
|
return window.location.pathname
|
|
}, [])
|
|
|
|
const ListItem = (item: SidebarItem) => {
|
|
return (
|
|
<li key={item.name}>
|
|
<a
|
|
href={item.href}
|
|
target={item.target}
|
|
className={classNames(
|
|
item.current
|
|
? 'bg-desert-green text-white'
|
|
: 'text-text-primary hover:bg-desert-green-light hover:text-white',
|
|
'group flex gap-x-3 rounded-md p-2 text-sm/6 font-semibold'
|
|
)}
|
|
>
|
|
{item.icon && <item.icon aria-hidden="true" className="size-6 shrink-0" />}
|
|
{item.name}
|
|
</a>
|
|
</li>
|
|
)
|
|
}
|
|
|
|
const Sidebar = () => {
|
|
return (
|
|
<div className="flex grow flex-col gap-y-5 overflow-y-auto bg-desert-sand px-6 ring-1 ring-white/5 pt-4 shadow-md">
|
|
<div className="flex h-16 shrink-0 items-center">
|
|
<img src="/project_nomad_logo.png" alt="Project Nomad Logo" className="h-16 w-16" />
|
|
<h1 className="ml-3 text-xl font-semibold text-text-primary">{title}</h1>
|
|
</div>
|
|
<nav className="flex flex-1 flex-col">
|
|
<ul role="list" className="flex flex-1 flex-col gap-y-7">
|
|
<li>
|
|
<ul role="list" className="-mx-2 space-y-1">
|
|
{items.map((item) => (
|
|
<ListItem key={item.name} {...item} current={currentPath === item.href} />
|
|
))}
|
|
<li className="ml-2 mt-4">
|
|
<a
|
|
href="/home"
|
|
className="flex flex-row items-center gap-x-3 text-desert-green text-sm font-semibold"
|
|
>
|
|
<IconArrowLeft aria-hidden="true" className="size-6 shrink-0" />
|
|
Back to Home
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
<div className="mb-4 flex flex-col items-center gap-1 text-sm text-text-secondary">
|
|
<p>Project N.O.M.A.D. Command Center v{appVersion}</p>
|
|
<ThemeToggle />
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
type="button"
|
|
className="absolute left-4 top-4 z-50 xl:hidden"
|
|
onClick={() => setSidebarOpen(true)}
|
|
>
|
|
<IconMenu2 aria-hidden="true" className="size-8" />
|
|
</button>
|
|
{/* Mobile sidebar */}
|
|
<Dialog open={sidebarOpen} onClose={setSidebarOpen} className="relative z-50 xl:hidden">
|
|
<DialogBackdrop
|
|
transition
|
|
className="fixed inset-0 bg-black/10 transition-opacity duration-300 ease-linear data-[closed]:opacity-0"
|
|
/>
|
|
|
|
<div className="fixed inset-0 flex">
|
|
<DialogPanel
|
|
transition
|
|
className="relative mr-16 flex w-full max-w-xs flex-1 transform transition duration-300 ease-in-out data-[closed]:-translate-x-full"
|
|
>
|
|
<TransitionChild>
|
|
<div className="absolute left-full top-0 flex w-16 justify-center pt-5 duration-300 ease-in-out data-[closed]:opacity-0">
|
|
<button
|
|
type="button"
|
|
onClick={() => setSidebarOpen(false)}
|
|
className="-m-2.5 p-2.5"
|
|
>
|
|
<span className="sr-only">Close sidebar</span>
|
|
<IconX aria-hidden="true" className="size-6 text-white" />
|
|
</button>
|
|
</div>
|
|
</TransitionChild>
|
|
<Sidebar />
|
|
</DialogPanel>
|
|
</div>
|
|
</Dialog>
|
|
{/* Desktop sidebar */}
|
|
<div className="hidden xl:fixed xl:inset-y-0 xl:z-50 xl:flex xl:w-72 xl:flex-col">
|
|
<Sidebar />
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default StyledSidebar
|