Skip to content

Commit

Permalink
Merge pull request #1562 from blockscout/fe-1559
Browse files Browse the repository at this point in the history
fix svg fullscreen
  • Loading branch information
isstuev authored Feb 6, 2024
2 parents 06649df + c864b8c commit 9802a72
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 106 deletions.
4 changes: 2 additions & 2 deletions ui/shared/nft/NftHtmlFullscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
onClose: () => void;
}

const NftHtmlWithFullscreen = ({ src, isOpen, onClose }: Props) => {
const NftHtmlFullscreen = ({ src, isOpen, onClose }: Props) => {
return (
<NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }>
<chakra.iframe
Expand All @@ -22,4 +22,4 @@ const NftHtmlWithFullscreen = ({ src, isOpen, onClose }: Props) => {
);
};

export default NftHtmlWithFullscreen;
export default NftHtmlFullscreen;
33 changes: 0 additions & 33 deletions ui/shared/nft/NftHtmlWithFullscreen.tsx

This file was deleted.

23 changes: 20 additions & 3 deletions ui/shared/nft/NftImageFullscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,29 @@ interface Props {
onClose: () => void;
}

const NftImageWithFullscreen = ({ src, isOpen, onClose }: Props) => {
const NftImageFullscreen = ({ src, isOpen, onClose }: Props) => {
const imgRef = React.useRef<HTMLImageElement>(null);
const [ hasDimentions, setHasDimentions ] = React.useState<boolean>(true);

const checkWidth = React.useCallback(() => {
if (imgRef.current?.getBoundingClientRect().width === 0) {
setHasDimentions(false);
}
}, [ ]);

return (
<NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }>
<Image src={ src } alt="Token instance image" maxH="90vh" maxW="90vw"/>
<Image
src={ src }
alt="Token instance image"
maxH="90vh"
maxW="90vw"
ref={ imgRef }
onLoad={ checkWidth }
sx={ hasDimentions ? {} : { width: '90vw', height: '90vh' } }
/>
</NftMediaFullscreenModal>
);
};

export default NftImageWithFullscreen;
export default NftImageFullscreen;
29 changes: 0 additions & 29 deletions ui/shared/nft/NftImageWithFullscreen.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions ui/shared/nft/NftVideoFullscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
onClose: () => void;
}

const NftVideoWithFullscreen = ({ src, isOpen, onClose }: Props) => {
const NftVideoFullscreen = ({ src, isOpen, onClose }: Props) => {
return (
<NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }>
<chakra.video
Expand All @@ -23,4 +23,4 @@ const NftVideoWithFullscreen = ({ src, isOpen, onClose }: Props) => {
);
};

export default NftVideoWithFullscreen;
export default NftVideoFullscreen;
37 changes: 0 additions & 37 deletions ui/shared/nft/NftVideoWithFullscreen.tsx

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9802a72

Please sign in to comment.