Skip to content

Commit 4dafc5b

Browse files
ThomasMetzgerSimonClo
authored andcommitted
💄(frontend) embed-block: add aspect ratio constraint to resize
1 parent c0f418a commit 4dafc5b

File tree

1 file changed

+22
-8
lines changed
  • src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks

1 file changed

+22
-8
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/EmbedBlock.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,37 @@ export const IFrameViewer = (
5050
>,
5151
) => {
5252
const url = props.block.props.url;
53+
const aspectRatio = props.block.props.aspectRatio || 16 / 9;
5354

5455
const [iframeError, setIframeError] = useState(false);
5556
if (!url) {
5657
return <Box>No URL provided for embed.</Box>;
5758
}
5859

5960
return !iframeError ? (
60-
<iframe
61-
src={url}
62-
className="bn-visual-media"
61+
<div
6362
style={{
64-
height: '300px',
63+
position: 'relative',
64+
width: '100%',
65+
paddingTop: `${100 / aspectRatio}%`, // padding-top sets height relative to width
6566
}}
66-
allowFullScreen
67-
title="Embedded content"
68-
onError={() => setIframeError(true)}
69-
/>
67+
>
68+
<iframe
69+
src={url}
70+
className="bn-visual-media"
71+
style={{
72+
position: 'absolute',
73+
top: 0,
74+
left: 0,
75+
width: '100%',
76+
height: '100%',
77+
border: 'none',
78+
}}
79+
allowFullScreen
80+
title="Embedded content"
81+
onError={() => setIframeError(true)}
82+
/>
83+
</div>
7084
) : (
7185
<Box
7286
$css={css`

0 commit comments

Comments
 (0)