@atlaskit/primitives 1.19.0 → 1.20.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,5 +1,16 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 1.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#68163](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68163) [`67d09e3f972d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/67d09e3f972d) - `weight` property added to `Text` to allow overriding text variant default font weight.
8
+ - [#69343](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69343) [`77249f536425`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77249f536425) - `Text` color prop defaults to `color.text` if not provided.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 1.19.0
4
15
 
5
16
  ### Minor Changes
@@ -83,21 +83,18 @@ var Text = function Text(_ref) {
83
83
  var children = _ref.children,
84
84
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
85
85
  var asElement = props.as,
86
- colorProp = props.color,
86
+ _props$color = props.color,
87
+ colorProp = _props$color === void 0 ? 'color.text' : _props$color,
87
88
  textAlign = props.textAlign,
88
89
  testId = props.testId,
89
90
  id = props.id,
90
91
  _props$variant = props.variant,
91
- variant = _props$variant === void 0 ? 'body' : _props$variant;
92
- var Component = asElement;
93
- if (!Component) {
94
- if (variant.includes('body')) {
95
- Component = 'p';
96
- } else {
97
- // ui text and default => span
98
- Component = 'span';
99
- }
100
- }
92
+ variant = _props$variant === void 0 ? 'body' : _props$variant,
93
+ weight = props.weight;
94
+
95
+ // body variants -> p
96
+ // ui variants -> span
97
+ var Component = asElement || (variant.includes('body') ? 'p' : 'span');
101
98
  (0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
102
99
 
103
100
  // Remove the ability to bypass typescript errors for maxLines
@@ -116,7 +113,7 @@ var Text = function Text(_ref) {
116
113
  return (0, _react2.jsx)(_react.Fragment, null, children);
117
114
  }
118
115
  var component = (0, _react2.jsx)(Component, {
119
- css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
116
+ css: [resetStyles, variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && _styleMaps.fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
120
117
  style: {
121
118
  WebkitLineClamp: maxLines
122
119
  },
@@ -496,7 +496,7 @@ var borderRadiusMap = exports.borderRadiusMap = {
496
496
 
497
497
  /**
498
498
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
499
- * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
499
+ * @codegen <<SignedSource::402816562c359603300fda81596a2978>>
500
500
  * @codegenId typography
501
501
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
502
502
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -514,10 +514,10 @@ var fontSizeMap = exports.fontSizeMap = {
514
514
  'font.size.600': "var(--ds-font-size-600, 35px)"
515
515
  };
516
516
  var fontWeightMap = exports.fontWeightMap = {
517
- 'font.weight.bold': "var(--ds-font-weight-bold, 700)",
518
- 'font.weight.medium': "var(--ds-font-weight-medium, 500)",
519
- 'font.weight.regular': "var(--ds-font-weight-regular, 400)",
520
- 'font.weight.semibold': "var(--ds-font-weight-semibold, 600)"
517
+ bold: "var(--ds-font-weight-bold, 700)",
518
+ medium: "var(--ds-font-weight-medium, 500)",
519
+ regular: "var(--ds-font-weight-regular, 400)",
520
+ semibold: "var(--ds-font-weight-semibold, 600)"
521
521
  };
522
522
  var fontFamilyMap = exports.fontFamilyMap = {
523
523
  'font.family.body': "var(--ds-font-family-body, ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
@@ -542,7 +542,7 @@ var bodyTextMap = exports.bodyTextMap = {
542
542
  'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
543
543
  };
544
544
  var uiTextMap = exports.uiTextMap = {
545
- ui: "var(--ds-font-ui, normal 400 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
545
+ ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
546
546
  'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
547
547
  };
548
548
 
@@ -2,7 +2,7 @@
2
2
  import { createContext, Fragment, useContext } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import invariant from 'tiny-invariant';
5
- import { bodyTextStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
5
+ import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
6
6
  import { useSurface } from './internal/surface-provider';
7
7
  const asAllowlist = ['span', 'p', 'strong', 'em'];
8
8
  // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
@@ -75,21 +75,17 @@ const Text = ({
75
75
  }) => {
76
76
  const {
77
77
  as: asElement,
78
- color: colorProp,
78
+ color: colorProp = 'color.text',
79
79
  textAlign,
80
80
  testId,
81
81
  id,
82
- variant = 'body'
82
+ variant = 'body',
83
+ weight
83
84
  } = props;
84
- let Component = asElement;
85
- if (!Component) {
86
- if (variant.includes('body')) {
87
- Component = 'p';
88
- } else {
89
- // ui text and default => span
90
- Component = 'span';
91
- }
92
- }
85
+
86
+ // body variants -> p
87
+ // ui variants -> span
88
+ const Component = asElement || (variant.includes('body') ? 'p' : 'span');
93
89
  invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
94
90
 
95
91
  // Remove the ability to bypass typescript errors for maxLines
@@ -108,7 +104,7 @@ const Text = ({
108
104
  return jsx(Fragment, null, children);
109
105
  }
110
106
  const component = jsx(Component, {
111
- css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
107
+ css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
112
108
  style: {
113
109
  WebkitLineClamp: maxLines
114
110
  },
@@ -484,7 +484,7 @@ export const borderRadiusMap = {
484
484
  */
485
485
  /**
486
486
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
487
- * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
487
+ * @codegen <<SignedSource::402816562c359603300fda81596a2978>>
488
488
  * @codegenId typography
489
489
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
490
490
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -502,10 +502,10 @@ export const fontSizeMap = {
502
502
  'font.size.600': "var(--ds-font-size-600, 35px)"
503
503
  };
504
504
  export const fontWeightMap = {
505
- 'font.weight.bold': "var(--ds-font-weight-bold, 700)",
506
- 'font.weight.medium': "var(--ds-font-weight-medium, 500)",
507
- 'font.weight.regular': "var(--ds-font-weight-regular, 400)",
508
- 'font.weight.semibold': "var(--ds-font-weight-semibold, 600)"
505
+ bold: "var(--ds-font-weight-bold, 700)",
506
+ medium: "var(--ds-font-weight-medium, 500)",
507
+ regular: "var(--ds-font-weight-regular, 400)",
508
+ semibold: "var(--ds-font-weight-semibold, 600)"
509
509
  };
510
510
  export const fontFamilyMap = {
511
511
  'font.family.body': "var(--ds-font-family-body, ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
@@ -530,7 +530,7 @@ export const bodyTextMap = {
530
530
  'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
531
531
  };
532
532
  export const uiTextMap = {
533
- ui: "var(--ds-font-ui, normal 400 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
533
+ ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
534
534
  'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
535
535
  };
536
536
 
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { createContext, Fragment, useContext } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import invariant from 'tiny-invariant';
10
- import { bodyTextStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
10
+ import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
11
11
  import { useSurface } from './internal/surface-provider';
12
12
  var asAllowlist = ['span', 'p', 'strong', 'em'];
13
13
  // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
@@ -77,21 +77,18 @@ var Text = function Text(_ref) {
77
77
  var children = _ref.children,
78
78
  props = _objectWithoutProperties(_ref, _excluded);
79
79
  var asElement = props.as,
80
- colorProp = props.color,
80
+ _props$color = props.color,
81
+ colorProp = _props$color === void 0 ? 'color.text' : _props$color,
81
82
  textAlign = props.textAlign,
82
83
  testId = props.testId,
83
84
  id = props.id,
84
85
  _props$variant = props.variant,
85
- variant = _props$variant === void 0 ? 'body' : _props$variant;
86
- var Component = asElement;
87
- if (!Component) {
88
- if (variant.includes('body')) {
89
- Component = 'p';
90
- } else {
91
- // ui text and default => span
92
- Component = 'span';
93
- }
94
- }
86
+ variant = _props$variant === void 0 ? 'body' : _props$variant,
87
+ weight = props.weight;
88
+
89
+ // body variants -> p
90
+ // ui variants -> span
91
+ var Component = asElement || (variant.includes('body') ? 'p' : 'span');
95
92
  invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
96
93
 
97
94
  // Remove the ability to bypass typescript errors for maxLines
@@ -110,7 +107,7 @@ var Text = function Text(_ref) {
110
107
  return jsx(Fragment, null, children);
111
108
  }
112
109
  var component = jsx(Component, {
113
- css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
110
+ css: [resetStyles, variant && variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
114
111
  style: {
115
112
  WebkitLineClamp: maxLines
116
113
  },
@@ -484,7 +484,7 @@ export var borderRadiusMap = {
484
484
  */
485
485
  /**
486
486
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
487
- * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
487
+ * @codegen <<SignedSource::402816562c359603300fda81596a2978>>
488
488
  * @codegenId typography
489
489
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
490
490
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -502,10 +502,10 @@ export var fontSizeMap = {
502
502
  'font.size.600': "var(--ds-font-size-600, 35px)"
503
503
  };
504
504
  export var fontWeightMap = {
505
- 'font.weight.bold': "var(--ds-font-weight-bold, 700)",
506
- 'font.weight.medium': "var(--ds-font-weight-medium, 500)",
507
- 'font.weight.regular': "var(--ds-font-weight-regular, 400)",
508
- 'font.weight.semibold': "var(--ds-font-weight-semibold, 600)"
505
+ bold: "var(--ds-font-weight-bold, 700)",
506
+ medium: "var(--ds-font-weight-medium, 500)",
507
+ regular: "var(--ds-font-weight-regular, 400)",
508
+ semibold: "var(--ds-font-weight-semibold, 600)"
509
509
  };
510
510
  export var fontFamilyMap = {
511
511
  'font.family.body': "var(--ds-font-family-body, ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
@@ -530,7 +530,7 @@ export var bodyTextMap = {
530
530
  'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
531
531
  };
532
532
  export var uiTextMap = {
533
- ui: "var(--ds-font-ui, normal 400 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
533
+ ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
534
534
  'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
535
535
  };
536
536
 
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { FC, ReactNode } from 'react';
3
- import { BodyText, TextColor, UiText } from '../xcss/style-maps.partial';
3
+ import { BodyText, FontWeight, TextColor, UiText } from '../xcss/style-maps.partial';
4
4
  import type { BasePrimitiveProps } from './types';
5
5
  declare const asAllowlist: readonly ["span", "p", "strong", "em"];
6
6
  type AsElement = (typeof asAllowlist)[number];
@@ -48,6 +48,10 @@ type TextPropsBase = {
48
48
  * Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
49
49
  */
50
50
  textAlign?: TextAlign;
51
+ /**
52
+ * Font weight https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
53
+ */
54
+ weight?: FontWeight;
51
55
  };
52
56
  export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
53
57
  type TextAlign = keyof typeof textAlignMap;
@@ -515,7 +515,7 @@ export type BorderRadius = keyof typeof borderRadiusMap;
515
515
  */
516
516
  /**
517
517
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
518
- * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
518
+ * @codegen <<SignedSource::402816562c359603300fda81596a2978>>
519
519
  * @codegenId typography
520
520
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
521
521
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -534,10 +534,10 @@ export declare const fontSizeMap: {
534
534
  };
535
535
  export type FontSize = keyof typeof fontSizeMap;
536
536
  export declare const fontWeightMap: {
537
- 'font.weight.bold': "var(--ds-font-weight-bold)";
538
- 'font.weight.medium': "var(--ds-font-weight-medium)";
539
- 'font.weight.regular': "var(--ds-font-weight-regular)";
540
- 'font.weight.semibold': "var(--ds-font-weight-semibold)";
537
+ bold: "var(--ds-font-weight-bold)";
538
+ medium: "var(--ds-font-weight-medium)";
539
+ regular: "var(--ds-font-weight-regular)";
540
+ semibold: "var(--ds-font-weight-semibold)";
541
541
  };
542
542
  export type FontWeight = keyof typeof fontWeightMap;
543
543
  export declare const fontFamilyMap: {
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { FC, ReactNode } from 'react';
3
- import { BodyText, TextColor, UiText } from '../xcss/style-maps.partial';
3
+ import { BodyText, FontWeight, TextColor, UiText } from '../xcss/style-maps.partial';
4
4
  import type { BasePrimitiveProps } from './types';
5
5
  declare const asAllowlist: readonly [
6
6
  "span",
@@ -53,6 +53,10 @@ type TextPropsBase = {
53
53
  * Text align https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
54
54
  */
55
55
  textAlign?: TextAlign;
56
+ /**
57
+ * Font weight https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
58
+ */
59
+ weight?: FontWeight;
56
60
  };
57
61
  export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'> & (TextPropsBody | TextPropsUi);
58
62
  type TextAlign = keyof typeof textAlignMap;
@@ -515,7 +515,7 @@ export type BorderRadius = keyof typeof borderRadiusMap;
515
515
  */
516
516
  /**
517
517
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
518
- * @codegen <<SignedSource::badcf0eda5c0c2a7dca4428cc42a5db9>>
518
+ * @codegen <<SignedSource::402816562c359603300fda81596a2978>>
519
519
  * @codegenId typography
520
520
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
521
521
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
@@ -534,10 +534,10 @@ export declare const fontSizeMap: {
534
534
  };
535
535
  export type FontSize = keyof typeof fontSizeMap;
536
536
  export declare const fontWeightMap: {
537
- 'font.weight.bold': "var(--ds-font-weight-bold)";
538
- 'font.weight.medium': "var(--ds-font-weight-medium)";
539
- 'font.weight.regular': "var(--ds-font-weight-regular)";
540
- 'font.weight.semibold': "var(--ds-font-weight-semibold)";
537
+ bold: "var(--ds-font-weight-bold)";
538
+ medium: "var(--ds-font-weight-medium)";
539
+ regular: "var(--ds-font-weight-regular)";
540
+ semibold: "var(--ds-font-weight-semibold)";
541
541
  };
542
542
  export type FontWeight = keyof typeof fontWeightMap;
543
543
  export declare const fontFamilyMap: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -105,7 +105,7 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "@atlaskit/app-provider": "^0.4.0",
108
- "@atlaskit/tokens": "^1.34.0",
108
+ "@atlaskit/tokens": "^1.35.0",
109
109
  "@babel/runtime": "^7.0.0",
110
110
  "@emotion/react": "^11.7.1",
111
111
  "@emotion/serialize": "^1.1.0",
@@ -61,10 +61,17 @@ const activeTokens: Token[] = tokens.map(t => ({
61
61
  }));
62
62
 
63
63
  const removeVerbosity = (name: string): string => {
64
- const toRemove = ['font.heading', 'font.ui', 'font.body'];
65
- if (toRemove.some(s => name.includes(s))) {
64
+ const partialRemove = ['font.heading', 'font.ui', 'font.body'];
65
+ if (partialRemove.some(s => name.includes(s))) {
66
66
  return name.replace('font.', '');
67
67
  }
68
+
69
+ const fullRemove = ['font.weight'];
70
+ const removeIndex = fullRemove.findIndex(s => name.includes(s));
71
+ if (removeIndex > -1) {
72
+ return name.replace(`${fullRemove[removeIndex]}.`, '');
73
+ }
74
+
68
75
  return name;
69
76
  };
70
77