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>
148 lines
4.9 KiB
TypeScript
148 lines
4.9 KiB
TypeScript
import classNames from '~/lib/classNames'
|
|
import StyledButton from '../StyledButton'
|
|
import { router, usePage } from '@inertiajs/react'
|
|
import { ChatSession } from '../../../types/chat'
|
|
import { IconMessage } from '@tabler/icons-react'
|
|
import { useState } from 'react'
|
|
import KnowledgeBaseModal from './KnowledgeBaseModal'
|
|
|
|
interface ChatSidebarProps {
|
|
sessions: ChatSession[]
|
|
activeSessionId: string | null
|
|
onSessionSelect: (id: string) => void
|
|
onNewChat: () => void
|
|
onClearHistory: () => void
|
|
isInModal?: boolean
|
|
}
|
|
|
|
export default function ChatSidebar({
|
|
sessions,
|
|
activeSessionId,
|
|
onSessionSelect,
|
|
onNewChat,
|
|
onClearHistory,
|
|
isInModal = false,
|
|
}: ChatSidebarProps) {
|
|
const { aiAssistantName } = usePage<{ aiAssistantName: string }>().props
|
|
const [isKnowledgeBaseModalOpen, setIsKnowledgeBaseModalOpen] = useState(
|
|
() => new URLSearchParams(window.location.search).get('knowledge_base') === 'true'
|
|
)
|
|
|
|
function handleCloseKnowledgeBase() {
|
|
setIsKnowledgeBaseModalOpen(false)
|
|
const params = new URLSearchParams(window.location.search)
|
|
if (params.has('knowledge_base')) {
|
|
params.delete('knowledge_base')
|
|
const newUrl = [window.location.pathname, params.toString()].filter(Boolean).join('?')
|
|
window.history.replaceState(window.history.state, '', newUrl)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="w-64 bg-surface-secondary border-r border-border-subtle flex flex-col h-full">
|
|
<div className="p-4 border-b border-border-subtle h-[75px] flex items-center justify-center">
|
|
<StyledButton onClick={onNewChat} icon="IconPlus" variant="primary" fullWidth>
|
|
New Chat
|
|
</StyledButton>
|
|
</div>
|
|
|
|
<div className="flex-1 overflow-y-auto">
|
|
{sessions.length === 0 ? (
|
|
<div className="p-4 text-center text-text-muted text-sm">No previous chats</div>
|
|
) : (
|
|
<div className="p-2 space-y-1">
|
|
{sessions.map((session) => (
|
|
<button
|
|
key={session.id}
|
|
onClick={() => onSessionSelect(session.id)}
|
|
className={classNames(
|
|
'w-full text-left px-3 py-2 rounded-lg transition-colors group',
|
|
activeSessionId === session.id
|
|
? 'bg-desert-green text-white'
|
|
: 'hover:bg-surface-secondary text-text-primary'
|
|
)}
|
|
>
|
|
<div className="flex items-start gap-2">
|
|
<IconMessage
|
|
className={classNames(
|
|
'h-5 w-5 mt-0.5 shrink-0',
|
|
activeSessionId === session.id ? 'text-white' : 'text-text-muted'
|
|
)}
|
|
/>
|
|
<div className="flex-1 min-w-0">
|
|
<div className="font-medium text-sm truncate">{session.title}</div>
|
|
{session.lastMessage && (
|
|
<div
|
|
className={classNames(
|
|
'text-xs truncate mt-0.5',
|
|
activeSessionId === session.id ? 'text-white/80' : 'text-text-muted'
|
|
)}
|
|
>
|
|
{session.lastMessage}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</button>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
<div className="p-4 flex flex-col items-center justify-center gap-y-2">
|
|
<img src="/project_nomad_logo.png" alt="Project Nomad Logo" className="h-28 w-28 mb-6" />
|
|
<StyledButton
|
|
onClick={() => {
|
|
if (isInModal) {
|
|
window.open('/chat', '_blank')
|
|
} else {
|
|
router.visit('/home')
|
|
}
|
|
}}
|
|
icon={isInModal ? 'IconExternalLink' : 'IconHome'}
|
|
variant="outline"
|
|
size="sm"
|
|
fullWidth
|
|
>
|
|
{isInModal ? 'Open in New Tab' : 'Back to Home'}
|
|
</StyledButton>
|
|
<StyledButton
|
|
onClick={() => {
|
|
router.visit('/settings/models')
|
|
}}
|
|
icon="IconDatabase"
|
|
variant="primary"
|
|
size="sm"
|
|
fullWidth
|
|
>
|
|
Models & Settings
|
|
</StyledButton>
|
|
<StyledButton
|
|
onClick={() => {
|
|
setIsKnowledgeBaseModalOpen(true)
|
|
}}
|
|
icon="IconBrain"
|
|
variant="primary"
|
|
size="sm"
|
|
fullWidth
|
|
>
|
|
Knowledge Base
|
|
</StyledButton>
|
|
{sessions.length > 0 && (
|
|
<StyledButton
|
|
onClick={onClearHistory}
|
|
icon="IconTrash"
|
|
variant="danger"
|
|
size="sm"
|
|
fullWidth
|
|
>
|
|
Clear History
|
|
</StyledButton>
|
|
)}
|
|
</div>
|
|
{isKnowledgeBaseModalOpen && (
|
|
<KnowledgeBaseModal aiAssistantName={aiAssistantName} onClose={handleCloseKnowledgeBase} />
|
|
)}
|
|
</div>
|
|
)
|
|
}
|