@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
|
@@ -7,16 +7,17 @@ import {
|
|
|
7
7
|
ReactNode,
|
|
8
8
|
} from 'react';
|
|
9
9
|
|
|
10
|
-
import { css, jsx } from '@emotion/
|
|
10
|
+
import { css, jsx } from '@emotion/react';
|
|
11
11
|
|
|
12
12
|
import { token } from '@atlaskit/tokens';
|
|
13
13
|
|
|
14
14
|
import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
|
|
15
15
|
|
|
16
|
+
import { SurfaceContext } from './surface-provider';
|
|
16
17
|
import { BasePrimitiveProps } from './types';
|
|
17
18
|
|
|
18
|
-
export interface BoxProps
|
|
19
|
-
extends Omit<HTMLAttributes<
|
|
19
|
+
export interface BoxProps<T extends HTMLElement = HTMLElement>
|
|
20
|
+
extends Omit<HTMLAttributes<T>, 'style' | 'as' | 'className'>,
|
|
20
21
|
BasePrimitiveProps {
|
|
21
22
|
/**
|
|
22
23
|
* The DOM element to render as the Box. Defaults to `div`.
|
|
@@ -25,7 +26,19 @@ export interface BoxProps
|
|
|
25
26
|
/**
|
|
26
27
|
* Elements to be rendered inside the Box.
|
|
27
28
|
*/
|
|
28
|
-
children
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* The html className attribute.
|
|
32
|
+
*
|
|
33
|
+
* Before using this prop please ensure:
|
|
34
|
+
* - The styles cannot otherwise be achieved through `Box` directly.
|
|
35
|
+
* - The use case needs custom styles that cannot be designed or implemented differently
|
|
36
|
+
*
|
|
37
|
+
* Ensure you're using the `@atlaskit/eslint-plugin-design-system` with this prop to prevent unbounded usage.
|
|
38
|
+
*
|
|
39
|
+
* @see `@atlaskit/eslint-plugin-design-system`
|
|
40
|
+
*/
|
|
41
|
+
className?: string;
|
|
29
42
|
/**
|
|
30
43
|
* Token representing background color with a fallback.
|
|
31
44
|
*/
|
|
@@ -85,64 +98,12 @@ export interface BoxProps
|
|
|
85
98
|
* Defines display type and layout. Defaults to `flex`.
|
|
86
99
|
*/
|
|
87
100
|
display?: Display;
|
|
101
|
+
/**
|
|
102
|
+
* CSS position property.
|
|
103
|
+
*/
|
|
104
|
+
position?: keyof typeof positionMap;
|
|
88
105
|
}
|
|
89
106
|
|
|
90
|
-
type BorderStyle = keyof typeof borderStyleMap;
|
|
91
|
-
const borderStyleMap = {
|
|
92
|
-
none: css({ borderStyle: 'none' }),
|
|
93
|
-
solid: css({ borderStyle: 'solid' }),
|
|
94
|
-
dashed: css({ borderStyle: 'dashed' }),
|
|
95
|
-
dotted: css({ borderStyle: 'dotted' }),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
type BorderWidth = keyof typeof borderWidthMap;
|
|
99
|
-
const borderWidthMap = {
|
|
100
|
-
'0px': css({ borderWidth: '0px' }),
|
|
101
|
-
'1px': css({ borderWidth: '1px' }),
|
|
102
|
-
'2px': css({ borderWidth: '2px' }),
|
|
103
|
-
'3px': css({ borderWidth: '3px' }),
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
type BorderRadius = keyof typeof borderRadiusMap;
|
|
107
|
-
const borderRadiusMap = {
|
|
108
|
-
normal: css({ borderRadius: '3px' }),
|
|
109
|
-
rounded: css({ borderRadius: '50%' }),
|
|
110
|
-
badge: css({ borderRadius: '8px' }),
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
type FlexDirection = keyof typeof flexDirectionMap;
|
|
114
|
-
const flexDirectionMap = {
|
|
115
|
-
column: css({ flexDirection: 'column' }),
|
|
116
|
-
row: css({ flexDirection: 'row' }),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
type FlexAlignItems = keyof typeof flexAlignItemsMap;
|
|
120
|
-
const flexAlignItemsMap = {
|
|
121
|
-
center: css({ alignItems: 'center' }),
|
|
122
|
-
baseline: css({ alignItems: 'baseline' }),
|
|
123
|
-
flexStart: css({ alignItems: 'flex-start' }),
|
|
124
|
-
flexEnd: css({ alignItems: 'flex-end' }),
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
type FlexJustifyContent = keyof typeof flexJustifyContentMap;
|
|
128
|
-
const flexJustifyContentMap = {
|
|
129
|
-
center: css({ justifyContent: 'center' }),
|
|
130
|
-
flexStart: css({ justifyContent: 'flex-start' }),
|
|
131
|
-
flexEnd: css({ justifyContent: 'flex-end' }),
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
type Display = keyof typeof displayMap;
|
|
135
|
-
const displayMap = {
|
|
136
|
-
block: css({ display: 'block' }),
|
|
137
|
-
inline: css({ display: 'inline' }),
|
|
138
|
-
flex: css({ display: 'flex' }),
|
|
139
|
-
inlineFlex: css({ display: 'inline-flex' }),
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const baseStyles = css({
|
|
143
|
-
boxSizing: 'border-box',
|
|
144
|
-
});
|
|
145
|
-
|
|
146
107
|
/**
|
|
147
108
|
* __Box__
|
|
148
109
|
*
|
|
@@ -156,6 +117,7 @@ const Box = forwardRef<HTMLElement, BoxProps>(
|
|
|
156
117
|
{
|
|
157
118
|
children,
|
|
158
119
|
as: Component = 'div',
|
|
120
|
+
className,
|
|
159
121
|
display = 'flex',
|
|
160
122
|
flexDirection,
|
|
161
123
|
alignItems,
|
|
@@ -168,16 +130,11 @@ const Box = forwardRef<HTMLElement, BoxProps>(
|
|
|
168
130
|
padding,
|
|
169
131
|
paddingBlock,
|
|
170
132
|
paddingInline,
|
|
133
|
+
position = 'relative',
|
|
171
134
|
height,
|
|
172
135
|
width,
|
|
173
136
|
UNSAFE_style,
|
|
174
137
|
testId,
|
|
175
|
-
/**
|
|
176
|
-
* Pull this out to prevent accidentaly spread
|
|
177
|
-
*/
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
// @eslint-disbale-next-line no-unused-vars
|
|
180
|
-
className: dontUseThisProperty,
|
|
181
138
|
...htmlAttributes
|
|
182
139
|
},
|
|
183
140
|
ref,
|
|
@@ -185,7 +142,8 @@ const Box = forwardRef<HTMLElement, BoxProps>(
|
|
|
185
142
|
const [backgroundColor, backgroundColorFallback] =
|
|
186
143
|
backgroundColorTuple || [];
|
|
187
144
|
const [borderColor, borderColorFallback] = borderColorTuple || [];
|
|
188
|
-
|
|
145
|
+
|
|
146
|
+
const node = (
|
|
189
147
|
<Component
|
|
190
148
|
style={{
|
|
191
149
|
...UNSAFE_style,
|
|
@@ -194,13 +152,16 @@ const Box = forwardRef<HTMLElement, BoxProps>(
|
|
|
194
152
|
...(borderColorFallback &&
|
|
195
153
|
({ '--ds-bo-fb': borderColorFallback } as CSSProperties)),
|
|
196
154
|
}}
|
|
155
|
+
// @ts-ignore
|
|
197
156
|
ref={ref}
|
|
198
157
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
199
158
|
{...htmlAttributes}
|
|
159
|
+
className={className}
|
|
200
160
|
css={[
|
|
201
161
|
baseStyles,
|
|
202
162
|
display && displayMap[display],
|
|
203
163
|
padding && paddingMap[padding],
|
|
164
|
+
position && positionMap[position],
|
|
204
165
|
paddingBlock && paddingBlockMap[paddingBlock],
|
|
205
166
|
paddingInline && paddingInlineMap[paddingInline],
|
|
206
167
|
alignItems && flexAlignItemsMap[alignItems],
|
|
@@ -219,14 +180,89 @@ const Box = forwardRef<HTMLElement, BoxProps>(
|
|
|
219
180
|
{children}
|
|
220
181
|
</Component>
|
|
221
182
|
);
|
|
183
|
+
|
|
184
|
+
return backgroundColor ? (
|
|
185
|
+
<SurfaceContext.Provider value={backgroundColor}>
|
|
186
|
+
{node}
|
|
187
|
+
</SurfaceContext.Provider>
|
|
188
|
+
) : (
|
|
189
|
+
node
|
|
190
|
+
);
|
|
222
191
|
},
|
|
223
192
|
);
|
|
224
193
|
|
|
194
|
+
Box.displayName = 'Box';
|
|
195
|
+
|
|
225
196
|
export default Box;
|
|
226
197
|
|
|
198
|
+
// <<< STYLES GO HERE >>>
|
|
199
|
+
type BorderStyle = keyof typeof borderStyleMap;
|
|
200
|
+
const borderStyleMap = {
|
|
201
|
+
none: css({ borderStyle: 'none' }),
|
|
202
|
+
solid: css({ borderStyle: 'solid' }),
|
|
203
|
+
dashed: css({ borderStyle: 'dashed' }),
|
|
204
|
+
dotted: css({ borderStyle: 'dotted' }),
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
type BorderWidth = keyof typeof borderWidthMap;
|
|
208
|
+
const borderWidthMap = {
|
|
209
|
+
'0px': css({ borderWidth: '0px' }),
|
|
210
|
+
'1px': css({ borderWidth: '1px' }),
|
|
211
|
+
'2px': css({ borderWidth: '2px' }),
|
|
212
|
+
'3px': css({ borderWidth: '3px' }),
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
type BorderRadius = keyof typeof borderRadiusMap;
|
|
216
|
+
const borderRadiusMap = {
|
|
217
|
+
normal: css({ borderRadius: '3px' }),
|
|
218
|
+
rounded: css({ borderRadius: '50%' }),
|
|
219
|
+
badge: css({ borderRadius: '8px' }),
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
type FlexDirection = keyof typeof flexDirectionMap;
|
|
223
|
+
const flexDirectionMap = {
|
|
224
|
+
column: css({ flexDirection: 'column' }),
|
|
225
|
+
row: css({ flexDirection: 'row' }),
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
type FlexAlignItems = keyof typeof flexAlignItemsMap;
|
|
229
|
+
const flexAlignItemsMap = {
|
|
230
|
+
center: css({ alignItems: 'center' }),
|
|
231
|
+
baseline: css({ alignItems: 'baseline' }),
|
|
232
|
+
flexStart: css({ alignItems: 'flex-start' }),
|
|
233
|
+
flexEnd: css({ alignItems: 'flex-end' }),
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
type FlexJustifyContent = keyof typeof flexJustifyContentMap;
|
|
237
|
+
const flexJustifyContentMap = {
|
|
238
|
+
center: css({ justifyContent: 'center' }),
|
|
239
|
+
flexStart: css({ justifyContent: 'flex-start' }),
|
|
240
|
+
flexEnd: css({ justifyContent: 'flex-end' }),
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
type Display = keyof typeof displayMap;
|
|
244
|
+
const displayMap = {
|
|
245
|
+
block: css({ display: 'block' }),
|
|
246
|
+
inline: css({ display: 'inline' }),
|
|
247
|
+
flex: css({ display: 'flex' }),
|
|
248
|
+
inlineFlex: css({ display: 'inline-flex' }),
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const baseStyles = css({
|
|
252
|
+
boxSizing: 'border-box',
|
|
253
|
+
appearance: 'none',
|
|
254
|
+
border: 'none',
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const positionMap = {
|
|
258
|
+
absolute: css({ position: 'absolute' }),
|
|
259
|
+
relative: css({ position: 'relative' }),
|
|
260
|
+
static: css({ position: 'static' }),
|
|
261
|
+
};
|
|
262
|
+
|
|
227
263
|
/**
|
|
228
264
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
229
|
-
* @codegen <<SignedSource::
|
|
265
|
+
* @codegen <<SignedSource::57b4c7c177fdfae3f7cd4f00287fd30e>>
|
|
230
266
|
* @codegenId spacing
|
|
231
267
|
* @codegenCommand yarn codegen-styles
|
|
232
268
|
* @codegenParams ["padding", "paddingBlock", "paddingInline", "width", "height"]
|
|
@@ -237,6 +273,7 @@ const paddingMap = {
|
|
|
237
273
|
'sp-50': css({ padding: SPACING_SCALE['sp-50'] }),
|
|
238
274
|
'sp-75': css({ padding: SPACING_SCALE['sp-75'] }),
|
|
239
275
|
'sp-100': css({ padding: SPACING_SCALE['sp-100'] }),
|
|
276
|
+
'sp-150': css({ padding: SPACING_SCALE['sp-150'] }),
|
|
240
277
|
'sp-200': css({ padding: SPACING_SCALE['sp-200'] }),
|
|
241
278
|
'sp-300': css({ padding: SPACING_SCALE['sp-300'] }),
|
|
242
279
|
'sp-400': css({ padding: SPACING_SCALE['sp-400'] }),
|
|
@@ -251,6 +288,7 @@ const paddingBlockMap = {
|
|
|
251
288
|
'sp-50': css({ paddingBlock: SPACING_SCALE['sp-50'] }),
|
|
252
289
|
'sp-75': css({ paddingBlock: SPACING_SCALE['sp-75'] }),
|
|
253
290
|
'sp-100': css({ paddingBlock: SPACING_SCALE['sp-100'] }),
|
|
291
|
+
'sp-150': css({ paddingBlock: SPACING_SCALE['sp-150'] }),
|
|
254
292
|
'sp-200': css({ paddingBlock: SPACING_SCALE['sp-200'] }),
|
|
255
293
|
'sp-300': css({ paddingBlock: SPACING_SCALE['sp-300'] }),
|
|
256
294
|
'sp-400': css({ paddingBlock: SPACING_SCALE['sp-400'] }),
|
|
@@ -265,6 +303,7 @@ const paddingInlineMap = {
|
|
|
265
303
|
'sp-50': css({ paddingInline: SPACING_SCALE['sp-50'] }),
|
|
266
304
|
'sp-75': css({ paddingInline: SPACING_SCALE['sp-75'] }),
|
|
267
305
|
'sp-100': css({ paddingInline: SPACING_SCALE['sp-100'] }),
|
|
306
|
+
'sp-150': css({ paddingInline: SPACING_SCALE['sp-150'] }),
|
|
268
307
|
'sp-200': css({ paddingInline: SPACING_SCALE['sp-200'] }),
|
|
269
308
|
'sp-300': css({ paddingInline: SPACING_SCALE['sp-300'] }),
|
|
270
309
|
'sp-400': css({ paddingInline: SPACING_SCALE['sp-400'] }),
|
|
@@ -279,6 +318,7 @@ const widthMap = {
|
|
|
279
318
|
'sp-50': css({ width: SPACING_SCALE['sp-50'] }),
|
|
280
319
|
'sp-75': css({ width: SPACING_SCALE['sp-75'] }),
|
|
281
320
|
'sp-100': css({ width: SPACING_SCALE['sp-100'] }),
|
|
321
|
+
'sp-150': css({ width: SPACING_SCALE['sp-150'] }),
|
|
282
322
|
'sp-200': css({ width: SPACING_SCALE['sp-200'] }),
|
|
283
323
|
'sp-300': css({ width: SPACING_SCALE['sp-300'] }),
|
|
284
324
|
'sp-400': css({ width: SPACING_SCALE['sp-400'] }),
|
|
@@ -293,6 +333,7 @@ const heightMap = {
|
|
|
293
333
|
'sp-50': css({ height: SPACING_SCALE['sp-50'] }),
|
|
294
334
|
'sp-75': css({ height: SPACING_SCALE['sp-75'] }),
|
|
295
335
|
'sp-100': css({ height: SPACING_SCALE['sp-100'] }),
|
|
336
|
+
'sp-150': css({ height: SPACING_SCALE['sp-150'] }),
|
|
296
337
|
'sp-200': css({ height: SPACING_SCALE['sp-200'] }),
|
|
297
338
|
'sp-300': css({ height: SPACING_SCALE['sp-300'] }),
|
|
298
339
|
'sp-400': css({ height: SPACING_SCALE['sp-400'] }),
|
|
@@ -307,7 +348,7 @@ const heightMap = {
|
|
|
307
348
|
|
|
308
349
|
/**
|
|
309
350
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
310
|
-
* @codegen <<SignedSource::
|
|
351
|
+
* @codegen <<SignedSource::ebb55786a54803214357d0eef0cac448>>
|
|
311
352
|
* @codegenId colors
|
|
312
353
|
* @codegenCommand yarn codegen-styles
|
|
313
354
|
* @codegenParams ["border", "background"]
|
|
@@ -354,7 +395,7 @@ const borderColorMap = {
|
|
|
354
395
|
}),
|
|
355
396
|
};
|
|
356
397
|
|
|
357
|
-
type BorderColor = keyof typeof borderColorMap;
|
|
398
|
+
export type BorderColor = keyof typeof borderColorMap;
|
|
358
399
|
|
|
359
400
|
const backgroundColorMap = {
|
|
360
401
|
disabled: css({
|
|
@@ -449,7 +490,7 @@ const backgroundColorMap = {
|
|
|
449
490
|
}),
|
|
450
491
|
};
|
|
451
492
|
|
|
452
|
-
type BackgroundColor = keyof typeof backgroundColorMap;
|
|
493
|
+
export type BackgroundColor = keyof typeof backgroundColorMap;
|
|
453
494
|
|
|
454
495
|
/**
|
|
455
496
|
* @codegenEnd
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Children, forwardRef, Fragment, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
import { css, jsx } from '@emotion/
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
5
|
|
|
6
6
|
import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
|
|
7
7
|
|
|
@@ -89,11 +89,13 @@ const Inline = forwardRef<HTMLDivElement, InlineProps>(
|
|
|
89
89
|
},
|
|
90
90
|
);
|
|
91
91
|
|
|
92
|
+
Inline.displayName = 'Inline';
|
|
93
|
+
|
|
92
94
|
export default Inline;
|
|
93
95
|
|
|
94
96
|
/**
|
|
95
97
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
96
|
-
* @codegen <<SignedSource::
|
|
98
|
+
* @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
|
|
97
99
|
* @codegenId spacing
|
|
98
100
|
* @codegenCommand yarn codegen-styles
|
|
99
101
|
* @codegenParams ["gap"]
|
|
@@ -104,6 +106,7 @@ const gapMap = {
|
|
|
104
106
|
'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
|
|
105
107
|
'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
|
|
106
108
|
'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
|
|
109
|
+
'sp-150': css({ gap: SPACING_SCALE['sp-150'] }),
|
|
107
110
|
'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
|
|
108
111
|
'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
|
|
109
112
|
'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
|
|
@@ -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
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { forwardRef, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
import { css, jsx } from '@emotion/
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
5
|
|
|
6
6
|
import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
|
|
7
7
|
|
|
@@ -73,11 +73,13 @@ const Stack = forwardRef<HTMLDivElement, StackProps>(
|
|
|
73
73
|
},
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
+
Stack.displayName = 'Stack';
|
|
77
|
+
|
|
76
78
|
export default Stack;
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
81
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
80
|
-
* @codegen <<SignedSource::
|
|
82
|
+
* @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
|
|
81
83
|
* @codegenId spacing
|
|
82
84
|
* @codegenCommand yarn codegen-styles
|
|
83
85
|
* @codegenParams ["gap"]
|
|
@@ -88,6 +90,7 @@ const gapMap = {
|
|
|
88
90
|
'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
|
|
89
91
|
'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
|
|
90
92
|
'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
|
|
93
|
+
'sp-150': css({ gap: SPACING_SCALE['sp-150'] }),
|
|
91
94
|
'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
|
|
92
95
|
'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
|
|
93
96
|
'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
|
|
@@ -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';
|