@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.
Files changed (101) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/box/package.json +15 -0
  3. package/dist/cjs/components/box.partial.js +184 -201
  4. package/dist/cjs/components/inline.partial.js +49 -30
  5. package/dist/cjs/components/interaction-surface.partial.js +35 -3
  6. package/dist/cjs/components/stack.partial.js +49 -30
  7. package/dist/cjs/components/text.partial.js +116 -85
  8. package/dist/cjs/index.js +1 -9
  9. package/dist/cjs/internal/color-map.js +6 -5
  10. package/dist/cjs/internal/spacing-scale.js +17 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/components/box.partial.js +182 -184
  13. package/dist/es2019/components/inline.partial.js +49 -29
  14. package/dist/es2019/components/interaction-surface.partial.js +35 -3
  15. package/dist/es2019/components/stack.partial.js +49 -29
  16. package/dist/es2019/components/text.partial.js +73 -35
  17. package/dist/es2019/index.js +1 -2
  18. package/dist/es2019/internal/color-map.js +4 -3
  19. package/dist/es2019/internal/spacing-scale.js +9 -0
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/esm/components/box.partial.js +183 -197
  22. package/dist/esm/components/inline.partial.js +49 -29
  23. package/dist/esm/components/interaction-surface.partial.js +35 -3
  24. package/dist/esm/components/stack.partial.js +49 -29
  25. package/dist/esm/components/text.partial.js +78 -46
  26. package/dist/esm/index.js +1 -2
  27. package/dist/esm/internal/color-map.js +4 -3
  28. package/dist/esm/internal/spacing-scale.js +9 -0
  29. package/dist/esm/version.json +1 -1
  30. package/dist/types/components/box.partial.d.ts +114 -18
  31. package/dist/types/components/inline.partial.d.ts +38 -4
  32. package/dist/types/components/interaction-surface.partial.d.ts +7 -3
  33. package/dist/types/components/stack.partial.d.ts +39 -6
  34. package/dist/types/components/text.partial.d.ts +5 -3
  35. package/dist/types/components/types.d.ts +1 -0
  36. package/dist/types/index.d.ts +0 -1
  37. package/dist/types/internal/color-map.d.ts +11 -9
  38. package/dist/types/internal/spacing-scale.d.ts +9 -0
  39. package/dist/types-ts4.0/components/box.partial.d.ts +114 -24
  40. package/dist/types-ts4.0/components/inline.partial.d.ts +38 -4
  41. package/dist/types-ts4.0/components/interaction-surface.partial.d.ts +7 -3
  42. package/dist/types-ts4.0/components/stack.partial.d.ts +39 -6
  43. package/dist/types-ts4.0/components/text.partial.d.ts +5 -6
  44. package/dist/types-ts4.0/components/types.d.ts +1 -0
  45. package/dist/types-ts4.0/index.d.ts +0 -1
  46. package/dist/types-ts4.0/internal/color-map.d.ts +11 -9
  47. package/dist/types-ts4.0/internal/spacing-scale.d.ts +22 -0
  48. package/examples/00-basic.tsx +4 -4
  49. package/examples/01-box.tsx +29 -46
  50. package/examples/02-text-advanced.tsx +38 -0
  51. package/examples/02-text.tsx +72 -62
  52. package/examples/03-stack.tsx +48 -74
  53. package/examples/04-inline.tsx +46 -75
  54. package/examples/05-badge.tsx +2 -2
  55. package/examples/06-section-message.tsx +7 -7
  56. package/examples/07-comment.tsx +4 -6
  57. package/examples/08-lozenge.tsx +9 -5
  58. package/examples/99-interactions.tsx +53 -46
  59. package/examples/config.jsonc +11 -0
  60. package/package.json +5 -2
  61. package/report.api.md +240 -54
  62. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +52 -64
  63. package/scripts/codegen-styles.tsx +34 -6
  64. package/scripts/color-codegen-template.tsx +10 -15
  65. package/scripts/color-map-template.tsx +1 -1
  66. package/scripts/spacing-codegen-template.tsx +48 -12
  67. package/scripts/spacing-scale-template.tsx +40 -0
  68. package/scripts/utils.tsx +1 -3
  69. package/src/components/__tests__/unit/box.test.tsx +18 -13
  70. package/src/components/__tests__/unit/inline.test.tsx +10 -10
  71. package/src/components/__tests__/unit/interaction-suface.test.tsx +14 -8
  72. package/src/components/__tests__/unit/stack.test.tsx +7 -7
  73. package/src/components/__tests__/unit/text.test.tsx +23 -0
  74. 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
  75. 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
  76. 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
  77. 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
  78. 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
  79. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +2 -2
  80. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +2 -2
  81. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +2 -2
  82. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +2 -2
  83. 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
  84. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +2 -2
  85. package/src/components/box.partial.tsx +296 -159
  86. package/src/components/inline.partial.tsx +75 -21
  87. package/src/components/interaction-surface.partial.tsx +6 -4
  88. package/src/components/stack.partial.tsx +75 -22
  89. package/src/components/text.partial.tsx +78 -41
  90. package/src/components/types.tsx +2 -0
  91. package/src/index.tsx +0 -1
  92. package/src/internal/color-map.tsx +4 -3
  93. package/src/internal/spacing-scale.tsx +22 -0
  94. package/text/package.json +15 -0
  95. package/tmp/api-report-tmp.d.ts +583 -0
  96. package/dist/cjs/constants.js +0 -21
  97. package/dist/es2019/constants.js +0 -14
  98. package/dist/esm/constants.js +0 -14
  99. package/dist/types/constants.d.ts +0 -15
  100. package/dist/types-ts4.0/constants.d.ts +0 -15
  101. 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
- css: [baseStyles, gap && gapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent]],
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::36d00b5586593733c7f84e9a10ddb7fd>>
84
+ * @codegen <<SignedSource::cff5655983f2243060cade5b107d7762>>
66
85
  * @codegenId spacing
67
86
  * @codegenCommand yarn codegen-styles
68
- * @codegenParams ["gap"]
87
+ * @codegenParams ["columnGap"]
88
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
69
89
  */
70
90
 
71
- const gapMap = {
72
- 'sp-0': css({
73
- gap: SPACING_SCALE['sp-0']
91
+ const columnGapMap = {
92
+ 'scale.0': css({
93
+ columnGap: "var(--ds-scale-0, 0px)"
74
94
  }),
75
- 'sp-25': css({
76
- gap: SPACING_SCALE['sp-25']
95
+ 'scale.025': css({
96
+ columnGap: "var(--ds-scale-025, 2px)"
77
97
  }),
78
- 'sp-50': css({
79
- gap: SPACING_SCALE['sp-50']
98
+ 'scale.050': css({
99
+ columnGap: "var(--ds-scale-050, 4px)"
80
100
  }),
81
- 'sp-75': css({
82
- gap: SPACING_SCALE['sp-75']
101
+ 'scale.075': css({
102
+ columnGap: "var(--ds-scale-075, 6px)"
83
103
  }),
84
- 'sp-100': css({
85
- gap: SPACING_SCALE['sp-100']
104
+ 'scale.100': css({
105
+ columnGap: "var(--ds-scale-100, 8px)"
86
106
  }),
87
- 'sp-150': css({
88
- gap: SPACING_SCALE['sp-150']
107
+ 'scale.150': css({
108
+ columnGap: "var(--ds-scale-150, 12px)"
89
109
  }),
90
- 'sp-200': css({
91
- gap: SPACING_SCALE['sp-200']
110
+ 'scale.200': css({
111
+ columnGap: "var(--ds-scale-200, 16px)"
92
112
  }),
93
- 'sp-300': css({
94
- gap: SPACING_SCALE['sp-300']
113
+ 'scale.250': css({
114
+ columnGap: "var(--ds-scale-250, 20px)"
95
115
  }),
96
- 'sp-400': css({
97
- gap: SPACING_SCALE['sp-400']
116
+ 'scale.300': css({
117
+ columnGap: "var(--ds-scale-300, 24px)"
98
118
  }),
99
- 'sp-500': css({
100
- gap: SPACING_SCALE['sp-500']
119
+ 'scale.400': css({
120
+ columnGap: "var(--ds-scale-400, 32px)"
101
121
  }),
102
- 'sp-600': css({
103
- gap: SPACING_SCALE['sp-600']
122
+ 'scale.500': css({
123
+ columnGap: "var(--ds-scale-500, 40px)"
104
124
  }),
105
- 'sp-800': css({
106
- gap: SPACING_SCALE['sp-800']
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
- * <WarningIcon label="icon button" />
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::45000716488a9f41306a232c1f4c9f8d>>
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
- css: [baseStyles, gap && gapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent]],
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::36d00b5586593733c7f84e9a10ddb7fd>>
79
+ * @codegen <<SignedSource::c486b14097494305925c3c989823d602>>
61
80
  * @codegenId spacing
62
81
  * @codegenCommand yarn codegen-styles
63
- * @codegenParams ["gap"]
82
+ * @codegenParams ["rowGap"]
83
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::0c1fe9904b2ff2465a532b97ab76491e>>
64
84
  */
65
85
 
66
- const gapMap = {
67
- 'sp-0': css({
68
- gap: SPACING_SCALE['sp-0']
86
+ const rowGapMap = {
87
+ 'scale.0': css({
88
+ rowGap: "var(--ds-scale-0, 0px)"
69
89
  }),
70
- 'sp-25': css({
71
- gap: SPACING_SCALE['sp-25']
90
+ 'scale.025': css({
91
+ rowGap: "var(--ds-scale-025, 2px)"
72
92
  }),
73
- 'sp-50': css({
74
- gap: SPACING_SCALE['sp-50']
93
+ 'scale.050': css({
94
+ rowGap: "var(--ds-scale-050, 4px)"
75
95
  }),
76
- 'sp-75': css({
77
- gap: SPACING_SCALE['sp-75']
96
+ 'scale.075': css({
97
+ rowGap: "var(--ds-scale-075, 6px)"
78
98
  }),
79
- 'sp-100': css({
80
- gap: SPACING_SCALE['sp-100']
99
+ 'scale.100': css({
100
+ rowGap: "var(--ds-scale-100, 8px)"
81
101
  }),
82
- 'sp-150': css({
83
- gap: SPACING_SCALE['sp-150']
102
+ 'scale.150': css({
103
+ rowGap: "var(--ds-scale-150, 12px)"
84
104
  }),
85
- 'sp-200': css({
86
- gap: SPACING_SCALE['sp-200']
105
+ 'scale.200': css({
106
+ rowGap: "var(--ds-scale-200, 16px)"
87
107
  }),
88
- 'sp-300': css({
89
- gap: SPACING_SCALE['sp-300']
108
+ 'scale.250': css({
109
+ rowGap: "var(--ds-scale-250, 20px)"
90
110
  }),
91
- 'sp-400': css({
92
- gap: SPACING_SCALE['sp-400']
111
+ 'scale.300': css({
112
+ rowGap: "var(--ds-scale-300, 24px)"
93
113
  }),
94
- 'sp-500': css({
95
- gap: SPACING_SCALE['sp-500']
114
+ 'scale.400': css({
115
+ rowGap: "var(--ds-scale-400, 32px)"
96
116
  }),
97
- 'sp-600': css({
98
- gap: SPACING_SCALE['sp-600']
117
+ 'scale.500': css({
118
+ rowGap: "var(--ds-scale-500, 40px)"
99
119
  }),
100
- 'sp-800': css({
101
- gap: SPACING_SCALE['sp-800']
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 { colorMap } from '../internal/color-map';
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
- color: colorTuple,
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 surface = useSurface(); // @ts-ignore
121
-
122
- const [color = colorMap[surface], fallback] = colorTuple || [];
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
- return jsx(Component, {
125
- style: { ...UNSAFE_style,
126
- ...(fallback && {
127
- '--ds-co-fb': fallback
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::140ffff6e1310c1c37e2067e2c232b92>>
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, var(--ds-co-fb))"
184
+ color: "var(--ds-text, #172B4D)"
147
185
  }),
148
186
  subtle: css({
149
- color: "var(--ds-text-subtle, var(--ds-co-fb))"
187
+ color: "var(--ds-text-subtle, #42526E)"
150
188
  }),
151
189
  subtlest: css({
152
- color: "var(--ds-text-subtlest, var(--ds-co-fb))"
190
+ color: "var(--ds-text-subtlest, #7A869A)"
153
191
  }),
154
192
  disabled: css({
155
- color: "var(--ds-text-disabled, var(--ds-co-fb))"
193
+ color: "var(--ds-text-disabled, #A5ADBA)"
156
194
  }),
157
195
  inverse: css({
158
- color: "var(--ds-text-inverse, var(--ds-co-fb))"
196
+ color: "var(--ds-text-inverse, #FFFFFF)"
159
197
  }),
160
198
  brand: css({
161
- color: "var(--ds-text-brand, var(--ds-co-fb))"
199
+ color: "var(--ds-text-brand, #0065FF)"
162
200
  }),
163
201
  selected: css({
164
- color: "var(--ds-text-selected, var(--ds-co-fb))"
202
+ color: "var(--ds-text-selected, #0052CC)"
165
203
  }),
166
204
  danger: css({
167
- color: "var(--ds-text-danger, var(--ds-co-fb))"
205
+ color: "var(--ds-text-danger, #DE350B)"
168
206
  }),
169
207
  warning: css({
170
- color: "var(--ds-text-warning, var(--ds-co-fb))"
208
+ color: "var(--ds-text-warning, #974F0C)"
171
209
  }),
172
210
  'warning.inverse': css({
173
- color: "var(--ds-text-warning-inverse, var(--ds-co-fb))"
211
+ color: "var(--ds-text-warning-inverse, #172B4D)"
174
212
  }),
175
213
  success: css({
176
- color: "var(--ds-text-success, var(--ds-co-fb))"
214
+ color: "var(--ds-text-success, #006644)"
177
215
  }),
178
216
  discovery: css({
179
- color: "var(--ds-text-discovery, var(--ds-co-fb))"
217
+ color: "var(--ds-text-discovery, #403294)"
180
218
  }),
181
219
  information: css({
182
- color: "var(--ds-text-information, var(--ds-co-fb))"
220
+ color: "var(--ds-text-information, #0052CC)"
183
221
  })
184
222
  };
185
223
  /**
@@ -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
- * Some artifact
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::8f568e4f0837f7af4a10429e060ad059>>
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 const colorMap = {
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'];
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/ds-explorations",
3
- "version": "0.1.4",
3
+ "version": "1.0.0",
4
4
  "sideEffects": false
5
5
  }