adding close preview
This commit is contained in:
parent
f9e2b28d27
commit
1f5db5ab3c
@ -1,15 +1,19 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import SplitPane from 'react-split-pane';
|
import SplitPane from 'react-split-pane';
|
||||||
|
import Button from 'react-toolbox/lib/button';
|
||||||
import { ScrollSync, ScrollSyncPane } from '../ScrollSync';
|
import { ScrollSync, ScrollSyncPane } from '../ScrollSync';
|
||||||
import ControlPane from '../ControlPanel/ControlPane';
|
import ControlPane from '../ControlPanel/ControlPane';
|
||||||
import PreviewPane from '../PreviewPane/PreviewPane';
|
import PreviewPane from '../PreviewPane/PreviewPane';
|
||||||
import Toolbar from './EntryEditorToolbar';
|
import Toolbar from './EntryEditorToolbar';
|
||||||
import styles from './EntryEditor.css';
|
import styles from './EntryEditor.css';
|
||||||
|
|
||||||
|
const PREVIEW_STATE = 'cms.preview-state';
|
||||||
|
|
||||||
class EntryEditor extends Component {
|
class EntryEditor extends Component {
|
||||||
state = {
|
state = {
|
||||||
showEventBlocker: false,
|
showEventBlocker: false,
|
||||||
|
previewOpen: localStorage.getItem(PREVIEW_STATE) === "open",
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSplitPaneDragStart = () => {
|
handleSplitPaneDragStart = () => {
|
||||||
@ -25,6 +29,15 @@ class EntryEditor extends Component {
|
|||||||
this.props.onPersist();
|
this.props.onPersist();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleTogglePreview = () => {
|
||||||
|
const { previewOpen } = this.state;
|
||||||
|
const newPreviewState = !previewOpen ? "open" : "closed";
|
||||||
|
this.setState(
|
||||||
|
{ previewOpen: !previewOpen },
|
||||||
|
localStorage.setItem(PREVIEW_STATE, newPreviewState)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
collection,
|
collection,
|
||||||
@ -40,20 +53,13 @@ class EntryEditor extends Component {
|
|||||||
onCancelEdit,
|
onCancelEdit,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
const { previewOpen } = this.state;
|
||||||
const controlClassName = `${ styles.controlPane } ${ this.state.showEventBlocker && styles.blocker }`;
|
const controlClassName = `${ styles.controlPane } ${ this.state.showEventBlocker && styles.blocker }`;
|
||||||
const previewClassName = `${ styles.previewPane } ${ this.state.showEventBlocker && styles.blocker }`;
|
const previewClassName = `${ styles.previewPane } ${ this.state.showEventBlocker && styles.blocker }`;
|
||||||
return (
|
|
||||||
<div className={styles.root}>
|
|
||||||
<ScrollSync>
|
|
||||||
<div className={styles.container}>
|
|
||||||
<SplitPane
|
|
||||||
defaultSize="50%"
|
|
||||||
onDragStarted={this.handleSplitPaneDragStart}
|
|
||||||
onDragFinished={this.handleSplitPaneDragFinished}
|
|
||||||
>
|
|
||||||
<ScrollSyncPane>
|
|
||||||
<div className={controlClassName}>
|
|
||||||
|
|
||||||
|
const editor = (
|
||||||
|
<div className={controlClassName}>
|
||||||
|
<Button onClick={this.handleTogglePreview}> TOGGLE PREVIEW </Button>
|
||||||
<ControlPane
|
<ControlPane
|
||||||
collection={collection}
|
collection={collection}
|
||||||
entry={entry}
|
entry={entry}
|
||||||
@ -67,8 +73,19 @@ class EntryEditor extends Component {
|
|||||||
onRemoveAsset={onRemoveAsset}
|
onRemoveAsset={onRemoveAsset}
|
||||||
ref={c => this.controlPaneRef = c} // eslint-disable-line
|
ref={c => this.controlPaneRef = c} // eslint-disable-line
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const editorWithPreivew = (
|
||||||
|
<ScrollSync>
|
||||||
|
<div className={styles.container}>
|
||||||
|
<SplitPane
|
||||||
|
defaultSize="50%"
|
||||||
|
onDragStarted={this.handleSplitPaneDragStart}
|
||||||
|
onDragFinished={this.handleSplitPaneDragFinished}
|
||||||
|
>
|
||||||
|
<ScrollSyncPane>
|
||||||
|
{editor}
|
||||||
</ScrollSyncPane>
|
</ScrollSyncPane>
|
||||||
<div className={previewClassName}>
|
<div className={previewClassName}>
|
||||||
<PreviewPane
|
<PreviewPane
|
||||||
@ -81,7 +98,11 @@ class EntryEditor extends Component {
|
|||||||
</div>
|
</div>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
</div>
|
</div>
|
||||||
</ ScrollSync>
|
</ScrollSync>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div className={styles.root}>
|
||||||
|
{previewOpen === true ? editorWithPreivew : editor}
|
||||||
<div className={styles.footer}>
|
<div className={styles.footer}>
|
||||||
<Toolbar
|
<Toolbar
|
||||||
isPersisting={entry.get('isPersisting')}
|
isPersisting={entry.get('isPersisting')}
|
||||||
@ -89,7 +110,6 @@ class EntryEditor extends Component {
|
|||||||
onCancelEdit={onCancelEdit}
|
onCancelEdit={onCancelEdit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user