Moved PreviewPane to a separate directory. Extracted Preview component to a separate file.
This commit is contained in:
parent
edf8abbc42
commit
f1eb93ee7f
@ -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 {
|
||||
|
39
src/components/PreviewPane/Preview.js
Normal file
39
src/components/PreviewPane/Preview.js
Normal file
@ -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 <div>
|
||||
{
|
||||
collection.get('fields').map(field => (
|
||||
<div key={field.get('name')}>
|
||||
{this.previewFor(field)}
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
Preview.propTypes = {
|
||||
collection: ImmutablePropTypes.map.isRequired,
|
||||
entry: ImmutablePropTypes.map.isRequired,
|
||||
getMedia: PropTypes.func.isRequired,
|
||||
};
|
@ -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 <div>
|
||||
{
|
||||
collection.get('fields').map(field => (
|
||||
<div
|
||||
key={field.get('name')}
|
||||
>
|
||||
{this.previewFor(field)}
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
Preview.propTypes = {
|
||||
collection: ImmutablePropTypes.map.isRequired,
|
||||
entry: ImmutablePropTypes.map.isRequired,
|
||||
getMedia: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default class PreviewPane extends React.Component {
|
||||
|
||||
componentDidUpdate(prevProps) {
|
Loading…
x
Reference in New Issue
Block a user