@splunk/themes 0.10.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/enterprise/comfortable.js +1 -1
  3. package/enterprise/compact.js +1 -1
  4. package/enterprise/light.js +18 -17
  5. package/mixins/index.js +59 -0
  6. package/mixins/tests/typography.unit.js +236 -0
  7. package/mixins/tests/utilityMixins.unit.js +138 -0
  8. package/mixins/typography.js +270 -0
  9. package/{mixins.js → mixins/utilityMixins.js} +2 -2
  10. package/package.json +20 -10
  11. package/prisma/base.js +9 -6
  12. package/prisma/comfortable.js +1 -1
  13. package/prisma/compact.js +1 -1
  14. package/prisma/dark.js +17 -17
  15. package/prisma/dataViz.js +507 -0
  16. package/prisma/light.js +18 -18
  17. package/storybook-addon-splunk-themes/ThemedDocsContainer.js +21 -9
  18. package/storybook-addon-splunk-themes/addParameter.js +1 -4
  19. package/storybook-addon-splunk-themes/themes.js +2 -2
  20. package/types/enterprise/comfortable.d.ts +1 -1
  21. package/types/enterprise/compact.d.ts +1 -1
  22. package/types/enterprise/dark.d.ts +1 -0
  23. package/types/enterprise/light.d.ts +1 -0
  24. package/types/mixins/index.d.ts +18 -0
  25. package/types/mixins/tests/typography.unit.d.ts +1 -0
  26. package/types/{tests/mixins.unit.d.ts → mixins/tests/utilityMixins.unit.d.ts} +0 -0
  27. package/types/mixins/typography.d.ts +83 -0
  28. package/types/{mixins.d.ts → mixins/utilityMixins.d.ts} +1 -1
  29. package/types/prisma/base.d.ts +215 -0
  30. package/types/prisma/comfortable.d.ts +1 -1
  31. package/types/prisma/compact.d.ts +1 -1
  32. package/types/prisma/dark.d.ts +1 -1
  33. package/types/prisma/dataViz.d.ts +432 -0
  34. package/types/prisma/light.d.ts +1 -1
  35. package/types/storybook-addon-splunk-themes/ThemedDocsContainer.d.ts +2 -2
  36. package/types/storybook-addon-splunk-themes/addDecorator.d.ts +4 -1
  37. package/types/storybook-addon-splunk-themes/addParameter.d.ts +1 -2
  38. package/types/storybook-addon-splunk-themes/themes.d.ts +1 -1
  39. package/types/storybook-addon-splunk-themes/withSplunkTheme.d.ts +4 -2
  40. package/types/withSplunkTheme.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  Change Log
2
2
  ============
3
3
 
4
+ 0.13.0 - September 6, 2022
5
+ ----------
6
+ New Features:
7
+ * Added `typography` mixin (SUI-2809).
8
+
9
+ 0.12.0 - August 2, 2022
10
+ ----------
11
+ New Features:
12
+ * Added `zIndexLayer` variable (SUI-2809).
13
+
14
+ API Changes:
15
+ * Status and accent colors have been updated in Prisma themes.
16
+
17
+ The amount of distinct color values have been consolidated: e.g. `statusColorHigh` and `accentColorNegative` are both `#e00000`.
18
+
19
+ The contrast between these colors have been increased to improve accessibility (SUI-3758).
20
+
21
+ 0.11.0 - May 4, 2022
22
+ ----------
23
+ New Features:
24
+ * Added Data visualization colors to Prisma themes.
25
+
4
26
  0.10.1 - April 5, 2022
5
27
  ----------
6
28
  Bug Fixes:
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
 
8
8
  /**
9
- * # Measures
9
+ * ## Measures
10
10
  * Spacing is used for margin on any element or padding on containers, but can be used for other
11
11
  * properties that position elements.
12
12
  *
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
 
8
8
  /**
9
- * # Measures
9
+ * ## Measures
10
10
  * Spacing is used for margin on any element or padding on containers, but can be used for other
11
11
  * properties that position elements.
12
12
  * * Larger containers, such as `Card` or `Modal`, use `spacing`.
@@ -14,7 +14,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
14
14
  var dragHandle = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAA2SURBVHgB7dKhEQAgDAPAhDnxDMAcDIBnT1pZV1FRk3e53EWFc+2P4N3DmLN+oKh/QADqB+IMUKEQD/CeueAAAAAASUVORK5CYII="; // see babel-plugin-base64-pngimport {
15
15
 
16
16
  /**
17
- * # Brand Colors
17
+ * ## Brand colors
18
18
  *
19
19
  * @colorSet
20
20
  */
@@ -33,7 +33,7 @@ var brandColors = {
33
33
  brandColorD50: '#286728'
34
34
  };
35
35
  /**
36
- * # Grayscale Colors
36
+ * ## Grayscale colors
37
37
  *
38
38
  * @colorSet
39
39
  */
@@ -53,7 +53,7 @@ var grays = {
53
53
  black: '#000000'
54
54
  };
55
55
  /**
56
- * # Accent Colors
56
+ * ## Accent colors
57
57
  *
58
58
  * @colorSet
59
59
  */
@@ -72,7 +72,7 @@ var accentColors = {
72
72
  accentColorD50: '#003d5e'
73
73
  };
74
74
  /**
75
- * # Error Colors
75
+ * ## Error Colors
76
76
  *
77
77
  * @colorSet
78
78
  */
@@ -91,7 +91,7 @@ var errorColors = {
91
91
  errorColorD50: '#6f261d'
92
92
  };
93
93
  /**
94
- * # Alert Colors
94
+ * ## Alert colors
95
95
  *
96
96
  * @colorSet
97
97
  * */
@@ -110,7 +110,7 @@ var alertColors = {
110
110
  alertColorD50: '#79401a'
111
111
  };
112
112
  /**
113
- * # Warning Colors
113
+ * ## Warning colors
114
114
  *
115
115
  * @colorSet
116
116
  */
@@ -129,7 +129,7 @@ var warningColors = {
129
129
  warningColorD50: '#7d600f'
130
130
  };
131
131
  /**
132
- * # Success Colors
132
+ * ## Success colors
133
133
  *
134
134
  * @colorSet
135
135
  */
@@ -148,7 +148,7 @@ var successColors = {
148
148
  successColorD50: '#275126'
149
149
  };
150
150
  /**
151
- * # Info Colors
151
+ * ## Info colors
152
152
  *
153
153
  * @colorSet
154
154
  */
@@ -167,7 +167,7 @@ var infoColors = {
167
167
  infoColorD50: '#002b3e'
168
168
  };
169
169
  /**
170
- * # Diverging Colors
170
+ * ## Diverging colors
171
171
  *
172
172
  * @colorSet alphabetical
173
173
  */
@@ -185,7 +185,7 @@ var divergingColors = {
185
185
  diverging5ColorB: '#b6c75a'
186
186
  };
187
187
  /**
188
- * # Categorical Colors
188
+ * ## Categorical Colors
189
189
  *
190
190
  * @colorSet alphabetical
191
191
  */
@@ -253,7 +253,7 @@ var categoricalColors = {
253
253
  cat30ColorL: '#a4bbe0'
254
254
  };
255
255
  /**
256
- * # Usage-based Colors
256
+ * ## Usage-based colors
257
257
  *
258
258
  * @colorSet verbose
259
259
  */
@@ -272,7 +272,7 @@ var usageColors = {
272
272
  transparent: 'transparent'
273
273
  };
274
274
  /**
275
- * # Syntax Colors
275
+ * ## Syntax colors
276
276
  * The following colors should only be used for syntax coloring of code.
277
277
  *
278
278
  * @colorSet verbose alphabetical
@@ -294,7 +294,7 @@ var syntaxColors = {
294
294
  syntaxTeal: '#00a8ab'
295
295
  };
296
296
  /**
297
- * # Shadows
297
+ * ## Shadows
298
298
  *
299
299
  * @shadowSet
300
300
  */
@@ -305,7 +305,7 @@ var shadows = {
305
305
  overlayShadow: '0 4px 8px rgba(0, 0, 0, 0.2)'
306
306
  };
307
307
  /**
308
- * # Backgrounds
308
+ * ## Backgrounds
309
309
  *
310
310
  * @colorSet verbose
311
311
  */
@@ -314,7 +314,7 @@ var backgrounds = {
314
314
  draggableBackground: "url('data:image/png;base64,".concat(dragHandle, "') 0 0 / 8px 8px repeat")
315
315
  };
316
316
  /**
317
- * # Border
317
+ * ## Border
318
318
  *
319
319
  * @valueSet
320
320
  */
@@ -325,7 +325,7 @@ var borders = {
325
325
  };
326
326
  var sansFontFamily = "'Splunk Platform Sans', 'Proxima Nova', Roboto, Droid, 'Helvetica Neue', Helvetica, Arial, sans-serif";
327
327
  /**
328
- * # Fonts
328
+ * ## Fonts
329
329
  *
330
330
  * @valueSet
331
331
  */
@@ -339,13 +339,14 @@ var fonts = {
339
339
  fontWeightSemiBold: '500'
340
340
  };
341
341
  /**
342
- * # Layers
342
+ * ## Layers
343
343
  * If a variable does not suit your purpose, set a value relatively, such as zindexModal +1.
344
344
  *
345
345
  * @valueSet
346
346
  */
347
347
 
348
348
  var zindexes = {
349
+ zindexLayer: 1000,
349
350
  zindexFixedNavbar: 1030,
350
351
  zindexModalBackdrop: 1040,
351
352
  zindexModal: 1050,
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ var _exportNames = {
9
+ typography: true
10
+ };
11
+ Object.defineProperty(exports, "typography", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _typography["default"];
15
+ }
16
+ });
17
+ exports["default"] = void 0;
18
+
19
+ var _utilityMixins = _interopRequireWildcard(require("./utilityMixins"));
20
+
21
+ Object.keys(_utilityMixins).forEach(function (key) {
22
+ if (key === "default" || key === "__esModule") return;
23
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
24
+ Object.defineProperty(exports, key, {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _utilityMixins[key];
28
+ }
29
+ });
30
+ });
31
+
32
+ var _typography = _interopRequireWildcard(require("./typography"));
33
+
34
+ Object.keys(_typography).forEach(function (key) {
35
+ if (key === "default" || key === "__esModule") return;
36
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
37
+ Object.defineProperty(exports, key, {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _typography[key];
41
+ }
42
+ });
43
+ });
44
+
45
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
46
+
47
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
48
+
49
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
50
+
51
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
52
+
53
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
54
+
55
+ var _default = _objectSpread(_objectSpread({}, _utilityMixins["default"]), {}, {
56
+ typography: _typography["default"]
57
+ });
58
+
59
+ exports["default"] = _default;
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
10
+
11
+ var _SplunkThemeProvider = _interopRequireDefault(require("@splunk/themes/SplunkThemeProvider"));
12
+
13
+ require("jest-styled-components");
14
+
15
+ var _typography = _interopRequireWildcard(require("../typography"));
16
+
17
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
18
+
19
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
22
+
23
+ function _templateObject6() {
24
+ var data = _taggedTemplateLiteral(["\n ", "\n ", ";\n ", ";\n "]);
25
+
26
+ _templateObject6 = function _templateObject6() {
27
+ return data;
28
+ };
29
+
30
+ return data;
31
+ }
32
+
33
+ function _templateObject5() {
34
+ var data = _taggedTemplateLiteral(["\n ", "\n "]);
35
+
36
+ _templateObject5 = function _templateObject5() {
37
+ return data;
38
+ };
39
+
40
+ return data;
41
+ }
42
+
43
+ function _templateObject4() {
44
+ var data = _taggedTemplateLiteral(["\n ", "\n "]);
45
+
46
+ _templateObject4 = function _templateObject4() {
47
+ return data;
48
+ };
49
+
50
+ return data;
51
+ }
52
+
53
+ function _templateObject3() {
54
+ var data = _taggedTemplateLiteral(["\n ", "\n "]);
55
+
56
+ _templateObject3 = function _templateObject3() {
57
+ return data;
58
+ };
59
+
60
+ return data;
61
+ }
62
+
63
+ function _templateObject2() {
64
+ var data = _taggedTemplateLiteral(["\n ", "\n "]);
65
+
66
+ _templateObject2 = function _templateObject2() {
67
+ return data;
68
+ };
69
+
70
+ return data;
71
+ }
72
+
73
+ function _templateObject() {
74
+ var data = _taggedTemplateLiteral(["\n ", "\n "]);
75
+
76
+ _templateObject = function _templateObject() {
77
+ return data;
78
+ };
79
+
80
+ return data;
81
+ }
82
+
83
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
84
+
85
+ describe('typography', function () {
86
+ function ThemeSettingsList(_ref) {
87
+ var family = _ref.family,
88
+ Component = _ref.component;
89
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
90
+ family: family,
91
+ colorScheme: "dark",
92
+ density: "comfortable"
93
+ }, /*#__PURE__*/_react["default"].createElement(Component, null, family, " dark comfortable")), /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
94
+ family: family,
95
+ colorScheme: "light",
96
+ density: "comfortable"
97
+ }, /*#__PURE__*/_react["default"].createElement(Component, null, family, " light comfortable")), /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
98
+ family: family,
99
+ colorScheme: "dark",
100
+ density: "compact"
101
+ }, /*#__PURE__*/_react["default"].createElement(Component, null, family, " dark compact")), /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
102
+ family: family,
103
+ colorScheme: "light",
104
+ density: "compact"
105
+ }, /*#__PURE__*/_react["default"].createElement(Component, null, family, " light compact")));
106
+ }
107
+
108
+ describe('uses default values based on theme family', function () {
109
+ var Component = _styledComponents["default"].p(_templateObject(), (0, _typography["default"])());
110
+
111
+ it('prisma', function () {
112
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(ThemeSettingsList, {
113
+ family: "prisma",
114
+ component: Component
115
+ })),
116
+ container = _render.container;
117
+
118
+ expect(container).toMatchInlineSnapshot("\n .c0 {\n color: #b5b5b5;\n font-family: 'Splunk Platform Sans','Splunk Data Sans',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c1 {\n color: #4d4d4d;\n font-family: 'Splunk Platform Sans','Splunk Data Sans',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n <div>\n <p\n class=\"c0\"\n >\n prisma\n dark comfortable\n </p>\n <p\n class=\"c1\"\n >\n prisma\n light comfortable\n </p>\n <p\n class=\"c0\"\n >\n prisma\n dark compact\n </p>\n <p\n class=\"c1\"\n >\n prisma\n light compact\n </p>\n </div>\n ");
119
+ });
120
+ it('enterprise', function () {
121
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(ThemeSettingsList, {
122
+ family: "enterprise",
123
+ component: Component
124
+ })),
125
+ container = _render2.container;
126
+
127
+ expect(container).toMatchInlineSnapshot("\n .c0 {\n color: #ffffff;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c1 {\n color: #3c444d;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c2 {\n color: #ffffff;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 12px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c3 {\n color: #3c444d;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 12px;\n font-weight: normal;\n line-height: 20px;\n }\n\n <div>\n <p\n class=\"c0\"\n >\n enterprise\n dark comfortable\n </p>\n <p\n class=\"c1\"\n >\n enterprise\n light comfortable\n </p>\n <p\n class=\"c2\"\n >\n enterprise\n dark compact\n </p>\n <p\n class=\"c3\"\n >\n enterprise\n light compact\n </p>\n </div>\n ");
128
+ });
129
+ });
130
+ describe('support variants in each theme', function () {
131
+ function testTypographyVariantForThemeFamily(variant, family) {
132
+ it("".concat(variant), function () {
133
+ var Component = _styledComponents["default"].p(_templateObject2(), (0, _typography["default"])(variant));
134
+
135
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(ThemeSettingsList, {
136
+ family: family,
137
+ component: Component
138
+ })),
139
+ container = _render3.container;
140
+
141
+ expect(container).toMatchSnapshot();
142
+ });
143
+ }
144
+
145
+ describe('prisma', function () {
146
+ _typography.typographyVariants.forEach(function (variant) {
147
+ return testTypographyVariantForThemeFamily(variant, 'prisma');
148
+ });
149
+ });
150
+ describe('enterprise', function () {
151
+ _typography.typographyVariants.forEach(function (variant) {
152
+ return testTypographyVariantForThemeFamily(variant, 'enterprise');
153
+ });
154
+ });
155
+ });
156
+ it('merges parameters with variant values', function () {
157
+ var Component = _styledComponents["default"].p(_templateObject3(), (0, _typography["default"])('body', {
158
+ color: 'muted',
159
+ family: 'monospace'
160
+ }));
161
+
162
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
163
+ container = _render4.container;
164
+
165
+ expect(container.firstChild).toMatchInlineSnapshot("\n .c0 {\n margin: 0;\n padding: 0;\n color: #909090;\n font-family: 'Splunk Platform Mono','Roboto Mono',Consolas,'Droid Sans Mono',Monaco,'Courier New',Courier,monospace;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n <p\n class=\"c0\"\n />\n ");
166
+ });
167
+ it('allows a variants values to be overridden', function () {
168
+ var Component = _styledComponents["default"].p(_templateObject4(), (0, _typography["default"])('body', {
169
+ color: 'muted',
170
+ family: 'monospace',
171
+ lineHeight: 64,
172
+ size: 56,
173
+ weight: 'extraBold',
174
+ withReset: false
175
+ }));
176
+
177
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
178
+ container = _render5.container;
179
+
180
+ expect(container.firstChild).toMatchInlineSnapshot("\n .c0 {\n color: #909090;\n font-family: 'Splunk Platform Mono','Roboto Mono',Consolas,'Droid Sans Mono',Monaco,'Courier New',Courier,monospace;\n font-size: 56px;\n font-weight: extraBold;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
181
+ });
182
+ it('allows default values to be overridden with params', function () {
183
+ var Component = _styledComponents["default"].p(_templateObject5(), (0, _typography["default"])({
184
+ color: 'muted',
185
+ family: 'monospace',
186
+ lineHeight: 64,
187
+ size: 56,
188
+ weight: 'extraBold',
189
+ withReset: false
190
+ }));
191
+
192
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
193
+ container = _render6.container;
194
+
195
+ expect(container.firstChild).toMatchInlineSnapshot("\n .c0 {\n color: #909090;\n font-family: 'Splunk Platform Mono','Roboto Mono',Consolas,'Droid Sans Mono',Monaco,'Courier New',Courier,monospace;\n font-size: 56px;\n font-weight: extraBold;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
196
+ });
197
+ it.skip('passes TS verification', function () {
198
+ (0, _typography["default"])();
199
+ (0, _typography["default"])({});
200
+ (0, _typography["default"])('title1');
201
+ (0, _typography["default"])('title1', {
202
+ color: 'disabled'
203
+ });
204
+ (0, _typography["default"])({
205
+ family: 'monospace'
206
+ }); // @ts-expect-error
207
+
208
+ (0, _typography["default"])('foo'); // @ts-expect-error
209
+
210
+ (0, _typography["default"])({
211
+ family: 'monospace'
212
+ }, true); // @ts-expect-error
213
+
214
+ (0, _typography["default"])({
215
+ family: 'monospace'
216
+ }, {
217
+ color: 'disabled'
218
+ }); // @ts-expect-error
219
+
220
+ (0, _typography["default"])(''); // @ts-expect-error
221
+
222
+ (0, _typography["default"])({
223
+ variant: 'title1'
224
+ });
225
+ });
226
+ });
227
+ describe('passes TS verification', function () {
228
+ it.skip('allows mixins in styled-components css', function () {
229
+ /* eslint-disable-next-line @typescript-eslint/no-unused-expressions */
230
+ (0, _styledComponents.css)(_templateObject6(), (0, _typography["default"])('title1'), (0, _typography["default"])('title1', {
231
+ color: 'disabled'
232
+ }), (0, _typography["default"])({
233
+ family: 'monospace'
234
+ }));
235
+ });
236
+ });
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ var _chai = require("chai");
4
+
5
+ var _sinon = require("sinon");
6
+
7
+ var _styledComponents = require("styled-components");
8
+
9
+ var _variables = _interopRequireDefault(require("../../variables"));
10
+
11
+ var _utilityMixins = require("../utilityMixins");
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+
15
+ function _templateObject() {
16
+ var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", "\n ", "\n ", ";\n "]);
17
+
18
+ _templateObject = function _templateObject() {
19
+ return data;
20
+ };
21
+
22
+ return data;
23
+ }
24
+
25
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
26
+
27
+ describe('colorWithAlpha', function () {
28
+ var defaultProps = {};
29
+ var enterpriseLightProps = {
30
+ theme: {
31
+ splunkThemeV1: {
32
+ family: 'enterprise',
33
+ colorScheme: 'light'
34
+ }
35
+ }
36
+ };
37
+ it('sets alpha on a string value', function () {
38
+ var result = (0, _utilityMixins.colorWithAlpha)('#70f', 0.5)(defaultProps);
39
+
40
+ _chai.assert.strictEqual(result, 'rgba(119, 0, 255, 0.5)');
41
+
42
+ var result2 = (0, _utilityMixins.colorWithAlpha)('#1700f3', 0.5)(defaultProps);
43
+
44
+ _chai.assert.strictEqual(result2, 'rgba(23, 0, 243, 0.5)');
45
+
46
+ var result3 = (0, _utilityMixins.colorWithAlpha)('rgb(51, 162, 212)', 0.2)(defaultProps);
47
+
48
+ _chai.assert.strictEqual(result3, 'rgba(51, 162, 212, 0.2)');
49
+
50
+ var result4 = (0, _utilityMixins.colorWithAlpha)('rgba(255, 255, 255, 0.7)', 0.2)(defaultProps);
51
+
52
+ _chai.assert.strictEqual(result4, 'rgba(255, 255, 255, 0.2)');
53
+ });
54
+ it('sets alpha on a variable', function () {
55
+ var result = (0, _utilityMixins.colorWithAlpha)(_variables["default"].white, 0.5)(defaultProps);
56
+
57
+ _chai.assert.strictEqual(result, 'rgba(255, 255, 255, 0.5)');
58
+
59
+ var result2 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].contentColorDefault, 0.2)(defaultProps);
60
+
61
+ _chai.assert.strictEqual(result2, 'rgba(181, 181, 181, 0.2)');
62
+
63
+ var result3 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].contentColorDefault, 0.3)(enterpriseLightProps);
64
+
65
+ _chai.assert.strictEqual(result3, 'rgba(60, 68, 77, 0.3)');
66
+
67
+ var result4 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].brandColor, 0.3)(enterpriseLightProps);
68
+
69
+ _chai.assert.strictEqual(result4, 'rgba(92, 192, 92, 0.3)');
70
+ });
71
+ it('defaults to black for undefined variable', function () {
72
+ var consoleStub = (0, _sinon.stub)(console, 'warn');
73
+ var result4 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].brandColor, 0.3)(defaultProps);
74
+
75
+ _chai.assert.strictEqual(result4, 'rgba(0, 0, 0, 0.3)');
76
+
77
+ _chai.assert.isTrue(consoleStub.calledOnce, "The colorWithAlpha's console warning was called");
78
+
79
+ _chai.assert.strictEqual(consoleStub.args[0][0], "The variable 'brandColor' does not exist in the theme 'prisma dark comfortable'.");
80
+
81
+ consoleStub.restore();
82
+ });
83
+ it('warns developers of invalid alpha prop at runtime', function () {
84
+ var consoleStub = (0, _sinon.stub)(console, 'warn');
85
+ (0, _utilityMixins.colorWithAlpha)(_variables["default"].white, 1.1)(defaultProps);
86
+ (0, _utilityMixins.colorWithAlpha)(_variables["default"].white, -0.1)(defaultProps);
87
+
88
+ _chai.assert.isTrue(consoleStub.calledTwice, "The colorWithAlpha's console warning was called twice");
89
+
90
+ _chai.assert.strictEqual(consoleStub.args[0][0], 'The alpha value "1.1" is not within acceptable 0-1 range.');
91
+
92
+ _chai.assert.strictEqual(consoleStub.args[1][0], 'The alpha value "-0.1" is not within acceptable 0-1 range.');
93
+
94
+ consoleStub.restore();
95
+ });
96
+ });
97
+ describe('overlayColors', function () {
98
+ var defaultProps = {};
99
+ it('overlays two string values', function () {
100
+ var result = (0, _utilityMixins.overlayColors)('#f0f', 'rgba(255, 255, 128, 0.5)')(defaultProps);
101
+
102
+ _chai.assert.strictEqual(result, 'rgb(255, 128, 192)');
103
+ });
104
+ it('overlays a solid color', function () {
105
+ var result = (0, _utilityMixins.overlayColors)('#f39', _variables["default"].black)(defaultProps);
106
+
107
+ _chai.assert.strictEqual(result, 'rgb(0, 0, 0)');
108
+ });
109
+ it('uses default theme variables', function () {
110
+ var result = (0, _utilityMixins.overlayColors)(_variables["default"].interactiveColorPrimary, _variables["default"].interactiveColorOverlayHover)(defaultProps);
111
+
112
+ _chai.assert.strictEqual(result, 'rgb(67, 152, 255)');
113
+ });
114
+ var enterpriseLightProps = {
115
+ theme: {
116
+ splunkThemeV1: {
117
+ family: 'enterprise',
118
+ colorScheme: 'light'
119
+ }
120
+ }
121
+ };
122
+ it('uses Enterprise variables', function () {
123
+ var result = (0, _utilityMixins.overlayColors)(_variables["default"].brandColor, 'rgba(255, 255, 255, 0.5)')(enterpriseLightProps);
124
+
125
+ _chai.assert.strictEqual(result, 'rgb(174, 224, 174)');
126
+ });
127
+ it('defaults to black for undefined colors', function () {
128
+ var result = (0, _utilityMixins.overlayColors)(_variables["default"].brandColor, 'rgba(255, 255, 255, 0.5)')(defaultProps);
129
+
130
+ _chai.assert.strictEqual(result, 'rgb(128, 128, 128)');
131
+ });
132
+ });
133
+ describe('passes TS verification', function () {
134
+ it.skip('allows mixins in styled-components css', function () {
135
+ /* eslint-disable-next-line @typescript-eslint/no-unused-expressions */
136
+ (0, _styledComponents.css)(_templateObject(), _utilityMixins.clearfix, (0, _utilityMixins.colorWithAlpha)('foo', 0.5), _utilityMixins.ellipsis, (0, _utilityMixins.overlayColors)('foo', 'bar'), _utilityMixins.printHide, _utilityMixins.printNoBackground, _utilityMixins.printWidth100Percent, _utilityMixins.printWrapAll, (0, _utilityMixins.reset)(), (0, _utilityMixins.reset)('block'), _utilityMixins.screenReaderContent);
137
+ });
138
+ });