-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add spinner while fetching data (#396)
- Loading branch information
1 parent
c9a29dd
commit 37078c5
Showing
5 changed files
with
75 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import { css, keyframes } from '@emotion/react'; | ||
|
||
const spin = keyframes` | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
`; | ||
|
||
const spinnerStyle = css` | ||
height: 40px; | ||
width: 40px; | ||
animation: ${spin} 0.8s linear infinite; | ||
`; | ||
|
||
export function FullSpinner() { | ||
// First div is used when using nextjs/dynamic even after component is loaded | ||
return ( | ||
<div style={{ height: '100%' }}> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
height: '100%', | ||
width: '100%', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<svg | ||
css={spinnerStyle} | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
> | ||
<circle | ||
style={{ opacity: 0.25 }} | ||
cx="12" | ||
cy="12" | ||
r="10" | ||
stroke="currentColor" | ||
strokeWidth="4" | ||
/> | ||
<path | ||
style={{ opacity: 0.75 }} | ||
fill="currentColor" | ||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
); | ||
} |
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 @@ | ||
export * from './FullSpinner'; |
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,9 @@ | ||
import { FullSpinner } from '../../src/components/index'; | ||
|
||
export default { | ||
title: 'Components / FullSpinner', | ||
}; | ||
|
||
export function Spinner() { | ||
return <FullSpinner />; | ||
} |