@splunk/themes 0.15.0 → 0.16.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 CHANGED
@@ -1,6 +1,18 @@
1
1
  Change Log
2
2
  ============
3
3
 
4
+ 0.16.0 - April 6, 2023
5
+ ----------
6
+ New Features:
7
+ * Added variables for supported font weights; the `typography` mixin's `weight` param supports these as keyword values (SUI-5344).
8
+
9
+ Breaking Changes:
10
+ * `typography` mixin's `weight` param now only accepts keyword values. Number values have been removed (SUI-5344).
11
+
12
+ Bug Fixes:
13
+ * `typography` mixin properly applies correct CSS for `weight` params (SUI-5344).
14
+
15
+
4
16
  0.15.0 - January 25, 2023
5
17
  ----------
6
18
  New Features:
@@ -325,18 +325,32 @@ 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
+ * ## Font family
329
329
  *
330
330
  * @valueSet
331
331
  */
332
332
 
333
- var fonts = {
333
+ var fontFamily = {
334
334
  sansFontFamily: sansFontFamily,
335
335
  serifFontFamily: "Georgia, 'Times New Roman', Times, serif",
336
336
  monoFontFamily: "'Splunk Platform Mono', Inconsolata, Consolas, 'Droid Sans Mono', Monaco, 'Courier New', Courier, monospace",
337
- fontFamily: sansFontFamily,
338
- fontWeightBold: '700',
339
- fontWeightSemiBold: '500'
337
+ fontFamily: sansFontFamily
338
+ };
339
+ /**
340
+ * ## Font weights
341
+ *
342
+ * Based on [common weight name mappings](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping)
343
+ *
344
+ * @valueSet
345
+ */
346
+
347
+ var fontWeights = {
348
+ fontWeightLight: 300,
349
+ fontWeightNormal: 400,
350
+ fontWeightSemiBold: 500,
351
+ fontWeightBold: 700,
352
+ fontWeightHeavy: 800,
353
+ fontWeightExtraBold: 900
340
354
  };
341
355
  /**
342
356
  * ## Layers
@@ -354,7 +368,7 @@ var zindexes = {
354
368
  zindexToastMessages: 2000
355
369
  };
356
370
 
357
- var theme = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, brandColors), grays), accentColors), errorColors), alertColors), warningColors), successColors), infoColors), categoricalColors), divergingColors), syntaxColors), fonts), usageColors), backgrounds), shadows), borders), zindexes);
371
+ var theme = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, brandColors), grays), accentColors), errorColors), alertColors), warningColors), successColors), infoColors), categoricalColors), divergingColors), syntaxColors), fontFamily), fontWeights), usageColors), backgrounds), shadows), borders), zindexes);
358
372
 
359
373
  var _default = theme;
360
374
  exports["default"] = _default;
@@ -20,9 +20,19 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
20
20
 
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
22
22
 
23
- function _templateObject6() {
23
+ function _templateObject7() {
24
24
  var data = _taggedTemplateLiteral(["\n ", "\n ", ";\n ", ";\n "]);
25
25
 
26
+ _templateObject7 = function _templateObject7() {
27
+ return data;
28
+ };
29
+
30
+ return data;
31
+ }
32
+
33
+ function _templateObject6() {
34
+ var data = _taggedTemplateLiteral(["\n ", "\n "]);
35
+
26
36
  _templateObject6 = function _templateObject6() {
27
37
  return data;
28
38
  };
@@ -177,7 +187,7 @@ describe('typography', function () {
177
187
  var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
178
188
  container = _render5.container;
179
189
 
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 ");
190
+ 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: 900;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
181
191
  });
182
192
  it('allows default values to be overridden with params', function () {
183
193
  var Component = _styledComponents["default"].p(_templateObject5(), (0, _typography["default"])({
@@ -192,7 +202,22 @@ describe('typography', function () {
192
202
  var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
193
203
  container = _render6.container;
194
204
 
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 ");
205
+ 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: 900;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
206
+ });
207
+ it('transforms params that are shorthand properly to CSS', function () {
208
+ var Component = _styledComponents["default"].p(_templateObject6(), (0, _typography["default"])({
209
+ color: 'muted',
210
+ family: 'monospace',
211
+ lineHeight: 64,
212
+ size: 56,
213
+ weight: 'extraBold',
214
+ withReset: false
215
+ }));
216
+
217
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
218
+ container = _render7.container;
219
+
220
+ 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: 900;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
196
221
  });
197
222
  it.skip('passes TS verification', function () {
198
223
  (0, _typography["default"])();
@@ -227,7 +252,7 @@ describe('typography', function () {
227
252
  describe('passes TS verification', function () {
228
253
  it.skip('allows mixins in styled-components css', function () {
229
254
  /* eslint-disable-next-line @typescript-eslint/no-unused-expressions */
230
- (0, _styledComponents.css)(_templateObject6(), (0, _typography["default"])('title1'), (0, _typography["default"])('title1', {
255
+ (0, _styledComponents.css)(_templateObject7(), (0, _typography["default"])('title1'), (0, _typography["default"])('title1', {
231
256
  color: 'disabled'
232
257
  }), (0, _typography["default"])({
233
258
  family: 'monospace'
@@ -230,6 +230,15 @@ var colorPropToVariableMap = {
230
230
  var familyPropToVariableMap = {
231
231
  sansSerif: _variables["default"].sansFontFamily,
232
232
  monospace: _variables["default"].monoFontFamily
233
+ }; // As defined by [font-weight | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping)
234
+
235
+ var weightPropToValueMap = {
236
+ light: _variables["default"].fontWeightLight,
237
+ normal: _variables["default"].fontWeightNormal,
238
+ semiBold: _variables["default"].fontWeightSemiBold,
239
+ bold: _variables["default"].fontWeightBold,
240
+ extraBold: _variables["default"].fontWeightExtraBold,
241
+ heavy: _variables["default"].fontWeightHeavy
233
242
  };
234
243
  /**
235
244
  * A mixin for styling text content using predefined typography variants
@@ -295,7 +304,8 @@ function typography(variantOrParams, additionalParams) {
295
304
  size: params.size ? "".concat(params.size, "px") : undefined,
296
305
  lineHeight: params.lineHeight ? "".concat(params.lineHeight, "px") : undefined,
297
306
  color: params.color ? colorPropToVariableMap[params.color] : undefined,
298
- family: params.family ? familyPropToVariableMap[params.family] : undefined
307
+ family: params.family ? familyPropToVariableMap[params.family] : undefined,
308
+ weight: params.weight ? weightPropToValueMap[params.weight] : undefined
299
309
  });
300
310
 
301
311
  var defaultTypographyParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splunk/themes",
3
- "version": "0.15.0",
3
+ "version": "0.16.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",
package/prisma/base.js CHANGED
@@ -62,18 +62,32 @@ function createPrismaBase(_ref) {
62
62
  };
63
63
  var sansFontFamily = "'Splunk Platform Sans', 'Splunk Data Sans', Roboto, Droid, 'Helvetica Neue', Helvetica, Arial, sans-serif";
64
64
  /**
65
- * ## Fonts
65
+ * ## Font family
66
66
  *
67
67
  * @valueSet
68
68
  */
69
69
 
70
- var fonts = {
70
+ var fontFamily = {
71
71
  sansFontFamily: sansFontFamily,
72
72
  serifFontFamily: "Georgia, 'Times New Roman', Times, serif",
73
73
  monoFontFamily: "'Splunk Platform Mono', 'Roboto Mono', Consolas, 'Droid Sans Mono', Monaco, 'Courier New', Courier, monospace",
74
- fontFamily: sansFontFamily,
75
- fontWeightBold: '700',
76
- fontWeightSemiBold: '500'
74
+ fontFamily: sansFontFamily
75
+ };
76
+ /**
77
+ * ## Font weights
78
+ *
79
+ * Based on [common weight name mappings](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping)
80
+ *
81
+ * @valueSet
82
+ */
83
+
84
+ var fontWeights = {
85
+ fontWeightLight: 300,
86
+ fontWeightNormal: 400,
87
+ fontWeightSemiBold: 500,
88
+ fontWeightBold: 700,
89
+ fontWeightHeavy: 800,
90
+ fontWeightExtraBold: 900
77
91
  };
78
92
  /**
79
93
  * ## Layers
@@ -90,7 +104,7 @@ function createPrismaBase(_ref) {
90
104
  zindexPopover: 1060,
91
105
  zindexToastMessages: 2000
92
106
  };
93
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, fonts), usageColors), _dataViz["default"]), shadows), backgrounds), zindexes);
107
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, fontFamily), fontWeights), usageColors), _dataViz["default"]), shadows), backgrounds), zindexes);
94
108
  }
95
109
 
96
110
  var _default = createPrismaBase;
@@ -25,12 +25,16 @@ declare const theme: {
25
25
  overlayShadow: string;
26
26
  focusColor: string;
27
27
  transparent: string;
28
+ fontWeightLight: number;
29
+ fontWeightNormal: number;
30
+ fontWeightSemiBold: number;
31
+ fontWeightBold: number;
32
+ fontWeightHeavy: number;
33
+ fontWeightExtraBold: number;
28
34
  sansFontFamily: string;
29
35
  serifFontFamily: string;
30
36
  monoFontFamily: string;
31
37
  fontFamily: string;
32
- fontWeightBold: string;
33
- fontWeightSemiBold: string;
34
38
  syntaxBlue: string;
35
39
  syntaxBlueLight: string;
36
40
  syntaxBrown: string;
@@ -22,12 +22,16 @@ declare const theme: {
22
22
  backgroundColorHover: string;
23
23
  backgroundColor: string;
24
24
  transparent: string;
25
+ fontWeightLight: number;
26
+ fontWeightNormal: number;
27
+ fontWeightSemiBold: number;
28
+ fontWeightBold: number;
29
+ fontWeightHeavy: number;
30
+ fontWeightExtraBold: number;
25
31
  sansFontFamily: string;
26
32
  serifFontFamily: string;
27
33
  monoFontFamily: string;
28
34
  fontFamily: string;
29
- fontWeightBold: string;
30
- fontWeightSemiBold: string;
31
35
  syntaxBlue: string;
32
36
  syntaxBlueLight: string;
33
37
  syntaxBrown: string;
@@ -1,6 +1,7 @@
1
1
  import { AnyTheme, Interpolation, ThemedProps } from '../types';
2
2
  declare const typographyVariants: readonly ["body", "title1", "title2", "title3", "title4", "title5", "title6", "title7", "largeBody", "smallBody", "footnote", "monoBody", "monoSmallBody"];
3
3
  declare type TypographyVariant = typeof typographyVariants[number];
4
+ declare type TypographyTitleVariant = Extract<TypographyVariant, 'title1' | 'title2' | 'title3' | 'title4' | 'title5' | 'title6' | 'title7'>;
4
5
  interface TypographyParams {
5
6
  /**
6
7
  * Set the font-family to sans-serif or monospace based on current theme.
@@ -20,11 +21,8 @@ interface TypographyParams {
20
21
  color?: 'active' | 'default' | 'disabled' | 'inverted' | 'muted' | 'inherit';
21
22
  /**
22
23
  * Set the font-weight to a system-standard value.
23
- *
24
- * Number or equivalent string can be used.
25
- * See: [font-weight | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
26
24
  */
27
- weight?: 300 | 400 | 500 | 600 | 700 | 800 | 900 | 'light' | 'normal' | 'semiBold' | 'bold' | 'extraBold' | 'heavy';
25
+ weight?: 'light' | 'normal' | 'semiBold' | 'bold' | 'extraBold' | 'heavy';
28
26
  /**
29
27
  * Apply a reset to the element's margin and padding. This defaults to true if using a `variant`.
30
28
  */
@@ -80,4 +78,4 @@ declare function typography<T extends AnyTheme, A extends ThemedProps>(variant:
80
78
  declare function typography<T extends AnyTheme, A extends ThemedProps>({ family, size, lineHeight, color, weight, withReset, }: TypographyParams): Interpolation<T, A>;
81
79
  declare function typography<T extends AnyTheme, A extends ThemedProps>(variant: TypographyVariant, additionalParams: TypographyParams): Interpolation<T, A>;
82
80
  export default typography;
83
- export { typographyVariants, TypographyVariant, TypographyParams };
81
+ export { typographyVariants, TypographyTitleVariant, TypographyVariant, TypographyParams };
@@ -229,12 +229,16 @@ declare function createPrismaBase({ colorScheme }: {
229
229
  focusColor: string;
230
230
  transparent: string;
231
231
  linkColor: string;
232
+ fontWeightLight: number;
233
+ fontWeightNormal: number;
234
+ fontWeightSemiBold: number;
235
+ fontWeightBold: number;
236
+ fontWeightHeavy: number;
237
+ fontWeightExtraBold: number;
232
238
  sansFontFamily: string;
233
239
  serifFontFamily: string;
234
240
  monoFontFamily: string;
235
241
  fontFamily: string;
236
- fontWeightBold: string;
237
- fontWeightSemiBold: string;
238
242
  };
239
243
  declare type PrismaBase = ReturnType<typeof createPrismaBase>;
240
244
  export default createPrismaBase;