@atlaskit/ds-explorations 0.1.1 → 0.1.2
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 +11 -0
- package/dist/cjs/components/box.partial.js +220 -182
- package/dist/cjs/components/inline.partial.js +28 -24
- package/dist/cjs/components/interaction-surface.partial.js +253 -0
- package/dist/cjs/components/stack.partial.js +26 -22
- package/dist/cjs/components/surface-provider.js +31 -0
- package/dist/cjs/components/text.partial.js +81 -36
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/index.js +17 -1
- package/dist/cjs/internal/color-map.js +42 -0
- package/dist/cjs/internal/role-to-element.js +36 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/box.partial.js +91 -60
- package/dist/es2019/components/inline.partial.js +6 -2
- package/dist/es2019/components/interaction-surface.partial.js +243 -0
- package/dist/es2019/components/stack.partial.js +6 -2
- package/dist/es2019/components/surface-provider.js +20 -0
- package/dist/es2019/components/text.partial.js +50 -9
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/index.js +3 -1
- package/dist/es2019/internal/color-map.js +34 -0
- package/dist/es2019/internal/role-to-element.js +28 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/box.partial.js +100 -62
- package/dist/esm/components/inline.partial.js +6 -2
- package/dist/esm/components/interaction-surface.partial.js +242 -0
- package/dist/esm/components/stack.partial.js +6 -2
- package/dist/esm/components/surface-provider.js +20 -0
- package/dist/esm/components/text.partial.js +51 -9
- package/dist/esm/constants.js +1 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/internal/color-map.js +34 -0
- package/dist/esm/internal/role-to-element.js +28 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.partial.d.ts +99 -78
- package/dist/types/components/inline.partial.d.ts +7 -7
- package/dist/types/components/interaction-surface.partial.d.ts +45 -0
- package/dist/types/components/stack.partial.d.ts +7 -7
- package/dist/types/components/surface-provider.d.ts +15 -0
- package/dist/types/components/text.partial.d.ts +58 -34
- package/dist/types/components/types.d.ts +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/internal/color-map.d.ts +34 -0
- package/dist/types/internal/role-to-element.d.ts +32 -0
- package/examples/02-text.tsx +34 -13
- package/examples/05-badge.tsx +1 -1
- package/examples/06-section-message.tsx +1 -1
- package/examples/07-comment.tsx +1 -1
- package/examples/08-lozenge.tsx +2 -2
- package/examples/99-interactions.tsx +175 -0
- package/package.json +7 -4
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +164 -3
- package/scripts/__tests__/codegen.test.tsx +5 -0
- package/scripts/codegen-styles.tsx +46 -14
- package/scripts/color-codegen-template.tsx +1 -1
- package/scripts/color-map-template.tsx +52 -0
- package/scripts/interaction-codegen.tsx +109 -0
- package/scripts/utils.tsx +5 -1
- package/src/components/__tests__/unit/box.test.tsx +31 -1
- package/src/components/__tests__/unit/interaction-suface.test.tsx +70 -0
- package/src/components/__tests__/unit/text.test.tsx +16 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-block-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-inline-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-font-sizes-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +2 -2
- package/src/components/box.partial.tsx +112 -71
- package/src/components/inline.partial.tsx +5 -2
- package/src/components/interaction-surface.partial.tsx +237 -0
- package/src/components/stack.partial.tsx +5 -2
- package/src/components/surface-provider.tsx +25 -0
- package/src/components/text.partial.tsx +63 -26
- package/src/components/types.tsx +1 -1
- package/src/constants.tsx +1 -0
- package/src/index.tsx +4 -0
- package/src/internal/color-map.tsx +34 -0
- package/src/internal/role-to-element.tsx +34 -0
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["children", "as", "display", "flexDirection", "alignItems", "justifyContent", "backgroundColor", "borderColor", "borderStyle", "borderWidth", "borderRadius", "padding", "paddingBlock", "paddingInline", "height", "width", "UNSAFE_style", "testId"
|
|
5
|
+
var _excluded = ["children", "as", "className", "display", "flexDirection", "alignItems", "justifyContent", "backgroundColor", "borderColor", "borderStyle", "borderWidth", "borderRadius", "padding", "paddingBlock", "paddingInline", "position", "height", "width", "UNSAFE_style", "testId"];
|
|
6
6
|
|
|
7
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
|
|
@@ -10,8 +10,75 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
10
10
|
|
|
11
11
|
/** @jsx jsx */
|
|
12
12
|
import { forwardRef } from 'react';
|
|
13
|
-
import { css, jsx } from '@emotion/
|
|
13
|
+
import { css, jsx } from '@emotion/react';
|
|
14
14
|
import { SPACING_SCALE } from '../constants';
|
|
15
|
+
import { SurfaceContext } from './surface-provider';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* __Box__
|
|
19
|
+
*
|
|
20
|
+
* Box is a primitive component that has the design decisions of the Atlassian Design System baked in.
|
|
21
|
+
* Renders a `div` by default.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
26
|
+
var children = _ref.children,
|
|
27
|
+
_ref$as = _ref.as,
|
|
28
|
+
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
29
|
+
className = _ref.className,
|
|
30
|
+
_ref$display = _ref.display,
|
|
31
|
+
display = _ref$display === void 0 ? 'flex' : _ref$display,
|
|
32
|
+
flexDirection = _ref.flexDirection,
|
|
33
|
+
alignItems = _ref.alignItems,
|
|
34
|
+
justifyContent = _ref.justifyContent,
|
|
35
|
+
backgroundColorTuple = _ref.backgroundColor,
|
|
36
|
+
borderColorTuple = _ref.borderColor,
|
|
37
|
+
borderStyle = _ref.borderStyle,
|
|
38
|
+
borderWidth = _ref.borderWidth,
|
|
39
|
+
borderRadius = _ref.borderRadius,
|
|
40
|
+
padding = _ref.padding,
|
|
41
|
+
paddingBlock = _ref.paddingBlock,
|
|
42
|
+
paddingInline = _ref.paddingInline,
|
|
43
|
+
_ref$position = _ref.position,
|
|
44
|
+
position = _ref$position === void 0 ? 'relative' : _ref$position,
|
|
45
|
+
height = _ref.height,
|
|
46
|
+
width = _ref.width,
|
|
47
|
+
UNSAFE_style = _ref.UNSAFE_style,
|
|
48
|
+
testId = _ref.testId,
|
|
49
|
+
htmlAttributes = _objectWithoutProperties(_ref, _excluded);
|
|
50
|
+
|
|
51
|
+
var _ref2 = backgroundColorTuple || [],
|
|
52
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
53
|
+
backgroundColor = _ref3[0],
|
|
54
|
+
backgroundColorFallback = _ref3[1];
|
|
55
|
+
|
|
56
|
+
var _ref4 = borderColorTuple || [],
|
|
57
|
+
_ref5 = _slicedToArray(_ref4, 2),
|
|
58
|
+
borderColor = _ref5[0],
|
|
59
|
+
borderColorFallback = _ref5[1];
|
|
60
|
+
|
|
61
|
+
var node = jsx(Component, _extends({
|
|
62
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, UNSAFE_style), backgroundColorFallback && {
|
|
63
|
+
'--ds-bg-fb': backgroundColorFallback
|
|
64
|
+
}), borderColorFallback && {
|
|
65
|
+
'--ds-bo-fb': borderColorFallback
|
|
66
|
+
}) // @ts-ignore
|
|
67
|
+
,
|
|
68
|
+
ref: ref // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
69
|
+
|
|
70
|
+
}, htmlAttributes, {
|
|
71
|
+
className: className,
|
|
72
|
+
css: [baseStyles, display && displayMap[display], padding && paddingMap[padding], position && positionMap[position], paddingBlock && paddingBlockMap[paddingBlock], paddingInline && paddingInlineMap[paddingInline], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent], backgroundColor && backgroundColorMap[backgroundColor], borderColor && borderColorMap[borderColor], borderStyle && borderStyleMap[borderStyle], borderWidth && borderWidthMap[borderWidth], borderRadius && borderRadiusMap[borderRadius], flexDirection && flexDirectionMap[flexDirection], width && widthMap[width], height && heightMap[height]],
|
|
73
|
+
"data-testid": testId
|
|
74
|
+
}), children);
|
|
75
|
+
return backgroundColor ? jsx(SurfaceContext.Provider, {
|
|
76
|
+
value: backgroundColor
|
|
77
|
+
}, node) : node;
|
|
78
|
+
});
|
|
79
|
+
Box.displayName = 'Box';
|
|
80
|
+
export default Box; // <<< STYLES GO HERE >>>
|
|
81
|
+
|
|
15
82
|
var borderStyleMap = {
|
|
16
83
|
none: css({
|
|
17
84
|
borderStyle: 'none'
|
|
@@ -99,68 +166,24 @@ var displayMap = {
|
|
|
99
166
|
})
|
|
100
167
|
};
|
|
101
168
|
var baseStyles = css({
|
|
102
|
-
boxSizing: 'border-box'
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* __Box__
|
|
106
|
-
*
|
|
107
|
-
* Box is a primitive component that has the design decisions of the Atlassian Design System baked in.
|
|
108
|
-
* Renders a `div` by default.
|
|
109
|
-
*
|
|
110
|
-
* @internal
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
114
|
-
var children = _ref.children,
|
|
115
|
-
_ref$as = _ref.as,
|
|
116
|
-
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
117
|
-
_ref$display = _ref.display,
|
|
118
|
-
display = _ref$display === void 0 ? 'flex' : _ref$display,
|
|
119
|
-
flexDirection = _ref.flexDirection,
|
|
120
|
-
alignItems = _ref.alignItems,
|
|
121
|
-
justifyContent = _ref.justifyContent,
|
|
122
|
-
backgroundColorTuple = _ref.backgroundColor,
|
|
123
|
-
borderColorTuple = _ref.borderColor,
|
|
124
|
-
borderStyle = _ref.borderStyle,
|
|
125
|
-
borderWidth = _ref.borderWidth,
|
|
126
|
-
borderRadius = _ref.borderRadius,
|
|
127
|
-
padding = _ref.padding,
|
|
128
|
-
paddingBlock = _ref.paddingBlock,
|
|
129
|
-
paddingInline = _ref.paddingInline,
|
|
130
|
-
height = _ref.height,
|
|
131
|
-
width = _ref.width,
|
|
132
|
-
UNSAFE_style = _ref.UNSAFE_style,
|
|
133
|
-
testId = _ref.testId,
|
|
134
|
-
dontUseThisProperty = _ref.className,
|
|
135
|
-
htmlAttributes = _objectWithoutProperties(_ref, _excluded);
|
|
136
|
-
|
|
137
|
-
var _ref2 = backgroundColorTuple || [],
|
|
138
|
-
_ref3 = _slicedToArray(_ref2, 2),
|
|
139
|
-
backgroundColor = _ref3[0],
|
|
140
|
-
backgroundColorFallback = _ref3[1];
|
|
141
|
-
|
|
142
|
-
var _ref4 = borderColorTuple || [],
|
|
143
|
-
_ref5 = _slicedToArray(_ref4, 2),
|
|
144
|
-
borderColor = _ref5[0],
|
|
145
|
-
borderColorFallback = _ref5[1];
|
|
146
|
-
|
|
147
|
-
return jsx(Component, _extends({
|
|
148
|
-
style: _objectSpread(_objectSpread(_objectSpread({}, UNSAFE_style), backgroundColorFallback && {
|
|
149
|
-
'--ds-bg-fb': backgroundColorFallback
|
|
150
|
-
}), borderColorFallback && {
|
|
151
|
-
'--ds-bo-fb': borderColorFallback
|
|
152
|
-
}),
|
|
153
|
-
ref: ref // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
154
|
-
|
|
155
|
-
}, htmlAttributes, {
|
|
156
|
-
css: [baseStyles, display && displayMap[display], padding && paddingMap[padding], paddingBlock && paddingBlockMap[paddingBlock], paddingInline && paddingInlineMap[paddingInline], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent], backgroundColor && backgroundColorMap[backgroundColor], borderColor && borderColorMap[borderColor], borderStyle && borderStyleMap[borderStyle], borderWidth && borderWidthMap[borderWidth], borderRadius && borderRadiusMap[borderRadius], flexDirection && flexDirectionMap[flexDirection], width && widthMap[width], height && heightMap[height]],
|
|
157
|
-
"data-testid": testId
|
|
158
|
-
}), children);
|
|
169
|
+
boxSizing: 'border-box',
|
|
170
|
+
appearance: 'none',
|
|
171
|
+
border: 'none'
|
|
159
172
|
});
|
|
160
|
-
|
|
173
|
+
var positionMap = {
|
|
174
|
+
absolute: css({
|
|
175
|
+
position: 'absolute'
|
|
176
|
+
}),
|
|
177
|
+
relative: css({
|
|
178
|
+
position: 'relative'
|
|
179
|
+
}),
|
|
180
|
+
static: css({
|
|
181
|
+
position: 'static'
|
|
182
|
+
})
|
|
183
|
+
};
|
|
161
184
|
/**
|
|
162
185
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
163
|
-
* @codegen <<SignedSource::
|
|
186
|
+
* @codegen <<SignedSource::57b4c7c177fdfae3f7cd4f00287fd30e>>
|
|
164
187
|
* @codegenId spacing
|
|
165
188
|
* @codegenCommand yarn codegen-styles
|
|
166
189
|
* @codegenParams ["padding", "paddingBlock", "paddingInline", "width", "height"]
|
|
@@ -182,6 +205,9 @@ var paddingMap = {
|
|
|
182
205
|
'sp-100': css({
|
|
183
206
|
padding: SPACING_SCALE['sp-100']
|
|
184
207
|
}),
|
|
208
|
+
'sp-150': css({
|
|
209
|
+
padding: SPACING_SCALE['sp-150']
|
|
210
|
+
}),
|
|
185
211
|
'sp-200': css({
|
|
186
212
|
padding: SPACING_SCALE['sp-200']
|
|
187
213
|
}),
|
|
@@ -217,6 +243,9 @@ var paddingBlockMap = {
|
|
|
217
243
|
'sp-100': css({
|
|
218
244
|
paddingBlock: SPACING_SCALE['sp-100']
|
|
219
245
|
}),
|
|
246
|
+
'sp-150': css({
|
|
247
|
+
paddingBlock: SPACING_SCALE['sp-150']
|
|
248
|
+
}),
|
|
220
249
|
'sp-200': css({
|
|
221
250
|
paddingBlock: SPACING_SCALE['sp-200']
|
|
222
251
|
}),
|
|
@@ -252,6 +281,9 @@ var paddingInlineMap = {
|
|
|
252
281
|
'sp-100': css({
|
|
253
282
|
paddingInline: SPACING_SCALE['sp-100']
|
|
254
283
|
}),
|
|
284
|
+
'sp-150': css({
|
|
285
|
+
paddingInline: SPACING_SCALE['sp-150']
|
|
286
|
+
}),
|
|
255
287
|
'sp-200': css({
|
|
256
288
|
paddingInline: SPACING_SCALE['sp-200']
|
|
257
289
|
}),
|
|
@@ -287,6 +319,9 @@ var widthMap = {
|
|
|
287
319
|
'sp-100': css({
|
|
288
320
|
width: SPACING_SCALE['sp-100']
|
|
289
321
|
}),
|
|
322
|
+
'sp-150': css({
|
|
323
|
+
width: SPACING_SCALE['sp-150']
|
|
324
|
+
}),
|
|
290
325
|
'sp-200': css({
|
|
291
326
|
width: SPACING_SCALE['sp-200']
|
|
292
327
|
}),
|
|
@@ -322,6 +357,9 @@ var heightMap = {
|
|
|
322
357
|
'sp-100': css({
|
|
323
358
|
height: SPACING_SCALE['sp-100']
|
|
324
359
|
}),
|
|
360
|
+
'sp-150': css({
|
|
361
|
+
height: SPACING_SCALE['sp-150']
|
|
362
|
+
}),
|
|
325
363
|
'sp-200': css({
|
|
326
364
|
height: SPACING_SCALE['sp-200']
|
|
327
365
|
}),
|
|
@@ -347,7 +385,7 @@ var heightMap = {
|
|
|
347
385
|
|
|
348
386
|
/**
|
|
349
387
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
350
|
-
* @codegen <<SignedSource::
|
|
388
|
+
* @codegen <<SignedSource::ebb55786a54803214357d0eef0cac448>>
|
|
351
389
|
* @codegenId colors
|
|
352
390
|
* @codegenCommand yarn codegen-styles
|
|
353
391
|
* @codegenParams ["border", "background"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Children, forwardRef, Fragment } from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { SPACING_SCALE } from '../constants';
|
|
5
5
|
import Text from './text.partial';
|
|
6
6
|
var flexAlignItemsMap = {
|
|
@@ -57,10 +57,11 @@ var Inline = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
57
57
|
return jsx(Fragment, null, divider && index > 0 ? dividerComponent : null, child);
|
|
58
58
|
}));
|
|
59
59
|
});
|
|
60
|
+
Inline.displayName = 'Inline';
|
|
60
61
|
export default Inline;
|
|
61
62
|
/**
|
|
62
63
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
63
|
-
* @codegen <<SignedSource::
|
|
64
|
+
* @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
|
|
64
65
|
* @codegenId spacing
|
|
65
66
|
* @codegenCommand yarn codegen-styles
|
|
66
67
|
* @codegenParams ["gap"]
|
|
@@ -82,6 +83,9 @@ var gapMap = {
|
|
|
82
83
|
'sp-100': css({
|
|
83
84
|
gap: SPACING_SCALE['sp-100']
|
|
84
85
|
}),
|
|
86
|
+
'sp-150': css({
|
|
87
|
+
gap: SPACING_SCALE['sp-150']
|
|
88
|
+
}),
|
|
85
89
|
'sp-200': css({
|
|
86
90
|
gap: SPACING_SCALE['sp-200']
|
|
87
91
|
}),
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Fragment, useContext } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { SurfaceContext } from './surface-provider';
|
|
5
|
+
var baseStyles = css({
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
borderRadius: 'inherit',
|
|
8
|
+
cursor: 'pointer',
|
|
9
|
+
inset: 0,
|
|
10
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
11
|
+
'~ *': {
|
|
12
|
+
position: 'relative',
|
|
13
|
+
pointerEvents: 'none'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* // a minimal icon button
|
|
22
|
+
* <Box as="button">
|
|
23
|
+
* <InteractionSurface />
|
|
24
|
+
* <WarningIcon label="icon button" />
|
|
25
|
+
* </Box>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
var InteractionSurface = function InteractionSurface(_ref) {
|
|
29
|
+
var appearance = _ref.appearance,
|
|
30
|
+
children = _ref.children,
|
|
31
|
+
testId = _ref.testId;
|
|
32
|
+
var defaultSurface = useContext(SurfaceContext);
|
|
33
|
+
var surface = appearance || defaultSurface; // This case will occur if the Box has not set a bg color and the ancestor surface
|
|
34
|
+
// is an elevation. An alternative would be to throw an error here as it may be better
|
|
35
|
+
// to ensure correct predictable behaviour based on user specification.
|
|
36
|
+
|
|
37
|
+
if (!(surface in backgroundActiveColorMap)) {
|
|
38
|
+
surface = 'neutral';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return jsx(Fragment, null, jsx("span", {
|
|
42
|
+
"data-testid": testId,
|
|
43
|
+
css: [baseStyles, surface && backgroundHoverColorMap[surface], surface && backgroundActiveColorMap[surface]]
|
|
44
|
+
}), children);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default InteractionSurface;
|
|
48
|
+
/**
|
|
49
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
50
|
+
* @codegen <<SignedSource::45000716488a9f41306a232c1f4c9f8d>>
|
|
51
|
+
* @codegenId interactions
|
|
52
|
+
* @codegenCommand yarn codegen-styles
|
|
53
|
+
* @codegenParams ["background"]
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
var backgroundActiveColorMap = {
|
|
57
|
+
'inverse.subtle': css({
|
|
58
|
+
':active': {
|
|
59
|
+
backgroundColor: "var(--ds-background-inverse-subtle-pressed, #00000052)"
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
input: css({
|
|
63
|
+
':active': {
|
|
64
|
+
backgroundColor: "var(--ds-background-input-pressed, #FFFFFF)"
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
neutral: css({
|
|
68
|
+
':active': {
|
|
69
|
+
backgroundColor: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
'neutral.subtle': css({
|
|
73
|
+
':active': {
|
|
74
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
'neutral.bold': css({
|
|
78
|
+
':active': {
|
|
79
|
+
backgroundColor: "var(--ds-background-neutral-bold-pressed, #172B4D)"
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
'brand.bold': css({
|
|
83
|
+
':active': {
|
|
84
|
+
backgroundColor: "var(--ds-background-brand-bold-pressed, #09326C)"
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
selected: css({
|
|
88
|
+
':active': {
|
|
89
|
+
backgroundColor: "var(--ds-background-selected-pressed, #85B8FF)"
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
'selected.bold': css({
|
|
93
|
+
':active': {
|
|
94
|
+
backgroundColor: "var(--ds-background-selected-bold-pressed, #09326C)"
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
danger: css({
|
|
98
|
+
':active': {
|
|
99
|
+
backgroundColor: "var(--ds-background-danger-pressed, #FF9C8F)"
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
'danger.bold': css({
|
|
103
|
+
':active': {
|
|
104
|
+
backgroundColor: "var(--ds-background-danger-bold-pressed, #601E16)"
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
warning: css({
|
|
108
|
+
':active': {
|
|
109
|
+
backgroundColor: "var(--ds-background-warning-pressed, #F5CD47)"
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
'warning.bold': css({
|
|
113
|
+
':active': {
|
|
114
|
+
backgroundColor: "var(--ds-background-warning-bold-pressed, #B38600)"
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
success: css({
|
|
118
|
+
':active': {
|
|
119
|
+
backgroundColor: "var(--ds-background-success-pressed, #7EE2B8)"
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
'success.bold': css({
|
|
123
|
+
':active': {
|
|
124
|
+
backgroundColor: "var(--ds-background-success-bold-pressed, #164B35)"
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
discovery: css({
|
|
128
|
+
':active': {
|
|
129
|
+
backgroundColor: "var(--ds-background-discovery-pressed, #B8ACF6)"
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
'discovery.bold': css({
|
|
133
|
+
':active': {
|
|
134
|
+
backgroundColor: "var(--ds-background-discovery-bold-pressed, #352C63)"
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
information: css({
|
|
138
|
+
':active': {
|
|
139
|
+
backgroundColor: "var(--ds-background-information-pressed, #85B8FF)"
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
'information.bold': css({
|
|
143
|
+
':active': {
|
|
144
|
+
backgroundColor: "var(--ds-background-information-bold-pressed, #09326C)"
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
var backgroundHoverColorMap = {
|
|
149
|
+
'inverse.subtle': css({
|
|
150
|
+
':hover': {
|
|
151
|
+
backgroundColor: "var(--ds-background-inverse-subtle-hovered, #0000003D)"
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
input: css({
|
|
155
|
+
':hover': {
|
|
156
|
+
backgroundColor: "var(--ds-background-input-hovered, #F7F8F9)"
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
neutral: css({
|
|
160
|
+
':hover': {
|
|
161
|
+
backgroundColor: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
'neutral.subtle': css({
|
|
165
|
+
':hover': {
|
|
166
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
'neutral.bold': css({
|
|
170
|
+
':hover': {
|
|
171
|
+
backgroundColor: "var(--ds-background-neutral-bold-hovered, #2C3E5D)"
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
'brand.bold': css({
|
|
175
|
+
':hover': {
|
|
176
|
+
backgroundColor: "var(--ds-background-brand-bold-hovered, #0055CC)"
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
selected: css({
|
|
180
|
+
':hover': {
|
|
181
|
+
backgroundColor: "var(--ds-background-selected-hovered, #CCE0FF)"
|
|
182
|
+
}
|
|
183
|
+
}),
|
|
184
|
+
'selected.bold': css({
|
|
185
|
+
':hover': {
|
|
186
|
+
backgroundColor: "var(--ds-background-selected-bold-hovered, #0055CC)"
|
|
187
|
+
}
|
|
188
|
+
}),
|
|
189
|
+
danger: css({
|
|
190
|
+
':hover': {
|
|
191
|
+
backgroundColor: "var(--ds-background-danger-hovered, #FFD2CC)"
|
|
192
|
+
}
|
|
193
|
+
}),
|
|
194
|
+
'danger.bold': css({
|
|
195
|
+
':hover': {
|
|
196
|
+
backgroundColor: "var(--ds-background-danger-bold-hovered, #AE2A19)"
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
warning: css({
|
|
200
|
+
':hover': {
|
|
201
|
+
backgroundColor: "var(--ds-background-warning-hovered, #F8E6A0)"
|
|
202
|
+
}
|
|
203
|
+
}),
|
|
204
|
+
'warning.bold': css({
|
|
205
|
+
':hover': {
|
|
206
|
+
backgroundColor: "var(--ds-background-warning-bold-hovered, #CF9F02)"
|
|
207
|
+
}
|
|
208
|
+
}),
|
|
209
|
+
success: css({
|
|
210
|
+
':hover': {
|
|
211
|
+
backgroundColor: "var(--ds-background-success-hovered, #BAF3DB)"
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
'success.bold': css({
|
|
215
|
+
':hover': {
|
|
216
|
+
backgroundColor: "var(--ds-background-success-bold-hovered, #216E4E)"
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
discovery: css({
|
|
220
|
+
':hover': {
|
|
221
|
+
backgroundColor: "var(--ds-background-discovery-hovered, #DFD8FD)"
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
'discovery.bold': css({
|
|
225
|
+
':hover': {
|
|
226
|
+
backgroundColor: "var(--ds-background-discovery-bold-hovered, #5E4DB2)"
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
229
|
+
information: css({
|
|
230
|
+
':hover': {
|
|
231
|
+
backgroundColor: "var(--ds-background-information-hovered, #CCE0FF)"
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
'information.bold': css({
|
|
235
|
+
':hover': {
|
|
236
|
+
backgroundColor: "var(--ds-background-information-bold-hovered, #0055CC)"
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* @codegenEnd
|
|
242
|
+
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { SPACING_SCALE } from '../constants';
|
|
5
5
|
var flexAlignItemsMap = {
|
|
6
6
|
center: css({
|
|
@@ -52,10 +52,11 @@ var Stack = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
52
52
|
ref: ref
|
|
53
53
|
}, children);
|
|
54
54
|
});
|
|
55
|
+
Stack.displayName = 'Stack';
|
|
55
56
|
export default Stack;
|
|
56
57
|
/**
|
|
57
58
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
58
|
-
* @codegen <<SignedSource::
|
|
59
|
+
* @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
|
|
59
60
|
* @codegenId spacing
|
|
60
61
|
* @codegenCommand yarn codegen-styles
|
|
61
62
|
* @codegenParams ["gap"]
|
|
@@ -77,6 +78,9 @@ var gapMap = {
|
|
|
77
78
|
'sp-100': css({
|
|
78
79
|
gap: SPACING_SCALE['sp-100']
|
|
79
80
|
}),
|
|
81
|
+
'sp-150': css({
|
|
82
|
+
gap: SPACING_SCALE['sp-150']
|
|
83
|
+
}),
|
|
80
84
|
'sp-200': css({
|
|
81
85
|
gap: SPACING_SCALE['sp-200']
|
|
82
86
|
}),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* __Surface context__
|
|
5
|
+
*
|
|
6
|
+
* A surface context provides context information on the current background (if set).
|
|
7
|
+
*/
|
|
8
|
+
export var SurfaceContext = /*#__PURE__*/createContext('elevation.surface');
|
|
9
|
+
/**
|
|
10
|
+
* __useSurface__
|
|
11
|
+
*
|
|
12
|
+
* Return the current surface. If no parent sets a surface color it falls back to the default surface.
|
|
13
|
+
*
|
|
14
|
+
* @see SurfaceContext
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var useSurface = function useSurface() {
|
|
18
|
+
return useContext(SurfaceContext);
|
|
19
|
+
};
|
|
20
|
+
SurfaceContext.displayName = 'SurfaceProvider';
|
|
@@ -6,16 +6,20 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
|
|
8
8
|
/** @jsx jsx */
|
|
9
|
-
import { css, jsx } from '@emotion/
|
|
9
|
+
import { css, jsx } from '@emotion/react';
|
|
10
|
+
import invariant from 'tiny-invariant';
|
|
11
|
+
import { colorMap } from '../internal/color-map';
|
|
12
|
+
import { useSurface } from './surface-provider';
|
|
13
|
+
var asAllowlist = ['span', 'div', 'p'];
|
|
10
14
|
var fontFamily = "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif";
|
|
11
15
|
var fontSizeMap = {
|
|
12
|
-
'
|
|
16
|
+
'11px': css({
|
|
13
17
|
fontSize: '11px'
|
|
14
18
|
}),
|
|
15
|
-
'
|
|
19
|
+
'12px': css({
|
|
16
20
|
fontSize: '12px'
|
|
17
21
|
}),
|
|
18
|
-
'
|
|
22
|
+
'14px': css({
|
|
19
23
|
fontSize: '14px'
|
|
20
24
|
})
|
|
21
25
|
};
|
|
@@ -26,6 +30,9 @@ var fontWeightMap = {
|
|
|
26
30
|
}),
|
|
27
31
|
'500': css({
|
|
28
32
|
fontWeight: 500
|
|
33
|
+
}),
|
|
34
|
+
'700': css({
|
|
35
|
+
fontWeight: 700
|
|
29
36
|
})
|
|
30
37
|
};
|
|
31
38
|
var lineHeightMap = {
|
|
@@ -62,9 +69,37 @@ var textAlignMap = {
|
|
|
62
69
|
textAlign: 'start'
|
|
63
70
|
})
|
|
64
71
|
};
|
|
72
|
+
var textTransformMap = {
|
|
73
|
+
none: css({
|
|
74
|
+
textTransform: 'none'
|
|
75
|
+
}),
|
|
76
|
+
lowercase: css({
|
|
77
|
+
textTransform: 'lowercase'
|
|
78
|
+
}),
|
|
79
|
+
uppercase: css({
|
|
80
|
+
textTransform: 'uppercase'
|
|
81
|
+
})
|
|
82
|
+
};
|
|
83
|
+
var verticalAlignMap = {
|
|
84
|
+
top: css({
|
|
85
|
+
verticalAlign: 'top'
|
|
86
|
+
}),
|
|
87
|
+
middle: css({
|
|
88
|
+
verticalAlign: 'middle'
|
|
89
|
+
}),
|
|
90
|
+
bottom: css({
|
|
91
|
+
verticalAlign: 'bottom'
|
|
92
|
+
})
|
|
93
|
+
};
|
|
65
94
|
var baseStyles = css({
|
|
95
|
+
boxSizing: 'border-box',
|
|
66
96
|
fontFamily: fontFamily
|
|
67
97
|
});
|
|
98
|
+
var truncateStyles = css({
|
|
99
|
+
overflow: 'hidden',
|
|
100
|
+
textOverflow: 'ellipsis',
|
|
101
|
+
whiteSpace: 'nowrap'
|
|
102
|
+
});
|
|
68
103
|
/**
|
|
69
104
|
* __Text__
|
|
70
105
|
*
|
|
@@ -76,6 +111,8 @@ var baseStyles = css({
|
|
|
76
111
|
*/
|
|
77
112
|
|
|
78
113
|
var Text = function Text(_ref) {
|
|
114
|
+
var _colorMap$surface;
|
|
115
|
+
|
|
79
116
|
var _ref$as = _ref.as,
|
|
80
117
|
Component = _ref$as === void 0 ? 'span' : _ref$as,
|
|
81
118
|
children = _ref.children,
|
|
@@ -83,22 +120,27 @@ var Text = function Text(_ref) {
|
|
|
83
120
|
fontSize = _ref.fontSize,
|
|
84
121
|
fontWeight = _ref.fontWeight,
|
|
85
122
|
lineHeight = _ref.lineHeight,
|
|
123
|
+
_ref$shouldTruncate = _ref.shouldTruncate,
|
|
124
|
+
shouldTruncate = _ref$shouldTruncate === void 0 ? false : _ref$shouldTruncate,
|
|
86
125
|
textAlign = _ref.textAlign,
|
|
87
|
-
|
|
126
|
+
textTransform = _ref.textTransform,
|
|
127
|
+
verticalAlign = _ref.verticalAlign,
|
|
88
128
|
testId = _ref.testId,
|
|
89
129
|
UNSAFE_style = _ref.UNSAFE_style;
|
|
130
|
+
var surface = useSurface(); // @ts-ignore
|
|
90
131
|
|
|
91
132
|
var _ref2 = colorTuple || [],
|
|
92
133
|
_ref3 = _slicedToArray(_ref2, 2),
|
|
93
|
-
|
|
134
|
+
_ref3$ = _ref3[0],
|
|
135
|
+
color = _ref3$ === void 0 ? (_colorMap$surface = colorMap[surface]) !== null && _colorMap$surface !== void 0 ? _colorMap$surface : 'color.text' : _ref3$,
|
|
94
136
|
fallback = _ref3[1];
|
|
95
137
|
|
|
138
|
+
invariant(asAllowlist.includes(Component), "@atlaskit/ds-explorations: Text received an invalid \"as\" value of \"".concat(Component, "\""));
|
|
96
139
|
return jsx(Component, {
|
|
97
140
|
style: _objectSpread(_objectSpread({}, UNSAFE_style), fallback && {
|
|
98
141
|
'--ds-co-fb': fallback
|
|
99
142
|
}),
|
|
100
|
-
css: [baseStyles, color && textColorMap[color], fontSize && fontSizeMap[fontSize], fontWeight && fontWeightMap[fontWeight], lineHeight && lineHeightMap[lineHeight], textAlign && textAlignMap[textAlign]],
|
|
101
|
-
href: href,
|
|
143
|
+
css: [baseStyles, color && textColorMap[color], fontSize && fontSizeMap[fontSize], fontWeight && fontWeightMap[fontWeight], lineHeight && lineHeightMap[lineHeight], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], textTransform && textTransformMap[textTransform], verticalAlign && verticalAlignMap[verticalAlign]],
|
|
102
144
|
"data-testid": testId
|
|
103
145
|
}, children);
|
|
104
146
|
};
|
|
@@ -106,7 +148,7 @@ var Text = function Text(_ref) {
|
|
|
106
148
|
export default Text;
|
|
107
149
|
/**
|
|
108
150
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
109
|
-
* @codegen <<SignedSource::
|
|
151
|
+
* @codegen <<SignedSource::140ffff6e1310c1c37e2067e2c232b92>>
|
|
110
152
|
* @codegenId colors
|
|
111
153
|
* @codegenCommand yarn codegen-styles
|
|
112
154
|
* @codegenParams ["text"]
|
package/dist/esm/constants.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as UNSAFE_Box } from './components/box.partial';
|
|
2
2
|
export { default as UNSAFE_Text } from './components/text.partial';
|
|
3
3
|
export { default as UNSAFE_Inline } from './components/inline.partial';
|
|
4
|
-
export { default as UNSAFE_Stack } from './components/stack.partial';
|
|
4
|
+
export { default as UNSAFE_Stack } from './components/stack.partial';
|
|
5
|
+
export { default as UNSAFE_InteractionSurface } from './components/interaction-surface.partial';
|
|
6
|
+
export { SPACING_SCALE as UNSAFE_SPACING_SCALE } from './constants';
|