From 53e0676d3c7226fbea6b69eaf195fc9643aea649 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 3 Jan 2021 10:56:31 +0100 Subject: [PATCH 1/3] [docs] Fix iframe demos with emotion --- docs/src/modules/components/DemoSandboxed.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/src/modules/components/DemoSandboxed.js b/docs/src/modules/components/DemoSandboxed.js index 9814f3ad84f828..133b8fba09291a 100644 --- a/docs/src/modules/components/DemoSandboxed.js +++ b/docs/src/modules/components/DemoSandboxed.js @@ -2,6 +2,8 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import { create } from 'jss'; +import createCache from '@emotion/cache'; +import { CacheProvider } from '@emotion/react'; import { makeStyles, useTheme, jssPreset, StylesProvider } from '@material-ui/core/styles'; import rtl from 'jss-rtl'; import DemoErrorBoundary from 'docs/src/modules/components/DemoErrorBoundary'; @@ -25,13 +27,25 @@ function FramedDemo(props) { }; }, [document]); + const cache = React.useMemo( + () => + createCache({ + key: 'iframe-demo', + prepend: true, + container: document.body, + }), + [document], + ); + const getWindow = React.useCallback(() => document.defaultView, [document]); return ( - {React.cloneElement(children, { - window: getWindow, - })} + + {React.cloneElement(children, { + window: getWindow, + })} + ); } From 797048de8f75a6da728b51c200f28d3fe0b00c62 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 3 Jan 2021 11:51:44 +0100 Subject: [PATCH 2/3] fix rendering --- docs/src/modules/components/DemoSandboxed.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/src/modules/components/DemoSandboxed.js b/docs/src/modules/components/DemoSandboxed.js index 133b8fba09291a..8d1b9bc0cfad37 100644 --- a/docs/src/modules/components/DemoSandboxed.js +++ b/docs/src/modules/components/DemoSandboxed.js @@ -32,7 +32,7 @@ function FramedDemo(props) { createCache({ key: 'iframe-demo', prepend: true, - container: document.body, + container: document.head, }), [document], ); @@ -68,7 +68,8 @@ const useStyles = makeStyles( ); function DemoFrame(props) { - const { children, title, ...other } = props; + const { children, name, ...other } = props; + const title = `${name} demo`; const classes = useStyles(); /** * @type {import('react').Ref} @@ -109,7 +110,7 @@ function DemoFrame(props) { DemoFrame.propTypes = { children: PropTypes.node.isRequired, - title: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, }; /** @@ -119,7 +120,7 @@ DemoFrame.propTypes = { function DemoSandboxed(props) { const { component: Component, iframe, name, onResetDemoClick, ...other } = props; const Sandbox = iframe ? DemoFrame : React.Fragment; - const sandboxProps = iframe ? { title: `${name} demo`, ...other } : {}; + const sandboxProps = iframe ? { name, ...other } : {}; const t = useTranslate(); From d3be514c2a0d74f96e6f55e3c8c5f9f86f509345 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 3 Jan 2021 15:34:00 +0100 Subject: [PATCH 3/3] rerun ci