-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisual-override.js
executable file
·80 lines (67 loc) · 2.96 KB
/
visual-override.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Custom function used to generate the output of the override.css file
*/
var generateOverride = function (params) {
let output = '';
if (params.minFontSize !== '1' || params.maxFontSize !== '1.5') {
output += `
html {
font-size: ${params.minFontSize}rem;
}
@media screen and (min-width: 20rem) {
html {
font-size: calc(${params.minFontSize}rem + (${params.maxFontSize} - ${params.minFontSize}) * ((100vw - 20rem) / 220));
}
}
@media screen and (min-width: 240rem) {
html {
font-size: ${params.maxFontSize}rem;
}
}`;
}
if (params.primaryColor !== '#A6752E') {
output += `
input[type=checkbox]:checked + label:before{
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 8'%3e%3cpolygon points='9.53 0 4.4 5.09 1.47 2.18 0 3.64 2.93 6.54 4.4 8 5.87 6.54 11 1.46 9.53 0' fill='${params.primaryColor.replace('#', '%23')}'/%3e%3c/svg%3e");
}
input[type=radio]:checked + label:before {
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3ccircle cx='4' cy='4' r='4' fill='${params.primaryColor.replace('#', '%23')}'/%3e%3c/svg%3e");
}`;
}
if (params.imageEffects) {
if (params.imageFilter !== '#saturate' || params.imageFilterValue !== '0') {
output += `
.hero > img {
-webkit-filter: ${params.imageFilter}(${params.imageFilterValue});
filter: ${params.imageFilter}(${params.imageFilterValue});
}`;
}
}
if (params.galleryItemGap !== '0.5rem') {
output += `
.gallery__item {
padding: ${params.galleryItemGap};
}
.gallery {
margin: calc(1.5rem + 1vw) -${params.galleryItemGap};
}`;
}
if(params.galleryZoom !== true) {
output += `
.pswp--zoom-allowed .pswp__img {
cursor: default !important
}`;
}
if (params.lazyLoadEffect === 'fadein') {
output += `
img[loading] {
opacity: 0;
}
img.is-loaded {
opacity: 1;
transition: opacity 1s cubic-bezier(0.215, 0.61, 0.355, 1);
}`;
}
return output;
}
module.exports = generateOverride;