Optimised iframe for offers (#19567)

This commit is contained in:
Princi Vershwal 2024-01-24 18:40:37 +05:30 committed by GitHub
parent cb9efc3ad4
commit 384cb44e6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,6 @@ const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab
const makeVisible = useCallback(() => {
setTimeout(() => {
if (iframeRef.current) {
setHasLoaded(true);
setIsInvisible(false);
}
}, 500);
@ -51,16 +50,22 @@ const PortalFrame: React.FC<PortalFrameProps> = ({href, onDestroyed, selectedTab
}
return (
<>{!hasLoaded && isInvisible && <div className="mt-[-7%] flex h-screen items-center justify-center"><span><LoadingIndicator /></span></div>}
<>
{isInvisible && (
<div className="mt-[-7%] flex h-screen items-center justify-center">
<span><LoadingIndicator /></span>
</div>
) }
<iframe
ref={iframeRef}
className={!isInvisible && hasLoaded ? '' : 'hidden'}
className={hasLoaded && !isInvisible ? '' : 'hidden'}
data-testid="portal-preview"
height="100%"
src={href}
title="Portal Preview"
width="100%"
onLoad={() => {
setHasLoaded(true);
}}
/>
</>