diff --git a/src/components/EntryEditor/EntryEditor.js b/src/components/EntryEditor/EntryEditor.js index ff62080d..1c04fba8 100644 --- a/src/components/EntryEditor/EntryEditor.js +++ b/src/components/EntryEditor/EntryEditor.js @@ -1,7 +1,7 @@ import React, { Component, PropTypes } from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ControlPane from '../ControlPanel/ControlPane'; -import PreviewPane from '../PreviewPane'; +import PreviewPane from '../PreviewPane/PreviewPane'; import styles from './EntryEditor.css'; export default class EntryEditor extends Component { diff --git a/src/components/PreviewPane/Preview.js b/src/components/PreviewPane/Preview.js new file mode 100644 index 00000000..0d1dabc0 --- /dev/null +++ b/src/components/PreviewPane/Preview.js @@ -0,0 +1,39 @@ +import React, { PropTypes } from 'react'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import { resolveWidget } from '../Widgets'; + +export default class Preview extends React.Component { + + previewFor(field) { + const { entry, getMedia } = this.props; + const widget = resolveWidget(field.get('widget')); + return React.createElement(widget.preview, { + field: field, + value: entry.getIn(['data', field.get('name')]), + getMedia: getMedia, + }); + } + + render() { + const { collection } = this.props; + if (!collection) { + return null; + } + + return
+ { + collection.get('fields').map(field => ( +
+ {this.previewFor(field)} +
+ )) + } +
; + } +} + +Preview.propTypes = { + collection: ImmutablePropTypes.map.isRequired, + entry: ImmutablePropTypes.map.isRequired, + getMedia: PropTypes.func.isRequired, +}; diff --git a/src/components/PreviewPane.css b/src/components/PreviewPane/PreviewPane.css similarity index 100% rename from src/components/PreviewPane.css rename to src/components/PreviewPane/PreviewPane.css diff --git a/src/components/PreviewPane.js b/src/components/PreviewPane/PreviewPane.js similarity index 72% rename from src/components/PreviewPane.js rename to src/components/PreviewPane/PreviewPane.js index 36daa6ca..59ab0e4f 100644 --- a/src/components/PreviewPane.js +++ b/src/components/PreviewPane/PreviewPane.js @@ -1,48 +1,11 @@ import React, { PropTypes } from 'react'; import { render } from 'react-dom'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import registry from '../lib/registry'; -import { resolveWidget } from './Widgets'; +import registry from '../../lib/registry'; +import { resolveWidget } from '../Widgets'; +import Preview from './Preview'; import styles from './PreviewPane.css'; -class Preview extends React.Component { - - previewFor(field) { - const { entry, getMedia } = this.props; - const widget = resolveWidget(field.get('widget')); - return React.createElement(widget.preview, { - field: field, - value: entry.getIn(['data', field.get('name')]), - getMedia: getMedia, - }); - } - - render() { - const { collection } = this.props; - if (!collection) { - return null; - } - - return
- { - collection.get('fields').map(field => ( -
- {this.previewFor(field)} -
- )) - } -
; - } -} - -Preview.propTypes = { - collection: ImmutablePropTypes.map.isRequired, - entry: ImmutablePropTypes.map.isRequired, - getMedia: PropTypes.func.isRequired, -}; - export default class PreviewPane extends React.Component { componentDidUpdate(prevProps) {