diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx index 4db7d242d..a79f49b6b 100644 --- a/frontend-modern/src/App.tsx +++ b/frontend-modern/src/App.tsx @@ -35,6 +35,16 @@ export const useWebSocket = () => { return context; }; +// Dark mode context for reactive theme switching +export const DarkModeContext = createContext<() => boolean>(() => false); +export const useDarkMode = () => { + const context = useContext(DarkModeContext); + if (!context) { + throw new Error('useDarkMode must be used within DarkModeContext.Provider'); + } + return context; +}; + function App() { // Simple auth state const [isLoading, setIsLoading] = createSignal(true); @@ -392,9 +402,10 @@ function App() { Initializing...}> - - -
+ + + +
{/* Header */}
@@ -606,6 +617,7 @@ function App() {
+ diff --git a/frontend-modern/src/components/Dashboard/TagBadges.tsx b/frontend-modern/src/components/Dashboard/TagBadges.tsx index 78bcd3892..a82508410 100644 --- a/frontend-modern/src/components/Dashboard/TagBadges.tsx +++ b/frontend-modern/src/components/Dashboard/TagBadges.tsx @@ -1,6 +1,7 @@ import { Component, For, Show, createSignal } from 'solid-js'; import { Portal } from 'solid-js/web'; import { getTagColorWithSpecial } from '@/utils/tagColors'; +import { useDarkMode } from '@/App'; interface TagBadgesProps { tags: string[]; @@ -12,7 +13,8 @@ interface TagBadgesProps { export const TagBadges: Component = (props) => { const maxVisible = () => props.maxVisible ?? 3; - const isDark = () => props.isDarkMode ?? document.documentElement.classList.contains('dark'); + const darkModeSignal = useDarkMode(); + const isDark = () => props.isDarkMode ?? darkModeSignal(); const visibleTags = () => props.tags?.slice(0, maxVisible()) || []; const hiddenTags = () => props.tags?.slice(maxVisible()) || []; @@ -26,7 +28,7 @@ export const TagBadges: Component = (props) => {
{(tag) => { - const colors = getTagColorWithSpecial(tag, isDark()); + const colors = () => getTagColorWithSpecial(tag, isDark()); const isActive = () => props.activeSearch?.includes(`tags:${tag}`) || false; return ( @@ -50,7 +52,7 @@ export const TagBadges: Component = (props) => {
= (props) => { // Tooltip for individual tag (() => { const tag = hoveredTag()!; - const colors = getTagColorWithSpecial(tag, isDark()); + const colors = () => getTagColorWithSpecial(tag, isDark()); return (
= (props) => { left: `${tooltipPos()!.x}px`, top: `${tooltipPos()!.y - 35}px`, transform: 'translateX(-50%)', - 'background-color': colors.bg, - 'color': colors.text, - 'border': `1px solid ${colors.border}`, + 'background-color': colors().bg, + 'color': colors().text, + 'border': `1px solid ${colors().border}`, 'z-index': '999999', }} >