feat(#680): add embed component
parent
0e147688a5
commit
443d768dc1
@ -0,0 +1,38 @@ |
|||||||
|
import styled from 'styled-components/macro' |
||||||
|
|
||||||
|
import { ButtonSolid, Input } from 'features/Common' |
||||||
|
|
||||||
|
const EmbedContainer = styled.div` |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
align-items: center; |
||||||
|
max-width: 100%; |
||||||
|
` |
||||||
|
|
||||||
|
const EmbedInput = styled(Input)` |
||||||
|
margin: 0; |
||||||
|
max-width: 400px; |
||||||
|
` |
||||||
|
|
||||||
|
type EmbedProps = { |
||||||
|
url: string, |
||||||
|
} |
||||||
|
|
||||||
|
export const EmbeddedComponent = ({ url }:EmbedProps) => { |
||||||
|
const iframeString = `<iframe src=${url}" width="300px" border="0" class="insports-embed" allowFullScreen srcdoc=${document.querySelector('#statsview')} />` |
||||||
|
|
||||||
|
const handleCopy = async (src: string) => { |
||||||
|
await navigator.clipboard.writeText(src) |
||||||
|
} |
||||||
|
|
||||||
|
return ( |
||||||
|
<EmbedContainer> |
||||||
|
<EmbedInput |
||||||
|
disabled={!!true} |
||||||
|
label='Embed Code' |
||||||
|
defaultValue={iframeString} |
||||||
|
/> |
||||||
|
<ButtonSolid onClick={() => handleCopy(iframeString)}>Copy code</ButtonSolid> |
||||||
|
</EmbedContainer> |
||||||
|
) |
||||||
|
} |
||||||
Loading…
Reference in new issue