Skip to content

Commit

Permalink
Merge pull request #10444 from storybookjs/improve/loading
Browse files Browse the repository at this point in the history
IMPROVE the loading of the storybook UI
  • Loading branch information
ndelangen authored Apr 17, 2020
2 parents 72feaf4 + 43a8375 commit 8558152
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lib/ui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ const App = React.memo<AppProps>(
);

if (!width || !height) {
content = (
<div>
{width} x {height}
</div>
);
content = <div />;
} else if (width < 600) {
content = <Mobile {...props} viewMode={viewMode} options={layout} />;
} else {
Expand Down
17 changes: 16 additions & 1 deletion lib/ui/src/components/preview/FramesRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ import { IFrame } from './iframe';
import { FramesRendererProps } from './utils/types';
import { stringifyQueryParams } from './utils/stringifyQueryParams';

const getActive = (
refId: FramesRendererProps['refId'],
storyId: FramesRendererProps['storyId']
) => {
if (storyId === '*') {
return undefined;
}

if (refId) {
return `storybook-ref-${refId}`;
}

return 'storybook-preview-iframe';
};

export const FramesRenderer: FunctionComponent<FramesRendererProps> = ({
refs,
story,
Expand All @@ -15,7 +30,7 @@ export const FramesRenderer: FunctionComponent<FramesRendererProps> = ({
storyId,
}) => {
const stringifiedQueryParams = stringifyQueryParams(queryParams);
const active = refId ? `storybook-ref-${refId}` : 'storybook-preview-iframe';
const active = getActive(refId, storyId);

const styles = useMemo<CSSObject>(() => {
return {
Expand Down

0 comments on commit 8558152

Please sign in to comment.