-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from orijtech/loading-bits
ui: improve ux by showing a spinner disabling further user inputs
- Loading branch information
Showing
2 changed files
with
84 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FC } from 'react'; | ||
import CircularProgress from '@mui/material/CircularProgress'; | ||
|
||
interface Props { | ||
loading: boolean; | ||
}; | ||
|
||
export const Spinner: FC<Props> = ({ loading }) => { | ||
const styles: {[key: string]: number|string} = { | ||
position: 'absolute', | ||
top: '0%', | ||
left: '0%', | ||
right: '0%', | ||
bottom: '0%', | ||
visibility: 'hidden', | ||
backgroundColor: '#ffffff00', | ||
transition: 'background-color 200ms ease-in-out', | ||
zIndex: -1, | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center' | ||
}; | ||
|
||
if (loading) { | ||
styles['visibility'] = 'visible'; | ||
styles['backgroundColor'] = '#ffffffd9'; | ||
styles['zIndex'] = 999; | ||
styles['opacity'] = 0.5; | ||
} | ||
|
||
return ( | ||
<div style={styles}> | ||
<CircularProgress size={100} color='info' /> | ||
</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