Compare commits
No commits in common. '73301a5c509115b578bce136929ce335ba5c7f33' and 'e8ebd6db27fa5c5048decd0d52f266d83a8cf52c' have entirely different histories.
73301a5c50
...
e8ebd6db27
10 changed files with 96 additions and 123 deletions
@ -1,55 +1,56 @@ |
|||||||
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>( |
const snackbar = useSelector<RootState, SnackbarState>(state => state.snackbar); |
||||||
(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 ( |
|
||||||
<Container> |
return ( |
||||||
{snackbar.text !== "" && ( |
<Container> |
||||||
<Snackbar onClick={onClick} text={snackbar.text} type={snackbar.type} /> |
{snackbar.text !== '' && <Snackbar onClick={onClick}
|
||||||
)} |
text={snackbar.text}
|
||||||
</Container> |
type={snackbar.type} />} |
||||||
); |
</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