Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Nov 23, 2024
1 parent 5125cda commit 9eebac6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/theme.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export const create_theme_setup_script = (
key = COLOR_SCHEME_STORAGE_KEY,
): string => `
<meta name="color-scheme" content="${fallback === 'dark' ? 'dark light' : 'light dark'}" />
${fallback === 'dark' ? "<style nonce='%sveltekit.nonce%'>:root:root { color-scheme: dark light; }</style>" : ''}
<script nonce="%sveltekit.nonce%">
${fallback === 'dark' ? '<style>:root:root { color-scheme: dark light; }</style>' : ''}
<script>
try {
let c = localStorage.getItem('${key}');
if (c === 'auto' || (c !== 'dark' && c !== 'light')) {
Expand All @@ -154,14 +154,12 @@ export const create_theme_setup_script = (
</script>
`;

// TODO does the `nonce` here and above behave as desired?

/**
* Creates an HTML style string to be inserted into the `head`
* that overrides the theme for a part of the page.
* @param style same as the result of a call to `render_theme_style`
* @returns HTML string with the style tag and its contents
*/
export const create_theme_style_html = (style: string): string => `<style nonce="%sveltekit.nonce%">
export const create_theme_style_html = (style: string): string => `<style>
${style}
</style>`;

0 comments on commit 9eebac6

Please sign in to comment.