diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 234f21d..05b781a 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,8 +1,9 @@ +import { UIConfigProvider } from "@/lib/ui-config-provider"; import type { Metadata } from "next"; -import "./globals.css"; import { Inter } from "next/font/google"; -import React from "react"; import { NuqsAdapter } from "nuqs/adapters/next/app"; +import React from "react"; +import "./globals.css"; const inter = Inter({ subsets: ["latin"], @@ -21,10 +22,12 @@ export default function RootLayout({ children: React.ReactNode; }>) { return ( - - - {children} - - + + + + {children} + + + ); } diff --git a/src/components/dark-mode-switcher.tsx b/src/components/dark-mode-switcher.tsx new file mode 100644 index 0000000..4e4b134 --- /dev/null +++ b/src/components/dark-mode-switcher.tsx @@ -0,0 +1,25 @@ +"use client"; + +import { Moon, Sun } from "lucide-react"; +import { useUIConfig } from "@/hooks/useUIConfig"; + +export const ThemeToggleButton = () => { + const { theme, setTheme } = useUIConfig(); + + const toggleTheme = () => { + setTheme(theme === "dark" ? "light" : "dark"); + }; + + const isDark = theme === "dark"; + + return ( + + ); +}; diff --git a/src/components/thread/index.tsx b/src/components/thread/index.tsx index 1cec4a2..d575262 100644 --- a/src/components/thread/index.tsx +++ b/src/components/thread/index.tsx @@ -26,6 +26,8 @@ import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom"; import ThreadHistory from "./history"; import { toast } from "sonner"; import { useMediaQuery } from "@/hooks/useMediaQuery"; +import { useUIConfig } from "@/hooks/useUIConfig"; +import { ThemeToggleButton } from "../dark-mode-switcher"; import { Label } from "../ui/label"; import { Switch } from "../ui/switch"; import { GitHubSVG } from "../icons/github"; @@ -114,6 +116,7 @@ export function Thread() { const [input, setInput] = useState(""); const [firstTokenReceived, setFirstTokenReceived] = useState(false); const isLargeScreen = useMediaQuery("(min-width: 1024px)"); + const { config } = useUIConfig(); const stream = useStreamContext(); const messages = stream.messages; @@ -212,30 +215,32 @@ export function Thread() { return (
-
- -
+ - -
-
-
+
+ +
+ +
+ )} {!chatStarted && (
-
- {(!chatHistoryOpen || !isLargeScreen) && ( - - )} -
-
- + {!config.layout?.hideThreadHistory && ( +
+ {(!chatHistoryOpen || !isLargeScreen) && ( + + )} +
+ )} +
+ {config.layout?.showThemeToggle && } + {!config.layout?.hideGithubButton && }
)} @@ -308,20 +316,29 @@ export function Thread() { damping: 30, }} > - - - Agent Chat - + {config.brand.brandHeaderTopLeft ? ( + config.brand.brandHeaderTopLeft() + ) : ( + <> + + + Agent Chat + + + )}
-
- -
+ {!config.layout?.hideGithubButton && ( +
+ +
+ )} + {config.layout?.showThemeToggle && } } footer={ -
- {!chatStarted && ( +
+ {!chatStarted && config.brand.brandHeaderWelcome ? ( + config.brand.brandHeaderWelcome() + ) : !config.layout?.hideBrandHeaderAboveChatBox ? (

Agent Chat

- )} + ) : null} @@ -420,19 +439,21 @@ export function Thread() {
-
- - -
+ {!config.layout?.hideToolCallsToggleButton && ( +
+ + +
+ )}
{stream.isLoading ? (