pagraphcontrol/utils/theme/index.js
2020-06-18 16:23:41 +03:00

32 lines
598 B
JavaScript

const camelCase = require('camelcase');
const {
map,
} = require('ramda');
const theme = require('../gtk-theme');
const colors = require('./default-colors.json');
theme.css.replace(/@define-color\s+([\w_]+?)\s+(.+?);/g, (_, name, value) => {
colors[camelCase(name)] = value;
});
const resolveColor = (value, depth = 0) => {
if (depth > 3) {
return value;
}
if (value && value.startsWith('@')) {
return resolveColor(colors[camelCase(value.slice(1))], depth + 1);
}
return value;
};
module.exports = {
iconThemeNames: theme.iconThemeNames,
colors: map(resolveColor, colors),
};