static-cms/src/components/PreviewPane.js

24 lines
610 B
JavaScript
Raw Normal View History

2016-05-30 16:55:32 -07:00
import React from 'react';
import Widgets from './Widgets';
export default class PreviewPane extends React.Component {
previewFor(field) {
const { entry } = this.props;
const widget = Widgets[field.get('widget')] || Widgets._unknown;
return React.createElement(widget.Preview, {
key: field.get('name'),
field: field,
value: entry.get(field.get('name'))
});
}
render() {
const { collection } = this.props;
if (!collection) { return null; }
return <div>
{collection.get('fields').map((field) => <div>{this.previewFor(field)}</div>)}
</div>;
}
}