Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/app/src/app/pages/Sandbox/Editor/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SettingsIcon from 'react-icons/lib/md/settings';
import ShareIcon from 'react-icons/lib/md/share';
import SaveIcon from 'react-icons/lib/md/save';
import { Button } from '@codesandbox/common/lib/components/Button';
import ProgressButton from '@codesandbox/common/lib/components/ProgressButton';
import SignInButton from 'app/pages/common/SignInButton';

import { saveAllModules } from 'app/store/modules/editor/utils';
Expand Down Expand Up @@ -75,20 +76,20 @@ const ForkButton = ({
isForking,
style,
}: ForkButtonProps) => (
<Button
<ProgressButton
onClick={() => {
signals.editor.forkSandboxClicked();
}}
style={style}
secondary={secondary}
disabled={isForking}
loading={isForking}
small
>
<>
<Fork style={{ marginRight: '.5rem' }} />
{isForking ? 'Forking...' : 'Fork'}
</>
</Button>
</ProgressButton>
);

const PickButton = ({ store, signals, secondary, style }: ButtonProps) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { inject, observer } from 'mobx-react';

import { Button } from '@codesandbox/common/lib/components/Button';
import ProgressButton from '@codesandbox/common/lib/components/ProgressButton';
import SignInButton from 'app/pages/common/SignInButton';
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
import track from '@codesandbox/common/lib/utils/analytics';
Expand Down Expand Up @@ -35,14 +35,14 @@ class More extends React.Component<Props> {
<Description>{message}</Description>
<Margin margin={1}>
{!owned ? (
<Button
<ProgressButton
small
block
disabled={isForkingSandbox}
loading={isForkingSandbox}
onClick={this.forkSandbox}
>
{isForkingSandbox ? 'Forking Sandbox...' : 'Fork Sandbox'}
</Button>
</ProgressButton>
) : (
<SignInButton block />
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { LinkButton, AButton, Button } from './elements';

type Props = {
export type Props = {
to?: string;
href?: string;
small?: boolean;
Expand Down
44 changes: 44 additions & 0 deletions packages/common/src/components/ProgressButton/elements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import styled, { css, keyframes } from 'styled-components';
import theme from '../../theme';

const loaderAnimation = keyframes`
0% { background-color: ${theme.secondary()}; }
50%, 100% { background-color: ${theme.secondary.lighten(0.5)()}; }
`;

export const Wrapper = styled.div`
position: relative;
`;

const circle = css`
width: 8px;
height: 8px;
border-radius: 50%;
background: ${theme.secondary()};
opacity: 0.7;
animation: ${loaderAnimation} 1s infinite linear alternate;
`;

export const Loader = styled.div`
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
${circle} animation-delay: 0.5s;

&:before {
content: ' ';
position: absolute;
left: -12px;
${circle};
animation-delay: 0s;
}

&:after {
content: ' ';
position: absolute;
left: 12px;
${circle};
animation-delay: 1s;
}
`;
22 changes: 22 additions & 0 deletions packages/common/src/components/ProgressButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { Button, Props as ButtonProps } from '../Button';
import { Wrapper, Loader } from './elements';

type Props = ButtonProps & {
loading?: boolean;
};

function ProgressButton({
loading = false,
disabled = false,
...props
}: Props) {
return (
<Wrapper>
<Button disabled={disabled || loading} {...props} />
{loading && <Loader />}
</Wrapper>
);
}

export default ProgressButton;