2023-09-26 19:41:20 +02:00
|
|
|
import { useContext, useState } from 'react'
|
|
|
|
import { ModalContext } from 'shared/context/modal-context.mjs'
|
|
|
|
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
|
2023-01-29 16:44:02 +01:00
|
|
|
|
2023-09-26 19:41:20 +02:00
|
|
|
export const Lightbox = ({ children, buttonClasses = '', boxClasses = false, modalProps = {} }) => {
|
|
|
|
const { setModal } = useContext(ModalContext)
|
2023-01-29 16:44:02 +01:00
|
|
|
const [box, setBox] = useState(false)
|
|
|
|
|
|
|
|
if (box)
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={`
|
|
|
|
fixed top-0 left-0 right-0 w-screen h-screen
|
|
|
|
bg-neutral bg-opacity-90 z-30
|
|
|
|
hover:cursor-zoom-out flex flex-col justify-center
|
|
|
|
`}
|
|
|
|
onClick={() => setBox(false)}
|
|
|
|
>
|
|
|
|
<div
|
2023-09-26 19:41:20 +02:00
|
|
|
className={`m-auto text-neutral-content lightbox ${className}`}
|
2023-01-29 16:44:02 +01:00
|
|
|
style={{
|
|
|
|
maxHeight: 'calc(100vh - 6rem)',
|
|
|
|
maxWidth: 'calc(100vw - 6rem)',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
2023-09-26 19:41:20 +02:00
|
|
|
<button
|
|
|
|
onClick={() =>
|
|
|
|
setModal(
|
|
|
|
<ModalWrapper
|
|
|
|
flex="col"
|
|
|
|
justify="top lg:justify-center"
|
|
|
|
slideFrom="right"
|
|
|
|
{...modalProps}
|
|
|
|
>
|
|
|
|
{boxClasses ? <div className={boxClasses}>{children}</div> : children}
|
|
|
|
</ModalWrapper>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
className={buttonClasses}
|
|
|
|
>
|
2023-01-29 16:44:02 +01:00
|
|
|
{children}
|
2023-08-23 12:18:20 +02:00
|
|
|
</button>
|
2023-01-29 16:44:02 +01:00
|
|
|
)
|
|
|
|
}
|
2023-09-26 19:41:20 +02:00
|
|
|
|
|
|
|
//<button onClick={() => setBox(!box)} className={`hover:cursor-zoom-in ${className}`}>
|