forked from learningequality/kolibri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitializeTheme.js
29 lines (27 loc) · 1.11 KB
/
initializeTheme.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
import '../styles/main.scss'; // attaches styles globally
import { setBrandColors, setTokenMapping } from 'kolibri-design-system/lib/styles/theme';
import generateGlobalStyles from 'kolibri-design-system/lib/styles/generateGlobalStyles';
import Vue from 'vue';
import trackInputModality from 'kolibri-design-system/lib/styles/trackInputModality';
import trackMediaType from 'kolibri-design-system/lib/styles/trackMediaType';
import { validateObject, objectWithDefaults } from 'kolibri.utils.objectSpecs';
import themeSpec from './themeSpec';
import themeConfig from './themeConfig';
import plugin_data from 'plugin_data';
export function setThemeConfig(theme) {
Object.keys(themeConfig).forEach(key => {
Vue.set(themeConfig, key, theme[key]);
});
}
export default function initializeTheme() {
validateObject(plugin_data.kolibriTheme, themeSpec);
const theme = objectWithDefaults(plugin_data.kolibriTheme, themeSpec);
if (theme.brandColors) {
setBrandColors(theme.brandColors);
}
setTokenMapping(theme.tokenMapping);
setThemeConfig(theme);
generateGlobalStyles();
trackInputModality();
trackMediaType();
}