@atlaskit/primitives 1.6.5 → 1.6.7
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 +13 -0
- package/constellation/box/examples.mdx +5 -2
- package/constellation/stack/examples.mdx +2 -2
- package/constellation/text/examples.mdx +27 -0
- package/constellation/text/usage.mdx +9 -0
- package/dist/cjs/components/box.js +18 -15
- package/dist/cjs/components/text.js +25 -41
- package/dist/cjs/xcss/style-maps.partial.js +44 -3
- package/dist/es2019/components/box.js +18 -15
- package/dist/es2019/components/text.js +25 -47
- package/dist/es2019/xcss/style-maps.partial.js +43 -2
- package/dist/esm/components/box.js +18 -15
- package/dist/esm/components/text.js +26 -46
- package/dist/esm/xcss/style-maps.partial.js +43 -2
- package/dist/types/components/flex.d.ts +1 -1
- package/dist/types/components/grid.d.ts +1 -1
- package/dist/types/components/inline.d.ts +1 -1
- package/dist/types/components/stack.d.ts +1 -1
- package/dist/types/components/text.d.ts +5 -5
- package/dist/types/xcss/style-maps.partial.d.ts +41 -2
- package/dist/types-ts4.5/components/flex.d.ts +1 -1
- package/dist/types-ts4.5/components/grid.d.ts +1 -1
- package/dist/types-ts4.5/components/inline.d.ts +1 -1
- package/dist/types-ts4.5/components/stack.d.ts +1 -1
- package/dist/types-ts4.5/components/text.d.ts +5 -6
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +41 -2
- package/package.json +11 -2
- package/scripts/codegen-styles.tsx +12 -0
- package/scripts/inverse-color-map-template.tsx +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 1.6.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41516](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41516) [`350e4081d89`](https://bitbucket.org/atlassian/atlassian-frontend/commits/350e4081d89) - [ux] Regenerates codegen artifacts as a result of changes to color palettes and token values
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 1.6.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#41440](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41440) [`5c01cb4e16d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5c01cb4e16d) - Add surface color context to Box. Refine Text API.
|
|
15
|
+
|
|
3
16
|
## 1.6.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -8,7 +8,7 @@ import BoxBasic from '../../examples/constellation/box/basic';
|
|
|
8
8
|
import BoxPadding from '../../examples/constellation/box/padding';
|
|
9
9
|
import BoxBackgroundColor from '../../examples/constellation/box/background-color';
|
|
10
10
|
import BoxXcss from '../../examples/constellation/box/xcss';
|
|
11
|
-
import
|
|
11
|
+
import BoxPracticalUseCase from '../../examples/constellation/box/practical-use-case';
|
|
12
12
|
|
|
13
13
|
import { CodeDocsHeader } from '@af/design-system-docs-ui';
|
|
14
14
|
|
|
@@ -53,4 +53,7 @@ For more information on xcss, see the dedicated [xcss documentation](/components
|
|
|
53
53
|
|
|
54
54
|
`Box` is designed to be used in conjunction with `Inline` and `Stack` to create layouts. This example demonstrates how primitives can be used to create familiar components and patterns.
|
|
55
55
|
|
|
56
|
-
<Example
|
|
56
|
+
<Example
|
|
57
|
+
Component={BoxPracticalUseCase}
|
|
58
|
+
packageName="@atlaskit/primitives/box"
|
|
59
|
+
/>
|
|
@@ -5,7 +5,7 @@ order: 0
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
import StackBasic from '../../examples/constellation/stack/basic';
|
|
8
|
-
import
|
|
8
|
+
import StackPracticalUseCase from '../../examples/constellation/stack/practical-use-case';
|
|
9
9
|
import StackSpaceBasic from '../../examples/constellation/stack/space-basic';
|
|
10
10
|
import StackAlignBlock from '../../examples/constellation/stack/align-block';
|
|
11
11
|
import StackAlignInline from '../../examples/constellation/stack/align-inline';
|
|
@@ -75,6 +75,6 @@ It's possible to control the rendered HTML element with the `as` prop.
|
|
|
75
75
|
## Practical use case
|
|
76
76
|
|
|
77
77
|
<Example
|
|
78
|
-
Component={
|
|
78
|
+
Component={StackPracticalUseCase}
|
|
79
79
|
packageName="@atlaskit/primitives/stack"
|
|
80
80
|
/>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 0
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import TextDefault from '../../examples/constellation/text/basic';
|
|
6
|
+
import TextAsElement from '../../examples/constellation/text/as-element';
|
|
7
|
+
import ColorInverse from '../../examples/constellation/text/color-inverse';
|
|
8
|
+
|
|
9
|
+
## Basic
|
|
10
|
+
|
|
11
|
+
Implements the [Atlassian typography system](/foundations/typography/) as a component, scoped to body and UI text usages.
|
|
12
|
+
|
|
13
|
+
The `variant` prop expresses the visual appearance of the text element.
|
|
14
|
+
|
|
15
|
+
<Example Component={TextDefault} pacckageName="@atlaskit/primitives" />
|
|
16
|
+
|
|
17
|
+
## Rendered HTML tag
|
|
18
|
+
|
|
19
|
+
By default, `body` variants are rendered as `<p>` tags and `ui` variants are rendered as `<span>` tags. This can be ovrridden by the `as` prop.
|
|
20
|
+
|
|
21
|
+
<Example Component={TextAsElement} packageName="@atlaskit/primitives" />
|
|
22
|
+
|
|
23
|
+
## Color
|
|
24
|
+
|
|
25
|
+
Set `color` to change the text color. When used within a [box component](/components/primitives/box) that has a background color set, the text color can be automatically inverted without setting the `color` prop depending on the background color of the box.
|
|
26
|
+
|
|
27
|
+
<Example Component={ColorInverse} pacckageName="@atlaskit/primitives" />
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 2
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
UI text variants should be used in cases where line height being equal to the font size is desired. This is likely to be in UI components such as buttons.
|
|
8
|
+
|
|
9
|
+
Body text variants should be used for multi-line text. For each variant, we have coupled a line height which fits the variant's font size, ensuring that it is compliant with accessibility standards.
|
|
@@ -11,6 +11,7 @@ var _react = require("react");
|
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _styleMaps = require("../xcss/style-maps.partial");
|
|
13
13
|
var _xcss = require("../xcss/xcss");
|
|
14
|
+
var _surfaceProvider = require("./internal/surface-provider");
|
|
14
15
|
var _excluded = ["as", "children", "backgroundColor", "padding", "paddingBlock", "paddingBlockStart", "paddingBlockEnd", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "style", "testId", "xcss"],
|
|
15
16
|
_excluded2 = ["className"];
|
|
16
17
|
/** @jsx jsx */
|
|
@@ -51,21 +52,23 @@ var Box = exports.Box = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
51
52
|
var _spreadClass = htmlAttributes.className,
|
|
52
53
|
safeHtmlAttributes = (0, _objectWithoutProperties2.default)(htmlAttributes, _excluded2);
|
|
53
54
|
var className = xcss && (0, _xcss.parseXcss)(xcss);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)
|
|
55
|
+
var node =
|
|
56
|
+
// @ts-expect-error Expression produces a union type that is too complex to represent. I think this is unavoidable
|
|
57
|
+
(0, _react2.jsx)(Component, (0, _extends2.default)({
|
|
58
|
+
style: style
|
|
59
|
+
// @ts-expect-error Expression produces a union type that is too complex to represent. We may be able to narrow the type here but unsure.
|
|
60
|
+
,
|
|
61
|
+
ref: ref
|
|
62
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
63
|
+
}, safeHtmlAttributes, {
|
|
64
|
+
css: [baseStyles, backgroundColor && _styleMaps.backgroundColorStylesMap[backgroundColor], (0, _styleMaps.isSurfaceColorToken)(backgroundColor) && _styleMaps.surfaceColorStylesMap[backgroundColor], padding && _styleMaps.paddingStylesMap.padding[padding], paddingBlock && _styleMaps.paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && _styleMaps.paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && _styleMaps.paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && _styleMaps.paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && _styleMaps.paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && _styleMaps.paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
65
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
66
|
+
className],
|
|
67
|
+
"data-testid": testId
|
|
68
|
+
}), children);
|
|
69
|
+
return backgroundColor ? (0, _react2.jsx)(_surfaceProvider.SurfaceContext.Provider, {
|
|
70
|
+
value: backgroundColor
|
|
71
|
+
}, node) : node;
|
|
69
72
|
});
|
|
70
73
|
var _default = exports.default = Box;
|
|
71
74
|
var baseStyles = (0, _react2.css)({
|
|
@@ -11,14 +11,18 @@ var _react = require("react");
|
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
|
|
13
13
|
var _styleMaps = require("../xcss/style-maps.partial");
|
|
14
|
+
var _surfaceProvider = require("./internal/surface-provider");
|
|
14
15
|
var _excluded = ["children"];
|
|
15
16
|
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; }
|
|
16
17
|
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) { (0, _defineProperty2.default)(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; } /** @jsx jsx */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// import { useSurface } from './internal/surface-provider';
|
|
20
|
-
var asAllowlist = ['span', 'p', 'strong', 'em', 'label'];
|
|
18
|
+
var asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
21
19
|
var variantStyles = _objectSpread(_objectSpread({}, _styleMaps.bodyTextStylesMap), _styleMaps.uiTextStylesMap);
|
|
20
|
+
var strongStyles = (0, _react2.css)({
|
|
21
|
+
fontWeight: "var(--ds-font-weight-bold, bold)"
|
|
22
|
+
});
|
|
23
|
+
var emStyles = (0, _react2.css)({
|
|
24
|
+
fontStyle: 'italic'
|
|
25
|
+
});
|
|
22
26
|
var textAlignMap = {
|
|
23
27
|
center: (0, _react2.css)({
|
|
24
28
|
textAlign: 'center'
|
|
@@ -30,43 +34,26 @@ var textAlignMap = {
|
|
|
30
34
|
textAlign: 'start'
|
|
31
35
|
})
|
|
32
36
|
};
|
|
33
|
-
|
|
34
|
-
// p tag has padding on top in css-reset. dont know if we want to add it here
|
|
35
|
-
var baseStyles = (0, _react2.css)({
|
|
36
|
-
margin: "var(--ds-space-0, 0px)",
|
|
37
|
-
padding: "var(--ds-space-0, 0px)"
|
|
38
|
-
});
|
|
39
37
|
var truncateStyles = (0, _react2.css)({
|
|
40
38
|
overflow: 'hidden',
|
|
41
39
|
textOverflow: 'ellipsis',
|
|
42
40
|
whiteSpace: 'nowrap'
|
|
43
41
|
});
|
|
44
42
|
|
|
45
|
-
// TODO
|
|
46
|
-
// const asElementStyles: Record<AsElement, SerializedStyles> = {
|
|
47
|
-
// abbr: css({
|
|
48
|
-
// borderBottom: `1px ${token('color.border', '#ccc')} dotted`,
|
|
49
|
-
// cursor: 'help',
|
|
50
|
-
// }),
|
|
51
|
-
// };
|
|
52
|
-
|
|
53
43
|
/**
|
|
54
44
|
* Custom hook designed to abstract the parsing of the color props and make it clearer in the future how color is reconciled between themes and tokens.
|
|
55
45
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// surfaceColorMap[surface as keyof typeof surfaceColorMap];
|
|
60
|
-
|
|
61
|
-
// /**
|
|
62
|
-
// * Where the color of the surface is inverted we override the user choice
|
|
63
|
-
// * as there is no valid choice that is not covered by the override.
|
|
64
|
-
// */
|
|
65
|
-
// const color = inverseTextColor ?? colorProp;
|
|
66
|
-
|
|
67
|
-
// return color;
|
|
68
|
-
// };
|
|
46
|
+
var useColor = function useColor(colorProp) {
|
|
47
|
+
var surface = (0, _surfaceProvider.useSurface)();
|
|
48
|
+
var inverseTextColor = _styleMaps.inverseColorMap[surface];
|
|
69
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Where the color of the surface is inverted we override the user choice
|
|
52
|
+
* as there is no valid choice that is not covered by the override.
|
|
53
|
+
*/
|
|
54
|
+
var color = inverseTextColor !== null && inverseTextColor !== void 0 ? inverseTextColor : colorProp;
|
|
55
|
+
return color;
|
|
56
|
+
};
|
|
70
57
|
var HasTextAncestorContext = /*#__PURE__*/(0, _react.createContext)(false);
|
|
71
58
|
var useHasTextAncestor = function useHasTextAncestor() {
|
|
72
59
|
return (0, _react.useContext)(HasTextAncestorContext);
|
|
@@ -85,12 +72,14 @@ var Text = function Text(_ref) {
|
|
|
85
72
|
var children = _ref.children,
|
|
86
73
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
87
74
|
var asElement = props.as,
|
|
75
|
+
colorProp = props.color,
|
|
88
76
|
_props$shouldTruncate = props.shouldTruncate,
|
|
89
77
|
shouldTruncate = _props$shouldTruncate === void 0 ? false : _props$shouldTruncate,
|
|
90
78
|
textAlign = props.textAlign,
|
|
91
79
|
testId = props.testId,
|
|
92
80
|
id = props.id,
|
|
93
|
-
variant = props.variant
|
|
81
|
+
_props$variant = props.variant,
|
|
82
|
+
variant = _props$variant === void 0 ? 'body' : _props$variant;
|
|
94
83
|
var Component = asElement;
|
|
95
84
|
if (!Component) {
|
|
96
85
|
if (variant.includes('body')) {
|
|
@@ -100,8 +89,8 @@ var Text = function Text(_ref) {
|
|
|
100
89
|
Component = 'span';
|
|
101
90
|
}
|
|
102
91
|
}
|
|
103
|
-
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/
|
|
104
|
-
|
|
92
|
+
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
93
|
+
var color = useColor(colorProp);
|
|
105
94
|
var isWrapped = useHasTextAncestor();
|
|
106
95
|
|
|
107
96
|
/**
|
|
@@ -111,13 +100,8 @@ var Text = function Text(_ref) {
|
|
|
111
100
|
if (isWrapped && Object.keys(props).length === 0) {
|
|
112
101
|
return (0, _react2.jsx)(_react.Fragment, null, children);
|
|
113
102
|
}
|
|
114
|
-
var component = (0, _react2.jsx)(Component
|
|
115
|
-
|
|
116
|
-
, {
|
|
117
|
-
css: [baseStyles, variant && variantStyles[variant],
|
|
118
|
-
// color && textColorMap[color],
|
|
119
|
-
// colorProp && textColorMap[colorProp],
|
|
120
|
-
shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign]],
|
|
103
|
+
var component = (0, _react2.jsx)(Component, {
|
|
104
|
+
css: [variant && variantStyles[variant], color && _styleMaps.textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
121
105
|
"data-testid": testId,
|
|
122
106
|
id: id
|
|
123
107
|
}, children);
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.uiTextStylesMap = exports.uiTextMap = exports.textColorStylesMap = exports.textColorMap = exports.surfaceColorStylesMap = exports.surfaceColorMap = exports.spaceStylesMap = exports.spaceMap = exports.shadowMap = exports.paddingStylesMap = exports.negativeSpaceMap = exports.lineHeightStylesMap = exports.lineHeightMap = exports.layerMap = exports.isSurfaceColorToken = exports.fontWeightStylesMap = exports.fontWeightMap = exports.fontSizeStylesMap = exports.fontSizeMap = exports.fontFamilyStylesMap = exports.fontFamilyMap = exports.fillMap = exports.dimensionMap = exports.borderWidthMap = exports.borderRadiusMap = exports.borderColorMap = exports.bodyTextStylesMap = exports.bodyTextMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = void 0;
|
|
7
|
+
exports.uiTextStylesMap = exports.uiTextMap = exports.textColorStylesMap = exports.textColorMap = exports.surfaceColorStylesMap = exports.surfaceColorMap = exports.spaceStylesMap = exports.spaceMap = exports.shadowMap = exports.paddingStylesMap = exports.negativeSpaceMap = exports.lineHeightStylesMap = exports.lineHeightMap = exports.layerMap = exports.isSurfaceColorToken = exports.inverseColorMap = exports.fontWeightStylesMap = exports.fontWeightMap = exports.fontSizeStylesMap = exports.fontSizeMap = exports.fontFamilyStylesMap = exports.fontFamilyMap = exports.fillMap = exports.dimensionMap = exports.borderWidthMap = exports.borderRadiusMap = exports.borderColorMap = exports.bodyTextStylesMap = exports.bodyTextMap = exports.backgroundColorStylesMap = exports.backgroundColorMap = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _tokens = require("@atlaskit/tokens");
|
|
@@ -70,11 +70,52 @@ var negativeSpaceMap = exports.negativeSpaceMap = {
|
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
73
|
-
* @codegen <<SignedSource::
|
|
73
|
+
* @codegen <<SignedSource::fcf1cfc01cda3c278e69b0b564c7746d>>
|
|
74
|
+
* @codegenId inverse-colors
|
|
75
|
+
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
76
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
77
|
+
*/
|
|
78
|
+
var inverseColorMap = exports.inverseColorMap = {
|
|
79
|
+
'color.background.neutral.bold': 'color.text.inverse',
|
|
80
|
+
'color.background.neutral.bold.hovered': 'color.text.inverse',
|
|
81
|
+
'color.background.neutral.bold.pressed': 'color.text.inverse',
|
|
82
|
+
'color.background.selected.bold': 'color.text.inverse',
|
|
83
|
+
'color.background.selected.bold.hovered': 'color.text.inverse',
|
|
84
|
+
'color.background.selected.bold.pressed': 'color.text.inverse',
|
|
85
|
+
'color.background.brand.bold': 'color.text.inverse',
|
|
86
|
+
'color.background.brand.bold.hovered': 'color.text.inverse',
|
|
87
|
+
'color.background.brand.bold.pressed': 'color.text.inverse',
|
|
88
|
+
'color.background.brand.boldest': 'color.text.inverse',
|
|
89
|
+
'color.background.brand.boldest.hovered': 'color.text.inverse',
|
|
90
|
+
'color.background.brand.boldest.pressed': 'color.text.inverse',
|
|
91
|
+
'color.background.danger.bold': 'color.text.inverse',
|
|
92
|
+
'color.background.danger.bold.hovered': 'color.text.inverse',
|
|
93
|
+
'color.background.danger.bold.pressed': 'color.text.inverse',
|
|
94
|
+
'color.background.warning.bold': 'color.text.warning.inverse',
|
|
95
|
+
'color.background.warning.bold.hovered': 'color.text.warning.inverse',
|
|
96
|
+
'color.background.warning.bold.pressed': 'color.text.warning.inverse',
|
|
97
|
+
'color.background.success.bold': 'color.text.inverse',
|
|
98
|
+
'color.background.success.bold.hovered': 'color.text.inverse',
|
|
99
|
+
'color.background.success.bold.pressed': 'color.text.inverse',
|
|
100
|
+
'color.background.discovery.bold': 'color.text.inverse',
|
|
101
|
+
'color.background.discovery.bold.hovered': 'color.text.inverse',
|
|
102
|
+
'color.background.discovery.bold.pressed': 'color.text.inverse',
|
|
103
|
+
'color.background.information.bold': 'color.text.inverse',
|
|
104
|
+
'color.background.information.bold.hovered': 'color.text.inverse',
|
|
105
|
+
'color.background.information.bold.pressed': 'color.text.inverse'
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @codegenEnd
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
114
|
+
* @codegen <<SignedSource::4f49a5a763f3c327f1d7ce5f2d030194>>
|
|
74
115
|
* @codegenId colors
|
|
75
116
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
76
117
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
77
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
118
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
78
119
|
*/
|
|
79
120
|
var borderColorMap = exports.borderColorMap = {
|
|
80
121
|
'color.border': "var(--ds-border, #091e4221)",
|
|
@@ -4,6 +4,7 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { backgroundColorStylesMap, isSurfaceColorToken, paddingStylesMap, surfaceColorStylesMap } from '../xcss/style-maps.partial';
|
|
6
6
|
import { parseXcss } from '../xcss/xcss';
|
|
7
|
+
import { SurfaceContext } from './internal/surface-provider';
|
|
7
8
|
|
|
8
9
|
// Can either Exclude or Extract - here we're excluding all SVG-related elements
|
|
9
10
|
|
|
@@ -43,21 +44,23 @@ export const Box = /*#__PURE__*/forwardRef(({
|
|
|
43
44
|
...safeHtmlAttributes
|
|
44
45
|
} = htmlAttributes;
|
|
45
46
|
const className = xcss && parseXcss(xcss);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
const node =
|
|
48
|
+
// @ts-expect-error Expression produces a union type that is too complex to represent. I think this is unavoidable
|
|
49
|
+
jsx(Component, _extends({
|
|
50
|
+
style: style
|
|
51
|
+
// @ts-expect-error Expression produces a union type that is too complex to represent. We may be able to narrow the type here but unsure.
|
|
52
|
+
,
|
|
53
|
+
ref: ref
|
|
54
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
55
|
+
}, safeHtmlAttributes, {
|
|
56
|
+
css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], isSurfaceColorToken(backgroundColor) && surfaceColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
57
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
58
|
+
className],
|
|
59
|
+
"data-testid": testId
|
|
60
|
+
}), children);
|
|
61
|
+
return backgroundColor ? jsx(SurfaceContext.Provider, {
|
|
62
|
+
value: backgroundColor
|
|
63
|
+
}, node) : node;
|
|
61
64
|
});
|
|
62
65
|
export default Box;
|
|
63
66
|
const baseStyles = css({
|
|
@@ -2,19 +2,19 @@
|
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
9
|
-
|
|
10
|
-
// import surfaceColorMap from '../internal/color-map';
|
|
11
|
-
|
|
12
|
-
// import { useSurface } from './internal/surface-provider';
|
|
13
|
-
const asAllowlist = ['span', 'p', 'strong', 'em', 'label'];
|
|
5
|
+
import { bodyTextStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
6
|
+
import { useSurface } from './internal/surface-provider';
|
|
7
|
+
const asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
14
8
|
const variantStyles = {
|
|
15
9
|
...bodyTextStylesMap,
|
|
16
10
|
...uiTextStylesMap
|
|
17
11
|
};
|
|
12
|
+
const strongStyles = css({
|
|
13
|
+
fontWeight: "var(--ds-font-weight-bold, bold)"
|
|
14
|
+
});
|
|
15
|
+
const emStyles = css({
|
|
16
|
+
fontStyle: 'italic'
|
|
17
|
+
});
|
|
18
18
|
const textAlignMap = {
|
|
19
19
|
center: css({
|
|
20
20
|
textAlign: 'center'
|
|
@@ -26,43 +26,26 @@ const textAlignMap = {
|
|
|
26
26
|
textAlign: 'start'
|
|
27
27
|
})
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
// p tag has padding on top in css-reset. dont know if we want to add it here
|
|
31
|
-
const baseStyles = css({
|
|
32
|
-
margin: "var(--ds-space-0, 0px)",
|
|
33
|
-
padding: "var(--ds-space-0, 0px)"
|
|
34
|
-
});
|
|
35
29
|
const truncateStyles = css({
|
|
36
30
|
overflow: 'hidden',
|
|
37
31
|
textOverflow: 'ellipsis',
|
|
38
32
|
whiteSpace: 'nowrap'
|
|
39
33
|
});
|
|
40
34
|
|
|
41
|
-
// TODO
|
|
42
|
-
// const asElementStyles: Record<AsElement, SerializedStyles> = {
|
|
43
|
-
// abbr: css({
|
|
44
|
-
// borderBottom: `1px ${token('color.border', '#ccc')} dotted`,
|
|
45
|
-
// cursor: 'help',
|
|
46
|
-
// }),
|
|
47
|
-
// };
|
|
48
|
-
|
|
49
35
|
/**
|
|
50
36
|
* Custom hook designed to abstract the parsing of the color props and make it clearer in the future how color is reconciled between themes and tokens.
|
|
51
37
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// surfaceColorMap[surface as keyof typeof surfaceColorMap];
|
|
56
|
-
|
|
57
|
-
// /**
|
|
58
|
-
// * Where the color of the surface is inverted we override the user choice
|
|
59
|
-
// * as there is no valid choice that is not covered by the override.
|
|
60
|
-
// */
|
|
61
|
-
// const color = inverseTextColor ?? colorProp;
|
|
62
|
-
|
|
63
|
-
// return color;
|
|
64
|
-
// };
|
|
38
|
+
const useColor = colorProp => {
|
|
39
|
+
const surface = useSurface();
|
|
40
|
+
const inverseTextColor = inverseColorMap[surface];
|
|
65
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Where the color of the surface is inverted we override the user choice
|
|
44
|
+
* as there is no valid choice that is not covered by the override.
|
|
45
|
+
*/
|
|
46
|
+
const color = inverseTextColor !== null && inverseTextColor !== void 0 ? inverseTextColor : colorProp;
|
|
47
|
+
return color;
|
|
48
|
+
};
|
|
66
49
|
const HasTextAncestorContext = /*#__PURE__*/createContext(false);
|
|
67
50
|
const useHasTextAncestor = () => useContext(HasTextAncestorContext);
|
|
68
51
|
|
|
@@ -81,12 +64,12 @@ const Text = ({
|
|
|
81
64
|
}) => {
|
|
82
65
|
const {
|
|
83
66
|
as: asElement,
|
|
84
|
-
|
|
67
|
+
color: colorProp,
|
|
85
68
|
shouldTruncate = false,
|
|
86
69
|
textAlign,
|
|
87
70
|
testId,
|
|
88
71
|
id,
|
|
89
|
-
variant
|
|
72
|
+
variant = 'body'
|
|
90
73
|
} = props;
|
|
91
74
|
let Component = asElement;
|
|
92
75
|
if (!Component) {
|
|
@@ -97,8 +80,8 @@ const Text = ({
|
|
|
97
80
|
Component = 'span';
|
|
98
81
|
}
|
|
99
82
|
}
|
|
100
|
-
invariant(asAllowlist.includes(Component), `@atlaskit/
|
|
101
|
-
|
|
83
|
+
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
|
|
84
|
+
const color = useColor(colorProp);
|
|
102
85
|
const isWrapped = useHasTextAncestor();
|
|
103
86
|
|
|
104
87
|
/**
|
|
@@ -108,13 +91,8 @@ const Text = ({
|
|
|
108
91
|
if (isWrapped && Object.keys(props).length === 0) {
|
|
109
92
|
return jsx(Fragment, null, children);
|
|
110
93
|
}
|
|
111
|
-
const component = jsx(Component
|
|
112
|
-
|
|
113
|
-
, {
|
|
114
|
-
css: [baseStyles, variant && variantStyles[variant],
|
|
115
|
-
// color && textColorMap[color],
|
|
116
|
-
// colorProp && textColorMap[colorProp],
|
|
117
|
-
shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign]],
|
|
94
|
+
const component = jsx(Component, {
|
|
95
|
+
css: [variant && variantStyles[variant], color && textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
118
96
|
"data-testid": testId,
|
|
119
97
|
id: id
|
|
120
98
|
}, children);
|
|
@@ -61,11 +61,52 @@ export const negativeSpaceMap = {
|
|
|
61
61
|
*/
|
|
62
62
|
/**
|
|
63
63
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
64
|
-
* @codegen <<SignedSource::
|
|
64
|
+
* @codegen <<SignedSource::fcf1cfc01cda3c278e69b0b564c7746d>>
|
|
65
|
+
* @codegenId inverse-colors
|
|
66
|
+
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
67
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
68
|
+
*/
|
|
69
|
+
export const inverseColorMap = {
|
|
70
|
+
'color.background.neutral.bold': 'color.text.inverse',
|
|
71
|
+
'color.background.neutral.bold.hovered': 'color.text.inverse',
|
|
72
|
+
'color.background.neutral.bold.pressed': 'color.text.inverse',
|
|
73
|
+
'color.background.selected.bold': 'color.text.inverse',
|
|
74
|
+
'color.background.selected.bold.hovered': 'color.text.inverse',
|
|
75
|
+
'color.background.selected.bold.pressed': 'color.text.inverse',
|
|
76
|
+
'color.background.brand.bold': 'color.text.inverse',
|
|
77
|
+
'color.background.brand.bold.hovered': 'color.text.inverse',
|
|
78
|
+
'color.background.brand.bold.pressed': 'color.text.inverse',
|
|
79
|
+
'color.background.brand.boldest': 'color.text.inverse',
|
|
80
|
+
'color.background.brand.boldest.hovered': 'color.text.inverse',
|
|
81
|
+
'color.background.brand.boldest.pressed': 'color.text.inverse',
|
|
82
|
+
'color.background.danger.bold': 'color.text.inverse',
|
|
83
|
+
'color.background.danger.bold.hovered': 'color.text.inverse',
|
|
84
|
+
'color.background.danger.bold.pressed': 'color.text.inverse',
|
|
85
|
+
'color.background.warning.bold': 'color.text.warning.inverse',
|
|
86
|
+
'color.background.warning.bold.hovered': 'color.text.warning.inverse',
|
|
87
|
+
'color.background.warning.bold.pressed': 'color.text.warning.inverse',
|
|
88
|
+
'color.background.success.bold': 'color.text.inverse',
|
|
89
|
+
'color.background.success.bold.hovered': 'color.text.inverse',
|
|
90
|
+
'color.background.success.bold.pressed': 'color.text.inverse',
|
|
91
|
+
'color.background.discovery.bold': 'color.text.inverse',
|
|
92
|
+
'color.background.discovery.bold.hovered': 'color.text.inverse',
|
|
93
|
+
'color.background.discovery.bold.pressed': 'color.text.inverse',
|
|
94
|
+
'color.background.information.bold': 'color.text.inverse',
|
|
95
|
+
'color.background.information.bold.hovered': 'color.text.inverse',
|
|
96
|
+
'color.background.information.bold.pressed': 'color.text.inverse'
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @codegenEnd
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
105
|
+
* @codegen <<SignedSource::4f49a5a763f3c327f1d7ce5f2d030194>>
|
|
65
106
|
* @codegenId colors
|
|
66
107
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
67
108
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
68
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
109
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
69
110
|
*/
|
|
70
111
|
export const borderColorMap = {
|
|
71
112
|
'color.border': "var(--ds-border, #091e4221)",
|
|
@@ -7,6 +7,7 @@ import { forwardRef } from 'react';
|
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import { backgroundColorStylesMap, isSurfaceColorToken, paddingStylesMap, surfaceColorStylesMap } from '../xcss/style-maps.partial';
|
|
9
9
|
import { parseXcss } from '../xcss/xcss';
|
|
10
|
+
import { SurfaceContext } from './internal/surface-provider';
|
|
10
11
|
|
|
11
12
|
// Can either Exclude or Extract - here we're excluding all SVG-related elements
|
|
12
13
|
|
|
@@ -44,21 +45,23 @@ export var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
44
45
|
var _spreadClass = htmlAttributes.className,
|
|
45
46
|
safeHtmlAttributes = _objectWithoutProperties(htmlAttributes, _excluded2);
|
|
46
47
|
var className = xcss && parseXcss(xcss);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
var node =
|
|
49
|
+
// @ts-expect-error Expression produces a union type that is too complex to represent. I think this is unavoidable
|
|
50
|
+
jsx(Component, _extends({
|
|
51
|
+
style: style
|
|
52
|
+
// @ts-expect-error Expression produces a union type that is too complex to represent. We may be able to narrow the type here but unsure.
|
|
53
|
+
,
|
|
54
|
+
ref: ref
|
|
55
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
56
|
+
}, safeHtmlAttributes, {
|
|
57
|
+
css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], isSurfaceColorToken(backgroundColor) && surfaceColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
|
|
58
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
59
|
+
className],
|
|
60
|
+
"data-testid": testId
|
|
61
|
+
}), children);
|
|
62
|
+
return backgroundColor ? jsx(SurfaceContext.Provider, {
|
|
63
|
+
value: backgroundColor
|
|
64
|
+
}, node) : node;
|
|
62
65
|
});
|
|
63
66
|
export default Box;
|
|
64
67
|
var baseStyles = css({
|
|
@@ -7,16 +7,16 @@ 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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
14
|
-
|
|
15
|
-
// import surfaceColorMap from '../internal/color-map';
|
|
16
|
-
|
|
17
|
-
// import { useSurface } from './internal/surface-provider';
|
|
18
|
-
var asAllowlist = ['span', 'p', 'strong', 'em', 'label'];
|
|
10
|
+
import { bodyTextStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
|
|
11
|
+
import { useSurface } from './internal/surface-provider';
|
|
12
|
+
var asAllowlist = ['span', 'p', 'strong', 'em'];
|
|
19
13
|
var variantStyles = _objectSpread(_objectSpread({}, bodyTextStylesMap), uiTextStylesMap);
|
|
14
|
+
var strongStyles = css({
|
|
15
|
+
fontWeight: "var(--ds-font-weight-bold, bold)"
|
|
16
|
+
});
|
|
17
|
+
var emStyles = css({
|
|
18
|
+
fontStyle: 'italic'
|
|
19
|
+
});
|
|
20
20
|
var textAlignMap = {
|
|
21
21
|
center: css({
|
|
22
22
|
textAlign: 'center'
|
|
@@ -28,43 +28,26 @@ var textAlignMap = {
|
|
|
28
28
|
textAlign: 'start'
|
|
29
29
|
})
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
// p tag has padding on top in css-reset. dont know if we want to add it here
|
|
33
|
-
var baseStyles = css({
|
|
34
|
-
margin: "var(--ds-space-0, 0px)",
|
|
35
|
-
padding: "var(--ds-space-0, 0px)"
|
|
36
|
-
});
|
|
37
31
|
var truncateStyles = css({
|
|
38
32
|
overflow: 'hidden',
|
|
39
33
|
textOverflow: 'ellipsis',
|
|
40
34
|
whiteSpace: 'nowrap'
|
|
41
35
|
});
|
|
42
36
|
|
|
43
|
-
// TODO
|
|
44
|
-
// const asElementStyles: Record<AsElement, SerializedStyles> = {
|
|
45
|
-
// abbr: css({
|
|
46
|
-
// borderBottom: `1px ${token('color.border', '#ccc')} dotted`,
|
|
47
|
-
// cursor: 'help',
|
|
48
|
-
// }),
|
|
49
|
-
// };
|
|
50
|
-
|
|
51
37
|
/**
|
|
52
38
|
* Custom hook designed to abstract the parsing of the color props and make it clearer in the future how color is reconciled between themes and tokens.
|
|
53
39
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// surfaceColorMap[surface as keyof typeof surfaceColorMap];
|
|
58
|
-
|
|
59
|
-
// /**
|
|
60
|
-
// * Where the color of the surface is inverted we override the user choice
|
|
61
|
-
// * as there is no valid choice that is not covered by the override.
|
|
62
|
-
// */
|
|
63
|
-
// const color = inverseTextColor ?? colorProp;
|
|
64
|
-
|
|
65
|
-
// return color;
|
|
66
|
-
// };
|
|
40
|
+
var useColor = function useColor(colorProp) {
|
|
41
|
+
var surface = useSurface();
|
|
42
|
+
var inverseTextColor = inverseColorMap[surface];
|
|
67
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Where the color of the surface is inverted we override the user choice
|
|
46
|
+
* as there is no valid choice that is not covered by the override.
|
|
47
|
+
*/
|
|
48
|
+
var color = inverseTextColor !== null && inverseTextColor !== void 0 ? inverseTextColor : colorProp;
|
|
49
|
+
return color;
|
|
50
|
+
};
|
|
68
51
|
var HasTextAncestorContext = /*#__PURE__*/createContext(false);
|
|
69
52
|
var useHasTextAncestor = function useHasTextAncestor() {
|
|
70
53
|
return useContext(HasTextAncestorContext);
|
|
@@ -83,12 +66,14 @@ var Text = function Text(_ref) {
|
|
|
83
66
|
var children = _ref.children,
|
|
84
67
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
85
68
|
var asElement = props.as,
|
|
69
|
+
colorProp = props.color,
|
|
86
70
|
_props$shouldTruncate = props.shouldTruncate,
|
|
87
71
|
shouldTruncate = _props$shouldTruncate === void 0 ? false : _props$shouldTruncate,
|
|
88
72
|
textAlign = props.textAlign,
|
|
89
73
|
testId = props.testId,
|
|
90
74
|
id = props.id,
|
|
91
|
-
variant = props.variant
|
|
75
|
+
_props$variant = props.variant,
|
|
76
|
+
variant = _props$variant === void 0 ? 'body' : _props$variant;
|
|
92
77
|
var Component = asElement;
|
|
93
78
|
if (!Component) {
|
|
94
79
|
if (variant.includes('body')) {
|
|
@@ -98,8 +83,8 @@ var Text = function Text(_ref) {
|
|
|
98
83
|
Component = 'span';
|
|
99
84
|
}
|
|
100
85
|
}
|
|
101
|
-
invariant(asAllowlist.includes(Component), "@atlaskit/
|
|
102
|
-
|
|
86
|
+
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
87
|
+
var color = useColor(colorProp);
|
|
103
88
|
var isWrapped = useHasTextAncestor();
|
|
104
89
|
|
|
105
90
|
/**
|
|
@@ -109,13 +94,8 @@ var Text = function Text(_ref) {
|
|
|
109
94
|
if (isWrapped && Object.keys(props).length === 0) {
|
|
110
95
|
return jsx(Fragment, null, children);
|
|
111
96
|
}
|
|
112
|
-
var component = jsx(Component
|
|
113
|
-
|
|
114
|
-
, {
|
|
115
|
-
css: [baseStyles, variant && variantStyles[variant],
|
|
116
|
-
// color && textColorMap[color],
|
|
117
|
-
// colorProp && textColorMap[colorProp],
|
|
118
|
-
shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign]],
|
|
97
|
+
var component = jsx(Component, {
|
|
98
|
+
css: [variant && variantStyles[variant], color && textColorStylesMap[color], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], asElement === 'em' && emStyles, asElement === 'strong' && strongStyles],
|
|
119
99
|
"data-testid": testId,
|
|
120
100
|
id: id
|
|
121
101
|
}, children);
|
|
@@ -62,11 +62,52 @@ export var negativeSpaceMap = {
|
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
64
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
65
|
-
* @codegen <<SignedSource::
|
|
65
|
+
* @codegen <<SignedSource::fcf1cfc01cda3c278e69b0b564c7746d>>
|
|
66
|
+
* @codegenId inverse-colors
|
|
67
|
+
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
69
|
+
*/
|
|
70
|
+
export var inverseColorMap = {
|
|
71
|
+
'color.background.neutral.bold': 'color.text.inverse',
|
|
72
|
+
'color.background.neutral.bold.hovered': 'color.text.inverse',
|
|
73
|
+
'color.background.neutral.bold.pressed': 'color.text.inverse',
|
|
74
|
+
'color.background.selected.bold': 'color.text.inverse',
|
|
75
|
+
'color.background.selected.bold.hovered': 'color.text.inverse',
|
|
76
|
+
'color.background.selected.bold.pressed': 'color.text.inverse',
|
|
77
|
+
'color.background.brand.bold': 'color.text.inverse',
|
|
78
|
+
'color.background.brand.bold.hovered': 'color.text.inverse',
|
|
79
|
+
'color.background.brand.bold.pressed': 'color.text.inverse',
|
|
80
|
+
'color.background.brand.boldest': 'color.text.inverse',
|
|
81
|
+
'color.background.brand.boldest.hovered': 'color.text.inverse',
|
|
82
|
+
'color.background.brand.boldest.pressed': 'color.text.inverse',
|
|
83
|
+
'color.background.danger.bold': 'color.text.inverse',
|
|
84
|
+
'color.background.danger.bold.hovered': 'color.text.inverse',
|
|
85
|
+
'color.background.danger.bold.pressed': 'color.text.inverse',
|
|
86
|
+
'color.background.warning.bold': 'color.text.warning.inverse',
|
|
87
|
+
'color.background.warning.bold.hovered': 'color.text.warning.inverse',
|
|
88
|
+
'color.background.warning.bold.pressed': 'color.text.warning.inverse',
|
|
89
|
+
'color.background.success.bold': 'color.text.inverse',
|
|
90
|
+
'color.background.success.bold.hovered': 'color.text.inverse',
|
|
91
|
+
'color.background.success.bold.pressed': 'color.text.inverse',
|
|
92
|
+
'color.background.discovery.bold': 'color.text.inverse',
|
|
93
|
+
'color.background.discovery.bold.hovered': 'color.text.inverse',
|
|
94
|
+
'color.background.discovery.bold.pressed': 'color.text.inverse',
|
|
95
|
+
'color.background.information.bold': 'color.text.inverse',
|
|
96
|
+
'color.background.information.bold.hovered': 'color.text.inverse',
|
|
97
|
+
'color.background.information.bold.pressed': 'color.text.inverse'
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @codegenEnd
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
106
|
+
* @codegen <<SignedSource::4f49a5a763f3c327f1d7ce5f2d030194>>
|
|
66
107
|
* @codegenId colors
|
|
67
108
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
109
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
69
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
110
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
70
111
|
*/
|
|
71
112
|
export var borderColorMap = {
|
|
72
113
|
'color.border': "var(--ds-border, #091e4221)",
|
|
@@ -133,5 +133,5 @@ declare const Flex: import("react").MemoExoticComponent<import("react").ForwardR
|
|
|
133
133
|
* Forwarded ref element
|
|
134
134
|
*/
|
|
135
135
|
ref?: any;
|
|
136
|
-
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "
|
|
136
|
+
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "children" | "as" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
|
|
137
137
|
export default Flex;
|
|
@@ -191,5 +191,5 @@ declare const Grid: import("react").MemoExoticComponent<import("react").ForwardR
|
|
|
191
191
|
* Forwarded ref element
|
|
192
192
|
*/
|
|
193
193
|
ref?: any;
|
|
194
|
-
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignContent" | "alignItems" | "justifyContent" | "justifyItems" | "
|
|
194
|
+
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignContent" | "alignItems" | "justifyContent" | "justifyItems" | "children" | "as" | "id" | keyof BasePrimitiveProps | "autoFlow" | "templateAreas" | "templateRows" | "templateColumns"> & import("react").RefAttributes<any>>>;
|
|
195
195
|
export default Grid;
|
|
@@ -109,5 +109,5 @@ declare const Inline: import("react").MemoExoticComponent<import("react").Forwar
|
|
|
109
109
|
* Forwarded ref element
|
|
110
110
|
*/
|
|
111
111
|
ref?: any;
|
|
112
|
-
} & BasePrimitiveProps, "space" | "separator" | "
|
|
112
|
+
} & BasePrimitiveProps, "space" | "separator" | "children" | "as" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
|
|
113
113
|
export default Inline;
|
|
@@ -83,5 +83,5 @@ declare const Stack: import("react").MemoExoticComponent<import("react").Forward
|
|
|
83
83
|
* Forwarded ref element
|
|
84
84
|
*/
|
|
85
85
|
ref?: any;
|
|
86
|
-
} & BasePrimitiveProps, "space" | "
|
|
86
|
+
} & BasePrimitiveProps, "space" | "children" | "as" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
|
|
87
87
|
export default Stack;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { FC, ReactNode } from 'react';
|
|
3
3
|
import { BodyText, TextColor, UiText } from '../xcss/style-maps.partial';
|
|
4
4
|
import type { BasePrimitiveProps } from './types';
|
|
5
|
-
declare const asAllowlist: readonly ["span", "p", "strong", "em"
|
|
5
|
+
declare const asAllowlist: readonly ["span", "p", "strong", "em"];
|
|
6
6
|
type AsElement = (typeof asAllowlist)[number];
|
|
7
7
|
type Variant = BodyText | UiText;
|
|
8
8
|
export interface TextProps extends BasePrimitiveProps {
|
|
@@ -17,10 +17,11 @@ export interface TextProps extends BasePrimitiveProps {
|
|
|
17
17
|
/**
|
|
18
18
|
* Text variant
|
|
19
19
|
*/
|
|
20
|
-
variant
|
|
20
|
+
variant?: Variant;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Token representing text color with a built-in fallback value.
|
|
23
|
+
* Will apply inverse text color automatically if placed within a Box with backgroundColor.
|
|
24
|
+
*
|
|
24
25
|
*/
|
|
25
26
|
color?: TextColor;
|
|
26
27
|
/**
|
|
@@ -30,7 +31,6 @@ export interface TextProps extends BasePrimitiveProps {
|
|
|
30
31
|
/**
|
|
31
32
|
* Truncates text with an ellipsis when text overflows its parent container
|
|
32
33
|
* (i.e. `width` has been set on parent that is shorter than text length).
|
|
33
|
-
* Pending truncation exploration -- remove for now?
|
|
34
34
|
*/
|
|
35
35
|
shouldTruncate?: boolean;
|
|
36
36
|
/**
|
|
@@ -62,11 +62,50 @@ export type NegativeSpace = keyof typeof negativeSpaceMap;
|
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
64
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
65
|
-
* @codegen <<SignedSource::
|
|
65
|
+
* @codegen <<SignedSource::fcf1cfc01cda3c278e69b0b564c7746d>>
|
|
66
|
+
* @codegenId inverse-colors
|
|
67
|
+
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
69
|
+
*/
|
|
70
|
+
export declare const inverseColorMap: {
|
|
71
|
+
readonly 'color.background.neutral.bold': "color.text.inverse";
|
|
72
|
+
readonly 'color.background.neutral.bold.hovered': "color.text.inverse";
|
|
73
|
+
readonly 'color.background.neutral.bold.pressed': "color.text.inverse";
|
|
74
|
+
readonly 'color.background.selected.bold': "color.text.inverse";
|
|
75
|
+
readonly 'color.background.selected.bold.hovered': "color.text.inverse";
|
|
76
|
+
readonly 'color.background.selected.bold.pressed': "color.text.inverse";
|
|
77
|
+
readonly 'color.background.brand.bold': "color.text.inverse";
|
|
78
|
+
readonly 'color.background.brand.bold.hovered': "color.text.inverse";
|
|
79
|
+
readonly 'color.background.brand.bold.pressed': "color.text.inverse";
|
|
80
|
+
readonly 'color.background.brand.boldest': "color.text.inverse";
|
|
81
|
+
readonly 'color.background.brand.boldest.hovered': "color.text.inverse";
|
|
82
|
+
readonly 'color.background.brand.boldest.pressed': "color.text.inverse";
|
|
83
|
+
readonly 'color.background.danger.bold': "color.text.inverse";
|
|
84
|
+
readonly 'color.background.danger.bold.hovered': "color.text.inverse";
|
|
85
|
+
readonly 'color.background.danger.bold.pressed': "color.text.inverse";
|
|
86
|
+
readonly 'color.background.warning.bold': "color.text.warning.inverse";
|
|
87
|
+
readonly 'color.background.warning.bold.hovered': "color.text.warning.inverse";
|
|
88
|
+
readonly 'color.background.warning.bold.pressed': "color.text.warning.inverse";
|
|
89
|
+
readonly 'color.background.success.bold': "color.text.inverse";
|
|
90
|
+
readonly 'color.background.success.bold.hovered': "color.text.inverse";
|
|
91
|
+
readonly 'color.background.success.bold.pressed': "color.text.inverse";
|
|
92
|
+
readonly 'color.background.discovery.bold': "color.text.inverse";
|
|
93
|
+
readonly 'color.background.discovery.bold.hovered': "color.text.inverse";
|
|
94
|
+
readonly 'color.background.discovery.bold.pressed': "color.text.inverse";
|
|
95
|
+
readonly 'color.background.information.bold': "color.text.inverse";
|
|
96
|
+
readonly 'color.background.information.bold.hovered': "color.text.inverse";
|
|
97
|
+
readonly 'color.background.information.bold.pressed': "color.text.inverse";
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @codegenEnd
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
104
|
+
* @codegen <<SignedSource::4f49a5a763f3c327f1d7ce5f2d030194>>
|
|
66
105
|
* @codegenId colors
|
|
67
106
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
107
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
69
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
108
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
70
109
|
*/
|
|
71
110
|
export declare const borderColorMap: {
|
|
72
111
|
readonly 'color.border': "var(--ds-border)";
|
|
@@ -133,5 +133,5 @@ declare const Flex: import("react").MemoExoticComponent<import("react").ForwardR
|
|
|
133
133
|
* Forwarded ref element
|
|
134
134
|
*/
|
|
135
135
|
ref?: any;
|
|
136
|
-
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "
|
|
136
|
+
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "children" | "as" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
|
|
137
137
|
export default Flex;
|
|
@@ -191,5 +191,5 @@ declare const Grid: import("react").MemoExoticComponent<import("react").ForwardR
|
|
|
191
191
|
* Forwarded ref element
|
|
192
192
|
*/
|
|
193
193
|
ref?: any;
|
|
194
|
-
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignContent" | "alignItems" | "justifyContent" | "justifyItems" | "
|
|
194
|
+
} & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignContent" | "alignItems" | "justifyContent" | "justifyItems" | "children" | "as" | "id" | keyof BasePrimitiveProps | "autoFlow" | "templateAreas" | "templateRows" | "templateColumns"> & import("react").RefAttributes<any>>>;
|
|
195
195
|
export default Grid;
|
|
@@ -109,5 +109,5 @@ declare const Inline: import("react").MemoExoticComponent<import("react").Forwar
|
|
|
109
109
|
* Forwarded ref element
|
|
110
110
|
*/
|
|
111
111
|
ref?: any;
|
|
112
|
-
} & BasePrimitiveProps, "space" | "separator" | "
|
|
112
|
+
} & BasePrimitiveProps, "space" | "separator" | "children" | "as" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
|
|
113
113
|
export default Inline;
|
|
@@ -83,5 +83,5 @@ declare const Stack: import("react").MemoExoticComponent<import("react").Forward
|
|
|
83
83
|
* Forwarded ref element
|
|
84
84
|
*/
|
|
85
85
|
ref?: any;
|
|
86
|
-
} & BasePrimitiveProps, "space" | "
|
|
86
|
+
} & BasePrimitiveProps, "space" | "children" | "as" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
|
|
87
87
|
export default Stack;
|
|
@@ -6,8 +6,7 @@ declare const asAllowlist: readonly [
|
|
|
6
6
|
"span",
|
|
7
7
|
"p",
|
|
8
8
|
"strong",
|
|
9
|
-
"em"
|
|
10
|
-
"label"
|
|
9
|
+
"em"
|
|
11
10
|
];
|
|
12
11
|
type AsElement = (typeof asAllowlist)[number];
|
|
13
12
|
type Variant = BodyText | UiText;
|
|
@@ -23,10 +22,11 @@ export interface TextProps extends BasePrimitiveProps {
|
|
|
23
22
|
/**
|
|
24
23
|
* Text variant
|
|
25
24
|
*/
|
|
26
|
-
variant
|
|
25
|
+
variant?: Variant;
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Token representing text color with a built-in fallback value.
|
|
28
|
+
* Will apply inverse text color automatically if placed within a Box with backgroundColor.
|
|
29
|
+
*
|
|
30
30
|
*/
|
|
31
31
|
color?: TextColor;
|
|
32
32
|
/**
|
|
@@ -36,7 +36,6 @@ export interface TextProps extends BasePrimitiveProps {
|
|
|
36
36
|
/**
|
|
37
37
|
* Truncates text with an ellipsis when text overflows its parent container
|
|
38
38
|
* (i.e. `width` has been set on parent that is shorter than text length).
|
|
39
|
-
* Pending truncation exploration -- remove for now?
|
|
40
39
|
*/
|
|
41
40
|
shouldTruncate?: boolean;
|
|
42
41
|
/**
|
|
@@ -62,11 +62,50 @@ export type NegativeSpace = keyof typeof negativeSpaceMap;
|
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
64
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
65
|
-
* @codegen <<SignedSource::
|
|
65
|
+
* @codegen <<SignedSource::fcf1cfc01cda3c278e69b0b564c7746d>>
|
|
66
|
+
* @codegenId inverse-colors
|
|
67
|
+
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
69
|
+
*/
|
|
70
|
+
export declare const inverseColorMap: {
|
|
71
|
+
readonly 'color.background.neutral.bold': "color.text.inverse";
|
|
72
|
+
readonly 'color.background.neutral.bold.hovered': "color.text.inverse";
|
|
73
|
+
readonly 'color.background.neutral.bold.pressed': "color.text.inverse";
|
|
74
|
+
readonly 'color.background.selected.bold': "color.text.inverse";
|
|
75
|
+
readonly 'color.background.selected.bold.hovered': "color.text.inverse";
|
|
76
|
+
readonly 'color.background.selected.bold.pressed': "color.text.inverse";
|
|
77
|
+
readonly 'color.background.brand.bold': "color.text.inverse";
|
|
78
|
+
readonly 'color.background.brand.bold.hovered': "color.text.inverse";
|
|
79
|
+
readonly 'color.background.brand.bold.pressed': "color.text.inverse";
|
|
80
|
+
readonly 'color.background.brand.boldest': "color.text.inverse";
|
|
81
|
+
readonly 'color.background.brand.boldest.hovered': "color.text.inverse";
|
|
82
|
+
readonly 'color.background.brand.boldest.pressed': "color.text.inverse";
|
|
83
|
+
readonly 'color.background.danger.bold': "color.text.inverse";
|
|
84
|
+
readonly 'color.background.danger.bold.hovered': "color.text.inverse";
|
|
85
|
+
readonly 'color.background.danger.bold.pressed': "color.text.inverse";
|
|
86
|
+
readonly 'color.background.warning.bold': "color.text.warning.inverse";
|
|
87
|
+
readonly 'color.background.warning.bold.hovered': "color.text.warning.inverse";
|
|
88
|
+
readonly 'color.background.warning.bold.pressed': "color.text.warning.inverse";
|
|
89
|
+
readonly 'color.background.success.bold': "color.text.inverse";
|
|
90
|
+
readonly 'color.background.success.bold.hovered': "color.text.inverse";
|
|
91
|
+
readonly 'color.background.success.bold.pressed': "color.text.inverse";
|
|
92
|
+
readonly 'color.background.discovery.bold': "color.text.inverse";
|
|
93
|
+
readonly 'color.background.discovery.bold.hovered': "color.text.inverse";
|
|
94
|
+
readonly 'color.background.discovery.bold.pressed': "color.text.inverse";
|
|
95
|
+
readonly 'color.background.information.bold': "color.text.inverse";
|
|
96
|
+
readonly 'color.background.information.bold.hovered': "color.text.inverse";
|
|
97
|
+
readonly 'color.background.information.bold.pressed': "color.text.inverse";
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @codegenEnd
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
104
|
+
* @codegen <<SignedSource::4f49a5a763f3c327f1d7ce5f2d030194>>
|
|
66
105
|
* @codegenId colors
|
|
67
106
|
* @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
|
|
68
107
|
* @codegenParams ["border", "background", "shadow", "text", "fill", "surface"]
|
|
69
|
-
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::
|
|
108
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::f1021f8d47ab63374e371ce18db72a1c>>
|
|
70
109
|
*/
|
|
71
110
|
export declare const borderColorMap: {
|
|
72
111
|
readonly 'color.border': "var(--ds-border)";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.7",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -108,6 +108,15 @@
|
|
|
108
108
|
"status": {
|
|
109
109
|
"type": "beta"
|
|
110
110
|
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"title": "Text",
|
|
114
|
+
"folder": "text",
|
|
115
|
+
"slug": "primitives/text",
|
|
116
|
+
"id": "@atlaskit/primitives/text",
|
|
117
|
+
"status": {
|
|
118
|
+
"type": "closed-beta"
|
|
119
|
+
}
|
|
111
120
|
}
|
|
112
121
|
]
|
|
113
122
|
}
|
|
@@ -116,7 +125,7 @@
|
|
|
116
125
|
"codegen-styles": "ts-node -r tsconfig-paths/register ./scripts/codegen-styles.tsx"
|
|
117
126
|
},
|
|
118
127
|
"dependencies": {
|
|
119
|
-
"@atlaskit/tokens": "^1.
|
|
128
|
+
"@atlaskit/tokens": "^1.27.0",
|
|
120
129
|
"@babel/runtime": "^7.0.0",
|
|
121
130
|
"@emotion/react": "^11.7.1",
|
|
122
131
|
"@emotion/serialize": "^1.1.0",
|
|
@@ -6,6 +6,7 @@ import { createPartialSignedArtifact } from '@atlassian/codegen';
|
|
|
6
6
|
|
|
7
7
|
import { createBorderStylesFromTemplate } from './border-codegen-template';
|
|
8
8
|
import { createColorStylesFromTemplate } from './color-codegen-template';
|
|
9
|
+
import { createInverseColorMapTemplate } from './inverse-color-map-template';
|
|
9
10
|
import { createStylesFromFileTemplate } from './misc-codegen-template';
|
|
10
11
|
import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
|
|
11
12
|
import { createTypographyStylesFromTemplate } from './typography-codegen-template';
|
|
@@ -68,6 +69,17 @@ const sourceFns = [
|
|
|
68
69
|
dependencies: [colorTokensDependencyPath],
|
|
69
70
|
},
|
|
70
71
|
),
|
|
72
|
+
// inverse color map
|
|
73
|
+
() =>
|
|
74
|
+
createPartialSignedArtifact(
|
|
75
|
+
createInverseColorMapTemplate,
|
|
76
|
+
'yarn workspace @atlaskit/primitives codegen-styles',
|
|
77
|
+
{
|
|
78
|
+
id: 'inverse-colors',
|
|
79
|
+
absoluteFilePath: targetPath,
|
|
80
|
+
dependencies: [colorTokensDependencyPath],
|
|
81
|
+
},
|
|
82
|
+
),
|
|
71
83
|
// border-width, border-radius
|
|
72
84
|
() =>
|
|
73
85
|
createPartialSignedArtifact(
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import prettier from 'prettier';
|
|
2
|
+
import parserTypeScript from 'prettier/parser-typescript';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
+
import tokens from '@atlaskit/tokens/src/artifacts/tokens-raw/atlassian-light';
|
|
6
|
+
|
|
7
|
+
import { compose, isAccent, not, pick } from './utils';
|
|
8
|
+
|
|
9
|
+
type Token = {
|
|
10
|
+
token: string;
|
|
11
|
+
fallback: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const activeTokens = tokens
|
|
15
|
+
.filter(
|
|
16
|
+
t =>
|
|
17
|
+
t.attributes.state !== 'deleted' && t.attributes.state !== 'deprecated',
|
|
18
|
+
)
|
|
19
|
+
.map(
|
|
20
|
+
(t): Token => ({
|
|
21
|
+
token: t.name,
|
|
22
|
+
fallback: t.value as string,
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.filter(compose(pick('token'), not(isAccent)))
|
|
26
|
+
.filter(t => t.token.includes('background'))
|
|
27
|
+
.filter(t => t.token.includes('bold'))
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
.map(t => ({ ...t, token: t.token.replaceAll('.[default]', '') }));
|
|
30
|
+
|
|
31
|
+
export const createInverseColorMapTemplate = () => {
|
|
32
|
+
return prettier.format(
|
|
33
|
+
`
|
|
34
|
+
export const inverseColorMap = {
|
|
35
|
+
${activeTokens
|
|
36
|
+
.map(t => {
|
|
37
|
+
// handle the default case eg color.border or color.text
|
|
38
|
+
const propName = t.token;
|
|
39
|
+
return `'${propName}': '${
|
|
40
|
+
propName.includes('warning')
|
|
41
|
+
? 'color.text.warning.inverse'
|
|
42
|
+
: 'color.text.inverse'
|
|
43
|
+
}'`;
|
|
44
|
+
})
|
|
45
|
+
.join(',\n\t')}
|
|
46
|
+
} as const;`,
|
|
47
|
+
{
|
|
48
|
+
singleQuote: true,
|
|
49
|
+
parser: 'typescript',
|
|
50
|
+
trailingComma: 'all',
|
|
51
|
+
plugins: [parserTypeScript],
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
};
|