Skip to content

Commit

Permalink
Fixed bug with splitting lines on preview mode change
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartozzz committed Sep 22, 2016
1 parent 9c5b6ce commit cbcaae4
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
4 changes: 2 additions & 2 deletions client/scripts/components/App.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import Alerts from "./alerts/Alerts.react";

export default class App extends Component {
state = {
isPreviewVisible : false,
isPreviewVisible : false
}

togglePreview = () => {
this.setState( {
isPreviewVisible : ! this.state.isPreviewVisible
} )
} );
}

render() {
Expand Down
29 changes: 15 additions & 14 deletions client/scripts/components/AppContent.react.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import React, { Component } from "react";
import className from "classnames";

import SplitPane from "react-split-pane";
import EditorEditable from "./editor/EditorEditable.react";
import EditorPreview from "./editor/EditorPreview.react";

export default class AppContent extends Component {
renderSplitPane() {
if ( ! this.props.isPreviewVisible ) {
return <EditorEditable />;
}

return (
<SplitPane split="vertical" minSize={50} defaultSize="50%" primary="second">
<EditorEditable />
<EditorPreview />
</SplitPane>
)
}

render() {
const splitPaneClasses = className( "app-content-pane", {
"is-preview-hidden" : ! this.props.isPreviewVisible
} );

return (
<div className="app-content">
<div className="app-content-main">
{this.renderSplitPane()}
<SplitPane
split="vertical"
minSize={300}
maxSize={-300}
defaultSize="50%"
className={splitPaneClasses}
>
<EditorEditable />
<EditorPreview />
</SplitPane>
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions client/scripts/stores/EditorStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class EditorStore extends BaseStore {
constructor() {
super();

this.path = null;
this.content = null;
this.path = "";
this.content = "";

this.subscribe( action => {
switch ( action.type ) {
Expand Down
10 changes: 10 additions & 0 deletions client/styles/components/_appContent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,15 @@

.app-content-main {
flex: 1;

.is-preview-hidden {
.Pane1 {
width: 100vw !important;
}

.Pane2 {
width: 0 !important;
}
}
}
}
6 changes: 3 additions & 3 deletions client/styles/vendor/_codeMirror.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
.CodeMirror-line {
line-height: 1.35rem;

padding-left: 7.5%;
padding-right: 7.5%;
padding-left: 2rem;
padding-right: 2rem;
}

.CodeMirror-cursor {
Expand Down Expand Up @@ -76,7 +76,7 @@

.cm-quote:before {
position: absolute;
left: 5%;
left: 1rem;

width: .5rem;
height: 100%;
Expand Down

0 comments on commit cbcaae4

Please sign in to comment.