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 styled from "styled-components"; |
||||||
import { useSelector, useDispatch } from 'react-redux' |
import { useSelector, useDispatch } from "react-redux"; |
||||||
// components
|
// components
|
||||||
import Snackbar from 'components/commons/Snackbar' |
import Snackbar from "components/commons/Snackbar"; |
||||||
// lib
|
// lib
|
||||||
import zIndex from 'lib/styles/zIndex' |
import zIndex from "lib/styles/zIndex"; |
||||||
import media from 'lib/styles/media' |
import media from "lib/styles/media"; |
||||||
// slices
|
// slices
|
||||||
import { deleteSnackbar } from 'slices/snackbar' |
import { deleteSnackbar } from "slices/snackbar"; |
||||||
// types
|
// types
|
||||||
import { RootState } from 'slices' |
import { RootState } from "slices"; |
||||||
import { SnackbarState } from 'slices/snackbar' |
import { SnackbarState } from "slices/snackbar"; |
||||||
|
|
||||||
|
const SnackbarWrapper = () => { |
||||||
const SnackbarWrapper = ()=> { |
|
||||||
const dispatch = useDispatch(); |
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>) => { |
const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { |
||||||
if (e) { |
if (e) { |
||||||
e.preventDefault(); |
e.preventDefault(); |
||||||
e.stopPropagation(); |
e.stopPropagation(); |
||||||
} |
} |
||||||
dispatch(deleteSnackbar()); |
dispatch(deleteSnackbar()); |
||||||
}; |
}; |
||||||
|
|
||||||
|
return ( |
||||||
return ( |
<Container> |
||||||
<Container> |
{snackbar.text !== "" && ( |
||||||
{snackbar.text !== '' && <Snackbar onClick={onClick}
|
<Snackbar onClick={onClick} text={snackbar.text} type={snackbar.type} /> |
||||||
text={snackbar.text}
|
)} |
||||||
type={snackbar.type} />} |
</Container> |
||||||
</Container> |
); |
||||||
); |
}; |
||||||
} |
|
||||||
|
|
||||||
const Container = styled.div` |
const Container = styled.div` |
||||||
position: fixed; |
position: fixed; |
||||||
top: 40px; |
top: 40px; |
||||||
right: 30px; |
right: 30px; |
||||||
width: 320px; |
width: 320px; |
||||||
height: auto; |
height: auto; |
||||||
z-index: ${zIndex.snackbar}; |
z-index: ${zIndex.snackbar}; |
||||||
|
|
||||||
${media.small} { |
${media.small} { |
||||||
width: 100%; |
width: 100%; |
||||||
top: initial; |
top: initial; |
||||||
bottom: 0; |
bottom: 0; |
||||||
left: 0; |
left: 0; |
||||||
right: 0; |
right: 0; |
||||||
margin: auto; |
margin: auto; |
||||||
} |
} |
||||||
`;
|
`;
|
||||||
|
|
||||||
export default SnackbarWrapper |
export default SnackbarWrapper; |
||||||
|
Loading…
Reference in new issue