Skip to content

Commit a2c5b24

Browse files
authored
add deleted skeleton (#3957)
1 parent 2ec8a5e commit a2c5b24

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

packages/app/src/app/pages/NewDashboard/Content/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import { Route, Switch, Redirect, withRouter } from 'react-router-dom';
1111
import { Element } from '@codesandbox/components';
1212
import { StartSandboxes } from './routes/StartSandboxes';
1313
import { Templates } from './routes/Templates';
14+
import { Deleted } from './routes/Deleted';
1415

1516
const ContentComponent = () => (
1617
<Element style={{ width: 960, margin: '40px auto' }}>
1718
<Switch>
1819
<Route path="/new-dashboard/start" component={StartSandboxes} />
1920
<Route path="/new-dashboard/templates" component={Templates} />
21+
<Route path="/new-dashboard/deleted" component={Deleted} />
2022
{/* <Route path="/dashboard/trash" component={DeletedSandboxes} />
2123
<Route path="/dashboard/templates" exact component={Templates} />
2224
<Route path="/dashboard/sandboxes/:path*" component={PathedSandboxes} />
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from 'react';
2+
import { Element, Text } from '@codesandbox/components';
3+
import { useQuery } from '@apollo/react-hooks';
4+
5+
import isSameWeek from 'date-fns/isSameWeek';
6+
import {
7+
DeletedSandboxesQueryVariables,
8+
DeletedSandboxesQuery,
9+
} from 'app/graphql/types';
10+
import { SandboxCard } from '../../../Components/SandboxCard';
11+
import { DELETED_SANDBOXES_CONTENT_QUERY } from '../../../queries';
12+
13+
export const Deleted = () => {
14+
const { data, error, loading } = useQuery<
15+
DeletedSandboxesQuery,
16+
DeletedSandboxesQueryVariables
17+
>(DELETED_SANDBOXES_CONTENT_QUERY, {
18+
fetchPolicy: 'cache-and-network',
19+
});
20+
21+
if (error) {
22+
return <Text>Error</Text>;
23+
}
24+
25+
if (loading) {
26+
return <Text>loading</Text>;
27+
}
28+
29+
const sandboxes = data && data.me && data.me.sandboxes;
30+
const orderedSandboxes = sandboxes.reduce(
31+
(accumulator, currentValue) => {
32+
if (isSameWeek(new Date(currentValue.removedAt), new Date())) {
33+
accumulator.week.push(currentValue);
34+
35+
return accumulator;
36+
}
37+
38+
accumulator.older.push(currentValue);
39+
40+
return accumulator;
41+
},
42+
{
43+
week: [],
44+
older: [],
45+
}
46+
);
47+
48+
return (
49+
<Element>
50+
<Text marginBottom={2} block>
51+
Recently Deleted
52+
</Text>
53+
<Text variant="muted" block marginBottom={11}>
54+
Sandboxes, Templates and Folders are permanently deleted after 30 days{' '}
55+
</Text>
56+
{orderedSandboxes.week.length && (
57+
<Element marginBottom={14}>
58+
<Text marginBottom={6} block>
59+
Archived this week
60+
</Text>
61+
{orderedSandboxes.week.map(sandbox => (
62+
<SandboxCard sandbox={sandbox} key={sandbox.id} />
63+
))}
64+
</Element>
65+
)}
66+
{orderedSandboxes.older.length && (
67+
<>
68+
<Text marginBottom={6} block>
69+
Archived Earlier
70+
</Text>
71+
{orderedSandboxes.older.map(sandbox => (
72+
<SandboxCard sandbox={sandbox} key={sandbox.id} />
73+
))}
74+
</>
75+
)}
76+
</Element>
77+
);
78+
};

packages/components/src/design-language/theme.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const theme = {
1919
// 9 - 36
2020
// 10 - 40
2121
// 11 - 44
22-
space: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],
23-
sizes: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],
22+
space: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],
23+
sizes: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],
2424

2525
// transition speeds in ms
2626
speeds: [0, '75ms', '100ms', '150ms', '200ms', '300ms', '500ms'],

0 commit comments

Comments
 (0)