Skip to content

Commit e7067c3

Browse files
authored
Merge pull request #308 from ag-ui-protocol/chore/disable-dark-theme-in-dojo
chore: disable dark theme in dojo
2 parents 8442577 + e72b717 commit e7067c3

File tree

3 files changed

+9
-46
lines changed

3 files changed

+9
-46
lines changed

typescript-sdk/apps/dojo/src/app/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ export default function RootLayout({
3232
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
3333
<ThemeProvider
3434
attribute="class"
35-
defaultTheme="system"
36-
enableSystem
35+
defaultTheme="light"
36+
enableSystem={false}
37+
themes={['light']}
3738
disableTransitionOnChange
3839
>
3940
<Suspense>

typescript-sdk/apps/dojo/src/components/sidebar/sidebar.tsx

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Feature } from "@/types/integration";
2121
import { useURLParams } from "@/contexts/url-params-context";
2222
import { View } from "@/types/interface";
2323
import { getTitleForCurrentDomain } from "@/utils/domain-config";
24+
import { useTheme } from "next-themes";
2425

2526
interface SidebarProps {
2627
isMobile?: boolean;
@@ -30,8 +31,10 @@ interface SidebarProps {
3031
export 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 (
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
"use client";
22

33
import * as React from "react";
4-
import { ThemeProvider as NextThemesProvider } from "next-themes";
4+
import { ThemeProvider as NextThemesProvider, ThemeProviderProps as NextThemeProviderProps } from "next-themes";
55

6-
type ThemeProviderProps = {
7-
children: React.ReactNode;
8-
attribute?: string;
9-
defaultTheme?: string;
10-
enableSystem?: boolean;
11-
disableTransitionOnChange?: boolean;
12-
};
13-
14-
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
15-
// @ts-expect-error -- ignore
6+
export function ThemeProvider({ children, ...props }: NextThemeProviderProps) {
167
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
178
}

0 commit comments

Comments
 (0)