-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ThemeInit component that place script inside <head> tag (#176)
* add ThemeInit component that place script inside <head> tag * Fix bug * proper sorting * instantiate ThemeInit inside Settings component * add comment about stringified function
- Loading branch information
Showing
5 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte-ux": patch | ||
--- | ||
|
||
Add ThemeInit component to prevent flash of unstyled content when SSR is enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
<script lang="ts"> | ||
import ThemeInit from './ThemeInit.svelte'; | ||
import { settings as setSettings, type Settings } from './settings'; | ||
export let settings: Settings; | ||
/** Include the ThemeInit component to improve SSR compatibility. */ | ||
export let themeInit = true; | ||
setSettings(settings); | ||
</script> | ||
|
||
{#if themeInit} | ||
<ThemeInit /> | ||
{/if} | ||
<slot /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import { createHeadSnippet } from '../styles/theme'; | ||
import { getSettings } from './settings'; | ||
const darkThemes = getSettings().themes?.dark ?? []; | ||
let headSnippet = createHeadSnippet(darkThemes); | ||
</script> | ||
<svelte:head> | ||
{@html headSnippet} | ||
</svelte:head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters