parent
c361a989c5
commit
6c029f98b8
10 changed files with 120 additions and 106 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 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> |
||||
); |
||||
} |
||||
const snackbar = useSelector<RootState, SnackbarState>( |
||||
(state) => state.snackbar |
||||
); |
||||
|
||||
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> |
||||
); |
||||
}; |
||||
|
||||
const Container = styled.div` |
||||
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; |
||||
} |
||||
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; |
||||
} |
||||
`;
|
||||
|
||||
export default SnackbarWrapper |
||||
export default SnackbarWrapper; |
||||
|
Loading…
Reference in new issue