Save theme in local storage
This commit is contained in:
parent
f774699bfb
commit
a51d5cf03d
@ -370,6 +370,8 @@ export default function Canvas(props) {
|
||||
};
|
||||
});
|
||||
|
||||
const theme = localStorage.getItem("theme");
|
||||
|
||||
return (
|
||||
<div className="flex-grow h-full" id="canvas">
|
||||
<div ref={canvas} className="w-full h-full">
|
||||
@ -380,8 +382,7 @@ export default function Canvas(props) {
|
||||
className="w-full h-full"
|
||||
style={{
|
||||
cursor: cursor,
|
||||
backgroundColor:
|
||||
settings.mode === "light" ? "white" : "rgba(22, 22, 26, 1)",
|
||||
backgroundColor: theme === "dark" ? "rgba(22, 22, 26, 1)" : "white",
|
||||
}}
|
||||
>
|
||||
{settings.showGrid && (
|
||||
|
@ -921,6 +921,7 @@ export default function ControlPanel(props) {
|
||||
if (body.hasAttribute("theme-mode")) {
|
||||
body.setAttribute("theme-mode", "light");
|
||||
}
|
||||
localStorage.setItem("theme", "light");
|
||||
setSettings((prev) => ({ ...prev, mode: "light" }));
|
||||
},
|
||||
},
|
||||
@ -930,6 +931,7 @@ export default function ControlPanel(props) {
|
||||
if (body.hasAttribute("theme-mode")) {
|
||||
body.setAttribute("theme-mode", "dark");
|
||||
}
|
||||
localStorage.setItem("theme", "dark");
|
||||
setSettings((prev) => ({ ...prev, mode: "dark" }));
|
||||
},
|
||||
},
|
||||
|
@ -490,6 +490,21 @@ export default function Editor(props) {
|
||||
socket.on("user-connected", onUserConnected);
|
||||
socket.on("user-disconnected", onUserDisconnected);
|
||||
|
||||
const theme = localStorage.getItem("theme");
|
||||
if (theme === "dark") {
|
||||
setSettings((prev) => ({ ...prev, mode: "dark" }));
|
||||
const body = document.body;
|
||||
if (body.hasAttribute("theme-mode")) {
|
||||
body.setAttribute("theme-mode", "dark");
|
||||
}
|
||||
} else {
|
||||
setSettings((prev) => ({ ...prev, mode: "light" }));
|
||||
const body = document.body;
|
||||
if (body.hasAttribute("theme-mode")) {
|
||||
body.setAttribute("theme-mode", "light");
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
socket.off("connect", onConnect);
|
||||
socket.off("recieve-message", onRecieve);
|
||||
|
Loading…
Reference in New Issue
Block a user