Files
pawol.nu/components/rezo-imaj.js
T

68 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-02-08 21:47:48 +04:00
import PropTypes from 'prop-types'
import Backdrop from '@mui/material/Backdrop'
import Image from 'next/image'
import useMediaQuery from '@mui/material/useMediaQuery'
2022-02-08 22:10:52 +04:00
import pale from '../public/captures/pale.png'
import gade from '../public/captures/gade.png'
import mobilize from '../public/captures/mobilize.png'
2022-02-19 21:52:18 +04:00
import mizik from '../public/captures/mizik.png'
2022-02-08 22:10:52 +04:00
import nouvel from '../public/captures/nouvel.png'
2022-02-08 21:47:48 +04:00
2022-02-09 19:34:06 +04:00
export default function RezoImaj({tit, img, open, setOpen}) {
2022-02-08 21:47:48 +04:00
const isSmallDevice = useMediaQuery('(max-width:1160px)')
2022-02-08 22:10:52 +04:00
const getSource = source => {
if (source === 'pale') {
return pale
}
if (source === 'gade') {
return gade
}
if (source === 'mobilize') {
return mobilize
}
2022-02-19 21:52:18 +04:00
if (source === 'mizik') {
return mizik
}
2022-02-08 22:10:52 +04:00
if (source === 'nouvel') {
return nouvel
}
}
const source = getSource(img)
2022-02-08 21:47:48 +04:00
const handleClose = () => {
setOpen(false)
}
return (
<div>
<Backdrop
sx={{color: '#fff', zIndex: theme => theme.zIndex.drawer + 1}}
open={open}
onClick={handleClose}
>
<div style={{width: isSmallDevice ? '100%' : '70%', height: isSmallDevice ? '100%' : '70%', position: 'relative'}}>
<Image
2022-02-08 22:10:52 +04:00
src={source}
2022-02-09 19:34:06 +04:00
alt={`Aperçu ${tit}`}
2022-02-08 21:47:48 +04:00
layout='fill'
objectFit='contain'
2022-02-08 22:10:52 +04:00
placeholder='blur'
2022-02-08 21:47:48 +04:00
/>
</div>
</Backdrop>
</div>
)
}
RezoImaj.propTypes = {
img: PropTypes.string.isRequired,
2022-02-09 19:34:06 +04:00
tit: PropTypes.string.isRequired,
2022-02-08 21:47:48 +04:00
open: PropTypes.bool.isRequired,
setOpen: PropTypes.func.isRequired
}