forked from stokingerl/hyper-aww
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (34 loc) · 975 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const urlArray = require("./image-array.js").urlArray;
const background = '#222222';
const getCss = (randomUrl) => {
const css = `
body:before {
content: ' ';
display: block;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
opacity: 0.069;
background-image: url('` + randomUrl + `');
background-repeat: no-repeat;
background-position: 50% 0;
-ms-background-size: cover;
-o-background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
background-size: cover;
}`;
return css;
}
exports.decorateConfig = config => {
const randomUrl = urlArray[Math.floor(Math.random() * urlArray.length)];
const css = getCss(randomUrl);
const newObj = Object.assign({}, config, {
css: config.css ? config.css + css : css,
backgroundColor: background
});
return newObj;
}