Add a prop for a custom document (good for iframes).#33
Add a prop for a custom document (good for iframes).#33Reklino wants to merge 3 commits intojakewtaylor:masterfrom
Conversation
jakewtaylor
left a comment
There was a problem hiding this comment.
Hi, thanks for submitting a PR! 🙏
I'm just a little confused about the PropTypes/Typescript definitions you've added, can you explain? 😃
|
Hi @Reklino, how's it going - did you manage to figure out what the types should be? 😆😋 |
|
@jakewtaylor thanks for the reminder. #document is just a good old |
|
Apologies for the delay @Reklino, the code looks good to me now. Sorry to be a pain, but could you provide a small example of how this new prop works, just so I can test it? 😄 |
|
@jakewtaylor sure! If you have a rendered Example using const MyComponent = (props, context) => (
<Fragment>
<Frame>
<FrameContextConsumer>
{
// Callback is invoked with iframe's window and document instances
({document, window}) => {
<Fragment>
<GoogleFontLoader
fonts={[
{
font: 'Roboto',
weights: [400, '400i'],
},
]}
contentDocument={document}
/>
<h1 style={{ fontFamily: 'Roboto'; }}>Will render with Roboto</h1>
</Fragment>
}
}
</FrameContextConsumer>
</Frame>
<h1 style={{ fontFamily: 'Roboto'; }}>Will not render with Roboto</h1>
</Fragment>
);Of course, you don't have to use |
|
Hey @jakewtaylor 👋 . Any chance we could merge this one in? |
Hey there! This is great little tool 🙏 . Thanks for putting it together.
I'm using this in a project that uses Google Fonts in an iframe, so I need the
<style>tags to be included in that document rather than the basedocument. This simply adds a new prop for this use case.