Skip to content

Commit 96b1cbe

Browse files
committed
🔨 Switch GitHub to use useOvermind
1 parent 3903655 commit 96b1cbe

File tree

3 files changed

+32
-136
lines changed

3 files changed

+32
-136
lines changed

‎packages/app/src/app/pages/GitHub/elements.js‎ renamed to ‎packages/app/src/app/pages/GitHub/elements.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import styled from 'styled-components';
2-
import Input from '@codesandbox/common/lib/components/Input';
31
import Centered from '@codesandbox/common/lib/components/flex/Centered';
2+
import InputBase from '@codesandbox/common/lib/components/Input';
3+
import styled, { css } from 'styled-components';
44

55
export const Container = styled.div`
66
height: 100%;
@@ -10,7 +10,7 @@ export const Container = styled.div`
1010

1111
export const Content = styled(Centered)`
1212
max-width: 50em;
13-
margin: auto;
13+
margin: 5rem auto auto;
1414
`;
1515

1616
export const Wrapper = styled.div`
@@ -28,12 +28,14 @@ export const Description = styled.div`
2828
margin-bottom: 1rem;
2929
`;
3030

31-
export const StyledInput = styled(Input)`
31+
export const Input = styled(InputBase)`
3232
font-size: 1.25rem;
3333
margin-bottom: 2rem;
3434
`;
3535

3636
export const ErrorMessage = styled.div`
37-
color: ${props => props.theme.red};
38-
margin-bottom: 2rem;
37+
${({ theme }) => css`
38+
color: ${theme.red};
39+
margin-bottom: 2rem;
40+
`};
3941
`;

‎packages/app/src/app/pages/GitHub/index.tsx‎

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
1-
import React, { useCallback, useEffect, useState } from 'react';
21
import { Button } from '@codesandbox/common/lib/components/Button';
32
import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth';
43
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
54
import {
65
gitHubToSandboxUrl,
7-
protocolAndHost,
86
gitHubRepoPattern,
7+
protocolAndHost,
98
} from '@codesandbox/common/lib/utils/url-generator';
10-
import { useOvermind } from 'app/overmind';
11-
import { Title } from 'app/components/Title';
9+
import React, {
10+
ChangeEvent,
11+
FunctionComponent,
12+
useEffect,
13+
useState,
14+
} from 'react';
15+
1216
import { SubTitle } from 'app/components/SubTitle';
17+
import { Title } from 'app/components/Title';
18+
import { useOvermind } from 'app/overmind';
1319
import { Navigation } from 'app/pages/common/Navigation';
20+
1421
import {
1522
Container,
1623
Content,
1724
Description,
1825
ErrorMessage,
26+
Input,
1927
Label,
20-
StyledInput,
2128
} from './elements';
2229

23-
const getFullGitHubUrl = url =>
30+
const getFullGitHubUrl = (url: string) =>
2431
`${protocolAndHost()}${gitHubToSandboxUrl(url)}`;
2532

26-
export const GitHub = () => {
27-
const [error, setError] = useState(null);
28-
const [transformedUrl, setTransformedUrl] = useState('');
29-
const [url, setUrl] = useState('');
30-
33+
export const GitHub: FunctionComponent = () => {
3134
const {
3235
actions: { githubPageMounted },
3336
} = useOvermind();
37+
const [error, setError] = useState(null);
38+
const [transformedUrl, setTransformedUrl] = useState('');
39+
const [url, setUrl] = useState('');
3440

3541
useEffect(() => {
3642
githubPageMounted();
3743
}, [githubPageMounted]);
3844

39-
const updateUrl = useCallback(({ target: { value: newUrl } }) => {
45+
const updateUrl = ({
46+
target: { value: newUrl },
47+
}: ChangeEvent<HTMLInputElement>) => {
4048
if (!newUrl) {
4149
setError(null);
4250
setTransformedUrl('');
@@ -50,21 +58,15 @@ export const GitHub = () => {
5058
setTransformedUrl(getFullGitHubUrl(newUrl.trim()));
5159
setUrl(newUrl);
5260
}
53-
}, []);
61+
};
5462

5563
return (
5664
<MaxWidth>
5765
<Margin vertical={1.5} horizontal={1.5}>
5866
<Container>
5967
<Navigation title="GitHub Import" />
6068

61-
<Content
62-
vertical
63-
horizontal
64-
css={`
65-
margin-top: 5rem;
66-
`}
67-
>
69+
<Content horizontal vertical>
6870
<Description>
6971
<Title>Import from GitHub</Title>
7072

@@ -87,7 +89,7 @@ export const GitHub = () => {
8789
URL to GitHub Repository (supports branches and paths too)
8890
</Label>
8991

90-
<StyledInput
92+
<Input
9193
name="githuburl"
9294
onChange={updateUrl}
9395
placeholder="Insert GitHub URL..."
@@ -98,7 +100,7 @@ export const GitHub = () => {
98100

99101
<Label htmlFor="sandboxurl">Converted Sandbox URL</Label>
100102

101-
<StyledInput
103+
<Input
102104
name="sandboxurl"
103105
placeholder="The Sandbox URL"
104106
value={transformedUrl}

‎packages/app/src/app/pages/GitHub/main.js‎

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)