Compare commits
2 Commits
e8ebd6db27
...
73301a5c50
Author | SHA1 | Date |
---|---|---|
taha12322 | 73301a5c50 | 3 years ago |
taha12322 | 6c029f98b8 | 3 years ago |
10 changed files with 123 additions and 96 deletions
@ -1,56 +1,55 @@ |
||||
import styled from 'styled-components' |
||||
import { useSelector, useDispatch } from 'react-redux' |
||||
import styled from "styled-components"; |
||||
import { useSelector, useDispatch } from "react-redux"; |
||||
// components
|
||||
import Snackbar from 'components/commons/Snackbar' |
||||
import Snackbar from "components/commons/Snackbar"; |
||||
// lib
|
||||
import zIndex from 'lib/styles/zIndex' |
||||
import media from 'lib/styles/media' |
||||
import zIndex from "lib/styles/zIndex"; |
||||
import media from "lib/styles/media"; |
||||
// slices
|
||||
import { deleteSnackbar } from 'slices/snackbar' |
||||
import { deleteSnackbar } from "slices/snackbar"; |
||||
// types
|
||||
import { RootState } from 'slices' |
||||
import { SnackbarState } from 'slices/snackbar' |
||||
import { RootState } from "slices"; |
||||
import { SnackbarState } from "slices/snackbar"; |
||||
|
||||
|
||||
const SnackbarWrapper = ()=> { |
||||
const SnackbarWrapper = () => { |
||||
const dispatch = useDispatch(); |
||||
const snackbar = useSelector<RootState, SnackbarState>(state => state.snackbar); |
||||
|
||||
const snackbar = useSelector<RootState, SnackbarState>( |
||||
(state) => state.snackbar |
||||
); |
||||
|
||||
const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { |
||||
if (e) { |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
} |
||||
dispatch(deleteSnackbar()); |
||||
}; |
||||
const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { |
||||
if (e) { |
||||
e.preventDefault(); |
||||
e.stopPropagation(); |
||||
} |
||||
dispatch(deleteSnackbar()); |
||||
}; |
||||
|
||||
|
||||
return ( |
||||
<Container> |
||||
{snackbar.text !== '' && <Snackbar onClick={onClick}
|
||||
text={snackbar.text}
|
||||
type={snackbar.type} />} |
||||
</Container> |
||||
); |
||||
} |
||||
return ( |
||||
<Container> |
||||
{snackbar.text !== "" && ( |
||||
<Snackbar onClick={onClick} text={snackbar.text} type={snackbar.type} /> |
||||
)} |
||||
</Container> |
||||
); |
||||
}; |
||||
|
||||
const Container = styled.div` |
||||
position: fixed; |
||||
top: 40px; |
||||
right: 30px; |
||||
width: 320px; |
||||
height: auto; |
||||
z-index: ${zIndex.snackbar}; |
||||
position: fixed; |
||||
top: 40px; |
||||
right: 30px; |
||||
width: 320px; |
||||
height: auto; |
||||
z-index: ${zIndex.snackbar}; |
||||
|
||||
${media.small} { |
||||
width: 100%; |
||||
top: initial; |
||||
bottom: 0; |
||||
left: 0; |
||||
right: 0; |
||||
margin: auto; |
||||
} |
||||
${media.small} { |
||||
width: 100%; |
||||
top: initial; |
||||
bottom: 0; |
||||
left: 0; |
||||
right: 0; |
||||
margin: auto; |
||||
} |
||||
`;
|
||||
|
||||
export default SnackbarWrapper |
||||
export default SnackbarWrapper; |
||||
|
Loading…
Reference in new issue