nope/resources/ui/helpers/colors.ts
2020-10-30 19:30:59 +01:00

23 lines
957 B
TypeScript

export function getCurrentThemeColors(){
if (process.browser){
const style = getComputedStyle(document.body);
const theme = {
colors: {
primary: style.getPropertyValue('--primary'),
secondary: style.getPropertyValue('--secondary'),
success: style.getPropertyValue('--success'),
info: style.getPropertyValue('--info'),
warning: style.getPropertyValue('--warning'),
danger: style.getPropertyValue('--danger'),
light: style.getPropertyValue('--light'),
dark: style.getPropertyValue('--dark'),
},
font: {
size: Number(window.getComputedStyle(document.body).getPropertyValue('font-size').match(/\d+/)[0]),
type: window.getComputedStyle(document.body).getPropertyValue('font-family')
}
};
return theme;
}
}