Skip to content

Commit

Permalink
fix: add iframe title ally issue
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Apr 28, 2021
1 parent 44cb551 commit 6910937
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ui/blocks/src/Story/StoryRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { useStore, useExternalOptions } from '@component-controls/store';
export interface IframeWrapperProps {
initialIframeContent?: string;
style?: CSSProperties;
title?: string;
}

const IframeWrapper: FC<IframeWrapperProps> = ({
children,
title,
style = { border: 0 },
initialIframeContent = `
<!DOCTYPE html>
Expand All @@ -38,6 +40,7 @@ const IframeWrapper: FC<IframeWrapperProps> = ({
return (
<Iframe
initialContent={initialIframeContent}
title={title}
style={{ ...style, height: size?.height, width: '100%' }}
>
<ReactResizeDetector
Expand All @@ -57,16 +60,22 @@ export type StoryWrapperType = 'wrapper' | 'iframe';
export interface StoryWrapperProps {
wrapper?: StoryWrapperType;
iframeStyle?: CSSProperties;
title?: string;
}

const StoryWrapper: FC<StoryWrapperProps> = ({
wrapper = 'wrapper',
iframeStyle,
children,
title,
}) => {
switch (wrapper) {
case 'iframe':
return <IframeWrapper style={iframeStyle}>{children}</IframeWrapper>;
return (
<IframeWrapper title={title} style={iframeStyle}>
{children}
</IframeWrapper>
);
default:
return <Fragment>{children}</Fragment>;
}
Expand Down Expand Up @@ -98,7 +107,11 @@ export const StoryRender: FC<StoryRenderProps & StoryWrapperProps> = forwardRef(
variant={`${NAME}.container`}
{...rest}
>
<StoryWrapper iframeStyle={iframeStyle} wrapper={wrapper}>
<StoryWrapper
title={story.name}
iframeStyle={iframeStyle}
wrapper={wrapper}
>
<Box
className="story-render-container"
variant={`${NAME}.wrapper`}
Expand Down

0 comments on commit 6910937

Please sign in to comment.