nope/resources/ui/helpers/colors.ts

37 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-12-01 12:05:35 +00:00
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"),
color: window
.getComputedStyle(document.body)
.getPropertyValue("font-color"),
computedFont: window
.getComputedStyle(document.body)
.getPropertyValue("font")
}
};
return theme;
}
}