File tree Expand file tree Collapse file tree 2 files changed +10
-19
lines changed Expand file tree Collapse file tree 2 files changed +10
-19
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useRef , useEffect } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import classNames from 'classnames ' ;
3
+ import styled from 'styled-components ' ;
4
4
import getConfig from '../../../utils/getConfig' ;
5
5
import { registerFrame } from '../../../utils/dispatcher' ;
6
6
7
+ const Frame = styled . iframe `
8
+ min-height: 100%;
9
+ min-width: 100%;
10
+ position: ${ ( props ) => ( props . fullView ? 'relative' : 'absolute' ) } ;
11
+ border-width: 0;
12
+ ` ;
13
+
7
14
function PreviewFrame ( { fullView } ) {
8
15
const iframe = useRef ( ) ;
9
16
const previewUrl = getConfig ( 'PREVIEW_URL' ) ;
@@ -14,22 +21,17 @@ function PreviewFrame({ fullView }) {
14
21
} ;
15
22
} ) ;
16
23
17
- // TODO move this to styled components
18
- const iframeClass = classNames ( {
19
- 'preview-frame' : true ,
20
- 'preview-frame--full-view' : fullView
21
- } ) ;
22
24
const frameUrl = previewUrl ;
23
25
const sandboxAttributes =
24
26
'allow-scripts allow-pointer-lock allow-popups allow-forms allow-modals allow-downloads allow-same-origin' ;
25
27
return (
26
- < iframe
28
+ < Frame
27
29
title = "sketch preview"
28
30
src = { frameUrl }
29
- className = { iframeClass }
30
31
sandbox = { sandboxAttributes }
31
32
frameBorder = "0"
32
33
ref = { iframe }
34
+ fullView = { fullView }
33
35
/>
34
36
) ;
35
37
}
Original file line number Diff line number Diff line change 1
- .preview-frame {
2
- min-height : 100% ;
3
- min-width : 100% ;
4
- position : absolute ;
5
- border-width : 0 ;
6
- }
7
-
8
- .preview-frame--full-view {
9
- position : relative ;
10
- }
11
-
12
1
.preview-frame-holder {
13
2
display : flex ;
14
3
flex-direction : column ;
You can’t perform that action at this time.
0 commit comments