Skip to content

Commit 9b3da04

Browse files
committed
Extract Environment
1 parent f793f0d commit 9b3da04

File tree

4 files changed

+61
-49
lines changed

4 files changed

+61
-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: 3 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';
@@ -43,13 +32,11 @@ export const Project: FunctionComponent<Props> = ({ editable = false }) => {
4332
forkedTemplateSandbox,
4433
git,
4534
team,
46-
template,
4735
},
4836
},
4937
isPatron,
5038
},
5139
} = useOvermind();
52-
const { url } = getTemplateDefinition(template);
5340

5441
return (
5542
<Container>
@@ -83,31 +70,7 @@ export const Project: FunctionComponent<Props> = ({ editable = false }) => {
8370

8471
{(forkedFromSandbox || forkedTemplateSandbox) && <ForkedFrom />}
8572

86-
<Item>
87-
<PropertyName>
88-
Environment{' '}
89-
<Tooltip
90-
boundary="viewport"
91-
content={
92-
<>
93-
The environment determines how a sandbox is executed, you can
94-
find more info{' '}
95-
<a href="/docs/environment" target="_blank">
96-
here
97-
</a>
98-
.
99-
</>
100-
}
101-
interactive
102-
>
103-
<Icon />
104-
</Tooltip>
105-
</PropertyName>
106-
107-
<PropertyValue>
108-
<BundlerLink href={url}>{template}</BundlerLink>
109-
</PropertyValue>
110-
</Item>
73+
<Environment />
11174
</Group>
11275

11376
{editable && <SandboxConfig />}

0 commit comments

Comments
 (0)