Skip to content

Commit e54a0c6

Browse files
committed
Extract ForkedFrom
1 parent e83bd39 commit e54a0c6

File tree

4 files changed

+41
-21
lines changed

4 files changed

+41
-21
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Link as LinkBase } from 'react-router-dom';
2+
import styled, { css } from 'styled-components';
3+
4+
export const Link = styled(LinkBase)`
5+
${({ theme }) => css`
6+
color: ${theme.templateColor} !important;
7+
`}
8+
`;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
2+
import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator';
3+
import React, { FunctionComponent } from 'react';
4+
5+
import { useOvermind } from 'app/overmind';
6+
7+
import { Item, PropertyName, PropertyValue } from '../elements';
8+
9+
import { Link } from './elements';
10+
11+
export const ForkedFrom: FunctionComponent = () => {
12+
const {
13+
state: {
14+
editor: {
15+
currentSandbox: { forkedFromSandbox },
16+
},
17+
},
18+
} = useOvermind();
19+
20+
return (
21+
<Item>
22+
<PropertyName>Forked From</PropertyName>
23+
24+
<PropertyValue>
25+
<Link to={sandboxUrl(forkedFromSandbox)}>
26+
{getSandboxName(forkedFromSandbox)}
27+
</Link>
28+
</PropertyValue>
29+
</Item>
30+
);
31+
};

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Question from 'react-icons/lib/go/question';
22
import EditPenIcon from 'react-icons/lib/md/create';
3-
import { Link } from 'react-router-dom';
43
import styled, { css } from 'styled-components';
54

65
export const Container = styled.div`
@@ -82,12 +81,6 @@ export const Icon = styled(Question)`
8281
cursor: pointer;
8382
`;
8483

85-
export const TemplateStyledLink = styled(Link)`
86-
${({ theme }) => css`
87-
color: ${theme.templateColor} !important;
88-
`}
89-
`;
90-
9184
export const BundlerLink = styled.a.attrs({
9285
target: '_blank',
9386
rel: 'noreferrer noopener',

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
22
import getTemplateDefinition from '@codesandbox/common/lib/templates';
3-
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
4-
import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator';
53
import React, { FunctionComponent } from 'react';
64

75
import { useOvermind } from 'app/overmind';
@@ -20,8 +18,8 @@ import {
2018
PropertyName,
2119
PropertyValue,
2220
StatsContainer,
23-
TemplateStyledLink,
2421
} from './elements';
22+
import { ForkedFrom } from './ForkedFrom';
2523
import { Frozen } from './Frozen';
2624
import { Git } from './Git';
2725
import { Keywords } from './Keywords';
@@ -76,17 +74,7 @@ export const Project: FunctionComponent<Props> = ({ editable = false }) => {
7674

7775
{editable && <Frozen />}
7876

79-
{forkedFromSandbox && (
80-
<Item>
81-
<PropertyName>Forked From</PropertyName>
82-
83-
<PropertyValue>
84-
<TemplateStyledLink to={sandboxUrl(forkedFromSandbox)}>
85-
{getSandboxName(forkedFromSandbox)}
86-
</TemplateStyledLink>
87-
</PropertyValue>
88-
</Item>
89-
)}
77+
{forkedFromSandbox && <ForkedFrom />}
9078

9179
<Item>
9280
<PropertyName>

0 commit comments

Comments
 (0)