mirror of
https://github.com/primer/css.git
synced 2024-11-28 04:43:05 +03:00
add iframe component
This commit is contained in:
parent
2aa63435b1
commit
724e44ced2
29
docs/src/Frame.js
Normal file
29
docs/src/Frame.js
Normal file
@ -0,0 +1,29 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import {BorderBox} from '@primer/components'
|
||||
|
||||
export default class Frame extends React.Component {
|
||||
componentDidMount() {
|
||||
this.doc = this.node.contentDocument
|
||||
this.forceUpdate()
|
||||
}
|
||||
|
||||
render() {
|
||||
const {children, head: _head, ...rest} = this.props
|
||||
const head = this.doc ? ReactDOM.createPortal(_head, this.doc.head) : null
|
||||
const body = this.doc ? ReactDOM.createPortal(children, this.doc.body) : null
|
||||
return (
|
||||
<BorderBox as="iframe" {...rest} ref={node => (this.node = node)}>
|
||||
{head}
|
||||
{body}
|
||||
</BorderBox>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Frame.defaultProps = {
|
||||
bg: 'white',
|
||||
border: 0,
|
||||
p: 3,
|
||||
width: '100%'
|
||||
}
|
Loading…
Reference in New Issue
Block a user