@atlaskit/ds-explorations 0.1.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/box/package.json +15 -0
- package/dist/cjs/components/box.partial.js +184 -201
- package/dist/cjs/components/inline.partial.js +49 -30
- package/dist/cjs/components/interaction-surface.partial.js +35 -3
- package/dist/cjs/components/stack.partial.js +49 -30
- package/dist/cjs/components/text.partial.js +116 -85
- package/dist/cjs/index.js +1 -9
- package/dist/cjs/internal/color-map.js +6 -5
- package/dist/cjs/internal/spacing-scale.js +17 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/box.partial.js +182 -184
- package/dist/es2019/components/inline.partial.js +49 -29
- package/dist/es2019/components/interaction-surface.partial.js +35 -3
- package/dist/es2019/components/stack.partial.js +49 -29
- package/dist/es2019/components/text.partial.js +73 -35
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/internal/color-map.js +4 -3
- package/dist/es2019/internal/spacing-scale.js +9 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/box.partial.js +183 -197
- package/dist/esm/components/inline.partial.js +49 -29
- package/dist/esm/components/interaction-surface.partial.js +35 -3
- package/dist/esm/components/stack.partial.js +49 -29
- package/dist/esm/components/text.partial.js +78 -46
- package/dist/esm/index.js +1 -2
- package/dist/esm/internal/color-map.js +4 -3
- package/dist/esm/internal/spacing-scale.js +9 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.partial.d.ts +114 -18
- package/dist/types/components/inline.partial.d.ts +38 -4
- package/dist/types/components/interaction-surface.partial.d.ts +7 -3
- package/dist/types/components/stack.partial.d.ts +39 -6
- package/dist/types/components/text.partial.d.ts +5 -3
- package/dist/types/components/types.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/internal/color-map.d.ts +11 -9
- package/dist/types/internal/spacing-scale.d.ts +9 -0
- package/dist/types-ts4.0/components/box.partial.d.ts +114 -24
- package/dist/types-ts4.0/components/inline.partial.d.ts +38 -4
- package/dist/types-ts4.0/components/interaction-surface.partial.d.ts +7 -3
- package/dist/types-ts4.0/components/stack.partial.d.ts +39 -6
- package/dist/types-ts4.0/components/text.partial.d.ts +5 -6
- package/dist/types-ts4.0/components/types.d.ts +1 -0
- package/dist/types-ts4.0/index.d.ts +0 -1
- package/dist/types-ts4.0/internal/color-map.d.ts +11 -9
- package/dist/types-ts4.0/internal/spacing-scale.d.ts +22 -0
- package/examples/00-basic.tsx +4 -4
- package/examples/01-box.tsx +29 -46
- package/examples/02-text-advanced.tsx +38 -0
- package/examples/02-text.tsx +72 -62
- package/examples/03-stack.tsx +48 -74
- package/examples/04-inline.tsx +46 -75
- package/examples/05-badge.tsx +2 -2
- package/examples/06-section-message.tsx +7 -7
- package/examples/07-comment.tsx +4 -6
- package/examples/08-lozenge.tsx +9 -5
- package/examples/99-interactions.tsx +53 -46
- package/examples/config.jsonc +11 -0
- package/package.json +5 -2
- package/report.api.md +240 -54
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +52 -64
- package/scripts/codegen-styles.tsx +34 -6
- package/scripts/color-codegen-template.tsx +10 -15
- package/scripts/color-map-template.tsx +1 -1
- package/scripts/spacing-codegen-template.tsx +48 -12
- package/scripts/spacing-scale-template.tsx +40 -0
- package/scripts/utils.tsx +1 -3
- package/src/components/__tests__/unit/box.test.tsx +18 -13
- package/src/components/__tests__/unit/inline.test.tsx +10 -10
- package/src/components/__tests__/unit/interaction-suface.test.tsx +14 -8
- package/src/components/__tests__/unit/stack.test.tsx +7 -7
- package/src/components/__tests__/unit/text.test.tsx +23 -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__/box-snapshot-test-tsx-box-example-with-background-color-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-color-should-match-snapshot-1-snap.png +2 -2
- package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-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-alignment-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-line-heights-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 +296 -159
- package/src/components/inline.partial.tsx +75 -21
- package/src/components/interaction-surface.partial.tsx +6 -4
- package/src/components/stack.partial.tsx +75 -22
- package/src/components/text.partial.tsx +78 -41
- package/src/components/types.tsx +2 -0
- package/src/index.tsx +0 -1
- package/src/internal/color-map.tsx +4 -3
- package/src/internal/spacing-scale.tsx +22 -0
- package/text/package.json +15 -0
- package/tmp/api-report-tmp.d.ts +583 -0
- package/dist/cjs/constants.js +0 -21
- package/dist/es2019/constants.js +0 -14
- package/dist/esm/constants.js +0 -14
- package/dist/types/constants.d.ts +0 -15
- package/dist/types-ts4.0/constants.d.ts +0 -15
- package/src/constants.tsx +0 -16
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Children, forwardRef, Fragment } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { SPACING_SCALE } from '../constants';
|
|
5
4
|
import Text from './text.partial';
|
|
6
5
|
const flexAlignItemsMap = {
|
|
7
6
|
center: css({
|
|
@@ -15,6 +14,12 @@ const flexAlignItemsMap = {
|
|
|
15
14
|
}),
|
|
16
15
|
flexEnd: css({
|
|
17
16
|
alignItems: 'flex-end'
|
|
17
|
+
}),
|
|
18
|
+
start: css({
|
|
19
|
+
alignItems: 'start'
|
|
20
|
+
}),
|
|
21
|
+
end: css({
|
|
22
|
+
alignItems: 'end'
|
|
18
23
|
})
|
|
19
24
|
};
|
|
20
25
|
const flexJustifyContentMap = {
|
|
@@ -26,6 +31,17 @@ const flexJustifyContentMap = {
|
|
|
26
31
|
}),
|
|
27
32
|
flexEnd: css({
|
|
28
33
|
justifyContent: 'flex-end'
|
|
34
|
+
}),
|
|
35
|
+
start: css({
|
|
36
|
+
justifyContent: 'start'
|
|
37
|
+
}),
|
|
38
|
+
end: css({
|
|
39
|
+
justifyContent: 'end'
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
const flexWrapMap = {
|
|
43
|
+
wrap: css({
|
|
44
|
+
flexWrap: 'wrap'
|
|
29
45
|
})
|
|
30
46
|
};
|
|
31
47
|
const baseStyles = css({
|
|
@@ -45,13 +61,16 @@ const Inline = /*#__PURE__*/forwardRef(({
|
|
|
45
61
|
gap,
|
|
46
62
|
alignItems,
|
|
47
63
|
justifyContent,
|
|
64
|
+
flexWrap,
|
|
48
65
|
divider,
|
|
66
|
+
UNSAFE_style,
|
|
49
67
|
children,
|
|
50
68
|
testId
|
|
51
69
|
}, ref) => {
|
|
52
70
|
const dividerComponent = typeof divider === 'string' ? jsx(Text, null, divider) : divider;
|
|
53
71
|
return jsx("div", {
|
|
54
|
-
|
|
72
|
+
style: UNSAFE_style,
|
|
73
|
+
css: [baseStyles, gap && columnGapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent], flexWrap && flexWrapMap[flexWrap]],
|
|
55
74
|
"data-testid": testId,
|
|
56
75
|
ref: ref
|
|
57
76
|
}, Children.map(children, (child, index) => {
|
|
@@ -62,48 +81,49 @@ Inline.displayName = 'Inline';
|
|
|
62
81
|
export default Inline;
|
|
63
82
|
/**
|
|
64
83
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
65
|
-
* @codegen <<SignedSource::
|
|
84
|
+
* @codegen <<SignedSource::cff5655983f2243060cade5b107d7762>>
|
|
66
85
|
* @codegenId spacing
|
|
67
86
|
* @codegenCommand yarn codegen-styles
|
|
68
|
-
* @codegenParams ["
|
|
87
|
+
* @codegenParams ["columnGap"]
|
|
88
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
|
|
69
89
|
*/
|
|
70
90
|
|
|
71
|
-
const
|
|
72
|
-
'
|
|
73
|
-
|
|
91
|
+
const columnGapMap = {
|
|
92
|
+
'scale.0': css({
|
|
93
|
+
columnGap: "var(--ds-scale-0, 0px)"
|
|
74
94
|
}),
|
|
75
|
-
'
|
|
76
|
-
|
|
95
|
+
'scale.025': css({
|
|
96
|
+
columnGap: "var(--ds-scale-025, 2px)"
|
|
77
97
|
}),
|
|
78
|
-
'
|
|
79
|
-
|
|
98
|
+
'scale.050': css({
|
|
99
|
+
columnGap: "var(--ds-scale-050, 4px)"
|
|
80
100
|
}),
|
|
81
|
-
'
|
|
82
|
-
|
|
101
|
+
'scale.075': css({
|
|
102
|
+
columnGap: "var(--ds-scale-075, 6px)"
|
|
83
103
|
}),
|
|
84
|
-
'
|
|
85
|
-
|
|
104
|
+
'scale.100': css({
|
|
105
|
+
columnGap: "var(--ds-scale-100, 8px)"
|
|
86
106
|
}),
|
|
87
|
-
'
|
|
88
|
-
|
|
107
|
+
'scale.150': css({
|
|
108
|
+
columnGap: "var(--ds-scale-150, 12px)"
|
|
89
109
|
}),
|
|
90
|
-
'
|
|
91
|
-
|
|
110
|
+
'scale.200': css({
|
|
111
|
+
columnGap: "var(--ds-scale-200, 16px)"
|
|
92
112
|
}),
|
|
93
|
-
'
|
|
94
|
-
|
|
113
|
+
'scale.250': css({
|
|
114
|
+
columnGap: "var(--ds-scale-250, 20px)"
|
|
95
115
|
}),
|
|
96
|
-
'
|
|
97
|
-
|
|
116
|
+
'scale.300': css({
|
|
117
|
+
columnGap: "var(--ds-scale-300, 24px)"
|
|
98
118
|
}),
|
|
99
|
-
'
|
|
100
|
-
|
|
119
|
+
'scale.400': css({
|
|
120
|
+
columnGap: "var(--ds-scale-400, 32px)"
|
|
101
121
|
}),
|
|
102
|
-
'
|
|
103
|
-
|
|
122
|
+
'scale.500': css({
|
|
123
|
+
columnGap: "var(--ds-scale-500, 40px)"
|
|
104
124
|
}),
|
|
105
|
-
'
|
|
106
|
-
|
|
125
|
+
'scale.600': css({
|
|
126
|
+
columnGap: "var(--ds-scale-600, 48px)"
|
|
107
127
|
})
|
|
108
128
|
};
|
|
109
129
|
/**
|
|
@@ -20,8 +20,9 @@ const baseStyles = css({
|
|
|
20
20
|
* ```js
|
|
21
21
|
* // a minimal icon button
|
|
22
22
|
* <Box as="button">
|
|
23
|
-
* <InteractionSurface
|
|
24
|
-
*
|
|
23
|
+
* <InteractionSurface>
|
|
24
|
+
* <WarningIcon label="icon button" />
|
|
25
|
+
* </InteractionSurface>
|
|
25
26
|
* </Box>
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
@@ -48,10 +49,11 @@ const InteractionSurface = ({
|
|
|
48
49
|
export default InteractionSurface;
|
|
49
50
|
/**
|
|
50
51
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
51
|
-
* @codegen <<SignedSource::
|
|
52
|
+
* @codegen <<SignedSource::1bad97ad2c03ae813521797686ac780d>>
|
|
52
53
|
* @codegenId interactions
|
|
53
54
|
* @codegenCommand yarn codegen-styles
|
|
54
55
|
* @codegenParams ["background"]
|
|
56
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
|
|
55
57
|
*/
|
|
56
58
|
|
|
57
59
|
const backgroundActiveColorMap = {
|
|
@@ -144,6 +146,21 @@ const backgroundActiveColorMap = {
|
|
|
144
146
|
':active': {
|
|
145
147
|
backgroundColor: "var(--ds-background-information-bold-pressed, #09326C)"
|
|
146
148
|
}
|
|
149
|
+
}),
|
|
150
|
+
'elevation.surface': css({
|
|
151
|
+
':active': {
|
|
152
|
+
backgroundColor: "var(--ds-surface-pressed, #DCDFE4)"
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
'elevation.surface.raised': css({
|
|
156
|
+
':active': {
|
|
157
|
+
backgroundColor: "var(--ds-surface-raised-pressed, #DCDFE4)"
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
'elevation.surface.overlay': css({
|
|
161
|
+
':active': {
|
|
162
|
+
backgroundColor: "var(--ds-surface-overlay-pressed, #DCDFE4)"
|
|
163
|
+
}
|
|
147
164
|
})
|
|
148
165
|
};
|
|
149
166
|
const backgroundHoverColorMap = {
|
|
@@ -236,6 +253,21 @@ const backgroundHoverColorMap = {
|
|
|
236
253
|
':hover': {
|
|
237
254
|
backgroundColor: "var(--ds-background-information-bold-hovered, #0055CC)"
|
|
238
255
|
}
|
|
256
|
+
}),
|
|
257
|
+
'elevation.surface': css({
|
|
258
|
+
':hover': {
|
|
259
|
+
backgroundColor: "var(--ds-surface-hovered, #F1F2F4)"
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
'elevation.surface.raised': css({
|
|
263
|
+
':hover': {
|
|
264
|
+
backgroundColor: "var(--ds-surface-raised-hovered, #F1F2F4)"
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
'elevation.surface.overlay': css({
|
|
268
|
+
':hover': {
|
|
269
|
+
backgroundColor: "var(--ds-surface-overlay-hovered, #F1F2F4)"
|
|
270
|
+
}
|
|
239
271
|
})
|
|
240
272
|
};
|
|
241
273
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { SPACING_SCALE } from '../constants';
|
|
5
4
|
const flexAlignItemsMap = {
|
|
6
5
|
center: css({
|
|
7
6
|
alignItems: 'center'
|
|
@@ -14,6 +13,12 @@ const flexAlignItemsMap = {
|
|
|
14
13
|
}),
|
|
15
14
|
flexEnd: css({
|
|
16
15
|
alignItems: 'flex-end'
|
|
16
|
+
}),
|
|
17
|
+
start: css({
|
|
18
|
+
alignItems: 'start'
|
|
19
|
+
}),
|
|
20
|
+
end: css({
|
|
21
|
+
alignItems: 'end'
|
|
17
22
|
})
|
|
18
23
|
};
|
|
19
24
|
const flexJustifyContentMap = {
|
|
@@ -25,6 +30,17 @@ const flexJustifyContentMap = {
|
|
|
25
30
|
}),
|
|
26
31
|
flexEnd: css({
|
|
27
32
|
justifyContent: 'flex-end'
|
|
33
|
+
}),
|
|
34
|
+
start: css({
|
|
35
|
+
justifyContent: 'start'
|
|
36
|
+
}),
|
|
37
|
+
end: css({
|
|
38
|
+
justifyContent: 'end'
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
const flexWrapMap = {
|
|
42
|
+
wrap: css({
|
|
43
|
+
flexWrap: 'wrap'
|
|
28
44
|
})
|
|
29
45
|
};
|
|
30
46
|
const baseStyles = css({
|
|
@@ -44,11 +60,14 @@ const Stack = /*#__PURE__*/forwardRef(({
|
|
|
44
60
|
gap,
|
|
45
61
|
alignItems,
|
|
46
62
|
justifyContent,
|
|
63
|
+
flexWrap,
|
|
47
64
|
children,
|
|
65
|
+
UNSAFE_style,
|
|
48
66
|
testId
|
|
49
67
|
}, ref) => {
|
|
50
68
|
return jsx("div", {
|
|
51
|
-
|
|
69
|
+
style: UNSAFE_style,
|
|
70
|
+
css: [baseStyles, gap && rowGapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent], flexWrap && flexWrapMap[flexWrap]],
|
|
52
71
|
"data-testid": testId,
|
|
53
72
|
ref: ref
|
|
54
73
|
}, children);
|
|
@@ -57,48 +76,49 @@ Stack.displayName = 'Stack';
|
|
|
57
76
|
export default Stack;
|
|
58
77
|
/**
|
|
59
78
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
60
|
-
* @codegen <<SignedSource::
|
|
79
|
+
* @codegen <<SignedSource::c486b14097494305925c3c989823d602>>
|
|
61
80
|
* @codegenId spacing
|
|
62
81
|
* @codegenCommand yarn codegen-styles
|
|
63
|
-
* @codegenParams ["
|
|
82
|
+
* @codegenParams ["rowGap"]
|
|
83
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
|
|
64
84
|
*/
|
|
65
85
|
|
|
66
|
-
const
|
|
67
|
-
'
|
|
68
|
-
|
|
86
|
+
const rowGapMap = {
|
|
87
|
+
'scale.0': css({
|
|
88
|
+
rowGap: "var(--ds-scale-0, 0px)"
|
|
69
89
|
}),
|
|
70
|
-
'
|
|
71
|
-
|
|
90
|
+
'scale.025': css({
|
|
91
|
+
rowGap: "var(--ds-scale-025, 2px)"
|
|
72
92
|
}),
|
|
73
|
-
'
|
|
74
|
-
|
|
93
|
+
'scale.050': css({
|
|
94
|
+
rowGap: "var(--ds-scale-050, 4px)"
|
|
75
95
|
}),
|
|
76
|
-
'
|
|
77
|
-
|
|
96
|
+
'scale.075': css({
|
|
97
|
+
rowGap: "var(--ds-scale-075, 6px)"
|
|
78
98
|
}),
|
|
79
|
-
'
|
|
80
|
-
|
|
99
|
+
'scale.100': css({
|
|
100
|
+
rowGap: "var(--ds-scale-100, 8px)"
|
|
81
101
|
}),
|
|
82
|
-
'
|
|
83
|
-
|
|
102
|
+
'scale.150': css({
|
|
103
|
+
rowGap: "var(--ds-scale-150, 12px)"
|
|
84
104
|
}),
|
|
85
|
-
'
|
|
86
|
-
|
|
105
|
+
'scale.200': css({
|
|
106
|
+
rowGap: "var(--ds-scale-200, 16px)"
|
|
87
107
|
}),
|
|
88
|
-
'
|
|
89
|
-
|
|
108
|
+
'scale.250': css({
|
|
109
|
+
rowGap: "var(--ds-scale-250, 20px)"
|
|
90
110
|
}),
|
|
91
|
-
'
|
|
92
|
-
|
|
111
|
+
'scale.300': css({
|
|
112
|
+
rowGap: "var(--ds-scale-300, 24px)"
|
|
93
113
|
}),
|
|
94
|
-
'
|
|
95
|
-
|
|
114
|
+
'scale.400': css({
|
|
115
|
+
rowGap: "var(--ds-scale-400, 32px)"
|
|
96
116
|
}),
|
|
97
|
-
'
|
|
98
|
-
|
|
117
|
+
'scale.500': css({
|
|
118
|
+
rowGap: "var(--ds-scale-500, 40px)"
|
|
99
119
|
}),
|
|
100
|
-
'
|
|
101
|
-
|
|
120
|
+
'scale.600': css({
|
|
121
|
+
rowGap: "var(--ds-scale-600, 48px)"
|
|
102
122
|
})
|
|
103
123
|
};
|
|
104
124
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
import { createContext, Fragment, useContext } from 'react';
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import invariant from 'tiny-invariant';
|
|
4
|
-
import
|
|
5
|
+
import surfaceColorMap from '../internal/color-map';
|
|
5
6
|
import { useSurface } from './surface-provider';
|
|
6
7
|
const asAllowlist = ['span', 'div', 'p'];
|
|
7
8
|
const fontFamily = `-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif`;
|
|
@@ -24,6 +25,9 @@ const fontWeightMap = {
|
|
|
24
25
|
'500': css({
|
|
25
26
|
fontWeight: 500
|
|
26
27
|
}),
|
|
28
|
+
'600': css({
|
|
29
|
+
fontWeight: 600
|
|
30
|
+
}),
|
|
27
31
|
'700': css({
|
|
28
32
|
fontWeight: 700
|
|
29
33
|
})
|
|
@@ -86,6 +90,8 @@ const verticalAlignMap = {
|
|
|
86
90
|
};
|
|
87
91
|
const baseStyles = css({
|
|
88
92
|
boxSizing: 'border-box',
|
|
93
|
+
margin: '0px',
|
|
94
|
+
padding: '0px',
|
|
89
95
|
fontFamily
|
|
90
96
|
});
|
|
91
97
|
const truncateStyles = css({
|
|
@@ -93,6 +99,25 @@ const truncateStyles = css({
|
|
|
93
99
|
textOverflow: 'ellipsis',
|
|
94
100
|
whiteSpace: 'nowrap'
|
|
95
101
|
});
|
|
102
|
+
/**
|
|
103
|
+
* 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.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
const useColor = colorProp => {
|
|
107
|
+
const surface = useSurface();
|
|
108
|
+
const inverseTextColor = surfaceColorMap[surface];
|
|
109
|
+
/**
|
|
110
|
+
* Where the color of the surface is inverted we override the user choice
|
|
111
|
+
* as there is no valid choice that is not covered by the override.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
const color = inverseTextColor !== null && inverseTextColor !== void 0 ? inverseTextColor : colorProp;
|
|
115
|
+
return color;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const HasTextAncestorContext = /*#__PURE__*/createContext(false);
|
|
119
|
+
|
|
120
|
+
const useHasTextAncestor = () => useContext(HasTextAncestorContext);
|
|
96
121
|
/**
|
|
97
122
|
* __Text__
|
|
98
123
|
*
|
|
@@ -103,83 +128,96 @@ const truncateStyles = css({
|
|
|
103
128
|
* @internal
|
|
104
129
|
*/
|
|
105
130
|
|
|
131
|
+
|
|
106
132
|
const Text = ({
|
|
107
|
-
as: Component = 'span',
|
|
108
133
|
children,
|
|
109
|
-
|
|
110
|
-
fontSize,
|
|
111
|
-
fontWeight,
|
|
112
|
-
lineHeight,
|
|
113
|
-
shouldTruncate = false,
|
|
114
|
-
textAlign,
|
|
115
|
-
textTransform,
|
|
116
|
-
verticalAlign,
|
|
117
|
-
testId,
|
|
118
|
-
UNSAFE_style
|
|
134
|
+
...props
|
|
119
135
|
}) => {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
const {
|
|
137
|
+
as: Component = 'span',
|
|
138
|
+
color: colorProp,
|
|
139
|
+
fontSize,
|
|
140
|
+
fontWeight,
|
|
141
|
+
lineHeight,
|
|
142
|
+
shouldTruncate = false,
|
|
143
|
+
textAlign,
|
|
144
|
+
textTransform,
|
|
145
|
+
verticalAlign,
|
|
146
|
+
testId,
|
|
147
|
+
UNSAFE_style
|
|
148
|
+
} = props;
|
|
123
149
|
invariant(asAllowlist.includes(Component), `@atlaskit/ds-explorations: Text received an invalid "as" value of "${Component}"`);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
150
|
+
const color = useColor(colorProp);
|
|
151
|
+
const isWrapped = useHasTextAncestor();
|
|
152
|
+
/**
|
|
153
|
+
* If the text is already wrapped and applies no props we can just
|
|
154
|
+
* render the children directly as a fragment.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
if (isWrapped && Object.keys(props).length === 0) {
|
|
158
|
+
return jsx(Fragment, null, children);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const component = jsx(Component, {
|
|
162
|
+
style: UNSAFE_style,
|
|
130
163
|
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]],
|
|
131
164
|
"data-testid": testId
|
|
132
165
|
}, children);
|
|
166
|
+
return isWrapped ? // no need to re-apply context if the text is already wrapped
|
|
167
|
+
component : jsx(HasTextAncestorContext.Provider, {
|
|
168
|
+
value: true
|
|
169
|
+
}, component);
|
|
133
170
|
};
|
|
134
171
|
|
|
135
172
|
export default Text;
|
|
136
173
|
/**
|
|
137
174
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
138
|
-
* @codegen <<SignedSource::
|
|
175
|
+
* @codegen <<SignedSource::21771f01de3c37646642de03274f0738>>
|
|
139
176
|
* @codegenId colors
|
|
140
177
|
* @codegenCommand yarn codegen-styles
|
|
141
178
|
* @codegenParams ["text"]
|
|
179
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
|
|
142
180
|
*/
|
|
143
181
|
|
|
144
182
|
const textColorMap = {
|
|
145
183
|
'color.text': css({
|
|
146
|
-
color: "var(--ds-text,
|
|
184
|
+
color: "var(--ds-text, #172B4D)"
|
|
147
185
|
}),
|
|
148
186
|
subtle: css({
|
|
149
|
-
color: "var(--ds-text-subtle,
|
|
187
|
+
color: "var(--ds-text-subtle, #42526E)"
|
|
150
188
|
}),
|
|
151
189
|
subtlest: css({
|
|
152
|
-
color: "var(--ds-text-subtlest,
|
|
190
|
+
color: "var(--ds-text-subtlest, #7A869A)"
|
|
153
191
|
}),
|
|
154
192
|
disabled: css({
|
|
155
|
-
color: "var(--ds-text-disabled,
|
|
193
|
+
color: "var(--ds-text-disabled, #A5ADBA)"
|
|
156
194
|
}),
|
|
157
195
|
inverse: css({
|
|
158
|
-
color: "var(--ds-text-inverse,
|
|
196
|
+
color: "var(--ds-text-inverse, #FFFFFF)"
|
|
159
197
|
}),
|
|
160
198
|
brand: css({
|
|
161
|
-
color: "var(--ds-text-brand,
|
|
199
|
+
color: "var(--ds-text-brand, #0065FF)"
|
|
162
200
|
}),
|
|
163
201
|
selected: css({
|
|
164
|
-
color: "var(--ds-text-selected,
|
|
202
|
+
color: "var(--ds-text-selected, #0052CC)"
|
|
165
203
|
}),
|
|
166
204
|
danger: css({
|
|
167
|
-
color: "var(--ds-text-danger,
|
|
205
|
+
color: "var(--ds-text-danger, #DE350B)"
|
|
168
206
|
}),
|
|
169
207
|
warning: css({
|
|
170
|
-
color: "var(--ds-text-warning,
|
|
208
|
+
color: "var(--ds-text-warning, #974F0C)"
|
|
171
209
|
}),
|
|
172
210
|
'warning.inverse': css({
|
|
173
|
-
color: "var(--ds-text-warning-inverse,
|
|
211
|
+
color: "var(--ds-text-warning-inverse, #172B4D)"
|
|
174
212
|
}),
|
|
175
213
|
success: css({
|
|
176
|
-
color: "var(--ds-text-success,
|
|
214
|
+
color: "var(--ds-text-success, #006644)"
|
|
177
215
|
}),
|
|
178
216
|
discovery: css({
|
|
179
|
-
color: "var(--ds-text-discovery,
|
|
217
|
+
color: "var(--ds-text-discovery, #403294)"
|
|
180
218
|
}),
|
|
181
219
|
information: css({
|
|
182
|
-
color: "var(--ds-text-information,
|
|
220
|
+
color: "var(--ds-text-information, #0052CC)"
|
|
183
221
|
})
|
|
184
222
|
};
|
|
185
223
|
/**
|
package/dist/es2019/index.js
CHANGED
|
@@ -2,5 +2,4 @@ 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
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';
|
|
5
|
+
export { default as UNSAFE_InteractionSurface } from './components/interaction-surface.partial';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The color map is used to map a background color token to a matching text color that will meet contrast.
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::c9429c38d12f88de9f5be644bf5e704a>>
|
|
7
7
|
* @codegenCommand yarn codegen-styles
|
|
8
|
+
* @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
+
export default {
|
|
10
11
|
'neutral.bold': 'inverse',
|
|
11
12
|
'neutral.bold.hovered': 'inverse',
|
|
12
13
|
'neutral.bold.pressed': 'inverse',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Some artifact
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::caecb926afa82b027fba396074de5c2c>>
|
|
7
|
+
* @codegenCommand yarn codegen-styles
|
|
8
|
+
*/
|
|
9
|
+
export const spacingScale = ['scale.0', 'scale.025', 'scale.050', 'scale.075', 'scale.100', 'scale.150', 'scale.200', 'scale.250', 'scale.300', 'scale.400', 'scale.500', 'scale.600'];
|
package/dist/es2019/version.json
CHANGED