@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
44import clsx from 'clsx' ;
55import copy from 'clipboard-copy' ;
66import { useSelector , useDispatch } from 'react-redux' ;
7- import { withStyles } from '@material-ui/core/styles' ;
7+ import { withStyles , fade } from '@material-ui/core/styles' ;
88import IconButton from '@material-ui/core/IconButton' ;
99import useMediaQuery from '@material-ui/core/useMediaQuery' ;
1010import Collapse from '@material-ui/core/Collapse' ;
@@ -54,14 +54,18 @@ const styles = theme => ({
5454 outline : 0 ,
5555 margin : 'auto' ,
5656 borderRadius : theme . shape . borderRadius ,
57- backgroundColor : theme . palette . background . level2 ,
5857 display : 'flex' ,
5958 justifyContent : 'center' ,
59+ border : `1px solid ${ fade ( theme . palette . action . active , 0.12 ) } ` ,
6060 padding : 20 ,
6161 [ theme . breakpoints . up ( 'sm' ) ] : {
6262 padding : theme . spacing ( 3 ) ,
6363 } ,
6464 } ,
65+ demoBg : {
66+ border : 'none' ,
67+ backgroundColor : theme . palette . background . level2 ,
68+ } ,
6569 demoHiddenHeader : {
6670 paddingTop : theme . spacing ( 2 ) ,
6771 [ theme . breakpoints . up ( 'sm' ) ] : {
@@ -133,7 +137,6 @@ function Demo(props) {
133137 const dispatch = useDispatch ( ) ;
134138 const t = useSelector ( state => state . options . t ) ;
135139 const codeVariant = useSelector ( state => state . options . codeVariant ) ;
136-
137140 const demoData = getDemoData ( codeVariant , demo , githubLocation ) ;
138141
139142 const [ sourceHintSeen , setSourceHintSeen ] = React . useState ( false ) ;
@@ -241,6 +244,10 @@ function Demo(props) {
241244 [ demoOptions . height , demoOptions . maxWidth ] ,
242245 ) ;
243246
247+ if ( demoOptions . iframe ) {
248+ demoOptions . bg = true ;
249+ }
250+
244251 const createHandleCodeSourceLink = anchor => async ( ) => {
245252 try {
246253 await copy ( `${ window . location . href . split ( '#' ) [ 0 ] } #${ anchor } ` ) ;
@@ -266,9 +273,12 @@ function Demo(props) {
266273
267274 const match = useMediaQuery ( theme => theme . breakpoints . up ( 'sm' ) ) ;
268275
269- const jsx = getJsxPreview ( demoData . raw || '' , demoOptions . defaultCodeOpen ) ;
276+ const jsx = getJsxPreview ( demoData . raw || '' ) ;
270277 const showPreview =
271- ! demoOptions . hideHeader && jsx !== demoData . raw && jsx . split ( / \n / ) . length <= 20 ;
278+ ! demoOptions . hideHeader &&
279+ demoOptions . defaultCodeOpen !== false &&
280+ jsx !== demoData . raw &&
281+ jsx . split ( / \n / ) . length <= 15 ;
272282
273283 let showCodeLabel ;
274284 if ( codeOpen ) {
@@ -282,6 +292,7 @@ function Demo(props) {
282292 < div
283293 className = { clsx ( classes . demo , {
284294 [ classes . demoHiddenHeader ] : demoOptions . hideHeader ,
295+ [ classes . demoBg ] : demoOptions . bg ,
285296 } ) }
286297 tabIndex = { - 1 }
287298 onMouseEnter = { handleDemoHover }
0 commit comments