UNPKG

1.55 kBJavaScriptView Raw
1import { mergeStyles } from '@uifabric/merge-styles';
2import { DefaultPalette } from '../styles/DefaultPalette';
3import { getTheme } from '../styles/index';
4export var ColorClassNames = {};
5for (var colorName in DefaultPalette) {
6 if (DefaultPalette.hasOwnProperty(colorName)) {
7 // Foreground color
8 _defineGetter(ColorClassNames, colorName, '', false, 'color');
9 // Hover color
10 _defineGetter(ColorClassNames, colorName, 'Hover', true, 'color');
11 // Background color
12 _defineGetter(ColorClassNames, colorName, 'Background', false, 'background');
13 // Background hover
14 _defineGetter(ColorClassNames, colorName, 'BackgroundHover', true, 'background');
15 // Border color
16 _defineGetter(ColorClassNames, colorName, 'Border', false, 'borderColor');
17 // Border hover color
18 _defineGetter(ColorClassNames, colorName, 'BorderHover', true, 'borderColor');
19 }
20}
21/**
22 * Defines a getter for the given class configuration.
23 */
24function _defineGetter(obj, colorName, suffix, isHover, cssProperty) {
25 Object.defineProperty(obj, colorName + suffix, {
26 get: function () {
27 var _a;
28 // eslint-disable-next-line @typescript-eslint/no-explicit-any
29 var style = (_a = {}, _a[cssProperty] = getTheme().palette[colorName], _a);
30 return mergeStyles(isHover ? { selectors: { ':hover': style } } : style).toString();
31 },
32 enumerable: true,
33 configurable: true,
34 });
35}
36//# sourceMappingURL=ColorClassNames.js.map
\No newline at end of file