mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
26 lines
797 B
JavaScript
26 lines
797 B
JavaScript
const { isString, kebabCase, forEach } = require('lodash');
|
|
const theme = require('weaveworks-ui-components/lib/theme').default;
|
|
|
|
// Flattens and collects all theme colors, names them
|
|
// as Scss vars and returns them as query string
|
|
// TODO: Move this helper to ui-components repo as
|
|
// it's currently used both here and in service-ui.
|
|
function themeColorsAsScss() {
|
|
const colors = [];
|
|
forEach(theme.colors, (value, name) => {
|
|
const colorPrefix = `$color-${kebabCase(name)}`;
|
|
if (isString(value)) {
|
|
colors.push(`${colorPrefix}: ${value}`);
|
|
} else {
|
|
forEach(value, (innerValue, subname) => {
|
|
colors.push(`${colorPrefix}-${kebabCase(subname)}: ${innerValue}`);
|
|
});
|
|
}
|
|
});
|
|
return `${colors.join('; ')};`;
|
|
}
|
|
|
|
module.exports = {
|
|
themeColorsAsScss,
|
|
};
|