-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a loader on the button while forking (#1733)
* Show a loader on the button while forking This is a follow-up of #1667. The effect is simple because for now I didn't want to modify the markup of the button. As far as my limited CSS skills lead me, @CompuIves suggestion regarding nzbin.github.io/three-dots would require to have a div wrapper around the button and a div to display the 3 dots. Do we want to do this? * Introduce ProgressButton to have more possibilities for the loader * Make the circles a bit smaller
- Loading branch information
Showing
5 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |