@splunk/themes 0.22.0 → 0.23.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.
- package/CHANGELOG.md +5 -0
- package/SplunkThemeProvider.js +18 -31
- package/enterprise/comfortable.js +0 -1
- package/enterprise/compact.js +0 -1
- package/enterprise/dark.js +10 -17
- package/enterprise/index.js +8 -16
- package/enterprise/light.js +24 -31
- package/enterprise/prismaAliases.js +3 -11
- package/getSettingsFromThemedProps.js +4 -8
- package/getTheme.js +13 -26
- package/index.js +1 -13
- package/mixins/index.js +8 -18
- package/mixins/tests/typography.unit.js +39 -85
- package/mixins/tests/utilityMixins.unit.js +2 -10
- package/mixins/typography.js +21 -52
- package/mixins/utilityMixins.js +11 -34
- package/package.json +18 -10
- package/pick.js +7 -18
- package/pickVariant.js +1 -7
- package/prisma/base.js +13 -20
- package/prisma/comfortable.js +0 -1
- package/prisma/compact.js +0 -1
- package/prisma/dark.js +15 -16
- package/prisma/dataViz.js +38 -49
- package/prisma/index.js +8 -16
- package/prisma/light.js +15 -16
- package/storybook-addon-splunk-themes/SplunkThemesTool.js +20 -42
- package/storybook-addon-splunk-themes/ThemedDocsContainer.js +3 -13
- package/storybook-addon-splunk-themes/index.js +0 -4
- package/storybook-addon-splunk-themes/manager.js +1 -7
- package/storybook-addon-splunk-themes/preview.js +4 -8
- package/storybook-addon-splunk-themes/tests/util.unit.js +0 -1
- package/storybook-addon-splunk-themes/themeOptions.js +0 -1
- package/storybook-addon-splunk-themes/themes.js +4 -15
- package/storybook-addon-splunk-themes/util.js +21 -39
- package/storybook-addon-splunk-themes/withSplunkTheme.js +27 -65
- package/useSplunkTheme.js +14 -22
- package/utils.js +25 -35
- package/variables.js +17 -31
- package/withSplunkTheme.js +26 -36
package/mixins/typography.js
CHANGED
|
@@ -4,66 +4,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.typographyVariants = exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _styledComponents = require("styled-components");
|
|
9
|
-
|
|
10
8
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
11
|
-
|
|
12
9
|
var _variables = _interopRequireDefault(require("../variables"));
|
|
13
|
-
|
|
14
10
|
var _pick = _interopRequireDefault(require("../pick"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
12
|
function _templateObject2() {
|
|
19
13
|
var data = _taggedTemplateLiteral(["\n margin: 0;\n padding: 0;\n "]);
|
|
20
|
-
|
|
21
14
|
_templateObject2 = function _templateObject2() {
|
|
22
15
|
return data;
|
|
23
16
|
};
|
|
24
|
-
|
|
25
17
|
return data;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
function _templateObject() {
|
|
29
20
|
var data = _taggedTemplateLiteral(["\n ", "\n\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n "]);
|
|
30
|
-
|
|
31
21
|
_templateObject = function _templateObject() {
|
|
32
22
|
return data;
|
|
33
23
|
};
|
|
34
|
-
|
|
35
24
|
return data;
|
|
36
25
|
}
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
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; }
|
|
45
|
-
|
|
46
|
-
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); }
|
|
47
|
-
|
|
26
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
27
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
31
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
48
33
|
var typographyVariants = ['body', 'title1', 'title2', 'title3', 'title4', 'title5', 'title6', 'title7', 'largeBody', 'smallBody', 'footnote', 'monoBody', 'monoSmallBody'];
|
|
49
|
-
exports.typographyVariants = typographyVariants;
|
|
50
34
|
|
|
35
|
+
// Keep in sync with react-ui/Typography for documentation
|
|
36
|
+
// TODO: SUI-5042 Improve docs-gen to render extended 3rd party types
|
|
37
|
+
// TODO: SUI-5043 UtilPage doesn't render public types
|
|
38
|
+
exports.typographyVariants = typographyVariants;
|
|
51
39
|
function isTypographyVariant(s) {
|
|
52
40
|
if (typeof s !== 'string') {
|
|
53
41
|
return false;
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
return typographyVariants.includes(s);
|
|
57
44
|
}
|
|
58
|
-
|
|
59
45
|
function getStylesForVariant(variant) {
|
|
60
46
|
var color = _variables["default"].contentColorDefault;
|
|
61
47
|
var family = _variables["default"].fontFamily;
|
|
62
48
|
var lineHeight = _variables["default"].lineHeight; // eslint-disable-line prefer-destructuring
|
|
63
|
-
|
|
64
49
|
var size = _variables["default"].fontSize;
|
|
65
|
-
var weight = 'normal';
|
|
50
|
+
var weight = 'normal';
|
|
66
51
|
|
|
52
|
+
// TODO: After sections are removed from Heading update HeadingStyles accordingly to preserve section styles as typography variants SUI-5268
|
|
67
53
|
switch (variant) {
|
|
68
54
|
case 'title1':
|
|
69
55
|
color = _variables["default"].contentColorActive;
|
|
@@ -80,7 +66,6 @@ function getStylesForVariant(variant) {
|
|
|
80
66
|
prisma: _variables["default"].fontWeightBold
|
|
81
67
|
});
|
|
82
68
|
break;
|
|
83
|
-
|
|
84
69
|
case 'title2':
|
|
85
70
|
color = _variables["default"].contentColorActive;
|
|
86
71
|
lineHeight = (0, _pick["default"])({
|
|
@@ -96,7 +81,6 @@ function getStylesForVariant(variant) {
|
|
|
96
81
|
prisma: _variables["default"].fontWeightBold
|
|
97
82
|
});
|
|
98
83
|
break;
|
|
99
|
-
|
|
100
84
|
case 'title3':
|
|
101
85
|
color = _variables["default"].contentColorActive;
|
|
102
86
|
lineHeight = (0, _pick["default"])({
|
|
@@ -112,7 +96,6 @@ function getStylesForVariant(variant) {
|
|
|
112
96
|
prisma: _variables["default"].fontWeightBold
|
|
113
97
|
});
|
|
114
98
|
break;
|
|
115
|
-
|
|
116
99
|
case 'title4':
|
|
117
100
|
color = _variables["default"].contentColorActive;
|
|
118
101
|
lineHeight = (0, _pick["default"])({
|
|
@@ -125,7 +108,6 @@ function getStylesForVariant(variant) {
|
|
|
125
108
|
});
|
|
126
109
|
weight = _variables["default"].fontWeightBold;
|
|
127
110
|
break;
|
|
128
|
-
|
|
129
111
|
case 'title5':
|
|
130
112
|
color = _variables["default"].contentColorActive;
|
|
131
113
|
lineHeight = _variables["default"].lineHeight;
|
|
@@ -138,7 +120,6 @@ function getStylesForVariant(variant) {
|
|
|
138
120
|
prisma: _variables["default"].fontWeightBold
|
|
139
121
|
});
|
|
140
122
|
break;
|
|
141
|
-
|
|
142
123
|
case 'title6':
|
|
143
124
|
color = _variables["default"].contentColorActive;
|
|
144
125
|
lineHeight = (0, _pick["default"])({
|
|
@@ -151,39 +132,33 @@ function getStylesForVariant(variant) {
|
|
|
151
132
|
});
|
|
152
133
|
weight = _variables["default"].fontWeightSemiBold;
|
|
153
134
|
break;
|
|
154
|
-
|
|
155
135
|
case 'title7':
|
|
156
136
|
color = _variables["default"].contentColorActive;
|
|
157
137
|
lineHeight = '16px';
|
|
158
138
|
size = _variables["default"].fontSizeSmall;
|
|
159
139
|
weight = _variables["default"].fontWeightSemiBold;
|
|
160
140
|
break;
|
|
161
|
-
|
|
162
141
|
case 'largeBody':
|
|
163
142
|
color = _variables["default"].contentColorDefault;
|
|
164
143
|
lineHeight = '24px';
|
|
165
144
|
size = _variables["default"].fontSizeLarge;
|
|
166
145
|
weight = 'normal';
|
|
167
146
|
break;
|
|
168
|
-
|
|
169
147
|
case 'smallBody':
|
|
170
148
|
color = _variables["default"].contentColorDefault;
|
|
171
149
|
lineHeight = '16px';
|
|
172
150
|
size = _variables["default"].fontSizeSmall;
|
|
173
151
|
weight = 'normal';
|
|
174
152
|
break;
|
|
175
|
-
|
|
176
153
|
case 'footnote':
|
|
177
154
|
color = _variables["default"].contentColorDefault;
|
|
178
155
|
lineHeight = '13px';
|
|
179
156
|
size = '10px';
|
|
180
157
|
weight = 'normal';
|
|
181
158
|
break;
|
|
182
|
-
|
|
183
159
|
case 'monoBody':
|
|
184
160
|
family = _variables["default"].monoFontFamily;
|
|
185
161
|
break;
|
|
186
|
-
|
|
187
162
|
case 'monoSmallBody':
|
|
188
163
|
color = _variables["default"].contentColorDefault;
|
|
189
164
|
family = _variables["default"].monoFontFamily;
|
|
@@ -191,24 +166,20 @@ function getStylesForVariant(variant) {
|
|
|
191
166
|
size = _variables["default"].fontSizeSmall;
|
|
192
167
|
weight = 'normal';
|
|
193
168
|
break;
|
|
194
|
-
|
|
195
169
|
case 'body':
|
|
196
170
|
// Theme defaults set the 'body' style
|
|
197
171
|
break;
|
|
198
|
-
|
|
199
172
|
default:
|
|
200
173
|
{
|
|
201
174
|
if (false) {
|
|
202
175
|
// eslint-disable-next-line no-console
|
|
203
176
|
console.log("Unknown typography variant, ".concat(variant, ". Using default values for theme."));
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
177
|
+
}
|
|
178
|
+
// Make sure this "never" happens https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking
|
|
207
179
|
var exhaustiveCheck = variant;
|
|
208
180
|
return exhaustiveCheck;
|
|
209
181
|
}
|
|
210
182
|
}
|
|
211
|
-
|
|
212
183
|
return {
|
|
213
184
|
color: color,
|
|
214
185
|
family: family,
|
|
@@ -218,7 +189,6 @@ function getStylesForVariant(variant) {
|
|
|
218
189
|
withReset: true
|
|
219
190
|
};
|
|
220
191
|
}
|
|
221
|
-
|
|
222
192
|
var colorPropToVariableMap = {
|
|
223
193
|
active: _variables["default"].contentColorActive,
|
|
224
194
|
"default": _variables["default"].contentColorDefault,
|
|
@@ -230,8 +200,9 @@ var colorPropToVariableMap = {
|
|
|
230
200
|
var familyPropToVariableMap = {
|
|
231
201
|
sansSerif: _variables["default"].sansFontFamily,
|
|
232
202
|
monospace: _variables["default"].monoFontFamily
|
|
233
|
-
};
|
|
203
|
+
};
|
|
234
204
|
|
|
205
|
+
// As defined by [font-weight | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping)
|
|
235
206
|
var weightPropToValueMap = {
|
|
236
207
|
light: _variables["default"].fontWeightLight,
|
|
237
208
|
normal: _variables["default"].fontWeightNormal,
|
|
@@ -240,6 +211,7 @@ var weightPropToValueMap = {
|
|
|
240
211
|
extraBold: _variables["default"].fontWeightExtraBold,
|
|
241
212
|
heavy: _variables["default"].fontWeightHeavy
|
|
242
213
|
};
|
|
214
|
+
|
|
243
215
|
/**
|
|
244
216
|
* A mixin for styling text content using predefined typography variants
|
|
245
217
|
* and/or customizing font-settings with system parameters: e.g. size, weight, font-family.
|
|
@@ -289,7 +261,6 @@ var weightPropToValueMap = {
|
|
|
289
261
|
function typography(variantOrParams, additionalParams) {
|
|
290
262
|
var variant = isTypographyVariant(variantOrParams) ? variantOrParams : undefined;
|
|
291
263
|
var params;
|
|
292
|
-
|
|
293
264
|
if (variant && additionalParams !== undefined) {
|
|
294
265
|
params = additionalParams;
|
|
295
266
|
} else if (variant === undefined && _typeof(variantOrParams) === 'object' && additionalParams === undefined) {
|
|
@@ -297,9 +268,9 @@ function typography(variantOrParams, additionalParams) {
|
|
|
297
268
|
} else {
|
|
298
269
|
params = {};
|
|
299
270
|
}
|
|
271
|
+
var variantParams = variant ? getStylesForVariant(variant) : {};
|
|
300
272
|
|
|
301
|
-
|
|
302
|
-
|
|
273
|
+
// Transform params to be ready for css literal below: i.e size="24" -> "24px"
|
|
303
274
|
var transformedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
304
275
|
size: params.size ? "".concat(params.size, "px") : undefined,
|
|
305
276
|
lineHeight: params.lineHeight ? "".concat(params.lineHeight, "px") : undefined,
|
|
@@ -307,7 +278,6 @@ function typography(variantOrParams, additionalParams) {
|
|
|
307
278
|
family: params.family ? familyPropToVariableMap[params.family] : undefined,
|
|
308
279
|
weight: params.weight ? weightPropToValueMap[params.weight] : undefined
|
|
309
280
|
});
|
|
310
|
-
|
|
311
281
|
var defaultTypographyParams = {
|
|
312
282
|
color: _variables["default"].contentColorDefault,
|
|
313
283
|
family: _variables["default"].fontFamily,
|
|
@@ -323,6 +293,5 @@ function typography(variantOrParams, additionalParams) {
|
|
|
323
293
|
}, finalParams.color, finalParams.family, finalParams.size, finalParams.weight, finalParams.lineHeight);
|
|
324
294
|
};
|
|
325
295
|
}
|
|
326
|
-
|
|
327
296
|
var _default = typography;
|
|
328
297
|
exports["default"] = _default;
|
package/mixins/utilityMixins.js
CHANGED
|
@@ -13,31 +13,20 @@ exports.screenReaderContent = screenReaderContent;
|
|
|
13
13
|
exports.overlayColors = overlayColors;
|
|
14
14
|
exports.colorWithAlpha = colorWithAlpha;
|
|
15
15
|
exports["default"] = exports.reset = void 0;
|
|
16
|
-
|
|
17
16
|
var _tinycolor = _interopRequireDefault(require("tinycolor2"));
|
|
18
|
-
|
|
19
17
|
var _styledComponents = require("styled-components");
|
|
20
|
-
|
|
21
18
|
var _colorBlend = require("color-blend");
|
|
22
|
-
|
|
23
19
|
var _variables = _interopRequireDefault(require("../variables"));
|
|
24
|
-
|
|
25
20
|
var _pick = _interopRequireDefault(require("../pick"));
|
|
26
|
-
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
28
|
-
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
29
22
|
function _templateObject() {
|
|
30
23
|
var data = _taggedTemplateLiteral(["\n /* Generic resets */\n animation: none 0s ease 0s 1 normal none running;\n backface-visibility: visible;\n background: transparent none repeat 0 0 / auto auto padding-box border-box scroll;\n border: medium none currentColor;\n border-collapse: separate;\n border-image: none;\n border-radius: 0;\n border-spacing: 0;\n bottom: auto;\n box-shadow: none;\n caption-side: top;\n clear: none;\n clip: auto;\n color-scheme: ", ";\n columns: auto;\n column-count: auto;\n column-fill: balance;\n column-gap: normal;\n column-rule: medium none currentColor;\n column-span: 1;\n column-width: auto;\n content: normal;\n counter-increment: none;\n counter-reset: none;\n empty-cells: show;\n float: none;\n font-style: normal;\n font-variant: normal;\n font-weight: normal;\n font-stretch: normal;\n height: auto;\n hyphens: none;\n left: auto;\n letter-spacing: normal;\n list-style: disc outside none;\n margin: 0;\n max-height: none;\n max-width: none;\n min-height: 0;\n min-width: 0;\n opacity: 1;\n orphans: 2;\n overflow: visible;\n overflow-x: visible;\n overflow-y: visible;\n padding: 0;\n page-break-after: auto;\n page-break-before: auto;\n page-break-inside: auto;\n perspective: none;\n perspective-origin: 50% 50%;\n pointer-events: auto;\n position: static;\n right: auto;\n tab-size: 8;\n table-layout: auto;\n text-align: left;\n text-align-last: auto;\n text-decoration: none;\n text-indent: 0;\n text-shadow: none;\n text-transform: none;\n top: auto;\n transform: none;\n transform-origin: 50% 50% 0;\n transform-style: flat;\n transition: none 0s ease 0s;\n user-select: auto;\n vertical-align: baseline;\n white-space: normal;\n widows: 2;\n width: auto;\n word-spacing: normal;\n z-index: auto;\n /* Splunk-specific resets */\n border-width: 1px;\n box-sizing: border-box;\n color: ", ";\n cursor: inherit;\n display: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: ", ";\n outline: medium none ", ";\n visibility: inherit;\n "]);
|
|
31
|
-
|
|
32
24
|
_templateObject = function _templateObject() {
|
|
33
25
|
return data;
|
|
34
26
|
};
|
|
35
|
-
|
|
36
27
|
return data;
|
|
37
28
|
}
|
|
38
|
-
|
|
39
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
40
|
-
|
|
29
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
41
30
|
/**
|
|
42
31
|
* @file
|
|
43
32
|
* A collection of style-related helper functions. All of them return a single object containing
|
|
@@ -62,6 +51,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
62
51
|
* @param {string} [display=inline] Set the `display` property (block, inline-block, …)
|
|
63
52
|
* @public
|
|
64
53
|
*/
|
|
54
|
+
|
|
65
55
|
var reset = function reset() {
|
|
66
56
|
var display = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'inline';
|
|
67
57
|
return function () {
|
|
@@ -79,6 +69,7 @@ var reset = function reset() {
|
|
|
79
69
|
}), display, _variables["default"].fontFamily, _variables["default"].fontSize, _variables["default"].lineHeight, _variables["default"].focusColor);
|
|
80
70
|
};
|
|
81
71
|
};
|
|
72
|
+
|
|
82
73
|
/**
|
|
83
74
|
* `clearfix` is used on a container to ensure its height is at least as tall as any floating
|
|
84
75
|
* children.
|
|
@@ -94,10 +85,7 @@ var reset = function reset() {
|
|
|
94
85
|
* ```
|
|
95
86
|
* @public
|
|
96
87
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
88
|
exports.reset = reset;
|
|
100
|
-
|
|
101
89
|
function clearfix() {
|
|
102
90
|
return {
|
|
103
91
|
'&::after': {
|
|
@@ -107,6 +95,7 @@ function clearfix() {
|
|
|
107
95
|
}
|
|
108
96
|
};
|
|
109
97
|
}
|
|
98
|
+
|
|
110
99
|
/**
|
|
111
100
|
* Use `ellipsis` for overflowing text. Requires `display` to be set to `inline-block` or `block`.
|
|
112
101
|
*
|
|
@@ -122,8 +111,6 @@ function clearfix() {
|
|
|
122
111
|
* ```
|
|
123
112
|
* @public
|
|
124
113
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
114
|
function ellipsis() {
|
|
128
115
|
return {
|
|
129
116
|
overflow: 'hidden',
|
|
@@ -131,6 +118,7 @@ function ellipsis() {
|
|
|
131
118
|
whiteSpace: 'nowrap'
|
|
132
119
|
};
|
|
133
120
|
}
|
|
121
|
+
|
|
134
122
|
/**
|
|
135
123
|
* Force an element to be exactly 100% wide so that it doesn't overflow the page.
|
|
136
124
|
*
|
|
@@ -150,8 +138,6 @@ function ellipsis() {
|
|
|
150
138
|
* ```
|
|
151
139
|
* @public
|
|
152
140
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
141
|
function printWidth100Percent() {
|
|
156
142
|
return {
|
|
157
143
|
maxWidth: '100% !important',
|
|
@@ -159,6 +145,7 @@ function printWidth100Percent() {
|
|
|
159
145
|
overflow: 'hidden !important'
|
|
160
146
|
};
|
|
161
147
|
}
|
|
148
|
+
|
|
162
149
|
/**
|
|
163
150
|
* Hide an element (such as a button).
|
|
164
151
|
*
|
|
@@ -177,13 +164,12 @@ function printWidth100Percent() {
|
|
|
177
164
|
* ```
|
|
178
165
|
* @public
|
|
179
166
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
167
|
function printHide() {
|
|
183
168
|
return {
|
|
184
169
|
display: 'none !important'
|
|
185
170
|
};
|
|
186
171
|
}
|
|
172
|
+
|
|
187
173
|
/**
|
|
188
174
|
* Remove background gradients and images.
|
|
189
175
|
*
|
|
@@ -202,13 +188,12 @@ function printHide() {
|
|
|
202
188
|
* ```
|
|
203
189
|
* @public
|
|
204
190
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
191
|
function printNoBackground() {
|
|
208
192
|
return {
|
|
209
193
|
background: 'none !important'
|
|
210
194
|
};
|
|
211
195
|
}
|
|
196
|
+
|
|
212
197
|
/**
|
|
213
198
|
* Ensure that all text wraps so that it doesn't overflow the page.
|
|
214
199
|
*
|
|
@@ -227,8 +212,6 @@ function printNoBackground() {
|
|
|
227
212
|
* ```
|
|
228
213
|
* @public
|
|
229
214
|
*/
|
|
230
|
-
|
|
231
|
-
|
|
232
215
|
function printWrapAll() {
|
|
233
216
|
// TS: have to assert as CSSObject because csstype doesn't allow !important
|
|
234
217
|
return {
|
|
@@ -238,6 +221,7 @@ function printWrapAll() {
|
|
|
238
221
|
whiteSpace: 'normal !important'
|
|
239
222
|
};
|
|
240
223
|
}
|
|
224
|
+
|
|
241
225
|
/**
|
|
242
226
|
* Visually hide content. Typically used to target content for assistive technologies.
|
|
243
227
|
*
|
|
@@ -251,8 +235,6 @@ function printWrapAll() {
|
|
|
251
235
|
* ```
|
|
252
236
|
* @public
|
|
253
237
|
*/
|
|
254
|
-
|
|
255
|
-
|
|
256
238
|
function screenReaderContent() {
|
|
257
239
|
return {
|
|
258
240
|
position: 'absolute',
|
|
@@ -265,7 +247,6 @@ function screenReaderContent() {
|
|
|
265
247
|
border: 0
|
|
266
248
|
};
|
|
267
249
|
}
|
|
268
|
-
|
|
269
250
|
/**
|
|
270
251
|
* Calculates how one color would appear over another using a normal blend mode.
|
|
271
252
|
* Colors can either be strings or functions, such as variable functions.
|
|
@@ -294,6 +275,7 @@ function overlayColors(c1, c2) {
|
|
|
294
275
|
return (0, _tinycolor["default"])(c3).toRgbString();
|
|
295
276
|
};
|
|
296
277
|
}
|
|
278
|
+
|
|
297
279
|
/**
|
|
298
280
|
* Sets the alpha value on a given color.
|
|
299
281
|
*
|
|
@@ -313,21 +295,16 @@ function overlayColors(c1, c2) {
|
|
|
313
295
|
* @param {number} alpha The alpha value accepts range between 0-1.
|
|
314
296
|
* @public
|
|
315
297
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
318
298
|
function colorWithAlpha(color, alpha) {
|
|
319
299
|
return function (props) {
|
|
320
300
|
var colorValue = typeof color === 'function' ? color(props) : color;
|
|
321
|
-
|
|
322
301
|
if (false && (alpha < 0 || alpha > 1)) {
|
|
323
302
|
// eslint-disable-next-line no-console
|
|
324
303
|
console.warn("The alpha value \"".concat(alpha, "\" is not within acceptable 0-1 range."));
|
|
325
304
|
}
|
|
326
|
-
|
|
327
305
|
return (0, _tinycolor["default"])(colorValue).setAlpha(alpha).toRgbString();
|
|
328
306
|
};
|
|
329
307
|
}
|
|
330
|
-
|
|
331
308
|
var _default = {
|
|
332
309
|
reset: reset,
|
|
333
310
|
clearfix: clearfix,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splunk/themes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Theme variables and mixins for the Splunk design language",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"babel": "babel src -d . --ignore src/babel-plugin-base64-png,src/tests --ignore \"**/docs\" --extensions .js,.ts,.tsx",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"@storybook/manager-api": ">= 7.x",
|
|
27
27
|
"@storybook/react": ">= 7.x",
|
|
28
28
|
"@storybook/theming": ">= 7.x",
|
|
29
|
+
"@types/lodash": "^4.14.156",
|
|
30
|
+
"@types/react": "^16.9.38",
|
|
29
31
|
"react": "^16.8",
|
|
30
32
|
"styled-components": "^5.3.10"
|
|
31
33
|
},
|
|
@@ -48,6 +50,12 @@
|
|
|
48
50
|
"@storybook/react": {
|
|
49
51
|
"optional": true
|
|
50
52
|
},
|
|
53
|
+
"@types/lodash": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@types/react": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
51
59
|
"@storybook/theming": {
|
|
52
60
|
"optional": true
|
|
53
61
|
}
|
|
@@ -63,7 +71,7 @@
|
|
|
63
71
|
"@babel/cli": "^7.2.0",
|
|
64
72
|
"@babel/core": "^7.2.0",
|
|
65
73
|
"@splunk/babel-preset": "^4.0.0",
|
|
66
|
-
"@splunk/eslint-config": "^
|
|
74
|
+
"@splunk/eslint-config": "^5.0.0",
|
|
67
75
|
"@storybook/blocks": "^7.6.17",
|
|
68
76
|
"@storybook/components": "^7.6.17",
|
|
69
77
|
"@storybook/manager-api": "^7.6.17",
|
|
@@ -78,16 +86,16 @@
|
|
|
78
86
|
"@types/tinycolor2": "^1.4.2",
|
|
79
87
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
80
88
|
"@typescript-eslint/parser": "^6.21.0",
|
|
81
|
-
"babel-eslint": "^10.1.0",
|
|
82
89
|
"babel-plugin-transform-define": "^2.0.0",
|
|
83
90
|
"cross-env": "^6.0.3",
|
|
84
|
-
"eslint": "^
|
|
85
|
-
"eslint-config-airbnb": "^
|
|
86
|
-
"eslint-config-prettier": "^
|
|
87
|
-
"eslint-
|
|
88
|
-
"eslint-plugin-
|
|
89
|
-
"eslint-plugin-
|
|
90
|
-
"eslint-plugin-react
|
|
91
|
+
"eslint": "^8.57.1",
|
|
92
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
93
|
+
"eslint-config-prettier": "^9.1.0",
|
|
94
|
+
"eslint-import-resolver-webpack": "^0.13.4",
|
|
95
|
+
"eslint-plugin-import": "^2.30.1",
|
|
96
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
97
|
+
"eslint-plugin-react": "^7.36.1",
|
|
98
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
91
99
|
"jest": "^26.6.3",
|
|
92
100
|
"jest-styled-components": "^7.0.8",
|
|
93
101
|
"react": "^16.12.0",
|
package/pick.js
CHANGED
|
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isInterpolationResult = isInterpolationResult;
|
|
7
7
|
exports["default"] = exports.getThemeVariant = void 0;
|
|
8
|
-
|
|
9
8
|
var _utils = require("./utils");
|
|
10
|
-
|
|
11
|
-
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); }
|
|
12
|
-
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
10
|
var valueToKey = {
|
|
14
11
|
enterprise: 'family',
|
|
15
12
|
prisma: 'family',
|
|
@@ -18,42 +15,38 @@ var valueToKey = {
|
|
|
18
15
|
compact: 'density',
|
|
19
16
|
comfortable: 'density'
|
|
20
17
|
};
|
|
21
|
-
|
|
22
18
|
function isInterpolationResult(tree) {
|
|
23
19
|
// for this to work as expected for objects/CSSProperties, it may be necessary to change
|
|
24
20
|
// it to only consider objects that have valid pick tree keys (but no other keys)
|
|
25
21
|
// as trees
|
|
26
22
|
return _typeof(tree) !== 'object' || Array.isArray(tree) || tree === null;
|
|
27
23
|
}
|
|
24
|
+
|
|
28
25
|
/**
|
|
29
26
|
* This function is exported for use in pickVariant exclusively.
|
|
30
27
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
28
|
var getThemeVariant = function getThemeVariant(tree, theme) {
|
|
34
29
|
// If it's not an object with one of the six keys, it must be an end value.
|
|
35
30
|
var treeKey = Object.keys(tree).shift();
|
|
36
|
-
|
|
37
31
|
if (!treeKey) {
|
|
38
32
|
throw new Error('A pick tree cannot be empty.');
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
var themeKey = valueToKey[treeKey];
|
|
42
|
-
|
|
43
35
|
if (!themeKey) {
|
|
44
36
|
throw new Error("Invalid pick tree key: ".concat(treeKey));
|
|
45
|
-
}
|
|
46
|
-
|
|
37
|
+
}
|
|
47
38
|
|
|
39
|
+
// Recursively crawl the tree.
|
|
48
40
|
var themeCurrentValue = theme[themeKey];
|
|
49
|
-
var treeValue = tree[themeCurrentValue];
|
|
41
|
+
var treeValue = tree[themeCurrentValue];
|
|
50
42
|
|
|
43
|
+
// If it's not an object or it's a null value, it must be the end value.
|
|
51
44
|
if (isInterpolationResult(treeValue)) {
|
|
52
45
|
return treeValue; // this may be undefined, when the css does not support the theme
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
return getThemeVariant(treeValue, theme);
|
|
56
48
|
};
|
|
49
|
+
|
|
57
50
|
/**
|
|
58
51
|
* Pick is used to create theme-specific css.
|
|
59
52
|
*
|
|
@@ -88,10 +81,7 @@ var getThemeVariant = function getThemeVariant(tree, theme) {
|
|
|
88
81
|
* @returns {function} The returned function is called by `styled-components`, which provides the theme context.
|
|
89
82
|
* @public
|
|
90
83
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
84
|
exports.getThemeVariant = getThemeVariant;
|
|
94
|
-
|
|
95
85
|
var pick = function pick(tree) {
|
|
96
86
|
return function (_ref) {
|
|
97
87
|
var theme = _ref.theme;
|
|
@@ -99,6 +89,5 @@ var pick = function pick(tree) {
|
|
|
99
89
|
return getThemeVariant(tree, themeCleaned);
|
|
100
90
|
};
|
|
101
91
|
};
|
|
102
|
-
|
|
103
92
|
var _default = pick;
|
|
104
93
|
exports["default"] = _default;
|
package/pickVariant.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _pick = require("./pick");
|
|
9
|
-
|
|
10
8
|
var _utils = require("./utils");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Pick Variant is used to create theme-specific css.
|
|
14
11
|
*
|
|
@@ -46,22 +43,19 @@ var _utils = require("./utils");
|
|
|
46
43
|
* @returns {function} The returned function is called by `styled-components`, which provides the props and theme context.
|
|
47
44
|
* @public
|
|
48
45
|
*/
|
|
46
|
+
|
|
49
47
|
var pickVariant = function pickVariant(propName, tree) {
|
|
50
48
|
return function (props) {
|
|
51
49
|
var _props$theme;
|
|
52
|
-
|
|
53
50
|
// TS: must assume prop value can be used as string key
|
|
54
51
|
var variantKey = props[propName];
|
|
55
52
|
var subTree = tree[variantKey];
|
|
56
|
-
|
|
57
53
|
if ((0, _pick.isInterpolationResult)(subTree)) {
|
|
58
54
|
return subTree;
|
|
59
55
|
}
|
|
60
|
-
|
|
61
56
|
var theme = (0, _utils.addThemeDefaults)((_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : _props$theme.splunkThemeV1);
|
|
62
57
|
return (0, _pick.getThemeVariant)(subTree, theme);
|
|
63
58
|
};
|
|
64
59
|
};
|
|
65
|
-
|
|
66
60
|
var _default = pickVariant;
|
|
67
61
|
exports["default"] = _default;
|