From 32858022edf1142d2b05e98290d8cca9b6a8c87a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Jun 2017 20:59:00 +0200 Subject: details page --- client/components/Details.jsx | 98 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 client/components/Details.jsx (limited to 'client/components/Details.jsx') diff --git a/client/components/Details.jsx b/client/components/Details.jsx new file mode 100644 index 0000000..fff06e0 --- /dev/null +++ b/client/components/Details.jsx @@ -0,0 +1,98 @@ +import { h, Component } from 'preact' +import { Link } from 'react-router-dom' + +export default class Details extends Component { + constructor(){ + super() + } + onWheel(e){ + e.stopPropagation() + } + render() { + const painting = this.props.painting + if (! painting) return + const source_images = findImages(painting.parameters) + const parameters = breakUpJSON(painting.parameters) + return ( +
+ < Go back +

{painting.title}

+
+ {painting.medium}
+ {painting.date}
+ {painting.image.caption} +
+ + {painting.originalImage && +
+

Original Image

+ +
+ } + {painting.parameters && +
+

Creation Parameters

+
+ {parameters} +
+

Source Images

+ {source_images} +
+ } +
+ ) + } +} + +class PossiblyBadImage extends Component { + constructor(){ + super() + this.state = { error: false } + this.onError = this.onError.bind(this) + } + onError(){ + this.setState({ error: true }) + } + render(){ + if (this.state.error) return + return ( + + ) + } +} + +function findImages(s) { + s = s || "" + const urlRegex = /(https?:\/\/[^\s]+)/g; + let match = urlRegex.exec(s); + let urls = [] + let url; + let seen = {}; + while (match != null) { + url = match[0].replace(/",?/,"") + if (url && ! seen[url]) { + seen[url] = true + urls.push( + + + + ) + } + match = urlRegex.exec(s); + } + return urls +} + +function breakUpJSON(ss){ + return (ss || '').split("} {").map( (s) => { + return ( +
+ {s} +
+
+
+ ) + }) +} \ No newline at end of file -- cgit v1.2.3-70-g09d2