feat(storybook): create ThemeDecorator to support themeManager logic in storybook
This commit is contained in:
30
.storybook/ThemeDecorator.svelte
Normal file
30
.storybook/ThemeDecorator.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
Component: ThemeDecorator
|
||||
Storybook decorator that initializes ThemeManager for theme-related stories.
|
||||
Ensures theme management works correctly in Storybook's iframe environment.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { themeManager } from '$features/ChangeAppTheme';
|
||||
import {
|
||||
onDestroy,
|
||||
onMount,
|
||||
} from 'svelte';
|
||||
|
||||
interface Props {
|
||||
children: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let { children }: Props = $props();
|
||||
|
||||
// Initialize themeManager on mount
|
||||
onMount(() => {
|
||||
themeManager.init();
|
||||
});
|
||||
|
||||
// Clean up themeManager when story unmounts
|
||||
onDestroy(() => {
|
||||
themeManager.destroy();
|
||||
});
|
||||
</script>
|
||||
|
||||
{@render children()}
|
||||
Reference in New Issue
Block a user