Skip to content

Commit

Permalink
feat(theme): theme crashing the aplication
Browse files Browse the repository at this point in the history
  • Loading branch information
m1guer committed Aug 17, 2024
1 parent f77c9d5 commit cfbd842
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions app/(app)/themes/themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,36 @@ export function Themes() {
const [themeId, setThemeId] = React.useState<ThemeProps>("default")
const themeContainerRef = React.useRef<HTMLDivElement>(null)

// Apply theme for current page
const applyTheme = (theme: ThemeProps) => {
const themeVars = themesList[theme].root
const darkThemeVars = themesList[theme].dark
const themeVars = themesList[theme]?.root
const darkThemeVars = themesList[theme]?.dark
localStorage.setItem("theme-id", theme)
setThemeId(theme)
const themeElement = themeContainerRef.current
if (themeElement) {
const themeVarsToApply = resolvedTheme === "dark" ? darkThemeVars : themeVars
Object.keys(themeVarsToApply).forEach((key) => {
themeElement.style.setProperty(key, themeVarsToApply[key])
})
if (themeVarsToApply) {
Object.keys(themeVarsToApply).forEach((key) => {
themeElement.style.setProperty(key, themeVarsToApply[key])
})
}
}
}

// Apply theme for whole page
// function applyTheme(theme: ThemeProps) {
// const themeVars = themesList[theme].root
// const darkThemeVars = themesList[theme].dark
// localStorage.setItem('theme-id', theme)
// setThemeId(theme)
// const themeElement = document.documentElement
// if (themeElement) {
// const themeVarsToApply = resolvedTheme === 'dark' ? darkThemeVars : themeVars
// Object.keys(themeVarsToApply).forEach((key) => {
// themeElement.style.setProperty(key, themeVarsToApply[key])
// })
// }
// const themeVars = themesList[theme].root;
// const darkThemeVars = themesList[theme].dark;
// localStorage.setItem("theme-id", theme);
// setThemeId(theme);
// const themeElement = document.documentElement;
// if (themeElement) {
// const themeVarsToApply =
// resolvedTheme === "dark" ? darkThemeVars : themeVars;
// Object.keys(themeVarsToApply).forEach((key) => {
// themeElement.style.setProperty(key, themeVarsToApply[key]);
// });
// }
// }

React.useEffect(() => {
Expand Down

0 comments on commit cfbd842

Please sign in to comment.