active-theme.tsx — ui Source File
Architecture documentation for active-theme.tsx, a tsx file in the ui codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3ee3a001_834b_9fc3_9ee9_c178663ea003["active-theme.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 3ee3a001_834b_9fc3_9ee9_c178663ea003 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 style 3ee3a001_834b_9fc3_9ee9_c178663ea003 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import {
createContext,
useContext,
useEffect,
useState,
type ReactNode,
} from "react"
const DEFAULT_THEME = "default"
type ThemeContextType = {
activeTheme: string
setActiveTheme: (theme: string) => void
}
const ThemeContext = createContext<ThemeContextType | undefined>(undefined)
export function ActiveThemeProvider({
children,
initialTheme,
}: {
children: ReactNode
initialTheme?: string
}) {
const [activeTheme, setActiveTheme] = useState<string>(
() => initialTheme || DEFAULT_THEME
)
useEffect(() => {
Array.from(document.body.classList)
.filter((className) => className.startsWith("theme-"))
.forEach((className) => {
document.body.classList.remove(className)
})
document.body.classList.add(`theme-${activeTheme}`)
if (activeTheme.endsWith("-scaled")) {
document.body.classList.add("theme-scaled")
}
}, [activeTheme])
return (
<ThemeContext.Provider value={{ activeTheme, setActiveTheme }}>
{children}
</ThemeContext.Provider>
)
}
export function useThemeConfig() {
const context = useContext(ThemeContext)
if (context === undefined) {
throw new Error("useThemeConfig must be used within an ActiveThemeProvider")
}
return context
}
Domain
Subdomains
Types
Dependencies
- react
Source
Frequently Asked Questions
What does active-theme.tsx do?
active-theme.tsx is a source file in the ui codebase, written in tsx. It belongs to the Internationalization domain, RTLLayout subdomain.
What functions are defined in active-theme.tsx?
active-theme.tsx defines 3 function(s): ActiveThemeProvider, theme, useThemeConfig.
What does active-theme.tsx depend on?
active-theme.tsx imports 1 module(s): react.
Where is active-theme.tsx in the architecture?
active-theme.tsx is located at apps/v4/components/active-theme.tsx (domain: Internationalization, subdomain: RTLLayout, directory: apps/v4/components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free