File tree Expand file tree Collapse file tree 5 files changed +73
-9
lines changed
app/src/app/pages/Sandbox/Editor Expand file tree Collapse file tree 5 files changed +73
-9
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import SettingsIcon from 'react-icons/lib/md/settings';
88import ShareIcon from 'react-icons/lib/md/share' ;
99import SaveIcon from 'react-icons/lib/md/save' ;
1010import { Button } from '@codesandbox/common/lib/components/Button' ;
11+ import ProgressButton from '@codesandbox/common/lib/components/ProgressButton' ;
1112import SignInButton from 'app/pages/common/SignInButton' ;
1213
1314import { saveAllModules } from 'app/store/modules/editor/utils' ;
@@ -75,21 +76,20 @@ const ForkButton = ({
7576 isForking,
7677 style,
7778} : ForkButtonProps ) => (
78- < Button
79+ < ProgressButton
7980 onClick = { ( ) => {
8081 signals . editor . forkSandboxClicked ( ) ;
8182 } }
8283 style = { style }
8384 secondary = { secondary }
84- disabled = { isForking }
8585 loading = { isForking }
8686 small
8787 >
8888 < >
8989 < Fork style = { { marginRight : '.5rem' } } />
9090 { isForking ? 'Forking...' : 'Fork' }
9191 </ >
92- </ Button >
92+ </ ProgressButton >
9393) ;
9494
9595const PickButton = ( { store, signals, secondary, style } : ButtonProps ) => {
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { inject , observer } from 'mobx-react' ;
33
4- import { Button } from '@codesandbox/common/lib/components/Button ' ;
4+ import ProgressButton from '@codesandbox/common/lib/components/ProgressButton ' ;
55import SignInButton from 'app/pages/common/SignInButton' ;
66import Margin from '@codesandbox/common/lib/components/spacing/Margin' ;
77import track from '@codesandbox/common/lib/utils/analytics' ;
@@ -35,15 +35,14 @@ class More extends React.Component<Props> {
3535 < Description > { message } </ Description >
3636 < Margin margin = { 1 } >
3737 { ! owned ? (
38- < Button
38+ < ProgressButton
3939 small
4040 block
41- disabled = { isForkingSandbox }
4241 loading = { isForkingSandbox }
4342 onClick = { this . forkSandbox }
4443 >
4544 { isForkingSandbox ? 'Forking Sandbox...' : 'Fork Sandbox' }
46- </ Button >
45+ </ ProgressButton >
4746 ) : (
4847 < SignInButton block />
4948 ) }
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { LinkButton , AButton , Button } from './elements' ;
33
4- type Props = {
4+ export type Props = {
55 to ?: string ;
66 href ?: string ;
77 small ?: boolean ;
@@ -11,7 +11,6 @@ type Props = {
1111 children ?: React . ReactElement | string ;
1212 disabled ?: boolean ;
1313 type ?: 'button' | 'reset' | 'submit' ;
14- loading ?: boolean ;
1514 secondary ?: boolean ;
1615} ;
1716
Original file line number Diff line number Diff line change 1+ import styled , { css , keyframes } from 'styled-components' ;
2+ import theme from '../../theme' ;
3+
4+ const loaderAnimation = keyframes `
5+ 0% { background-color: ${ theme . secondary ( ) } ; }
6+ 50%, 100% { background-color: ${ theme . secondary . lighten ( 0.5 ) ( ) } ; }
7+ ` ;
8+
9+ export const Wrapper = styled . div `
10+ position: relative;
11+ ` ;
12+
13+ const circle = css `
14+ width: 10px;
15+ height: 10px;
16+ border-radius: 50%;
17+ background: ${ theme . secondary ( ) } ;
18+ opacity: 0.5;
19+ animation: ${ loaderAnimation } 1s infinite linear alternate;
20+ ` ;
21+
22+ export const Loader = styled . div `
23+ position: absolute;
24+ top: 50%;
25+ left: 50%;
26+ transform: translate(-50%, -50%);
27+ ${ circle } animation-delay: 0.5s;
28+
29+ &:before {
30+ content: ' ';
31+ position: absolute;
32+ left: -15px;
33+ ${ circle } ;
34+ animation-delay: 0s;
35+ }
36+
37+ &:after {
38+ content: ' ';
39+ position: absolute;
40+ left: 15px;
41+ ${ circle } ;
42+ animation-delay: 1s;
43+ }
44+ ` ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Button , Props as ButtonProps } from '../Button' ;
3+ import { Wrapper , Loader } from './elements' ;
4+
5+ type Props = ButtonProps & {
6+ loading ?: boolean ;
7+ } ;
8+
9+ function ProgressButton ( {
10+ loading = false ,
11+ disabled = false ,
12+ ...props
13+ } : Props ) {
14+ return (
15+ < Wrapper >
16+ < Button disabled = { disabled || loading } { ...props } />
17+ { loading && < Loader /> }
18+ </ Wrapper >
19+ ) ;
20+ }
21+
22+ export default ProgressButton ;
You can’t perform that action at this time.
0 commit comments