Skip to content

Commit 78f8464

Browse files
authored
Sidebar - fix position of delete button (codesandbox#3474)
1 parent d325b72 commit 78f8464

File tree

3 files changed

+55
-38
lines changed

3 files changed

+55
-38
lines changed
Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React, { MouseEvent } from 'react';
22
import getTemplateDefinition from '@codesandbox/common/lib/templates';
33
import { useOvermind } from 'app/overmind';
4-
import { css } from '@styled-system/css';
5-
import { Button, Element, Stack } from '@codesandbox/components';
4+
import { Button, Element } from '@codesandbox/components';
65

76
export const Config = () => {
87
const {
98
actions: {
109
modalOpened,
11-
workspace: { addedTemplate, deleteTemplate },
10+
workspace: { addedTemplate },
1211
},
1312
state: {
1413
user,
@@ -21,16 +20,6 @@ export const Config = () => {
2120
},
2221
} = useOvermind();
2322

24-
const onDelete = (event: MouseEvent<HTMLButtonElement>) => {
25-
event.preventDefault();
26-
27-
if (customTemplate) {
28-
deleteTemplate();
29-
} else {
30-
modalOpened({ modal: 'deleteSandbox' });
31-
}
32-
};
33-
3423
const onCreateTemplate = (event: MouseEvent<HTMLButtonElement>) => {
3524
event.preventDefault();
3625

@@ -60,26 +49,6 @@ export const Config = () => {
6049
</Button>
6150
</Element>
6251
)}
63-
64-
<Stack
65-
justify="center"
66-
css={css({
67-
bottom: 3,
68-
position: 'absolute',
69-
width: '100%',
70-
})}
71-
>
72-
<Button
73-
// @ts-ignore
74-
onClick={onDelete}
75-
variant="link"
76-
css={css({
77-
':hover,:focus': { color: 'dangerButton.background' },
78-
})}
79-
>
80-
{`Delete ${customTemplate ? `Template` : `Sandbox`}`}
81-
</Button>
82-
</Stack>
8352
</>
8453
);
8554
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, { MouseEvent } from 'react';
2+
import { useOvermind } from 'app/overmind';
3+
import { css } from '@styled-system/css';
4+
import { Button, Stack } from '@codesandbox/components';
5+
6+
export const Delete = () => {
7+
const {
8+
actions: {
9+
modalOpened,
10+
workspace: { deleteTemplate },
11+
},
12+
state: {
13+
editor: {
14+
currentSandbox: { customTemplate },
15+
},
16+
},
17+
} = useOvermind();
18+
19+
const onDelete = (event: MouseEvent<HTMLButtonElement>) => {
20+
event.preventDefault();
21+
22+
if (customTemplate) {
23+
deleteTemplate();
24+
} else {
25+
modalOpened({ modal: 'deleteSandbox' });
26+
}
27+
};
28+
29+
return (
30+
<Stack justify="center" marginBottom={3}>
31+
<Button
32+
// @ts-ignore
33+
onClick={onDelete}
34+
variant="link"
35+
css={css({
36+
':hover,:focus': { color: 'errorForeground' },
37+
})}
38+
>
39+
{`Delete ${customTemplate ? `Template` : `Sandbox`}`}
40+
</Button>
41+
</Stack>
42+
);
43+
};
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import React from 'react';
2+
import { Stack } from '@codesandbox/components';
23
import { Summary } from './Summary';
34
import { Privacy } from './Privacy';
45
import { Config } from './Config';
6+
import { Delete } from './Delete';
57

68
export const ProjectInfo = () => (
7-
<>
8-
<Summary />
9-
<Privacy />
10-
<Config />
11-
</>
9+
<Stack direction="vertical" justify="space-between" css={{ height: '100%' }}>
10+
<div>
11+
<Summary />
12+
<Privacy />
13+
<Config />
14+
</div>
15+
<Delete />
16+
</Stack>
1217
);

0 commit comments

Comments
 (0)