parent
c361a989c5
commit
6c029f98b8
10 changed files with 120 additions and 106 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>) => { |
|
||||||
if (e) { |
const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { |
||||||
e.preventDefault(); |
if (e) { |
||||||
e.stopPropagation(); |
e.preventDefault(); |
||||||
} |
e.stopPropagation(); |
||||||
dispatch(deleteSnackbar()); |
} |
||||||
}; |
dispatch(deleteSnackbar()); |
||||||
|
}; |
||||||
|
|
||||||
return ( |
return ( |
||||||
<Container> |
<Container> |
||||||
{snackbar.text !== '' && <Snackbar onClick={onClick}
|
{snackbar.text !== "" && ( |
||||||
text={snackbar.text}
|
<Snackbar onClick={onClick} text={snackbar.text} type={snackbar.type} /> |
||||||
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