-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an `<Embed />` block that instantiate an iframe for the use case [described here](https://github.com/NASA-IMPACT/veda-architecture/issues/308). ![Sandbox-Fire-—-VEDA-UI](https://github.com/NASA-IMPACT/veda-ui/assets/1583415/db204a51-3598-4205-b6f4-2468ff59f2ac)
- Loading branch information
Showing
4 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 { | ||
src: string; | ||
height: number; | ||
} | ||
|
||
export default function Embed({ src, height = 800 }: EmbedProps) { | ||
if (!src) { | ||
throw new HintedError('Embed block requires a URL'); | ||
} | ||
|
||
return ( | ||
<EmbedWrapper> | ||
<BrowserFrame link={src}> | ||
<IframeWrapper src={src} height={height} /> | ||
</BrowserFrame> | ||
</EmbedWrapper> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters