Skip to content

Commit

Permalink
fix: update docId for new state
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 30, 2020
1 parent 46354d3 commit 7930fb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion integrations/storybook/src/context/BlockContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export const BlockContextProvider: React.FC<BlockContextProviderProps> = ({
}) => {
const defaultStoyId = useStoryId();
const storyId = id ? id : defaultStoyId;
const docId = storyId && store ? store.stories[storyId].doc : undefined;
return (
<BlocksContextProvider store={store} storyId={storyId}>
<BlocksContextProvider store={store} storyId={storyId} docId={docId}>
{children}
</BlocksContextProvider>
);
Expand Down
9 changes: 8 additions & 1 deletion integrations/storybook/src/docs-page/DocsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ import { store } from '@component-controls/store/live_store';
export const PageContextContainer: FC = ({ children }) => {
const options = React.useMemo(() => getGlobalOptions(), []);
const storyId = useStoryId();
const docId = storyId && store ? store.stories[storyId].doc : undefined;
console.group('HERE', docId);
return (
<ThemeProvider theme={store.config.theme}>
<BlockContextProvider storyId={storyId} store={store} options={options}>
<BlockContextProvider
storyId={storyId}
store={store}
docId={docId}
options={options}
>
<BlockPageContainer variant="pagecontainer.storybook">
{children}
</BlockPageContainer>
Expand Down
4 changes: 2 additions & 2 deletions integrations/storybook/src/panel/AddonPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export const AddonPanel: React.FC<AddonPanelProps> = ({
channel.on(SET_CURRENT_STORY, onChangeStory);
return () => channel.off(SET_CURRENT_STORY, onChangeStory);
}, [api, channel]);

const docId = storyId && store ? store.stories[storyId].doc : undefined;
return active && storyId ? (
<ThemeProvider>
<BlockContextProvider store={store} storyId={storyId}>
<BlockContextProvider store={store} storyId={storyId} docId={docId}>
{children}
</BlockContextProvider>
</ThemeProvider>
Expand Down

0 comments on commit 7930fb7

Please sign in to comment.