Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion src/frontend/src/pad/containers/Terminal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,81 @@
overflow: hidden;
}

.terminal-iframe-wrapper {
position: relative;
flex: 1;
height: 100%;
width: 100%;
overflow: hidden;
border-bottom-left-radius: var(--embeddable-radius);
border-bottom-right-radius: var(--embeddable-radius);
background-color: #000000;
}

.terminal-iframe {
flex: 1;
background-color: #1e1e1e;
background-color: #000000;
height: 100%;
width: 100%;
border: 0px !important;
overflow: hidden;
border-bottom-left-radius: var(--embeddable-radius);
border-bottom-right-radius: var(--embeddable-radius);

&--loading {
display: flex;
align-items: center;
justify-content: center;
position: relative;
}

&--loading-fade {
opacity: 0;
transition: opacity 0.5s ease-in;
}

&--loaded {
opacity: 1;
transition: opacity 0.5s ease-in;
}
}

.terminal-loading-animation {
position: absolute;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;

&--fade {
opacity: 1;
transition: opacity 0.15s ease-out;
z-index: 1;
background-color: #000000;
}

&--hidden {
opacity: 0;
pointer-events: none;
}
}

.terminal-loading-logo {
width: 60px;
height: 60px;
object-fit: contain;
animation: terminal-logo-slide 300ms cubic-bezier(0.00, 1.26, 0.64, 0.95) forwards;
position: relative;
}

@keyframes terminal-logo-slide {
from {
transform: translateX(-100px);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
50 changes: 45 additions & 5 deletions src/frontend/src/pad/containers/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const Terminal: React.FC<TerminalProps> = ({
}) => {
const { data: workspaceState } = useWorkspaceState();
const [terminalId, setTerminalId] = useState<string | null>(null);
const [iframeLoaded, setIframeLoaded] = useState(false);
const [shouldRenderIframe, setShouldRenderIframe] = useState(false);
const elementIdRef = useRef(element?.id);
const isInitializedRef = useRef(false);

Expand Down Expand Up @@ -172,13 +174,51 @@ export const Terminal: React.FC<TerminalProps> = ({

const terminalUrl = getTerminalUrl();

// Effect to delay loading the iframe
useEffect(() => {
// Set a small timeout to allow the scrolling to complete first
const timer = setTimeout(() => {
setShouldRenderIframe(true);
}, 500);

return () => clearTimeout(timer);
}, []);

// Handle iframe load event
const handleIframeLoad = () => {
setIframeLoaded(true);
console.debug('[pad.ws] Terminal iframe loaded');
};

return (
<div className="terminal-container">
<iframe
className="terminal-iframe"
src={terminalUrl}
title="Terminal"
/>
{shouldRenderIframe ? (
<div className="terminal-iframe-wrapper">
<iframe
className={`terminal-iframe ${iframeLoaded ? 'terminal-iframe--loaded' : 'terminal-iframe--loading-fade'}`}
src={terminalUrl}
title="Terminal"
onLoad={handleIframeLoad}
/>
<div className={`terminal-loading-animation terminal-loading-animation--fade ${iframeLoaded ? 'terminal-loading-animation--hidden' : ''}`}>
<img
src="/assets/images/favicon.png"
alt="pad.ws logo"
className="terminal-loading-logo"
/>
</div>
</div>
) : (
<div className="terminal-iframe terminal-iframe--loading">
<div className="terminal-loading-animation">
<img
src="/assets/images/favicon.png"
alt="pad.ws logo"
className="terminal-loading-logo"
/>
</div>
</div>
)}
</div>
);
};
Expand Down