@@ -21,6 +21,7 @@ import { Feature } from "@/types/integration";
21
21
import { useURLParams } from "@/contexts/url-params-context" ;
22
22
import { View } from "@/types/interface" ;
23
23
import { getTitleForCurrentDomain } from "@/utils/domain-config" ;
24
+ import { useTheme } from "next-themes" ;
24
25
25
26
interface SidebarProps {
26
27
isMobile ?: boolean ;
@@ -30,8 +31,10 @@ interface SidebarProps {
30
31
export function Sidebar ( { isMobile, onMobileClose } : SidebarProps ) {
31
32
const router = useRouter ( ) ;
32
33
const pathname = usePathname ( ) ;
34
+ const { theme, setTheme } = useTheme ( ) ;
35
+ const isDarkTheme = theme === "dark"
36
+ console . log ( isDarkTheme )
33
37
const { view, frameworkPickerHidden, viewPickerHidden, featurePickerHidden, setView} = useURLParams ( ) ;
34
- const [ isDarkTheme , setIsDarkTheme ] = useState < boolean > ( false ) ;
35
38
36
39
// Extract the current integration ID from the pathname
37
40
const pathParts = pathname . split ( "/" ) ;
@@ -67,38 +70,6 @@ export function Sidebar({ isMobile, onMobileClose }: SidebarProps) {
67
70
router . push ( `/${ integrationId } ` ) ;
68
71
} ;
69
72
70
- // Check for dark mode using media query
71
- useEffect ( ( ) => {
72
- // Check if we're in the browser
73
- if ( typeof window !== "undefined" ) {
74
- // Initial check
75
- setIsDarkTheme ( window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches ) ;
76
-
77
- // Listen for changes
78
- const mediaQuery = window . matchMedia ( "(prefers-color-scheme: dark)" ) ;
79
- const handleChange = ( e : MediaQueryListEvent ) => {
80
- setIsDarkTheme ( e . matches ) ;
81
- } ;
82
-
83
- mediaQuery . addEventListener ( "change" , handleChange ) ;
84
-
85
- // Also check for .dark class which is added by next-themes
86
- const observer = new MutationObserver ( ( ) => {
87
- setIsDarkTheme ( document . documentElement . classList . contains ( "dark" ) ) ;
88
- } ) ;
89
-
90
- observer . observe ( document . documentElement , {
91
- attributes : true ,
92
- attributeFilter : [ "class" ] ,
93
- } ) ;
94
-
95
- return ( ) => {
96
- mediaQuery . removeEventListener ( "change" , handleChange ) ;
97
- observer . disconnect ( ) ;
98
- } ;
99
- }
100
- } , [ ] ) ;
101
-
102
73
const tabClass = `cursor-pointer flex-1 h-8 px-2 text-sm text-primary shadow-none bg-none border-none font-medium gap-1 rounded-lg data-[state=active]:bg-white data-[state=active]:text-primary data-[state=active]:shadow-none`
103
74
104
75
return (
0 commit comments