Skip to content

Commit

Permalink
v1.4.0-alpha.4 | fix: first initialize colors
Browse files Browse the repository at this point in the history
  • Loading branch information
programming-with-ia committed Nov 12, 2024
1 parent 3715582 commit 7c42ff0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
18 changes: 10 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shadcn-theme-editor",
"version": "1.4.0-alpha.2",
"version": "1.4.0-alpha.4",
"description": "Shadcn Theme Editor",
"module": "dist/index.mjs",
"main": "dist/index.js",
Expand Down
8 changes: 2 additions & 6 deletions src/components/SideBarColors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ function SideBarColors() {
}, 2000);

useEffect(() => {
let isSavedThemeApplied = false;
if (typeof colors == "undefined" || isMount) {
// If colors are not defined (i.e., they haven't been set by other functions yet, meaning it's the first time),
// or if this is due to a re-render caused by dependency changes (e.g., when currentTheme is updated).
try {
isSavedThemeApplied = setSavedTheme(currentTheme);
return;
} catch (error) {}
if (setSavedTheme(currentTheme)) return; // isSavedThemeApplied
}

if (typeof colors == "undefined") {
themeEmittor.setDefaultTheme();
}
}, [currentTheme]);
}, [currentTheme, isMount]);

return (
<>
Expand Down

0 comments on commit 7c42ff0

Please sign in to comment.