|
1 | | -import React, { useEffect } from 'react'; |
2 | | -import { useOvermind } from 'app/overmind'; |
3 | 1 | import getTemplateDefinition from '@codesandbox/common/lib/templates'; |
4 | | -import { SignInButton } from 'app/pages/common/SignInButton'; |
| 2 | +import React, { FunctionComponent, useEffect } from 'react'; |
| 3 | + |
| 4 | +import { useOvermind } from 'app/overmind'; |
5 | 5 |
|
6 | 6 | import { Container, Heading, Explanation } from '../elements'; |
7 | 7 |
|
8 | | -export const ForkServerModal: React.FC = () => { |
| 8 | +import { NiceName as NiceNameBase, SignInButton } from './elements'; |
| 9 | + |
| 10 | +export const ForkServerModal: FunctionComponent = () => { |
9 | 11 | const { |
10 | | - state: { |
11 | | - isLoggedIn, |
12 | | - editor: { currentSandbox }, |
13 | | - }, |
14 | 12 | actions: { |
15 | | - modalClosed, |
16 | 13 | editor: { forkSandboxClicked }, |
| 14 | + modalClosed, |
| 15 | + }, |
| 16 | + state: { |
| 17 | + editor: { |
| 18 | + currentSandbox: { template }, |
| 19 | + }, |
| 20 | + isLoggedIn, |
17 | 21 | }, |
18 | 22 | } = useOvermind(); |
19 | 23 |
|
20 | 24 | useEffect(() => { |
21 | | - // Which means that the user signed in in the meantime with the intention to |
22 | | - // fork |
| 25 | + // Which means that the user signed in in the meantime with the intention to fork |
23 | 26 | if (isLoggedIn) { |
24 | 27 | forkSandboxClicked(); |
| 28 | + |
25 | 29 | modalClosed(); |
26 | 30 | } |
27 | 31 | }, [forkSandboxClicked, isLoggedIn, modalClosed]); |
28 | 32 |
|
29 | | - const templateDefinition = getTemplateDefinition(currentSandbox.template); |
30 | | - const niceName = ( |
31 | | - <span style={{ color: templateDefinition.color(), fontWeight: 500 }}> |
32 | | - {templateDefinition.niceName} |
33 | | - </span> |
| 33 | + const { color, niceName } = getTemplateDefinition(template); |
| 34 | + const NiceName: FunctionComponent = () => ( |
| 35 | + <NiceNameBase color={color()}>{niceName}</NiceNameBase> |
34 | 36 | ); |
35 | 37 |
|
36 | 38 | return ( |
37 | 39 | <Container> |
38 | | - <Heading>Fork {niceName} Sandbox</Heading> |
| 40 | + <Heading> |
| 41 | + Fork <NiceName /> Sandbox |
| 42 | + </Heading> |
| 43 | + |
39 | 44 | <Explanation> |
40 | | - We execute {niceName} sandboxes in a server container. This is still in |
41 | | - beta, so we require you to sign in before you can fork a {niceName}{' '} |
| 45 | + We execute <NiceName /> sandboxes in a server container. This is still |
| 46 | + in beta, so we require you to sign in before you can fork a <NiceName />{' '} |
42 | 47 | sandbox. |
43 | 48 | </Explanation> |
44 | 49 |
|
45 | | - <SignInButton style={{ marginTop: 12 }} /> |
| 50 | + <SignInButton /> |
46 | 51 | </Container> |
47 | 52 | ); |
48 | 53 | }; |
0 commit comments