Skip to content

Commit e2733e5

Browse files
committed
chore: minify
1 parent 36a2106 commit e2733e5

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

examples/nextjs/src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }):
1414
<html lang="en">
1515
<body className={inter.className}>
1616
<ServerTarget />
17-
<Core />
17+
<Core t="all .5s" />
1818
<Layout>
1919
<Header />
2020
{children}

lib/src/client/core/core.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ export interface CoreProps {
1111
const modifyTransition = (documentMinify: Document, themeTransition = "none") => {
1212
const css = documentMinify.createElement("style");
1313
/** split by ';' to prevent CSS injection */
14-
css.appendChild(
15-
documentMinify.createTextNode(`*{transition:${themeTransition.split(";")[0]} !important;}`),
16-
);
17-
documentMinify.head.appendChild(css);
14+
css.textContent = `*{transition:${themeTransition.split(";")[0]} !important;}`;
15+
const head = documentMinify.head;
16+
head.appendChild(css);
1817

1918
return () => {
2019
// Force restyle
2120
getComputedStyle(documentMinify.body);
2221
// Wait for next tick before removing
23-
setTimeout(() => {
24-
documentMinify.head.removeChild(css);
25-
}, 1);
22+
setTimeout(() => head.removeChild(css), 1);
2623
};
2724
};
2825

@@ -83,7 +80,7 @@ export const Core = ({ t }: CoreProps) => {
8380
localStorage.setItem(COOKIE_KEY, mode);
8481
if (serverTargetEl)
8582
documentMinify.cookie = `${COOKIE_KEY}=${resolvedMode};max-age=31536000;SameSite=Strict;`;
86-
}, [resolvedMode, systemMode, mode]);
83+
}, [resolvedMode, systemMode, mode, t]);
8784

8885
return null;
8986
};

0 commit comments

Comments
 (0)