Skip to content

Commit feca41f

Browse files
committed
fix(dark): 다크모드 새로고침시 transition 효과로 flicker 발생 방지
1 parent 0d167b3 commit feca41f

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/components/layout/Provider.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { Global, ThemeProvider } from "@emotion/react";
4-
import Script from "next/script";
4+
import { useEffect } from "react";
55
import { RecoilRoot } from "recoil";
66

77
import { rootThemeSetting } from "@/utils/dom";
@@ -13,10 +13,14 @@ export const ScriptDom = () => {
1313
const stringifyFn = String(rootThemeSetting);
1414
const fnToRunOnClient = `(${stringifyFn})()`;
1515

16-
return <Script dangerouslySetInnerHTML={{ __html: fnToRunOnClient }} />;
16+
return <script dangerouslySetInnerHTML={{ __html: fnToRunOnClient }} />;
1717
};
1818

1919
export default function Provider(props: React.PropsWithChildren) {
20+
useEffect(() => {
21+
document.body.style.transition = "background var(--delay)";
22+
}, []);
23+
2024
return (
2125
<ThemeProvider theme={baseTheme}>
2226
<Global styles={GlobalStyle(baseTheme)} />

src/styles/GlobalStyle.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ const GlobalStyle = (theme: Theme) => css`
3939
body {
4040
color: var(--black);
4141
background-color: var(--white);
42-
transition: background var(--delay);
43-
-moz-transition: background var(--delay);
44-
-webkit-transition: background var(--delay);
45-
-ms-transition: background var(--delay);
46-
-o-transition: background var(--delay);
4742
&.modal-open {
4843
overflow: hidden;
4944
padding-right: 1rem;

src/utils/dom.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export function rootThemeSetting() {
1616

1717
export function modalOpenPadding() {
1818
try {
19-
var root = document.documentElement;
20-
var themeStorage = localStorage.getItem("theme");
21-
22-
if (themeStorage) {
23-
root.setAttribute("data-theme", themeStorage);
24-
}
2519
} catch (e) {
2620
console.log(e);
2721
}

0 commit comments

Comments
 (0)