Merge pull request #104 from scissorsneedfoodtoo/fix/firefox-pane-resizing
Fix Firefox Pane Resizing
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
5dea8b58d0
commit
89acc49a31
@@ -85,6 +85,27 @@ const propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ShowClassic extends PureComponent {
|
class ShowClassic extends PureComponent {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
|
||||||
|
this.resizeProps = {
|
||||||
|
onStopResize: this.onStopResize.bind(this),
|
||||||
|
onResize: this.onResize.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
resizing: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onResize() {
|
||||||
|
this.setState({ resizing: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
onStopResize() {
|
||||||
|
this.setState({ resizing: false });
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {
|
const {
|
||||||
challengeMounted,
|
challengeMounted,
|
||||||
@@ -136,6 +157,7 @@ class ShowClassic extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
// console.log(this.state)
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
challengeNode: {
|
challengeNode: {
|
||||||
@@ -154,17 +176,18 @@ class ShowClassic extends PureComponent {
|
|||||||
.map(key => files[key])
|
.map(key => files[key])
|
||||||
.map((file, index) => (
|
.map((file, index) => (
|
||||||
<ReflexContainer key={file.key + index} orientation='horizontal'>
|
<ReflexContainer key={file.key + index} orientation='horizontal'>
|
||||||
{index !== 0 && <ReflexSplitter />}
|
{index !== 0 && <ReflexSplitter propagate={true} {...this.resizeProps} />}
|
||||||
<ReflexElement
|
<ReflexElement
|
||||||
flex={1}
|
flex={1}
|
||||||
propagateDimensions={true}
|
propagateDimensions={true}
|
||||||
renderOnResize={true}
|
renderOnResize={true}
|
||||||
renderOnResizeRate={20}
|
renderOnResizeRate={20}
|
||||||
|
{...this.resizeProps}
|
||||||
>
|
>
|
||||||
<Editor {...file} fileKey={file.key} />
|
<Editor {...file} fileKey={file.key} />
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
{index + 1 === Object.keys(files).length && (
|
{index + 1 === Object.keys(files).length && (
|
||||||
<ReflexSplitter propagate={true} />
|
<ReflexSplitter propagate={true} {...this.resizeProps} />
|
||||||
)}
|
)}
|
||||||
{index + 1 === Object.keys(files).length ? (
|
{index + 1 === Object.keys(files).length ? (
|
||||||
<ReflexElement
|
<ReflexElement
|
||||||
@@ -172,6 +195,7 @@ class ShowClassic extends PureComponent {
|
|||||||
propagateDimensions={true}
|
propagateDimensions={true}
|
||||||
renderOnResize={true}
|
renderOnResize={true}
|
||||||
renderOnResizeRate={20}
|
renderOnResizeRate={20}
|
||||||
|
{...this.resizeProps}
|
||||||
>
|
>
|
||||||
<Output
|
<Output
|
||||||
defaultOutput={`
|
defaultOutput={`
|
||||||
@@ -196,18 +220,18 @@ class ShowClassic extends PureComponent {
|
|||||||
<Helmet title={`${blockNameTitle} | Learn freeCodeCamp`} />
|
<Helmet title={`${blockNameTitle} | Learn freeCodeCamp`} />
|
||||||
<ToolPanel guideUrl={guideUrl} />
|
<ToolPanel guideUrl={guideUrl} />
|
||||||
<ReflexContainer orientation='vertical'>
|
<ReflexContainer orientation='vertical'>
|
||||||
<ReflexElement flex={1}>
|
<ReflexElement flex={1} {...this.resizeProps}>
|
||||||
<SidePanel
|
<SidePanel
|
||||||
className='full-height'
|
className='full-height'
|
||||||
description={description}
|
description={description}
|
||||||
title={blockNameTitle}
|
title={blockNameTitle}
|
||||||
/>
|
/>
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
<ReflexSplitter />
|
<ReflexSplitter propagate={true} {...this.resizeProps} />
|
||||||
<ReflexElement flex={1}>{editors}</ReflexElement>
|
<ReflexElement flex={1} {...this.resizeProps}>{editors}</ReflexElement>
|
||||||
<ReflexSplitter />
|
<ReflexSplitter propagate={true} {...this.resizeProps} />
|
||||||
<ReflexElement flex={0.5}>
|
<ReflexElement flex={0.5} {...this.resizeProps}>
|
||||||
{showPreview ? <Preview className='full-height' /> : null}
|
{showPreview ? <Preview className='full-height' disableIframe={this.state.resizing} /> : null}
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<TestSuite tests={tests} />
|
<TestSuite tests={tests} />
|
||||||
</ReflexElement>
|
</ReflexElement>
|
||||||
|
@@ -11,10 +11,9 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: end;
|
align-items: end;
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.monaco-menu .action-label {
|
.monaco-menu .action-label {
|
||||||
color: #a2bd9b;
|
color: #a2bd9b;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
@@ -39,8 +39,6 @@ class Output extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeOutput = () => this._editor.layout();
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { output, defaultOutput, height } = this.props;
|
const { output, defaultOutput, height } = this.props;
|
||||||
return (
|
return (
|
||||||
|
@@ -1,17 +1,41 @@
|
|||||||
import React from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import './preview.css';
|
import './preview.css';
|
||||||
|
|
||||||
const mainId = 'fcc-main-frame';
|
const mainId = 'fcc-main-frame';
|
||||||
|
|
||||||
export function Preview() {
|
const propTypes = {
|
||||||
return (
|
className: PropTypes.string,
|
||||||
<div className='challenge-preview'>
|
disableIframe: PropTypes.bool
|
||||||
<iframe className={'challenge-preview-frame'} id={mainId} />
|
};
|
||||||
</div>
|
|
||||||
);
|
class Preview extends PureComponent {
|
||||||
|
constructor(...props) {
|
||||||
|
super(...props)
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
iframeStatus: this.props.disableIframe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
if (this.props.disableIframe !== nextProps.disableIframe) {
|
||||||
|
this.setState({ iframeStatus: !this.state.iframeStatus })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const iframeToggle = this.state.iframeStatus ? 'disable' : 'enable';
|
||||||
|
return (
|
||||||
|
<div className={`challenge-preview ${iframeToggle}-iframe`}>
|
||||||
|
<iframe className={'challenge-preview-frame'} id={mainId} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Preview.displayName = 'Preview';
|
Preview.displayName = 'Preview';
|
||||||
|
Preview.propTypes = propTypes;
|
||||||
|
|
||||||
export default Preview;
|
export default Preview;
|
||||||
|
@@ -10,4 +10,12 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enable-iframe {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable-iframe {
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
Reference in New Issue
Block a user