UNPKG

@grafana/ui

Version:
55 lines (49 loc) 2.16 kB
'use strict'; var tinycolor = require('tinycolor2'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } var tinycolor__default = /*#__PURE__*/_interopDefaultCompat(tinycolor); "use strict"; function getColors(theme) { if (theme === void 0) { return {}; } else { const colors = { "editor.background": theme.components.input.background, "minimap.background": theme.colors.background.secondary }; Object.keys(colors).forEach((resultKey) => { colors[resultKey] = normalizeColorForMonaco(colors[resultKey]); }); return colors; } } function normalizeColorForMonaco(color) { return tinycolor__default.default(color).toHexString(); } function defineThemes(monaco, theme) { const colors = getColors(theme); monaco.editor.defineTheme("grafana-dark", { base: "vs-dark", inherit: true, colors, // fallback syntax highlighting for languages that microsoft doesn't handle (ex cloudwatch's metric math) rules: [ { token: "predefined", foreground: normalizeColorForMonaco(theme == null ? void 0 : theme.visualization.getColorByName("purple")) }, { token: "operator", foreground: normalizeColorForMonaco(theme == null ? void 0 : theme.visualization.getColorByName("orange")) }, { token: "tag", foreground: normalizeColorForMonaco(theme == null ? void 0 : theme.visualization.getColorByName("green")) } ] }); monaco.editor.defineTheme("grafana-light", { base: "vs", inherit: true, colors, // fallback syntax highlighting for languages that microsoft doesn't handle (ex cloudwatch's metric math) rules: [ { token: "predefined", foreground: normalizeColorForMonaco(theme == null ? void 0 : theme.visualization.getColorByName("purple")) }, { token: "operator", foreground: normalizeColorForMonaco(theme == null ? void 0 : theme.visualization.getColorByName("orange")) }, { token: "tag", foreground: normalizeColorForMonaco(theme == null ? void 0 : theme.visualization.getColorByName("green")) } ] }); } module.exports = defineThemes; //# sourceMappingURL=theme.cjs.map