diff --git a/src/components/RenderContext.svelte b/src/components/RenderContext.svelte
index 0bf740e..53921f3 100644
--- a/src/components/RenderContext.svelte
+++ b/src/components/RenderContext.svelte
@@ -3,17 +3,15 @@
* @component
* @wrapper
*/
- import { createRenderContext } from './context';
- import { tick } from 'svelte';
+ import { createRenderContext, setStoryRenderContext } from './context';
export let Stories;
- let exporttime = 0;
+ export let args = {};
+ export let storyContext = {};
- $: {
- createRenderContext($$props);
- }
+ createRenderContext($$props);
+
+ $: setStoryRenderContext(args, storyContext);
-{#key $$props.args}
-
-{/key}
+
diff --git a/src/components/Story.svelte b/src/components/Story.svelte
index a770d13..a67e5c8 100644
--- a/src/components/Story.svelte
+++ b/src/components/Story.svelte
@@ -1,5 +1,5 @@
{#if render}
-
+
{/if}
diff --git a/src/components/Template.svelte b/src/components/Template.svelte
index 143f1dd..e0bcc26 100644
--- a/src/components/Template.svelte
+++ b/src/components/Template.svelte
@@ -1,15 +1,18 @@
{#if render}
-
+
{/if}
diff --git a/src/components/context.ts b/src/components/context.ts
index b5f8ba6..bd17197 100644
--- a/src/components/context.ts
+++ b/src/components/context.ts
@@ -1,6 +1,8 @@
-import { getContext, hasContext, setContext } from "svelte";
+import { getContext, hasContext, setContext } from 'svelte';
+import { writable, Writable } from 'svelte/store';
-const CONTEXT_KEY = "storybook-registration-context";
+const CONTEXT_KEY = 'storybook-registration-context';
+const CONTEXT_KEY_COMPONENT = 'storybook-registration-context-component';
export function createRenderContext(props: any = {}) {
setContext(CONTEXT_KEY, {
@@ -32,3 +34,18 @@ export function useContext() {
}
return getContext(CONTEXT_KEY);
}
+export function getStoryRenderContext(): {
+ argsStore: Writable>;
+ storyContextStore: Writable>;
+} {
+ if (!hasContext(CONTEXT_KEY_COMPONENT)) {
+ setContext(CONTEXT_KEY_COMPONENT, { argsStore: writable({}), storyContextStore: writable({}) });
+ }
+ return getContext(CONTEXT_KEY_COMPONENT);
+}
+
+export function setStoryRenderContext(args, storyContext) {
+ const ctx = getStoryRenderContext();
+ ctx.argsStore.set(args);
+ ctx.storyContextStore.set(storyContext);
+}