Skip to content

Commit

Permalink
fix: block container id when using '.' for id
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Apr 30, 2020
1 parent bbd06f7 commit 8cb87bf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
46 changes: 24 additions & 22 deletions ui/blocks/src/PageContainer/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const PageContainer: FC<PageContainerProps> = ({
options,
components = {},
}) => {
return storyId ? (
return (
<ThemeProvider theme={theme} dark={dark}>
<Box
sx={{
Expand All @@ -71,28 +71,30 @@ export const PageContainer: FC<PageContainerProps> = ({
}}
>
<Box sx={{ maxWidth: '1000px', width: '100%' }}>
<BlockContextProvider
storyId={storyId}
store={mockStore || store}
options={options}
>
<StoryContextConsumer id={storyId}>
{({ kind }) => {
const { MDXPage } = kind || {};
return MDXPage ? (
<MDXProvider
components={{ ...markdownComponents, ...components }}
>
<MDXPage />
</MDXProvider>
) : (
children
);
}}
</StoryContextConsumer>
</BlockContextProvider>
{storyId && (
<BlockContextProvider
storyId={storyId}
store={mockStore || store}
options={options}
>
<StoryContextConsumer id={storyId}>
{({ kind }) => {
const { MDXPage } = kind || {};
return MDXPage ? (
<MDXProvider
components={{ ...markdownComponents, ...components }}
>
<MDXPage />
</MDXProvider>
) : (
children
);
}}
</StoryContextConsumer>
</BlockContextProvider>
)}
</Box>
</Box>
</ThemeProvider>
) : null;
);
};
5 changes: 4 additions & 1 deletion ui/components/src/BlockContainer/BlockContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export const BlockContainer: FC<BlockContainerProps> = ({
}) => {
const [isOpen, setIsOpen] = React.useState(true);
const blockId =
id || (title ? title.toLowerCase().replace(/\s/g, '-') : undefined);
id !== '.'
? id
: undefined ||
(title ? title.toLowerCase().replace(/\s/g, '-') : undefined);
const BlockTitle: FC = () => (
<Subtitle
color="text"
Expand Down

0 comments on commit 8cb87bf

Please sign in to comment.