Skip to content

Commit 21cc8c5

Browse files
authored
feat(minimal mode/overview): show preview first in minimal mode (#9395)
1 parent c529579 commit 21cc8c5

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

scopes/docs/docs/overview/overview.tsx

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable complexity */
12
import React, { useContext, ComponentType, useState } from 'react';
23
import classNames from 'classnames';
34
import { flatten } from 'lodash';
@@ -10,6 +11,7 @@ import { ComponentPreview, ComponentPreviewProps } from '@teambit/preview.ui.com
1011
import { ComponentOverview } from '@teambit/component.ui.component-meta';
1112
import { CompositionGallery, CompositionGallerySkeleton } from '@teambit/compositions.panels.composition-gallery';
1213
import { useThemePicker } from '@teambit/base-react.themes.theme-switcher';
14+
import { useWorkspaceMode } from '@teambit/workspace.ui.use-workspace-mode';
1315
import { ReadmeSkeleton } from './readme-skeleton';
1416
import styles from './overview.module.scss';
1517

@@ -54,7 +56,7 @@ export function Overview({ titleBadges, overviewOptions, previewProps, getEmptyS
5456
const defaultLoadingState = React.useMemo(() => {
5557
return isScaling && !includesEnvTemplate;
5658
}, [isScaling, includesEnvTemplate]);
57-
59+
const { isMinimal } = useWorkspaceMode();
5860
const [isLoading, setLoading] = useState(defaultLoadingState);
5961

6062
const iframeQueryParams = `onlyOverview=${component.preview?.onlyOverview || 'false'}&skipIncludes=${
@@ -106,19 +108,39 @@ export function Overview({ titleBadges, overviewOptions, previewProps, getEmptyS
106108
<CompositionGallerySkeleton compositionsLength={Math.min(component.compositions.length, 3)} />
107109
</ReadmeSkeleton>
108110
)}
109-
<ComponentPreview
110-
onLoad={onPreviewLoad}
111-
previewName="overview"
112-
pubsub={true}
113-
queryParams={[iframeQueryParams, themeParams, overviewPropsValues?.queryParams || '']}
114-
viewport={null}
115-
fullContentHeight
116-
disableScroll={true}
117-
{...rest}
118-
component={component}
119-
style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}
120-
/>
121-
{component.preview?.onlyOverview && !isLoading && <CompositionGallery component={component} />}
111+
{!isMinimal ? (
112+
<>
113+
<ComponentPreview
114+
onLoad={onPreviewLoad}
115+
previewName="overview"
116+
pubsub={true}
117+
queryParams={[iframeQueryParams, themeParams, overviewPropsValues?.queryParams || '']}
118+
viewport={null}
119+
fullContentHeight
120+
disableScroll={true}
121+
{...rest}
122+
component={component}
123+
style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}
124+
/>
125+
{component.preview?.onlyOverview && !isLoading && <CompositionGallery component={component} />}
126+
</>
127+
) : (
128+
<>
129+
{component.preview?.onlyOverview && !isLoading && <CompositionGallery component={component} />}
130+
<ComponentPreview
131+
onLoad={onPreviewLoad}
132+
previewName="overview"
133+
pubsub={true}
134+
queryParams={[iframeQueryParams, themeParams, overviewPropsValues?.queryParams || '']}
135+
viewport={null}
136+
fullContentHeight
137+
disableScroll={true}
138+
{...rest}
139+
component={component}
140+
style={{ width: '100%', height: '100%', minHeight: !isScaling ? 500 : undefined }}
141+
/>
142+
</>
143+
)}
122144
{component.preview?.onlyOverview && !isLoading && TaggedAPI && (
123145
<TaggedAPI componentId={component.id.toString()} />
124146
)}

0 commit comments

Comments
 (0)