Skip to content

Commit 2252989

Browse files
committed
Move PreviewFrame to styled components
1 parent d912502 commit 2252989

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import React, { useRef, useEffect } from 'react';
22
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
3+
import styled from 'styled-components';
44
import getConfig from '../../../utils/getConfig';
55
import { registerFrame } from '../../../utils/dispatcher';
66

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+
714
function PreviewFrame({ fullView }) {
815
const iframe = useRef();
916
const previewUrl = getConfig('PREVIEW_URL');
@@ -14,22 +21,17 @@ function PreviewFrame({ fullView }) {
1421
};
1522
});
1623

17-
// TODO move this to styled components
18-
const iframeClass = classNames({
19-
'preview-frame': true,
20-
'preview-frame--full-view': fullView
21-
});
2224
const frameUrl = previewUrl;
2325
const sandboxAttributes =
2426
'allow-scripts allow-pointer-lock allow-popups allow-forms allow-modals allow-downloads allow-same-origin';
2527
return (
26-
<iframe
28+
<Frame
2729
title="sketch preview"
2830
src={frameUrl}
29-
className={iframeClass}
3031
sandbox={sandboxAttributes}
3132
frameBorder="0"
3233
ref={iframe}
34+
fullView={fullView}
3335
/>
3436
);
3537
}

client/styles/components/_preview-frame.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
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-
121
.preview-frame-holder {
132
display: flex;
143
flex-direction: column;

0 commit comments

Comments
 (0)