Skip to content

Commit fa88aaf

Browse files
ghalsemonkeyiq
authored andcommitted
Allow themes to override chrome with custom properties
1 parent 23674db commit fa88aaf

2 files changed

Lines changed: 63 additions & 15 deletions

File tree

‎resources/css/default.scss‎

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@ $fa-font-path: "../webfonts";
1212

1313
$light-yellow: #fffdbf;
1414

15+
// Theming overrides using CSS custom properties. Note that all uses of var() are preceeded by a static fallback color.
16+
// Fallbacks could be removed if we don't care about older browsers such as IE11 and out-of-date embedded webviews.
17+
:root {
18+
/* Default red color scheme */
19+
--ssp-chrome-primary-background: #{$primaryBackground};
20+
--ssp-chrome-transition-background: #{$transitionBackground};
21+
--ssp-chrome-secondary-background: #{$secondaryBackground};
22+
--ssp-chrome-text: #{$chromeText};
23+
--ssp-chrome-text-shadow: #{$chromeTextShadow};
24+
25+
/* small screen menu colors */
26+
--ssp-chrome-menu: var(--ssp-chrome-secondary-background, #e8410c);
27+
--ssp-chrome-menu-divider: var(--ssp-chrome-transition-background, #db0100);
28+
--ssp-chrome-menu-active: var(--ssp-chrome-primary-background, #b8002c);
29+
--ssp-chrome-menu-text: var(--ssp-chrome-text, #fff);
30+
31+
/* Loader dots color */
32+
--ssp-chrome-loader: var(--ssp-chrome-transition-background, #db0100);
33+
34+
/* primary button colors */
35+
--ssp-primary-button: var(--ssp-chrome-transition-background, #db0100);
36+
--ssp-primary-button-text: var(--ssp-chrome-text, #fff);
37+
}
38+
1539
/************************************************************
1640
* GENERAL
1741
************************************************************/
@@ -180,6 +204,7 @@ appears on the left side of the page.
180204
bottom: 0;
181205
z-index: 1000; /* so the menu or its navicon stays above all content */
182206
background: $secondaryBackground;
207+
background: var(--ssp-chrome-menu);
183208
overflow-y: auto;
184209
-webkit-overflow-scrolling: touch;
185210
}
@@ -188,7 +213,8 @@ appears on the left side of the page.
188213
All anchors inside the menu should be styled like this.
189214
*/
190215
#menu a {
191-
color: #fff;
216+
color: $chromeText;
217+
color: var(--ssp-chrome-menu-text);
192218
border: none;
193219
padding: 0.6em 0 0.6em 0.6em;
194220
}
@@ -208,6 +234,7 @@ Add that light border to separate items into groups.
208234
#menu .pure-menu ul,
209235
#menu .pure-menu .menu-item-divided {
210236
border-top: 1px solid $transitionBackground;
237+
border-top: 1px solid var(--ssp-chrome-menu-divider);
211238
}
212239

213240
/*
@@ -216,22 +243,25 @@ This styles the selected menu item `<li>`.
216243
#menu .pure-menu-selected,
217244
#menu .pure-menu-heading {
218245
background: $primaryBackground;
219-
color: black;
246+
background: var(--ssp-chrome-menu-active);
247+
color: var(--ssp-chrome-menu-active-text, black);
220248
}
221249

222250
/*
223251
This styles a link within a selected menu item `<li>`.
224252
*/
225253
#menu .pure-menu-selected a {
226-
color: #fff;
254+
color: $chromeText;
255+
color: var(--ssp-chrome-menu-text);
227256
}
228257

229258
/*
230259
This styles the menu heading.
231260
*/
232261
#menu .pure-menu-heading {
233262
font-size: 110%;
234-
color: #fff;
263+
color: $chromeText;
264+
color: var(--ssp-chrome-menu-text);
235265
margin: 0;
236266
text-transform: none;
237267
}
@@ -268,7 +298,8 @@ small screens.
268298
.menu-link span {
269299
position: relative;
270300
display: block;
271-
color: #fff;
301+
color: $chromeText;
302+
color: var(--ssp-chrome-menu-link, var(--ssp-chrome-menu-text));
272303
}
273304

274305
.menu-link span,
@@ -280,6 +311,7 @@ small screens.
280311
.menu-link span:focus,
281312
.menu-link span:hover {
282313
color: #010101cc;
314+
color: var(--ssp-chrome-menu-link-active, #010101cc);
283315
}
284316

285317
/* -- Responsive Styles (Media Queries) ------------------------------------- */
@@ -308,6 +340,7 @@ HEADER
308340
#header {
309341
height: 6rem;
310342
background: linear-gradient(141deg, $primaryBackground 0%, $transitionBackground 51%, $secondaryBackground 75%);
343+
background: linear-gradient(141deg, var(--ssp-chrome-primary-background) 0%, var(--ssp-chrome-transition-background) 51%, var(--ssp-chrome-secondary-background) 75%);
311344
}
312345

313346
.logo-header {
@@ -319,8 +352,10 @@ HEADER
319352
#logo {
320353
font-family: sans-serif;
321354
font-size: 2.5em;
322-
color: white;
323-
text-shadow: 0 3px 2px #532900;
355+
color: $chromeText;
356+
color: var(--ssp-chrome-text);
357+
text-shadow: 0 3px 2px $chromeTextShadow;
358+
text-shadow: 0 3px 2px var(--ssp-chrome-text-shadow);
324359
}
325360

326361
.simple {
@@ -443,14 +478,17 @@ pre#xmlmetadata {
443478
#footer {
444479
width: 100%;
445480
background: linear-gradient(141deg, $primaryBackground 0%, $transitionBackground 51%, $secondaryBackground 75%);
481+
background: linear-gradient(141deg, var(--ssp-chrome-primary-background) 0%, var(--ssp-chrome-transition-background) 51%, var(--ssp-chrome-secondary-background) 75%);
446482
height: 4rem;
447483
padding: 2rem 0 0;
448484
text-align: center;
449-
color: white;
485+
color: $chromeText;
486+
color: var(--ssp-chrome-text);
450487

451488
a,
452489
a:visited {
453-
color: white;
490+
color: $chromeText;
491+
color: var(--ssp-chrome-text);
454492

455493
&:focus,
456494
&:hover {
@@ -579,12 +617,15 @@ html[dir="rtl"] .pure-select {
579617
}
580618

581619
.pure-button-red {
582-
background-color: #db0100;
583-
color: #fff;
620+
background-color: $transitionBackground;
621+
background-color: var(--ssp-primary-button);
622+
color: $chromeText;
623+
color: var(--ssp-primary-button-text);
584624

585625
&:hover,
586626
&:focus {
587627
background-color: #555;
628+
background-color: var(--ssp-primary-button-active, #555);
588629
padding: 0.5em 1em;
589630
}
590631
}
@@ -931,14 +972,17 @@ div.preferredidp {
931972
@keyframes shadowPulse {
932973
33% {
933974
background: #FFF;
934-
box-shadow: -24px 0 #db0100, 24px 0 #FFF;
975+
box-shadow: -24px 0 $transitionBackground, 24px 0 #FFF;
976+
box-shadow: -24px 0 var(--ssp-chrome-loader), 24px 0 #FFF;
935977
}
936978
66% {
937-
background: #db0100;
979+
background: $transitionBackground;
980+
background: var(--ssp-chrome-loader);
938981
box-shadow: -24px 0 #FFF, 24px 0 #FFF;
939982
}
940983
100% {
941984
background: #FFF;
942-
box-shadow: -24px 0 #FFF, 24px 0 #db0100;
985+
box-shadow: -24px 0 #FFF, 24px 0 $transitionBackground;
986+
box-shadow: -24px 0 #FFF, 24px 0 var(--ssp-chrome-loader);
943987
}
944988
}

‎webpack.config.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module.exports = environment => {
1414
const primaryBackground = Object.prototype.hasOwnProperty.call(env, 'primaryBackground') ? env.primaryBackground : '#b8002c';
1515
const transitionBackground = Object.prototype.hasOwnProperty.call(env, 'transitionBackground') ? env.transitionBackground : '#db0100';
1616
const secondaryBackground = Object.prototype.hasOwnProperty.call(env, 'secondaryBackground') ? env.secondaryBackground : '#e8410c';
17+
const chromeText = Object.prototype.hasOwnProperty.call(env, 'chromeText') ? env.chromeText : '#fff';
18+
const chromeTextShadow = Object.prototype.hasOwnProperty.call(env, 'chromeTextShadow') ? env.chromeTextShadow : '#532900';
1719
return {
1820
entry: {
1921
bundle: './resources/js/bundle/main',
@@ -60,7 +62,9 @@ module.exports = environment => {
6062
},
6163
additionalData: "$primaryBackground: " + primaryBackground + '; ' +
6264
"$transitionBackground: " + transitionBackground + "; " +
63-
"$secondaryBackground: " + secondaryBackground + ";"
65+
"$secondaryBackground: " + secondaryBackground + "; " +
66+
"$chromeText: " + chromeText + "; " +
67+
"$chromeTextShadow: " + chromeTextShadow + ";"
6468
}
6569
}
6670
]

0 commit comments

Comments
 (0)