Updated styles for entry page layout.

This removes the need for resize handlers and height calc anymore.
Re-written the component in a functional way.
This commit is contained in:
Andrey Okonetchnikov 2016-09-28 12:24:17 +02:00
parent 4192945a3b
commit d09e9b40e4
3 changed files with 26 additions and 47 deletions

View File

@ -1,26 +1,27 @@
.entryEditor { .root {
position: absolute;
top: 64px;
bottom: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%;
} }
.container { .container {
flex: 1;
display: flex; display: flex;
height: 100%;
} }
.footer { .footer {
flex: 0;
background: #fff; background: #fff;
height: 45px; height: 45px;
border-top: 1px solid #e8eae8; border-top: 1px solid #e8eae8;
padding: 10px 20px; padding: 10px 20px;
z-index: 10;
} }
.controlPane { .controlPane {
width: 50%; flex: 1;
max-height: 100%;
overflow: auto; overflow: auto;
padding: 0 20px; padding: 0 20px;
border-right: 1px solid #e8eae8; border-right: 1px solid #e8eae8;
} }
.previewPane { .previewPane {
width: 50%; flex: 1;
} }

View File

@ -4,57 +4,35 @@ import ControlPane from './ControlPane';
import PreviewPane from './PreviewPane'; import PreviewPane from './PreviewPane';
import styles from './EntryEditor.css'; import styles from './EntryEditor.css';
export default class EntryEditor extends React.Component { export default function EntryEditor(props) {
constructor(props) { const { collection, entry, getMedia, onChange, onAddMedia, onRemoveMedia, onPersist } = props;
super(props);
this.state = {};
this.handleResize = this.handleResize.bind(this);
}
componentDidMount() { return (
this.calculateHeight(); <div className={styles.root}>
window.addEventListener('resize', this.handleResize, false);
}
componengWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}
handleResize() {
this.calculateHeight();
}
calculateHeight() {
const height = window.innerHeight - 54;
console.log('setting height to %s', height);
this.setState({ height });
}
render() {
const { collection, entry, getMedia, onChange, onAddMedia, onRemoveMedia, onPersist } = this.props;
const { height } = this.state;
return <div className={styles.entryEditor} style={{ height }}>
<div className={styles.container}> <div className={styles.container}>
<div className={styles.controlPane}> <div className={styles.controlPane}>
<ControlPane <ControlPane
collection={collection} collection={collection}
entry={entry} entry={entry}
getMedia={getMedia} getMedia={getMedia}
onChange={onChange} onChange={onChange}
onAddMedia={onAddMedia} onAddMedia={onAddMedia}
onRemoveMedia={onRemoveMedia} onRemoveMedia={onRemoveMedia}
/> />
</div> </div>
<div className={styles.previewPane}> <div className={styles.previewPane}>
<PreviewPane collection={collection} entry={entry} getMedia={getMedia} /> <PreviewPane
collection={collection}
entry={entry}
getMedia={getMedia}
/>
</div> </div>
</div> </div>
<div className={styles.footer}> <div className={styles.footer}>
<button onClick={onPersist}>Save</button> <button onClick={onPersist}>Save</button>
</div> </div>
</div>; </div>
} );
} }
EntryEditor.propTypes = { EntryEditor.propTypes = {

View File

@ -1,6 +1,6 @@
.frame { .frame {
width: 100%; width: 100%;
height: 100vh; height: 100%;
border: none; border: none;
background: #fff; background: #fff;
} }