1- import React , { useCallback , useEffect , useState } from 'react' ;
21import { Button } from '@codesandbox/common/lib/components/Button' ;
32import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth' ;
43import Margin from '@codesandbox/common/lib/components/spacing/Margin' ;
54import {
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+
1216import { SubTitle } from 'app/components/SubTitle' ;
17+ import { Title } from 'app/components/Title' ;
18+ import { useOvermind } from 'app/overmind' ;
1319import { Navigation } from 'app/pages/common/Navigation' ;
20+
1421import {
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 }
0 commit comments