aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/cms-preview-templates/values.js
diff options
context:
space:
mode:
authorMathias Biilmann <info@mathias-biilmann.net>2017-12-07 10:20:11 -0800
committerGitHub <noreply@github.com>2017-12-07 10:20:11 -0800
commit8745627e7d171b4b1fd2062b4328bf23899663e9 (patch)
tree5f0399bf843f5a3055e0bb6d3da6774b1a01f307 /src/js/cms-preview-templates/values.js
parent2db9a63c54df63e95c1fbf39391d201c98a62b86 (diff)
parenta4bfd44601069a1b054c396ad754c8a2b7ec688c (diff)
Merge pull request #11 from netlify-templates/update-for-cms-1-0
Update for CMS 1.0
Diffstat (limited to 'src/js/cms-preview-templates/values.js')
-rw-r--r--src/js/cms-preview-templates/values.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/js/cms-preview-templates/values.js b/src/js/cms-preview-templates/values.js
new file mode 100644
index 0000000..173d0c9
--- /dev/null
+++ b/src/js/cms-preview-templates/values.js
@@ -0,0 +1,46 @@
+import React from "react";
+import { List } from 'immutable';
+
+import Jumbotron from "./components/jumbotron";
+
+const MediaBlock = ({heading, text, imageUrl, reverse}) => {
+ const imageContainerClassName = reverse
+ ? "ph3-m w-50-m"
+ : "ph3-m w-50-m order-last-m";
+ return <div className="flex-m mhn3-m mb4">
+ <div className={imageContainerClassName}>
+ <img src={imageUrl} alt="" className="db mb2" />
+ </div>
+ <div className="ph3-m w-50-m">
+ <h3 className="f3 b lh-title mb1">{heading}</h3>
+ <p>{text}</p>
+ </div>
+ </div>;
+};
+
+export default class ValuesPreview extends React.Component {
+ render() {
+ const {entry, getAsset} = this.props;
+
+ let image = getAsset(entry.getIn(["data", "image"]));
+
+ // Bit of a nasty hack to make relative paths work as expected as a background image here
+ if (image && !image.fileObj) {
+ image = window.parent.location.protocol + "//" + window.parent.location.host + image;
+ }
+
+ const entryValues = entry.getIn(["data", "values"]);
+ const values = entryValues ? entryValues.toJS() : [];
+
+ return <div>
+ <Jumbotron image={image} title={entry.getIn(["data", "title"])} />
+ <div className="bg-off-white pv4">
+ <div className="mw7 center ph3 pt4">
+ {values.map(({text, heading, imageUrl}, i) =>
+ <MediaBlock key={i} text={text} heading={heading} imageUrl={imageUrl} reverse={i % 2 === 0} />
+ )}
+ </div>
+ </div>
+ </div>;
+ }
+}