|
1 | | -import React from 'react'; |
| 1 | +import Centered from '@codesandbox/common/lib/components/flex/Centered'; |
| 2 | +import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth'; |
| 3 | +import Margin from '@codesandbox/common/lib/components/spacing/Margin'; |
| 4 | +import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator'; |
2 | 5 | import { inject } from 'mobx-react'; |
| 6 | +import React, { useEffect } from 'react'; |
3 | 7 |
|
4 | 8 | import Navigation from 'app/pages/common/Navigation'; |
5 | | - |
6 | | -import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth'; |
7 | | -import Centered from '@codesandbox/common/lib/components/flex/Centered'; |
8 | | -import Margin from '@codesandbox/common/lib/components/spacing/Margin'; |
9 | 9 | import history from 'app/utils/history'; |
10 | | -import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator'; |
11 | 10 |
|
12 | 11 | import NewSandboxModal from '../Dashboard/Content/CreateNewSandbox/Modal'; |
13 | 12 |
|
14 | | -class NewSandboxComponent extends React.PureComponent { |
15 | | - componentDidMount() { |
16 | | - this.props.signals.sandboxPageMounted(); |
17 | | - } |
18 | | - |
19 | | - createSandbox = template => { |
20 | | - history.push(sandboxUrl({ id: template.shortid })); |
21 | | - }; |
22 | | - |
23 | | - render() { |
24 | | - return ( |
25 | | - <MaxWidth> |
26 | | - <Margin style={{ height: '100%' }} vertical={1.5} horizontal={1.5}> |
27 | | - <Navigation title="New Sandbox" /> |
28 | | - |
29 | | - <Margin top={5}> |
30 | | - <Centered horizontal vertical> |
31 | | - <Margin style={{ maxWidth: '100%', width: 900 }} top={2}> |
32 | | - <NewSandboxModal |
33 | | - createSandbox={this.createSandbox} |
34 | | - width={950} |
35 | | - /> |
36 | | - </Margin> |
37 | | - </Centered> |
38 | | - </Margin> |
| 13 | +const createSandbox = template => { |
| 14 | + history.push(sandboxUrl({ id: template.shortid })); |
| 15 | +}; |
| 16 | + |
| 17 | +const NewSandbox = ({ signals: { sandboxPageMounted } }) => { |
| 18 | + useEffect(() => { |
| 19 | + sandboxPageMounted(); |
| 20 | + }, [sandboxPageMounted]); |
| 21 | + |
| 22 | + return ( |
| 23 | + <MaxWidth> |
| 24 | + <Margin horizontal={1.5} style={{ height: '100%' }} vertical={1.5}> |
| 25 | + <Navigation title="New Sandbox" /> |
| 26 | + |
| 27 | + <Margin top={5}> |
| 28 | + <Centered horizontal vertical> |
| 29 | + <Margin style={{ maxWidth: '100%', width: 900 }} top={2}> |
| 30 | + <NewSandboxModal createSandbox={createSandbox} width={950} /> |
| 31 | + </Margin> |
| 32 | + </Centered> |
39 | 33 | </Margin> |
40 | | - </MaxWidth> |
41 | | - ); |
42 | | - } |
43 | | -} |
| 34 | + </Margin> |
| 35 | + </MaxWidth> |
| 36 | + ); |
| 37 | +}; |
44 | 38 |
|
45 | | -export default inject('signals')(NewSandboxComponent); |
| 39 | +export default inject('signals')(NewSandbox); |
0 commit comments