Skip to content

Commit c029a8d

Browse files
committed
Fix ThemeScript init issue
1 parent b99448c commit c029a8d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/neat-ducks-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/react": patch
3+
---
4+
5+
Fix theme script

packages/react/src/components/ThemeScript.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function ThemeScript({ auto = true, theme }: ThemeScriptProps) {
1212
<script
1313
dangerouslySetInnerHTML={{
1414
__html: theme
15-
? `(function (){document.documentElement.setAttribute('data-theme',${theme});}())`
15+
? `(function (){document.documentElement.setAttribute('data-theme','${theme}');}())`
1616
: `(function (){document.documentElement.setAttribute('data-theme',localStorage.getItem('__DF_THEME_SELECTED__')||(${String(auto)}&&window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'${process.env.DEVUP_UI_DEFAULT_THEME ?? 'default'}'));})()`,
1717
}}
1818
/>

packages/react/src/components/__tests__/__snapshots__/ThemeScript.browser.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exports[`ThemeScript > should apply ThemeScript with not auto 1`] = `
1919
exports[`ThemeScript > should apply ThemeScript with theme 1`] = `
2020
<div>
2121
<script>
22-
(function (){document.documentElement.setAttribute('data-theme',default);}())
22+
(function (){document.documentElement.setAttribute('data-theme','default');}())
2323
</script>
2424
</div>
2525
`;

0 commit comments

Comments
 (0)