mirror of https://github.com/sgoudham/carbon.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
import React from 'react'
|
|
import { withRouter } from 'next/router'
|
|
|
|
import CopyButton from './CopyButton'
|
|
|
|
const toIFrame = url =>
|
|
`<iframe
|
|
src="https://carbon.now.sh/embed${url}"
|
|
style="transform:scale(0.7); width:1024px; height:473px; border:0; overflow:hidden;"
|
|
sandbox="allow-scripts allow-same-origin">
|
|
</iframe>
|
|
`
|
|
|
|
function ExportButton({ router, color }) {
|
|
return (
|
|
<React.Fragment>
|
|
<CopyButton text={toIFrame(router.asPath)}>
|
|
{({ copied }) => <button>{copied ? 'Copied!' : 'Copy Embed'}</button>}
|
|
</CopyButton>
|
|
<style jsx>
|
|
{`
|
|
button {
|
|
margin: 0;
|
|
padding: 0;
|
|
border: 0;
|
|
font-size: 100%;
|
|
vertical-align: baseline;
|
|
color: ${color};
|
|
background: transparent;
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
|
|
&:active {
|
|
outline: none;
|
|
}
|
|
`}
|
|
</style>
|
|
</React.Fragment>
|
|
)
|
|
}
|
|
|
|
export default withRouter(ExportButton)
|