This repository has been archived on 2025-09-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Netflix-Clone/src/components/Modal.tsx
2022-11-26 16:25:35 -05:00

36 lines
809 B
TypeScript

import React from 'react'
interface IBackdrop {
toggleBackdrop?: () => void
show: boolean
}
interface IModal extends IBackdrop {
backgroundImage: string
children: JSX.Element
}
const Backdrop = ({ toggleBackdrop, show }: IBackdrop) =>
show ? <div onClick={toggleBackdrop} className='backdrop'></div> : null
const Modal = ({ show, toggleBackdrop, children, backgroundImage }: IModal) => {
const backgroundStyle = {
backgroundSize: 'cover',
backgroundImage: `url(https://image.tmdb.org/t/p/original/${backgroundImage})`,
}
return (
<div>
<Backdrop show={show} toggleBackdrop={toggleBackdrop} />
<div
style={backgroundStyle}
className={show ? 'modal show' : 'modal hide'}
>
{children}
</div>
</div>
)
}
export default Modal