Skip to content

Commit ba388cc

Browse files
author
Ives van Hoorne
committed
Update embed url to go to relevant git sandbox
1 parent 4df08dc commit ba388cc

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

src/embed/components/EditorLink.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22
import styled from 'styled-components';
33
import Logo from 'app/components/Logo';
44

5+
import { sandboxUrl } from 'app/utils/url-generator';
6+
57
type Props = {
68
id: string,
79
small: boolean,
@@ -24,16 +26,13 @@ const Text = styled.span`
2426
}
2527
`;
2628

27-
export default ({ id, small }: Props) => (
29+
export default ({ sandbox, small }: Props) =>
2830
<EditText
2931
small={small}
3032
target="_blank"
3133
rel="noopener noreferrer"
32-
href={`/s/${id}`}
34+
href={sandboxUrl(sandbox) + document.location.search}
3335
>
34-
<Text small={small}>
35-
Edit on CodeSandbox
36-
</Text>
36+
<Text small={small}>Edit on CodeSandbox</Text>
3737
<Logo />
38-
</EditText>
39-
);
38+
</EditText>;

src/embed/components/EditorLink.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import EditorLink from './EditorLink';
44

55
describe('EditorLink', () => {
66
it('renders', () => {
7-
testRender(<EditorLink />);
7+
testRender(<EditorLink sandbox={{}} />);
88
});
99
});

src/embed/components/Header.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ const RightAligned = styled.div`
3737
justify-content: center;
3838
`;
3939

40-
const Title = styled.div`
41-
@media (max-width: 450px) {
42-
display: none;
43-
}
44-
`;
40+
const Title = styled.div`@media (max-width: 450px) {display: none;}`;
4541

4642
type Props = {
4743
sandbox: Sandbox,
@@ -69,7 +65,9 @@ export default class Header extends React.PureComponent {
6965
return (
7066
<Container>
7167
<MenuIcon onClick={toggleSidebar} />
72-
<Title>{sandbox.title || sandbox.id}</Title>
68+
<Title>
69+
{sandbox.title || sandbox.id}
70+
</Title>
7371
<ModeIcons
7472
showEditor={showEditor}
7573
showPreview={showPreview}
@@ -78,7 +76,7 @@ export default class Header extends React.PureComponent {
7876
setMixedView={setMixedView}
7977
/>
8078
<RightAligned>
81-
<EditorLink small id={sandbox.id} />
79+
<EditorLink small sandbox={sandbox} />
8280
</RightAligned>
8381
</Container>
8482
);

src/embed/components/Sidebar.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import type { Sandbox } from 'common/types';
55

66
import EditorLink from './EditorLink';
77
import Files from './Files';
8-
import EntryContainer
9-
from '../../app/pages/Sandbox/Editor/Workspace/EntryContainer';
8+
import EntryContainer from '../../app/pages/Sandbox/Editor/Workspace/EntryContainer';
109
import Padding from '../../app/components/spacing/Padding';
1110

1211
const Container = styled.div`
@@ -44,7 +43,8 @@ const Description = styled.p`
4443

4544
const Item = styled.div`
4645
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
47-
${({ hover, theme }) => hover && `&:hover { background-color: ${theme.background.darken(0.3)()};}`}
46+
${({ hover, theme }) =>
47+
hover && `&:hover { background-color: ${theme.background.darken(0.3)()};}`};
4848
`;
4949

5050
const Version = styled.div`
@@ -82,13 +82,20 @@ type Props = {
8282
currentModule: string,
8383
};
8484

85-
export default ({ sandbox, setCurrentModule, currentModule }: Props) => (
85+
export default ({ sandbox, setCurrentModule, currentModule }: Props) =>
8686
<Container>
8787
<Item>
88-
<Title>{sandbox.title || sandbox.id}</Title>
88+
<Title>
89+
{sandbox.title || sandbox.id}
90+
</Title>
8991
{sandbox.author &&
90-
<Author>Made by <strong>{sandbox.author.username}</strong></Author>}
91-
{sandbox.description && <Description>{sandbox.description}</Description>}
92+
<Author>
93+
Made by <strong>{sandbox.author.username}</strong>
94+
</Author>}
95+
{sandbox.description &&
96+
<Description>
97+
{sandbox.description}
98+
</Description>}
9299
</Item>
93100

94101
<Item>
@@ -106,27 +113,28 @@ export default ({ sandbox, setCurrentModule, currentModule }: Props) => (
106113
<Title>Dependencies</Title>
107114

108115
<Subtitle>NPM Dependencies</Subtitle>
109-
{Object.keys(sandbox.npmDependencies).map(dep => (
116+
{Object.keys(sandbox.npmDependencies).map(dep =>
110117
<EntryContainer key={dep}>
111118
{dep}
112-
<Version>{sandbox.npmDependencies[dep]}</Version>
113-
</EntryContainer>
114-
))}
119+
<Version>
120+
{sandbox.npmDependencies[dep]}
121+
</Version>
122+
</EntryContainer>,
123+
)}
115124

116125
<Subtitle>External Resources</Subtitle>
117-
{sandbox.externalResources.map(dep => (
126+
{sandbox.externalResources.map(dep =>
118127
<EntryContainer key={dep}>
119128
<a href={dep} rel="nofollow noopener noreferrer" target="_blank">
120129
{getName(dep)}
121130
</a>
122-
</EntryContainer>
123-
))}
131+
</EntryContainer>,
132+
)}
124133
</Item>
125134

126135
<Item hover>
127136
<Padding margin={1}>
128-
<EditorLink id={sandbox.id} />
137+
<EditorLink sandbox={sandbox} />
129138
</Padding>
130139
</Item>
131-
</Container>
132-
);
140+
</Container>;

src/homepage/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ <h3>Example Projects</h3>
152152
<a href="/s/mZRjw05yp" class="project">
153153
Redux Form
154154
</a>
155-
<a href="/s/github/faceyspacey/redux-first-router-codesandbox" class="project">
155+
<a href="/s/github/faceyspacey/redux-first-router-codesandbox?module=rJHWLQms2rZ" class="project">
156156
Redux-First Router
157157
</a>
158158
<a href="/s/nZ26kGMD" class="project">

0 commit comments

Comments
 (0)