Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme): theme crashing the aplication #199

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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