1- import React , { useEffect } from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import { X , Scan } from '@phosphor-icons/react' ;
33import { motion , AnimatePresence } from 'framer-motion' ;
44
55const ImageModal = ( { src, alt, onClose } ) => {
6+ const [ dimensions , setDimensions ] = useState ( null ) ;
7+
68 useEffect ( ( ) => {
79 if ( src ) {
810 document . body . style . overflow = 'hidden' ;
@@ -26,11 +28,20 @@ const ImageModal = ({ src, alt, onClose }) => {
2628 } ;
2729 } , [ src , onClose ] ) ;
2830
31+ const handleImageLoad = ( e ) => {
32+ setDimensions ( {
33+ width : e . target . naturalWidth ,
34+ height : e . target . naturalHeight
35+ } ) ;
36+ } ;
37+
38+ const showAlt = alt && ! [ 'Project Detail' , 'Enlarged Content' , 'Intel Imagery' , 'Full size image' ] . includes ( alt ) ;
39+
2940 return (
3041 < AnimatePresence >
3142 { src && (
3243 < motion . div
33- className = "fixed inset-0 z-[100] flex items-center justify-center bg-black/90 backdrop-blur-xl p-4 md:p-8 "
44+ className = "fixed inset-0 z-[100] flex items-center justify-center bg-black/90 backdrop-blur-xl p-2 md:p-4 "
3445 onClick = { onClose }
3546 initial = { { opacity : 0 } }
3647 animate = { { opacity : 1 } }
@@ -43,7 +54,7 @@ const ImageModal = ({ src, alt, onClose }) => {
4354 />
4455
4556 < motion . div
46- className = "relative max-w-7xl w- full h-full max-h-[90vh ] flex flex-col"
57+ className = "relative w- full h-full max-w-[85vw] max- h-[85vh ] flex flex-col"
4758 onClick = { ( e ) => e . stopPropagation ( ) }
4859 initial = { { scale : 0.98 , opacity : 0 } }
4960 animate = { { scale : 1 , opacity : 1 } }
@@ -70,7 +81,7 @@ const ImageModal = ({ src, alt, onClose }) => {
7081 </ div >
7182
7283 { /* Image Container */ }
73- < div className = "relative flex-1 border border-white/10 bg-black/40 backdrop-blur-sm rounded-b-sm overflow-hidden flex items-center justify-center" >
84+ < div className = "relative flex-1 min-h-0 bg-black/40 backdrop-blur-sm rounded-b-sm overflow-hidden flex items-center justify-center" >
7485 { /* Corner Accents */ }
7586 < div className = "absolute top-0 left-0 w-6 h-6 border-l-2 border-t-2 border-emerald-500/30 z-10" />
7687 < div className = "absolute top-0 right-0 w-6 h-6 border-r-2 border-t-2 border-emerald-500/30 z-10" />
@@ -80,28 +91,21 @@ const ImageModal = ({ src, alt, onClose }) => {
8091 < img
8192 src = { src }
8293 alt = { alt }
83- className = "max-w-full max-h-full object-contain shadow-[0_0_50px_rgba(0,0,0,0.5)] select-none"
94+ onLoad = { handleImageLoad }
95+ style = { { maxWidth : '100%' , maxHeight : '100%' } }
96+ className = "w-auto h-auto object-contain block shadow-[0_0_50px_rgba(0,0,0,0.5)] select-none"
8497 />
85-
86- { /* Caption */ }
87- { alt && alt !== 'Project Detail' && (
88- < div className = "absolute bottom-6 left-0 right-0 mx-auto w-max max-w-[80%] bg-black/90 backdrop-blur-xl border border-white/10 px-6 py-2.5 rounded-sm text-center shadow-2xl" >
89- < p className = "font-mono text-xs text-emerald-400 uppercase tracking-[0.2em] font-medium" >
90- { alt }
91- </ p >
92- </ div >
93- ) }
9498 </ div >
9599
96100 { /* Footer Metadata */ }
97- < div className = "mt-2 flex justify-between items-center opacity-40 px-2" >
101+ < div className = "mt-3 flex justify-between items-center px-2" >
98102 < div className = "flex gap-4" >
99- < span className = "font-mono text-[9px] uppercase tracking-widest text-gray-500 " >
100- RAW_STREAM: ACTIVE
103+ < span className = "font-mono text-sm uppercase tracking-widest text-white font-bold truncate max-w-[50vw] " >
104+ { showAlt ? alt : 'RAW_STREAM' }
101105 </ span >
102106 </ div >
103- < span className = "font-mono text-[9px] uppercase tracking-widest text-gray-500 text-right" >
104- DECRYPTED_AT: { new Date ( ) . toLocaleTimeString ( ) }
107+ < span className = "font-mono text-sm uppercase tracking-widest text-white font-bold text-right" >
108+ { dimensions ? ` ${ dimensions . width } x ${ dimensions . height } PX` : 'CALCULATING...' }
105109 </ span >
106110 </ div >
107111
@@ -112,4 +116,4 @@ const ImageModal = ({ src, alt, onClose }) => {
112116 ) ;
113117} ;
114118
115- export default ImageModal ;
119+ export default ImageModal ;
0 commit comments