Skip to content

Commit 9d07172

Browse files
committed
Extract Environment
1 parent e54a0c6 commit 9d07172

File tree

4 files changed

+62
-49
lines changed

4 files changed

+62
-49
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import styled, { css } from 'styled-components';
2+
3+
export const BundlerLink = styled.a.attrs({
4+
target: '_blank',
5+
rel: 'noreferrer noopener',
6+
})`
7+
${({ theme }) => css`
8+
color: ${theme.templateColor} !important;
9+
`}
10+
`;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
2+
import getTemplateDefinition from '@codesandbox/common/lib/templates';
3+
import React, { FunctionComponent } from 'react';
4+
5+
import { useOvermind } from 'app/overmind';
6+
7+
import { Icon, Item, PropertyName, PropertyValue } from '../elements';
8+
9+
import { BundlerLink } from './elements';
10+
11+
export const Environment: FunctionComponent = () => {
12+
const {
13+
state: {
14+
editor: {
15+
currentSandbox: { template },
16+
},
17+
},
18+
} = useOvermind();
19+
const { url } = getTemplateDefinition(template);
20+
21+
return (
22+
<Item>
23+
<PropertyName>
24+
Environment{' '}
25+
<Tooltip
26+
boundary="viewport"
27+
content={
28+
<>
29+
The environment determines how a sandbox is executed, you can find
30+
more info{' '}
31+
<a href="/docs/environment" target="_blank">
32+
here
33+
</a>
34+
.
35+
</>
36+
}
37+
interactive
38+
>
39+
<Icon />
40+
</Tooltip>
41+
</PropertyName>
42+
43+
<PropertyValue>
44+
<BundlerLink href={url}>{template}</BundlerLink>
45+
</PropertyValue>
46+
</Item>
47+
);
48+
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/elements.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ export const Icon = styled(Question)`
8181
cursor: pointer;
8282
`;
8383

84-
export const BundlerLink = styled.a.attrs({
85-
target: '_blank',
86-
rel: 'noreferrer noopener',
87-
})`
88-
${({ theme }) => css`
89-
color: ${theme.templateColor} !important;
90-
`}
91-
`;
92-
9384
export const Explanation = styled.span`
9485
${({ theme }) => css`
9586
display: block;

packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/index.tsx

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
2-
import getTemplateDefinition from '@codesandbox/common/lib/templates';
31
import React, { FunctionComponent } from 'react';
42

53
import { useOvermind } from 'app/overmind';
@@ -8,17 +6,8 @@ import { Stats } from 'app/pages/common/Stats';
86
// import { Alias } from './Alias';
97
import { Author } from './Author';
108
import { Description } from './Description';
11-
import {
12-
BasicInfo,
13-
BundlerLink,
14-
Container,
15-
Group,
16-
Icon,
17-
Item,
18-
PropertyName,
19-
PropertyValue,
20-
StatsContainer,
21-
} from './elements';
9+
import { BasicInfo, Container, Group, StatsContainer } from './elements';
10+
import { Environment } from './Environment';
2211
import { ForkedFrom } from './ForkedFrom';
2312
import { Frozen } from './Frozen';
2413
import { Git } from './Git';
@@ -37,12 +26,11 @@ export const Project: FunctionComponent<Props> = ({ editable = false }) => {
3726
state: {
3827
editor: {
3928
currentSandbox,
40-
currentSandbox: { author, forkedFromSandbox, git, team, template },
29+
currentSandbox: { author, forkedFromSandbox, git, team },
4130
},
4231
isPatron,
4332
},
4433
} = useOvermind();
45-
const { url } = getTemplateDefinition(template);
4634

4735
return (
4836
<Container>
@@ -76,31 +64,7 @@ export const Project: FunctionComponent<Props> = ({ editable = false }) => {
7664

7765
{forkedFromSandbox && <ForkedFrom />}
7866

79-
<Item>
80-
<PropertyName>
81-
Environment{' '}
82-
<Tooltip
83-
boundary="viewport"
84-
content={
85-
<>
86-
The environment determines how a sandbox is executed, you can
87-
find more info{' '}
88-
<a href="/docs/environment" target="_blank">
89-
here
90-
</a>
91-
.
92-
</>
93-
}
94-
interactive
95-
>
96-
<Icon />
97-
</Tooltip>
98-
</PropertyName>
99-
100-
<PropertyValue>
101-
<BundlerLink href={url}>{template}</BundlerLink>
102-
</PropertyValue>
103-
</Item>
67+
<Environment />
10468
</Group>
10569

10670
{editable && <SandboxConfig />}

0 commit comments

Comments
 (0)