improved background rendering slightly

This commit is contained in:
Danny Coates 2018-06-21 11:28:31 -07:00
parent ff092d3d84
commit 863a2e9c29
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
3 changed files with 17 additions and 17 deletions

View file

@ -1,14 +1,12 @@
const html = require('choo/html');
const assets = require('../../../common/assets');
module.exports = function(state) {
if (!state.backgroundUrl) {
const backgrounds = assets.match(/background/);
state.backgroundUrl =
backgrounds[Math.floor(Math.random() * backgrounds.length)];
if (!state.backgroundClass) {
const backgrounds = assets.match(/background_/);
state.backgroundClass = `background_${Math.floor(
Math.random() * backgrounds.length
) + 1}`;
}
return html`<div class="background">
<img src="${state.backgroundUrl}">
</div>`;
return state.backgroundClass;
};