From 0b854ecccfe7832ba9a837605822a103fd9d8bc0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Jun 2017 00:50:15 +0200 Subject: clearing out old code --- client/components/App.jsx | 41 +++++++++++++++++++++++++++++++++++++++++ client/db.js | 33 +++++++++++++++++++++++++++++++++ client/index.jsx | 5 +++++ client/util.js | 10 ++++++++++ 4 files changed, 89 insertions(+) create mode 100644 client/components/App.jsx create mode 100644 client/db.js create mode 100644 client/index.jsx create mode 100644 client/util.js (limited to 'client') diff --git a/client/components/App.jsx b/client/components/App.jsx new file mode 100644 index 0000000..e478ea0 --- /dev/null +++ b/client/components/App.jsx @@ -0,0 +1,41 @@ +import { h, Component } from 'preact' +import db from '../db' + +export default class App extends Component { + constructor() { + super() + this.state = { + data: db.backupDB, + } + db.fetch( data => this.setState({ data }) ) + } + render() { + const paintings = this.state.data.painting.map( (painting, i) => { + return ( +
+
+
+
+
+
+
+ {painting.title} +
+ {painting.medium}
+ {painting.date}
+ {painting.image.caption}
+
+
+
+ ) + }) + return ( +
+
Procedural Paintings by Pepper
+
+ {paintings} +
+
+ ) + } +} diff --git a/client/db.js b/client/db.js new file mode 100644 index 0000000..8c3a6b5 --- /dev/null +++ b/client/db.js @@ -0,0 +1,33 @@ +function fetchDB(cb) { + let raw_db; + fetch('/db.json', { + method: 'GET' + }).then(res => { + if (res.status !== 200) { + return null + } + return res.json() + }).then(json => { + if (json) { + raw_db = parse(json) + } + cb(raw_db) + }).catch((err) => { + console.warn(err) + }) +} + +function parse(db) { + Object.keys(db).forEach(key => { + db[key] = db[key] + .filter((el) => ! el.disabled) + .sort((a,b) => a.__index, document.getElementById('container')) diff --git a/client/util.js b/client/util.js new file mode 100644 index 0000000..fe8ec35 --- /dev/null +++ b/client/util.js @@ -0,0 +1,10 @@ +const isIphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) +const isIpad = (navigator.userAgent.match(/iPad/i)) +const isAndroid = (navigator.userAgent.match(/Android/i)) +const isMobile = isIphone || isIpad || isAndroid +const isDesktop = ! isMobile + +document.body.classList.add(isDesktop ? 'desktop' : 'mobile') + +export default { isIphone, isIpad, isAndroid, isMobile, isDesktop } + -- cgit v1.2.3-70-g09d2