forked from GetPublii/theme-Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visual-override.js
executable file
·192 lines (165 loc) · 4.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
* 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.3') {
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) / 113));
}
}
@media screen and (min-width: 133rem) {
html {
font-size: ${params.maxFontSize}rem;
}
}`;
}
if(params.textColor !== '#343434') {
output += `
body {
color: ${params.textColor};
}`;
}
if(params.headingColor !== '#343434') {
output += `
h1,
h2,
h3,
h4,
h5,
h6 {
color: ${params.headingColor};
}`;
}
if(params.linkColor !== '#343434') {
output += `
a {
color: ${params.linkColor};
}
.post__entry a:hover,
.post__entry a:active,
.post__entry a:focus {
color: ${params.linkColor};
}`;
}
if(params.linkHoverColor !== '#3949ab') {
output += `
a:hover,
a:active,
a:focus {
color: ${params.linkHoverColor};
}
.post__entry a {
color: ${params.linkHoverColor};
}
.post__nav__link:hover h5 {
color: ${params.linkHoverColor};
}`;
}
if(params.primaryColor !== '#3949ab') {
output += `
.btn,
[type=button],
[type=submit],
button {
background: ${params.primaryColor};
}
[type=text]:focus,
[type=url]:focus,
[type=tel]:focus,
[type=number]:focus,
[type=email]:focus,
[type=search]:focus,
textarea:focus,
select:focus {
-webkit-box-shadow: inset 0 0 2px ${params.primaryColor};
box-shadow: inset 0 0 2px ${params.primaryColor};
}
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");
}
select[multiple]:focus {
border-color: ${params.primaryColor};
}
.box__title {
color: ${params.primaryColor};
}
.page-header__title {
color: ${params.primaryColor};
}
.cookie-popup,
.cookie-popup__save {
background: ${params.primaryColor};
}`;
}
if(params.mainWidth !== '42rem' || params.sidebarWidth !== '20rem') {
output += `
@media all and (min-width: 56.25em) {
.container {
grid-template-columns: 1fr minmax(auto, ${params.mainWidth}) ${params.sidebarWidth} 1fr;
}
}`;
}
if(params.submenu === 'custom') {
output += `
@media all and (min-width: 56.25em) {
.navbar__submenu {
width: ${params.submenuWidth}rem;
}
}`;
}
if(params.linkColorMenu !== '#343434') {
output += `
.navbar__menu li a,
.navbar__menu li span {
color: ${params.linkColorMenu};
}`;
}
if(params.linkHoverColorMenu !== '#3949ab') {
output += `
.navbar__menu li a:hover:not(span),
.navbar__menu li span:hover:not(span) {
color: ${params.linkHoverColorMenu};
}`;
}
if(params.heightHero !== '29rem') {
output += `
.hero {
min-height: ${params.heightHero}
}
.hero__image {
min-height: ${params.heightHero}
}`;
}
if(params.headingHeroColor !== '#ffffff') {
output += `
.hero__text > h1 {
color: ${params.headingHeroColor};
}`;
}
if(params.textHeroColor !== '#ffffff') {
output += `
.hero__text {
color: ${params.textHeroColor};
}`;
}
if(params.galleryItemGap !== '0.53333rem') {
output += `
gallery__item {
padding: ${params.galleryItemGap};
}
gallery {
margin: calc(1.6rem + 1vw) -${params.galleryItemGap};
}`;
}
return output;
}
module.exports = generateOverride;