import cn from "classnames"; import React, { useRef } from "react"; import { ReactPhotoSphereViewer } from "react-photo-sphere-viewer"; import { PhotoSphereLightboxData } from "@mt/common-types"; import "./AttractionMedia.css"; import { useLightboxContext } from "../../lightbox"; import { Icons } from "@mt/components"; interface PhotoSphereMediaProps { url: string; watermarkUrl?: string; } export const PhotoSphereMedia = ({ url, watermarkUrl, }: PhotoSphereMediaProps) => { // prettier-ignore const { setData, openLightbox } = useLightboxContext(); // react-photo-sphere-viewer doesn't have exported types, so here's a bit of a hardcoded piece const photoSphereRef = useRef(null); const handlePhotoSphereFullscreenOpen = () => { photoSphereRef.current?.stopAutoRotate(); setData({ type: "PHOTO_SPHERE", imageUrl: url, watermarkUrl, }); openLightbox(); }; return (
{watermarkUrl && ( Watermark )} {/* the following is a workaround to open lightbox-like preview in the middle of the screen instead of the real fullscreen */} handlePhotoSphereFullscreenOpen()} />
); };