-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-components): add loading spinner to button
- Loading branch information
Showing
6 changed files
with
109 additions
and
3 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
24 changes: 24 additions & 0 deletions
24
packages/game-app/src/_shared/components/Spinner/Spinner.stories.tsx
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,24 @@ | ||
import React from 'react'; | ||
import { Story, Meta } from '@storybook/react'; | ||
|
||
import Spinner from './Spinner'; | ||
import { Clear } from '../Input/Input.stories'; | ||
|
||
export default { | ||
title: 'Components/Spinner', | ||
component: Spinner, | ||
argTypes: {}, | ||
} as Meta; | ||
|
||
const Template: Story<React.ComponentProps<typeof Spinner>> = args => <Spinner {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
|
||
Default.args = {}; | ||
Default.decorators = [ | ||
Story => ( | ||
<div style={{ padding: '50px', background: 'lightgray' }}> | ||
<Story /> | ||
</div> | ||
), | ||
]; |
42 changes: 42 additions & 0 deletions
42
packages/game-app/src/_shared/components/Spinner/Spinner.styled.tsx
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,42 @@ | ||
import styled, { keyframes } from 'styled-components'; | ||
|
||
const spinnerAnimation = keyframes` | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
}`; | ||
|
||
export const StyledSpinner = styled.div` | ||
display: inline-block; | ||
position: relative; | ||
width: 30px; | ||
height: 30px; | ||
& > div.thumb { | ||
box-sizing: border-box; | ||
display: block; | ||
position: absolute; | ||
width: 30px; | ||
height: 30px; | ||
border: 4px solid #fff; | ||
border-radius: 50%; | ||
animation: ${spinnerAnimation} 1.2s linear infinite; | ||
border-color: #fff transparent transparent transparent; | ||
} | ||
& > div.placeholder { | ||
box-sizing: border-box; | ||
display: block; | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
top: 0; | ||
border: 4px solid rgba(255, 255, 255, 0.5); | ||
border-radius: 50%; | ||
} | ||
`; | ||
|
||
StyledSpinner.displayName = 'StyledSpinner'; |
17 changes: 17 additions & 0 deletions
17
packages/game-app/src/_shared/components/Spinner/Spinner.tsx
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,17 @@ | ||
import React from 'react'; | ||
import { StyledSpinner } from './Spinner.styled'; | ||
|
||
type Props = {}; | ||
|
||
const Spinner: React.FC<Props> = ({}) => { | ||
return ( | ||
<StyledSpinner> | ||
<div className="thumb"></div> | ||
<div className="placeholder"></div> | ||
</StyledSpinner> | ||
); | ||
}; | ||
|
||
Spinner.displayName = 'Spinner'; | ||
|
||
export default Spinner; |
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,3 @@ | ||
import Spinner from './Spinner'; | ||
|
||
export default Spinner; |