Auto-commit: add functionality fo expand all the images on click. it should be expanded in popup. second click sh

This commit is contained in:
2026-01-16 16:42:35 +01:00
parent 1257796e66
commit 03b52d12aa
2 changed files with 52 additions and 27 deletions

View File

@@ -1,4 +1,29 @@
import type { Metadata } from "next";
'use client';
import { useState, useEffect } from 'react';
function ImagePopup() {
const [isOpen, setIsOpen] = useState(false);
const [imageSrc, setImageSrc] = useState('');
useEffect(() => {
const handleClick = (e) => {
if (e.target.tagName === 'IMG' && !e.target.closest('[data-no-popup]')) {
setImageSrc(e.target.src);
setIsOpen(true);
}
};
document.addEventListener('click', handleClick);
return () => document.removeEventListener('click', handleClick);
}, []);
if (!isOpen) return null;
return (
<div className='fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center cursor-pointer' onClick={() => setIsOpen(false)}>
<img src={imageSrc} alt='Expanded' className='max-w-[90vw] max-h-[90vh] object-contain' />
</div>
);
}
import { Cormorant_Garamond } from "next/font/google";
import "./globals.css";
import { ServiceWrapper } from "@/components/ServiceWrapper";