import { useEffect, useRef } from 'react'; import Viewer from 'viewerjs'; import 'viewerjs/dist/viewer.css'; import { clsx } from 'clsx/lite'; import FullscreenButton from '../FullscreenButton'; export default function ImageActions({ children, enableImageActions = false, className, }: { children: React.ReactNode; enableImageActions?: boolean; className?: string; }) { const containerRef = useRef(null); const viewerRef = useRef(null); useEffect(() => { if (containerRef.current && enableImageActions) { viewerRef.current = new Viewer(containerRef.current, { inline: false, button: true, navbar: false, title: false, toolbar: { zoomIn: 1, zoomOut: 1, reset: 1, tooltip: 1, }, }); return () => { viewerRef.current?.destroy(); }; } }, [enableImageActions]); return ( <>
{children} {enableImageActions && ( )}
); }