-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathembed.tsx
More file actions
43 lines (37 loc) · 846 Bytes
/
embed.tsx
File metadata and controls
43 lines (37 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import styled from 'styled-components';
import { HintedError } from '$utils/hinted-error';
import BrowserFrame from '$styles/browser-frame';
const EmbedWrapper = styled.div`
width: 100%;
> div {
width: 100%;
}
`;
const IframeWrapper = styled.iframe`
width: 100%;
border: 0;
height: ${(props: { height: number }) => props.height}px;
`;
interface EmbedProps {
className?: string;
src: string;
height: number;
}
export default function Embed({
className,
src,
height = 800,
...props
}: EmbedProps) {
if (!src) {
throw new HintedError('Embed block requires a URL');
}
return (
<EmbedWrapper className={className}>
<BrowserFrame link={src}>
<IframeWrapper loading='lazy' src={src} height={height} {...props} />
</BrowserFrame>
</EmbedWrapper>
);
}