2016-09-30 16:25:15 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
|
2016-11-11 17:54:58 -02:00
|
|
|
function isVisible(field) {
|
|
|
|
return field.get('widget') !== 'hidden';
|
|
|
|
}
|
|
|
|
|
2016-11-23 16:23:32 -02:00
|
|
|
const style = {
|
|
|
|
fontFamily: 'Roboto, "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif',
|
|
|
|
};
|
|
|
|
|
2016-10-21 20:42:14 -02:00
|
|
|
export default function Preview({ collection, fields, widgetFor }) {
|
|
|
|
if (!collection || !fields) {
|
2016-09-30 16:38:10 +02:00
|
|
|
return null;
|
2016-09-30 16:25:15 +02:00
|
|
|
}
|
2016-09-30 16:38:10 +02:00
|
|
|
return (
|
2016-11-23 16:23:32 -02:00
|
|
|
<div style={style}>
|
2016-11-11 17:54:58 -02:00
|
|
|
{fields.filter(isVisible).map(field => widgetFor(field.get('name')))}
|
2016-09-30 16:38:10 +02:00
|
|
|
</div>
|
|
|
|
);
|
2016-09-30 16:25:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Preview.propTypes = {
|
|
|
|
collection: ImmutablePropTypes.map.isRequired,
|
|
|
|
entry: ImmutablePropTypes.map.isRequired,
|
2016-10-21 20:42:14 -02:00
|
|
|
fields: ImmutablePropTypes.list.isRequired,
|
2017-01-10 22:23:22 -02:00
|
|
|
getAsset: PropTypes.func.isRequired,
|
2016-09-30 16:38:10 +02:00
|
|
|
widgetFor: PropTypes.func.isRequired,
|
2016-09-30 16:25:15 +02:00
|
|
|
};
|