diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/components/Modal.jsx | 6 | ||||
| -rw-r--r-- | client/components/Paintings.jsx | 17 | ||||
| -rw-r--r-- | client/util.js | 9 |
3 files changed, 22 insertions, 10 deletions
diff --git a/client/components/Modal.jsx b/client/components/Modal.jsx index fded5e2..2d7cc13 100644 --- a/client/components/Modal.jsx +++ b/client/components/Modal.jsx @@ -1,5 +1,6 @@ import { h, Component } from 'preact' import { Link } from 'react-router-dom' +import { randrange } from '../util' export default class Modal extends Component { render() { @@ -14,7 +15,7 @@ export default class Modal extends Component { ? 'modal visible' : 'modal' - const style = 'background-color:hsl(' + randint(360) + ',20%,95%)' + const style = 'background-color:hsl(' + randrange(0,140) + ',100%,98%)' return ( <div class={className} style={style}> @@ -25,6 +26,3 @@ export default class Modal extends Component { ) } } - -function randint(n){ return (Math.random()*n)|0 } -function randrange(n){ return (Math.random()*n)|0 }
\ No newline at end of file diff --git a/client/components/Paintings.jsx b/client/components/Paintings.jsx index 93b24eb..a2eb601 100644 --- a/client/components/Paintings.jsx +++ b/client/components/Paintings.jsx @@ -1,6 +1,6 @@ import { h, Component } from 'preact' import { Link } from 'react-router-dom' -import util from '../util' +import { randrange } from '../util' export default class Paintings extends Component { constructor() { @@ -8,10 +8,13 @@ export default class Paintings extends Component { } render() { const paintings = this.props.data.painting.map( (painting, i) => { + painting.style = painting.style || 'background-color:hsl(' + randrange(300,460) + ',50%,98%)' return ( - <div class='cell' key={i}> + <div class='cell' key={i} style={painting.style}> <div class='painting'> - <div class='image' style={'background-image: url(' + painting.image.uri + ')'} /> + <Link to={'/painting/' + painting.id}> + <div class='image' style={'background-image: url(' + painting.image.uri + ')'} /> + </Link> </div> <div class='about'> <div> @@ -33,9 +36,13 @@ export default class Paintings extends Component { const page = ( <div class='cell'> <div class='painting'> - <div class='image' style={'background-image: url(' + about.image.uri + ')'} /> + <a href='http://asdf.us/pepper' target='_blank'> + <div class='image' style={'background-image: url(' + about.image.uri + ')'} /> + </a> + </div> + <div class='about'> + <div dangerouslySetInnerHTML={{ __html: body }} /> </div> - <div class='about' dangerouslySetInnerHTML={{ __html: body }} /> </div> ) return ( diff --git a/client/util.js b/client/util.js index 0fe17e9..6b1e274 100644 --- a/client/util.js +++ b/client/util.js @@ -6,5 +6,12 @@ const isDesktop = ! isMobile document.body.classList.add(isDesktop ? 'desktop' : 'mobile') -export default { isIphone, isIpad, isAndroid, isMobile, isDesktop } +function randint(n){ return (Math.random()*n)|0 } +function randrange(a,b){ return (Math.random()*(b-a)+a)|0 } +function choice(a){ return a[randint(a.length)] } + +export { + isIphone, isIpad, isAndroid, isMobile, isDesktop, + randint, randrange, choice, +} |
