@atlaskit/ds-explorations 0.0.3 → 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.
Files changed (114) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/components/box.partial.js +355 -185
  3. package/dist/cjs/components/inline.partial.js +124 -0
  4. package/dist/cjs/components/interaction-surface.partial.js +253 -0
  5. package/dist/cjs/components/stack.partial.js +116 -0
  6. package/dist/cjs/components/surface-provider.js +31 -0
  7. package/dist/cjs/components/text.partial.js +152 -49
  8. package/dist/cjs/components/types.js +5 -0
  9. package/dist/cjs/constants.js +3 -0
  10. package/dist/cjs/index.js +50 -3
  11. package/dist/cjs/internal/color-map.js +42 -0
  12. package/dist/cjs/internal/role-to-element.js +36 -0
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/es2019/components/box.partial.js +259 -113
  15. package/dist/es2019/components/inline.partial.js +111 -0
  16. package/dist/es2019/components/interaction-surface.partial.js +243 -0
  17. package/dist/es2019/components/stack.partial.js +106 -0
  18. package/dist/es2019/components/surface-provider.js +20 -0
  19. package/dist/es2019/components/text.partial.js +122 -35
  20. package/dist/es2019/components/types.js +1 -0
  21. package/dist/es2019/constants.js +3 -0
  22. package/dist/es2019/index.js +6 -1
  23. package/dist/es2019/internal/color-map.js +34 -0
  24. package/dist/es2019/internal/role-to-element.js +28 -0
  25. package/dist/es2019/version.json +1 -1
  26. package/dist/esm/components/box.partial.js +274 -109
  27. package/dist/esm/components/inline.partial.js +110 -0
  28. package/dist/esm/components/interaction-surface.partial.js +242 -0
  29. package/dist/esm/components/stack.partial.js +105 -0
  30. package/dist/esm/components/surface-provider.js +20 -0
  31. package/dist/esm/components/text.partial.js +132 -34
  32. package/dist/esm/components/types.js +1 -0
  33. package/dist/esm/constants.js +3 -0
  34. package/dist/esm/index.js +6 -1
  35. package/dist/esm/internal/color-map.js +34 -0
  36. package/dist/esm/internal/role-to-element.js +28 -0
  37. package/dist/esm/version.json +1 -1
  38. package/dist/types/components/box.partial.d.ts +157 -76
  39. package/dist/types/components/inline.partial.d.ts +52 -0
  40. package/dist/types/components/interaction-surface.partial.d.ts +45 -0
  41. package/dist/types/components/stack.partial.d.ts +47 -0
  42. package/dist/types/components/surface-provider.d.ts +15 -0
  43. package/dist/types/components/text.partial.d.ts +100 -28
  44. package/dist/types/components/types.d.ts +13 -0
  45. package/dist/types/constants.d.ts +3 -0
  46. package/dist/types/index.d.ts +8 -2
  47. package/dist/types/internal/color-map.d.ts +34 -0
  48. package/dist/types/internal/role-to-element.d.ts +32 -0
  49. package/examples/00-basic.tsx +18 -1
  50. package/examples/01-box.tsx +126 -2
  51. package/examples/02-text.tsx +76 -2
  52. package/examples/03-stack.tsx +125 -0
  53. package/examples/04-inline.tsx +134 -0
  54. package/examples/{03-badge.tsx → 05-badge.tsx} +4 -4
  55. package/examples/{04-section-message.tsx → 06-section-message.tsx} +6 -6
  56. package/examples/{05-comment.tsx → 07-comment.tsx} +11 -9
  57. package/examples/08-lozenge.tsx +29 -0
  58. package/examples/99-interactions.tsx +175 -0
  59. package/package.json +8 -5
  60. package/report.api.md +457 -4
  61. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +244 -50
  62. package/scripts/__tests__/codegen.test.tsx +5 -0
  63. package/scripts/codegen-styles.tsx +46 -10
  64. package/scripts/color-codegen-template.tsx +34 -12
  65. package/scripts/color-map-template.tsx +52 -0
  66. package/scripts/interaction-codegen.tsx +109 -0
  67. package/scripts/spacing-codegen-template.tsx +9 -1
  68. package/scripts/utils.tsx +5 -1
  69. package/src/components/__tests__/unit/box.test.tsx +50 -0
  70. package/src/components/__tests__/unit/inline.test.tsx +43 -0
  71. package/src/components/__tests__/unit/interaction-suface.test.tsx +70 -0
  72. package/src/components/__tests__/unit/stack.test.tsx +31 -0
  73. package/src/components/__tests__/unit/text.test.tsx +33 -0
  74. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-basic-example-should-match-production-example-1-snap.png +3 -0
  75. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-alignment-should-match-snapshot-1-snap.png +3 -0
  76. 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 +3 -0
  77. 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 +3 -0
  78. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-should-match-snapshot-1-snap.png +3 -0
  79. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-color-should-match-snapshot-1-snap.png +3 -0
  80. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-color-should-match-snapshot-1-snap.png +3 -0
  81. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-should-match-snapshot-1-snap.png +3 -0
  82. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +3 -0
  83. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +3 -0
  84. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +3 -0
  85. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +3 -0
  86. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-font-sizes-should-match-snapshot-1-snap.png +3 -0
  87. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-font-weights-should-match-snapshot-1-snap.png +3 -0
  88. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-line-heights-should-match-snapshot-1-snap.png +3 -0
  89. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +3 -0
  90. package/src/components/__tests__/visual-regression/box-snapshot-test.tsx +33 -0
  91. package/src/components/__tests__/visual-regression/inline-snapshot-test.tsx +28 -0
  92. package/src/components/__tests__/visual-regression/stack-snapshot-test.tsx +28 -0
  93. package/src/components/__tests__/visual-regression/text-snapshot-test.tsx +31 -0
  94. package/src/components/box.partial.tsx +305 -127
  95. package/src/components/inline.partial.tsx +120 -0
  96. package/src/components/interaction-surface.partial.tsx +237 -0
  97. package/src/components/stack.partial.tsx +104 -0
  98. package/src/components/surface-provider.tsx +25 -0
  99. package/src/components/text.partial.tsx +149 -38
  100. package/src/components/types.tsx +15 -0
  101. package/src/constants.tsx +3 -0
  102. package/src/index.tsx +8 -1
  103. package/src/internal/color-map.tsx +34 -0
  104. package/src/internal/role-to-element.tsx +34 -0
  105. package/dist/cjs/components/inline.js +0 -45
  106. package/dist/cjs/components/stack.js +0 -33
  107. package/dist/es2019/components/inline.js +0 -31
  108. package/dist/es2019/components/stack.js +0 -22
  109. package/dist/esm/components/inline.js +0 -30
  110. package/dist/esm/components/stack.js +0 -21
  111. package/dist/types/components/inline.d.ts +0 -19
  112. package/dist/types/components/stack.d.ts +0 -16
  113. package/src/components/inline.tsx +0 -49
  114. package/src/components/stack.tsx +0 -30
@@ -0,0 +1,120 @@
1
+ /** @jsx jsx */
2
+ import { Children, forwardRef, Fragment, ReactNode } from 'react';
3
+
4
+ import { css, jsx } from '@emotion/react';
5
+
6
+ import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
7
+
8
+ import Text from './text.partial';
9
+ import { BasePrimitiveProps } from './types';
10
+
11
+ interface InlineProps extends BasePrimitiveProps {
12
+ /**
13
+ * Used to align children along the cross axis.
14
+ */
15
+ alignItems?: FlexAlignItems;
16
+ /**
17
+ * Used to align children along the main axis.
18
+ */
19
+ justifyContent?: FlexJustifyContent;
20
+ /**
21
+ * Token representing gap between children.
22
+ */
23
+ gap: GlobalSpacingToken;
24
+ /**
25
+ * Renders a divider between children.
26
+ * If a string is provided it will automatically be wrapped in a `<Text>` component.
27
+ */
28
+ divider?: ReactNode;
29
+ /**
30
+ * Elements to be rendered inside the Inline.
31
+ */
32
+ children: ReactNode;
33
+ }
34
+
35
+ type FlexAlignItems = keyof typeof flexAlignItemsMap;
36
+ const flexAlignItemsMap = {
37
+ center: css({ alignItems: 'center' }),
38
+ baseline: css({ alignItems: 'baseline' }),
39
+ flexStart: css({ alignItems: 'flex-start' }),
40
+ flexEnd: css({ alignItems: 'flex-end' }),
41
+ };
42
+
43
+ type FlexJustifyContent = keyof typeof flexJustifyContentMap;
44
+ const flexJustifyContentMap = {
45
+ center: css({ justifyContent: 'center' }),
46
+ flexStart: css({ justifyContent: 'flex-start' }),
47
+ flexEnd: css({ justifyContent: 'flex-end' }),
48
+ };
49
+
50
+ const baseStyles = css({
51
+ display: 'flex',
52
+ boxSizing: 'border-box',
53
+ flexDirection: 'row',
54
+ });
55
+
56
+ /**
57
+ * __Inline__
58
+ *
59
+ * Inline is a primitive component based on flexbox that manages the horizontal layout of direct children.
60
+ * Renders a `div` by default.
61
+ *
62
+ */
63
+ const Inline = forwardRef<HTMLDivElement, InlineProps>(
64
+ ({ gap, alignItems, justifyContent, divider, children, testId }, ref) => {
65
+ const dividerComponent =
66
+ typeof divider === 'string' ? <Text>{divider}</Text> : divider;
67
+
68
+ return (
69
+ <div
70
+ css={[
71
+ baseStyles,
72
+ gap && gapMap[gap],
73
+ alignItems && flexAlignItemsMap[alignItems],
74
+ justifyContent && flexJustifyContentMap[justifyContent],
75
+ ]}
76
+ data-testid={testId}
77
+ ref={ref}
78
+ >
79
+ {Children.map(children, (child, index) => {
80
+ return (
81
+ <Fragment>
82
+ {divider && index > 0 ? dividerComponent : null}
83
+ {child}
84
+ </Fragment>
85
+ );
86
+ })}
87
+ </div>
88
+ );
89
+ },
90
+ );
91
+
92
+ Inline.displayName = 'Inline';
93
+
94
+ export default Inline;
95
+
96
+ /**
97
+ * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
98
+ * @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
99
+ * @codegenId spacing
100
+ * @codegenCommand yarn codegen-styles
101
+ * @codegenParams ["gap"]
102
+ */
103
+ const gapMap = {
104
+ 'sp-0': css({ gap: SPACING_SCALE['sp-0'] }),
105
+ 'sp-25': css({ gap: SPACING_SCALE['sp-25'] }),
106
+ 'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
107
+ 'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
108
+ 'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
109
+ 'sp-150': css({ gap: SPACING_SCALE['sp-150'] }),
110
+ 'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
111
+ 'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
112
+ 'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
113
+ 'sp-500': css({ gap: SPACING_SCALE['sp-500'] }),
114
+ 'sp-600': css({ gap: SPACING_SCALE['sp-600'] }),
115
+ 'sp-800': css({ gap: SPACING_SCALE['sp-800'] }),
116
+ };
117
+
118
+ /**
119
+ * @codegenEnd
120
+ */
@@ -0,0 +1,237 @@
1
+ /** @jsx jsx */
2
+ import { Fragment, ReactNode, useContext } from 'react';
3
+
4
+ import { css, jsx } from '@emotion/react';
5
+
6
+ import { token } from '@atlaskit/tokens';
7
+
8
+ import { SurfaceContext } from './surface-provider';
9
+ import { BasePrimitiveProps } from './types';
10
+
11
+ const baseStyles = css({
12
+ position: 'absolute',
13
+ borderRadius: 'inherit',
14
+ cursor: 'pointer',
15
+ inset: 0,
16
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
17
+ '~ *': {
18
+ position: 'relative',
19
+ pointerEvents: 'none',
20
+ },
21
+ });
22
+
23
+ interface InteractionSurfaceProps extends BasePrimitiveProps {
24
+ children?: ReactNode;
25
+ appearance?: InteractionBackgroundColor;
26
+ }
27
+
28
+ /**
29
+ *
30
+ * @example
31
+ * ```js
32
+ * // a minimal icon button
33
+ * <Box as="button">
34
+ * <InteractionSurface />
35
+ * <WarningIcon label="icon button" />
36
+ * </Box>
37
+ * ```
38
+ */
39
+ const InteractionSurface = ({
40
+ appearance,
41
+ children,
42
+ testId,
43
+ }: InteractionSurfaceProps) => {
44
+ const defaultSurface = useContext(SurfaceContext);
45
+ let surface = (appearance || defaultSurface) as InteractionBackgroundColor;
46
+
47
+ // This case will occur if the Box has not set a bg color and the ancestor surface
48
+ // is an elevation. An alternative would be to throw an error here as it may be better
49
+ // to ensure correct predictable behaviour based on user specification.
50
+ if (!(surface in backgroundActiveColorMap)) {
51
+ surface = 'neutral';
52
+ }
53
+ return (
54
+ <Fragment>
55
+ <span
56
+ data-testid={testId}
57
+ css={[
58
+ baseStyles,
59
+ surface && backgroundHoverColorMap[surface],
60
+ surface && backgroundActiveColorMap[surface],
61
+ ]}
62
+ />
63
+ {children}
64
+ </Fragment>
65
+ );
66
+ };
67
+
68
+ export default InteractionSurface;
69
+
70
+ /**
71
+ * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
72
+ * @codegen <<SignedSource::45000716488a9f41306a232c1f4c9f8d>>
73
+ * @codegenId interactions
74
+ * @codegenCommand yarn codegen-styles
75
+ * @codegenParams ["background"]
76
+ */
77
+ const backgroundActiveColorMap = {
78
+ 'inverse.subtle': css({
79
+ ':active': {
80
+ backgroundColor: token('color.background.inverse.subtle.pressed'),
81
+ },
82
+ }),
83
+ input: css({
84
+ ':active': { backgroundColor: token('color.background.input.pressed') },
85
+ }),
86
+ neutral: css({
87
+ ':active': { backgroundColor: token('color.background.neutral.pressed') },
88
+ }),
89
+ 'neutral.subtle': css({
90
+ ':active': {
91
+ backgroundColor: token('color.background.neutral.subtle.pressed'),
92
+ },
93
+ }),
94
+ 'neutral.bold': css({
95
+ ':active': {
96
+ backgroundColor: token('color.background.neutral.bold.pressed'),
97
+ },
98
+ }),
99
+ 'brand.bold': css({
100
+ ':active': {
101
+ backgroundColor: token('color.background.brand.bold.pressed'),
102
+ },
103
+ }),
104
+ selected: css({
105
+ ':active': { backgroundColor: token('color.background.selected.pressed') },
106
+ }),
107
+ 'selected.bold': css({
108
+ ':active': {
109
+ backgroundColor: token('color.background.selected.bold.pressed'),
110
+ },
111
+ }),
112
+ danger: css({
113
+ ':active': { backgroundColor: token('color.background.danger.pressed') },
114
+ }),
115
+ 'danger.bold': css({
116
+ ':active': {
117
+ backgroundColor: token('color.background.danger.bold.pressed'),
118
+ },
119
+ }),
120
+ warning: css({
121
+ ':active': { backgroundColor: token('color.background.warning.pressed') },
122
+ }),
123
+ 'warning.bold': css({
124
+ ':active': {
125
+ backgroundColor: token('color.background.warning.bold.pressed'),
126
+ },
127
+ }),
128
+ success: css({
129
+ ':active': { backgroundColor: token('color.background.success.pressed') },
130
+ }),
131
+ 'success.bold': css({
132
+ ':active': {
133
+ backgroundColor: token('color.background.success.bold.pressed'),
134
+ },
135
+ }),
136
+ discovery: css({
137
+ ':active': { backgroundColor: token('color.background.discovery.pressed') },
138
+ }),
139
+ 'discovery.bold': css({
140
+ ':active': {
141
+ backgroundColor: token('color.background.discovery.bold.pressed'),
142
+ },
143
+ }),
144
+ information: css({
145
+ ':active': {
146
+ backgroundColor: token('color.background.information.pressed'),
147
+ },
148
+ }),
149
+ 'information.bold': css({
150
+ ':active': {
151
+ backgroundColor: token('color.background.information.bold.pressed'),
152
+ },
153
+ }),
154
+ };
155
+
156
+ const backgroundHoverColorMap = {
157
+ 'inverse.subtle': css({
158
+ ':hover': {
159
+ backgroundColor: token('color.background.inverse.subtle.hovered'),
160
+ },
161
+ }),
162
+ input: css({
163
+ ':hover': { backgroundColor: token('color.background.input.hovered') },
164
+ }),
165
+ neutral: css({
166
+ ':hover': { backgroundColor: token('color.background.neutral.hovered') },
167
+ }),
168
+ 'neutral.subtle': css({
169
+ ':hover': {
170
+ backgroundColor: token('color.background.neutral.subtle.hovered'),
171
+ },
172
+ }),
173
+ 'neutral.bold': css({
174
+ ':hover': {
175
+ backgroundColor: token('color.background.neutral.bold.hovered'),
176
+ },
177
+ }),
178
+ 'brand.bold': css({
179
+ ':hover': { backgroundColor: token('color.background.brand.bold.hovered') },
180
+ }),
181
+ selected: css({
182
+ ':hover': { backgroundColor: token('color.background.selected.hovered') },
183
+ }),
184
+ 'selected.bold': css({
185
+ ':hover': {
186
+ backgroundColor: token('color.background.selected.bold.hovered'),
187
+ },
188
+ }),
189
+ danger: css({
190
+ ':hover': { backgroundColor: token('color.background.danger.hovered') },
191
+ }),
192
+ 'danger.bold': css({
193
+ ':hover': {
194
+ backgroundColor: token('color.background.danger.bold.hovered'),
195
+ },
196
+ }),
197
+ warning: css({
198
+ ':hover': { backgroundColor: token('color.background.warning.hovered') },
199
+ }),
200
+ 'warning.bold': css({
201
+ ':hover': {
202
+ backgroundColor: token('color.background.warning.bold.hovered'),
203
+ },
204
+ }),
205
+ success: css({
206
+ ':hover': { backgroundColor: token('color.background.success.hovered') },
207
+ }),
208
+ 'success.bold': css({
209
+ ':hover': {
210
+ backgroundColor: token('color.background.success.bold.hovered'),
211
+ },
212
+ }),
213
+ discovery: css({
214
+ ':hover': { backgroundColor: token('color.background.discovery.hovered') },
215
+ }),
216
+ 'discovery.bold': css({
217
+ ':hover': {
218
+ backgroundColor: token('color.background.discovery.bold.hovered'),
219
+ },
220
+ }),
221
+ information: css({
222
+ ':hover': {
223
+ backgroundColor: token('color.background.information.hovered'),
224
+ },
225
+ }),
226
+ 'information.bold': css({
227
+ ':hover': {
228
+ backgroundColor: token('color.background.information.bold.hovered'),
229
+ },
230
+ }),
231
+ };
232
+
233
+ type InteractionBackgroundColor = keyof typeof backgroundHoverColorMap;
234
+
235
+ /**
236
+ * @codegenEnd
237
+ */
@@ -0,0 +1,104 @@
1
+ /** @jsx jsx */
2
+ import { forwardRef, ReactNode } from 'react';
3
+
4
+ import { css, jsx } from '@emotion/react';
5
+
6
+ import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
7
+
8
+ import { BasePrimitiveProps } from './types';
9
+
10
+ interface StackProps extends BasePrimitiveProps {
11
+ /**
12
+ * Used to align children along the cross axis.
13
+ */
14
+ alignItems?: FlexAlignItems;
15
+ /**
16
+ * Used to align children along the main axis.
17
+ */
18
+ justifyContent?: FlexJustifyContent;
19
+ /**
20
+ * Token representing gap between children.
21
+ */
22
+ gap: GlobalSpacingToken;
23
+ /**
24
+ * Elements to be rendered inside the Stack.
25
+ */
26
+ children: ReactNode;
27
+ }
28
+
29
+ type FlexAlignItems = keyof typeof flexAlignItemsMap;
30
+ const flexAlignItemsMap = {
31
+ center: css({ alignItems: 'center' }),
32
+ baseline: css({ alignItems: 'baseline' }),
33
+ flexStart: css({ alignItems: 'flex-start' }),
34
+ flexEnd: css({ alignItems: 'flex-end' }),
35
+ };
36
+
37
+ type FlexJustifyContent = keyof typeof flexJustifyContentMap;
38
+ const flexJustifyContentMap = {
39
+ center: css({ justifyContent: 'center' }),
40
+ flexStart: css({ justifyContent: 'flex-start' }),
41
+ flexEnd: css({ justifyContent: 'flex-end' }),
42
+ };
43
+
44
+ const baseStyles = css({
45
+ display: 'flex',
46
+ boxSizing: 'border-box',
47
+ flexDirection: 'column',
48
+ });
49
+
50
+ /**
51
+ * __Stack__
52
+ *
53
+ * Stack is a primitive component based on flexbox that manages the vertical layout of direct children.
54
+ * Renders a `div` by default.
55
+ *
56
+ */
57
+ const Stack = forwardRef<HTMLDivElement, StackProps>(
58
+ ({ gap, alignItems, justifyContent, children, testId }, ref) => {
59
+ return (
60
+ <div
61
+ css={[
62
+ baseStyles,
63
+ gap && gapMap[gap],
64
+ alignItems && flexAlignItemsMap[alignItems],
65
+ justifyContent && flexJustifyContentMap[justifyContent],
66
+ ]}
67
+ data-testid={testId}
68
+ ref={ref}
69
+ >
70
+ {children}
71
+ </div>
72
+ );
73
+ },
74
+ );
75
+
76
+ Stack.displayName = 'Stack';
77
+
78
+ export default Stack;
79
+
80
+ /**
81
+ * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
82
+ * @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
83
+ * @codegenId spacing
84
+ * @codegenCommand yarn codegen-styles
85
+ * @codegenParams ["gap"]
86
+ */
87
+ const gapMap = {
88
+ 'sp-0': css({ gap: SPACING_SCALE['sp-0'] }),
89
+ 'sp-25': css({ gap: SPACING_SCALE['sp-25'] }),
90
+ 'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
91
+ 'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
92
+ 'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
93
+ 'sp-150': css({ gap: SPACING_SCALE['sp-150'] }),
94
+ 'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
95
+ 'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
96
+ 'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
97
+ 'sp-500': css({ gap: SPACING_SCALE['sp-500'] }),
98
+ 'sp-600': css({ gap: SPACING_SCALE['sp-600'] }),
99
+ 'sp-800': css({ gap: SPACING_SCALE['sp-800'] }),
100
+ };
101
+
102
+ /**
103
+ * @codegenEnd
104
+ */
@@ -0,0 +1,25 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ import type { BackgroundColor } from './box.partial';
4
+
5
+ /**
6
+ * __Surface context__
7
+ *
8
+ * A surface context provides context information on the current background (if set).
9
+ */
10
+ export const SurfaceContext = createContext<BackgroundColor>(
11
+ 'elevation.surface',
12
+ );
13
+
14
+ /**
15
+ * __useSurface__
16
+ *
17
+ * Return the current surface. If no parent sets a surface color it falls back to the default surface.
18
+ *
19
+ * @see SurfaceContext
20
+ */
21
+ export const useSurface = () => {
22
+ return useContext(SurfaceContext);
23
+ };
24
+
25
+ SurfaceContext.displayName = 'SurfaceProvider';