@@ -21,6 +21,7 @@ import { Feature } from "@/types/integration";
2121import { useURLParams } from "@/contexts/url-params-context" ;
2222import { View } from "@/types/interface" ;
2323import { getTitleForCurrentDomain } from "@/utils/domain-config" ;
24+ import { useTheme } from "next-themes" ;
2425
2526interface SidebarProps {
2627 isMobile ?: boolean ;
@@ -30,8 +31,10 @@ interface SidebarProps {
3031export function Sidebar ( { isMobile, onMobileClose } : SidebarProps ) {
3132 const router = useRouter ( ) ;
3233 const pathname = usePathname ( ) ;
34+ const { theme, setTheme } = useTheme ( ) ;
35+ const isDarkTheme = theme === "dark"
36+ console . log ( isDarkTheme )
3337 const { view, frameworkPickerHidden, viewPickerHidden, featurePickerHidden, setView} = useURLParams ( ) ;
34- const [ isDarkTheme , setIsDarkTheme ] = useState < boolean > ( false ) ;
3538
3639 // Extract the current integration ID from the pathname
3740 const pathParts = pathname . split ( "/" ) ;
@@ -67,38 +70,6 @@ export function Sidebar({ isMobile, onMobileClose }: SidebarProps) {
6770 router . push ( `/${ integrationId } ` ) ;
6871 } ;
6972
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-
10273 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`
10374
10475 return (
0 commit comments