2016-06-16 19:20:36 -03:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2016-05-30 16:55:32 -07:00
|
|
|
import ControlPane from './ControlPane';
|
|
|
|
import PreviewPane from './PreviewPane';
|
2016-09-11 23:08:18 +02:00
|
|
|
import styles from './EntryEditor.css';
|
2016-05-30 16:55:32 -07:00
|
|
|
|
2016-09-12 11:14:21 +02:00
|
|
|
export default class EntryEditor extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {};
|
|
|
|
this.handleResize = this.handleResize.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.calculateHeight();
|
|
|
|
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);
|
2016-09-13 15:30:58 +02:00
|
|
|
this.setState({ height });
|
2016-09-12 11:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { collection, entry, getMedia, onChange, onAddMedia, onRemoveMedia, onPersist } = this.props;
|
2016-09-13 15:30:58 +02:00
|
|
|
const { height } = this.state;
|
2016-09-12 11:14:21 +02:00
|
|
|
|
2016-09-13 15:30:58 +02:00
|
|
|
return <div className={styles.entryEditor} style={{ height }}>
|
2016-09-12 11:14:21 +02:00
|
|
|
<div className={styles.container}>
|
|
|
|
<div className={styles.controlPane}>
|
|
|
|
<ControlPane
|
|
|
|
collection={collection}
|
|
|
|
entry={entry}
|
|
|
|
getMedia={getMedia}
|
|
|
|
onChange={onChange}
|
|
|
|
onAddMedia={onAddMedia}
|
|
|
|
onRemoveMedia={onRemoveMedia}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.previewPane}>
|
|
|
|
<PreviewPane collection={collection} entry={entry} getMedia={getMedia} />
|
|
|
|
</div>
|
2016-05-30 16:55:32 -07:00
|
|
|
</div>
|
2016-09-12 11:14:21 +02:00
|
|
|
<div className={styles.footer}>
|
|
|
|
<button onClick={onPersist}>Save</button>
|
2016-06-16 19:20:36 -03:00
|
|
|
</div>
|
2016-09-12 11:14:21 +02:00
|
|
|
</div>;
|
|
|
|
}
|
2016-05-30 16:55:32 -07:00
|
|
|
}
|
2016-06-05 01:52:18 -07:00
|
|
|
|
2016-06-16 19:20:36 -03:00
|
|
|
EntryEditor.propTypes = {
|
|
|
|
collection: ImmutablePropTypes.map.isRequired,
|
|
|
|
entry: ImmutablePropTypes.map.isRequired,
|
|
|
|
getMedia: PropTypes.func.isRequired,
|
|
|
|
onAddMedia: PropTypes.func.isRequired,
|
|
|
|
onChange: PropTypes.func.isRequired,
|
|
|
|
onPersist: PropTypes.func.isRequired,
|
|
|
|
onRemoveMedia: PropTypes.func.isRequired,
|
|
|
|
};
|