Skip to content

Commit 7f9c5d4

Browse files
authored
feat(dashboard): skeletons for repositories and synced sandboxes (#7017)
* wip: repository skeleton * diff between default and repository skeleton * rename Repo to SyncedSandbox * synced sandbox skeleton * different skeleton for synced sandboxes * wip: simplify * fixup * fixup * pass viewmode as prop to skeletons
1 parent eeb7caf commit 7f9c5d4

File tree

12 files changed

+166
-76
lines changed

12 files changed

+166
-76
lines changed

packages/app/src/app/pages/Dashboard/Components/Sandbox/SandboxCard.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
Input,
77
Icon,
88
IconButton,
9-
SkeletonText,
109
Link,
1110
Tooltip,
1211
} from '@codesandbox/components';
@@ -388,24 +387,3 @@ const Thumbnail = ({
388387
</>
389388
);
390389
};
391-
392-
export const SkeletonCard = () => (
393-
<Stack
394-
direction="vertical"
395-
gap={4}
396-
css={css({
397-
width: '100%',
398-
height: 240,
399-
border: '1px solid',
400-
borderColor: 'grays.600',
401-
borderRadius: 'medium',
402-
overflow: 'hidden',
403-
})}
404-
>
405-
<SkeletonText css={{ width: '100%', height: 120, borderRadius: 0 }} />
406-
<Stack direction="vertical" gap={2} marginX={4}>
407-
<SkeletonText css={{ width: 120 }} />
408-
<SkeletonText css={{ width: 180 }} />
409-
</Stack>
410-
</Stack>
411-
);

packages/app/src/app/pages/Dashboard/Components/Sandbox/SandboxListItem.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
Input,
1010
ListAction,
1111
IconButton,
12-
SkeletonText,
1312
Tooltip,
1413
} from '@codesandbox/components';
1514
import css from '@styled-system/css';
@@ -198,24 +197,3 @@ export const SandboxListItem = ({
198197
</Element>
199198
</ListAction>
200199
);
201-
202-
export const SkeletonListItem = () => (
203-
<Stack
204-
paddingX={2}
205-
align="center"
206-
justify="space-between"
207-
css={css({
208-
height: 64,
209-
paddingX: 2,
210-
borderBottom: '1px solid',
211-
borderBottomColor: 'grays.600',
212-
})}
213-
>
214-
<Stack align="center" gap={4}>
215-
<SkeletonText css={{ height: 32, width: 32 }} />
216-
<SkeletonText css={{ width: 120 }} />
217-
</Stack>
218-
<SkeletonText css={{ width: 120 }} />
219-
<SkeletonText css={{ width: 120 }} />
220-
</Stack>
221-
);

packages/app/src/app/pages/Dashboard/Components/Sandbox/index.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import track, {
1212
} from '@codesandbox/common/lib/utils/analytics';
1313
import { Icon } from '@codesandbox/components';
1414
import { formatNumber } from '@codesandbox/components/lib/components/Stats';
15-
import { SandboxCard, SkeletonCard } from './SandboxCard';
16-
import { SandboxListItem, SkeletonListItem } from './SandboxListItem';
15+
import { SandboxCard } from './SandboxCard';
16+
import { SandboxListItem } from './SandboxListItem';
1717
import { getTemplateIcon } from './TemplateIcon';
1818
import { useSelection } from '../Selection';
1919
import { DashboardSandbox, DashboardTemplate, PageTypes } from '../../types';
@@ -337,18 +337,3 @@ const GenericSandbox = ({ isScrolling, item, page }: GenericSandboxProps) => {
337337
};
338338

339339
export const Sandbox = GenericSandbox;
340-
341-
export const SkeletonSandbox = () => {
342-
const { dashboard } = useAppState();
343-
344-
const location = useLocation();
345-
346-
let viewMode;
347-
if (location.pathname.includes('archive')) viewMode = 'list';
348-
else viewMode = dashboard.viewMode;
349-
350-
if (viewMode === 'list') {
351-
return <SkeletonListItem />;
352-
}
353-
return <SkeletonCard />;
354-
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from 'react';
2+
import css from '@styled-system/css';
3+
4+
import { SkeletonText, Stack } from '@codesandbox/components';
5+
import { ViewMode } from '../../types';
6+
7+
const DefaultSkeletonCard = () => (
8+
<Stack
9+
direction="vertical"
10+
gap={4}
11+
css={css({
12+
width: '100%',
13+
height: 240,
14+
border: '1px solid',
15+
borderColor: 'grays.600',
16+
borderRadius: 'medium',
17+
overflow: 'hidden',
18+
})}
19+
>
20+
<SkeletonText css={{ width: '100%', height: 120, borderRadius: 0 }} />
21+
<Stack direction="vertical" gap={2} marginX={4}>
22+
<SkeletonText css={{ width: 120 }} />
23+
<SkeletonText css={{ width: 180 }} />
24+
</Stack>
25+
</Stack>
26+
);
27+
28+
const DefaultSkeletonListItem = () => (
29+
<Stack
30+
paddingX={2}
31+
align="center"
32+
justify="space-between"
33+
css={css({
34+
height: 64,
35+
paddingX: 2,
36+
borderBottom: '1px solid',
37+
borderBottomColor: 'grays.600',
38+
})}
39+
>
40+
<Stack align="center" gap={4}>
41+
<SkeletonText css={{ height: 32, width: 32 }} />
42+
<SkeletonText css={{ width: 120 }} />
43+
</Stack>
44+
<SkeletonText css={{ width: 120 }} />
45+
<SkeletonText css={{ width: 120 }} />
46+
</Stack>
47+
);
48+
49+
export const DefaultSkeleton: React.FC<{ viewMode: ViewMode }> = ({
50+
viewMode,
51+
}) => {
52+
return {
53+
list: <DefaultSkeletonListItem />,
54+
grid: <DefaultSkeletonCard />,
55+
}[viewMode];
56+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
import css from '@styled-system/css';
3+
4+
import { Column, Grid, SkeletonText, Stack } from '@codesandbox/components';
5+
import { ViewMode } from '../../types';
6+
7+
export const SolidCardSkeleton: React.FC = () => (
8+
<Stack
9+
direction="vertical"
10+
gap={4}
11+
css={css({
12+
width: '100%',
13+
height: 240,
14+
border: '1px solid',
15+
borderColor: 'grays.600',
16+
borderRadius: '4px',
17+
overflow: 'hidden',
18+
})}
19+
>
20+
<SkeletonText css={{ width: '100%', height: '100%' }} />
21+
</Stack>
22+
);
23+
24+
export const SolidListItemSkeleton: React.FC = () => (
25+
<Stack>
26+
<Grid css={{ width: 'calc(100% - 26px - 8px)' }}>
27+
<Column
28+
span={[12, 5, 5]}
29+
css={{
30+
display: 'block',
31+
overflow: 'hidden',
32+
paddingBottom: 4,
33+
paddingTop: 4,
34+
}}
35+
>
36+
<Stack gap={4} align="center" marginLeft={2}>
37+
<SkeletonText
38+
css={css({
39+
width: '16px',
40+
})}
41+
/>
42+
<SkeletonText />
43+
</Stack>
44+
</Column>
45+
<Column span={[0, 4, 4]} as={Stack} align="center">
46+
<SkeletonText />
47+
</Column>
48+
</Grid>
49+
</Stack>
50+
);
51+
52+
export const SolidSkeleton: React.FC<{ viewMode: ViewMode }> = ({
53+
viewMode,
54+
}) => {
55+
return {
56+
list: <SolidListItemSkeleton />,
57+
grid: <SolidCardSkeleton />,
58+
}[viewMode];
59+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { DefaultSkeleton } from './DefaultSkeleton';
2+
export { SolidSkeleton } from './SolidSkeleton';

packages/app/src/app/pages/Dashboard/Components/Repo/RepoCard.tsx renamed to packages/app/src/app/pages/Dashboard/Components/SyncedSandbox/SyncedSandboxCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Stack, Text, Icon } from '@codesandbox/components';
33
import css from '@styled-system/css';
44
import { noop } from 'overmind';
55

6-
export const RepoCard = ({
6+
export const SyncedSandboxCard = ({
77
name,
88
path,
99
// interactions

packages/app/src/app/pages/Dashboard/Components/Repo/RepoListItem.tsx renamed to packages/app/src/app/pages/Dashboard/Components/SyncedSandbox/SyncedSandboxListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { noop } from 'overmind';
1111
import css from '@styled-system/css';
1212

13-
export const RepoListItem = ({
13+
export const SyncedSandboxListItem = ({
1414
name,
1515
path,
1616
// interactions

packages/app/src/app/pages/Dashboard/Components/Repo/index.tsx renamed to packages/app/src/app/pages/Dashboard/Components/SyncedSandbox/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import React from 'react';
22
import { useHistory } from 'react-router-dom';
33
import { useAppState } from 'app/overmind';
4-
import { RepoCard } from './RepoCard';
5-
import { RepoListItem } from './RepoListItem';
4+
import { SyncedSandboxCard } from './SyncedSandboxCard';
5+
import { SyncedSandboxListItem } from './SyncedSandboxListItem';
66
import { useSelection } from '../Selection';
77
import { DashboardRepo } from '../../types';
88

9-
export const Repo = ({ name = '', path = null, ...props }: DashboardRepo) => {
9+
export const SyncedSandbox = ({
10+
name = '',
11+
path = null,
12+
...props
13+
}: DashboardRepo) => {
1014
const { dashboard } = useAppState();
1115

12-
const Component = dashboard.viewMode === 'list' ? RepoListItem : RepoCard;
16+
const Component =
17+
dashboard.viewMode === 'list' ? SyncedSandboxListItem : SyncedSandboxCard;
1318

1419
// interactions
1520
const {

0 commit comments

Comments
 (0)