Files
copilotkit__copilotkit/examples/canvas/gemini/app/contexts/LayoutContext.tsx
Jordan Ritter fd34bbfbf6 style: format all example files with prettier
Run prettier on ~1,865 files across examples/ to match the monorepo's
formatting standards. These files were imported as-is from standalone
repos that used different prettier configs.
2026-03-12 13:06:04 -07:00

61 lines
1.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { usePathname } from "next/navigation";
import React, { createContext, useContext, useState, ReactNode } from "react";
interface LayoutState {
title: string;
description: string;
showHeader: boolean;
headerContent?: ReactNode;
sidebarContent?: ReactNode;
theme: "light" | "dark" | "auto";
agent: string;
}
interface LayoutContextType {
layoutState: LayoutState;
updateLayout: (updates: Partial<LayoutState>) => void;
}
const defaultLayoutState: LayoutState = {
title: "DeepMind × Gemini",
description:
"Powered by Google's most advanced AI models for generating LinkedIn and X posts",
showHeader: true,
theme: "light",
agent: "post_generation_agent",
};
const LayoutContext = createContext<LayoutContextType | undefined>(undefined);
export function LayoutProvider({ children }: { children: ReactNode }) {
const pathname = usePathname();
console.log(pathname);
const [layoutState, setLayoutState] = useState<LayoutState>({
...defaultLayoutState,
agent:
pathname == "/post-generator"
? "post_generation_agent"
: "stack_analysis_agent",
});
console.log(layoutState);
const updateLayout = (updates: Partial<LayoutState>) => {
setLayoutState((prev) => ({ ...prev, ...updates }));
};
return (
<LayoutContext.Provider value={{ layoutState, updateLayout }}>
{children}
</LayoutContext.Provider>
);
}
export function useLayout() {
const context = useContext(LayoutContext);
if (context === undefined) {
throw new Error("useLayout must be used within a LayoutProvider");
}
return context;
}