-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig-loader.js
32 lines (28 loc) · 1.67 KB
/
config-loader.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
fetch('config/config.json').then(response => {
return response.json();
}).then(data => {
window.thorConfig = data;
document.querySelector('#title').innerText = window.thorConfig.title;
const colors = window.thorConfig.color_scheme;
const setColor = (variable, color) => { document.documentElement.style.setProperty(variable, color) };
colors.main_brand ? setColor('--main-brand', colors.main_brand) : undefined;
colors.main_brand_darkened ? setColor('--main-brand-darkened', colors.main_brand_darkened) : undefined;
colors.secondary_brand ? setColor('--secondary-brand', colors.secondary_brand) : undefined;
colors.secondary_brand_darkened ? setColor('--secondary-brand-darkened', colors.secondary_brand_darkened) : undefined;
colors.main_text ? setColor('--main-text', colors.main_text) : undefined;
colors.main_text_lighted ? setColor('--main-text-lighted', colors.main_text_lighted) : undefined;
colors.secondary_text ? setColor('--secondary-text', colors.secondary_text) : undefined;
colors.background ? setColor('--background', colors.background) : undefined;
colors.background_shaded ? setColor('--background-shaded', colors.background_shaded) : undefined;
colors.border ? setColor('--border', colors.border) : undefined;
// set the default favicon to the success one
const favicon = document.createElement('link');
favicon.rel = 'icon';
favicon.type = 'image/svg+xml';
favicon.href = (window.thorConfig?.favicons?.favicon_success ?? 'assets/success-favicon.svg');
document.head.appendChild(favicon);
if (window.thorConfig.demo_tour && !store.getItem('hasStartedTour')) {
tour.start();
}
init();
});