@atlaskit/ds-explorations 0.0.1 → 0.1.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 +28 -0
- package/LICENSE +13 -0
- package/dist/cjs/components/box.partial.js +495 -0
- package/dist/cjs/components/inline.partial.js +120 -0
- package/dist/cjs/components/stack.partial.js +112 -0
- package/dist/cjs/components/text.partial.js +169 -0
- package/dist/cjs/components/types.js +5 -0
- package/dist/cjs/constants.js +20 -0
- package/dist/cjs/index.js +34 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/box.partial.js +470 -0
- package/dist/es2019/components/inline.partial.js +107 -0
- package/dist/es2019/components/stack.partial.js +102 -0
- package/dist/es2019/components/text.partial.js +148 -0
- package/dist/es2019/components/types.js +1 -0
- package/dist/es2019/constants.js +13 -0
- package/dist/es2019/index.js +4 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/box.partial.js +479 -0
- package/dist/esm/components/inline.partial.js +106 -0
- package/dist/esm/components/stack.partial.js +101 -0
- package/dist/esm/components/text.partial.js +158 -0
- package/dist/esm/components/types.js +1 -0
- package/dist/esm/constants.js +13 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.partial.d.ts +186 -0
- package/dist/types/components/inline.partial.d.ts +52 -0
- package/dist/types/components/stack.partial.d.ts +47 -0
- package/dist/types/components/text.partial.d.ts +101 -0
- package/dist/types/components/types.d.ts +13 -0
- package/dist/types/constants.d.ts +14 -0
- package/dist/types/index.d.ts +4 -2
- package/docs/01-basic.tsx +19 -0
- package/examples/00-basic.tsx +18 -1
- package/examples/01-box.tsx +131 -0
- package/examples/02-text.tsx +60 -0
- package/examples/03-stack.tsx +125 -0
- package/examples/04-inline.tsx +134 -0
- package/examples/05-badge.tsx +23 -0
- package/examples/06-section-message.tsx +84 -0
- package/examples/07-comment.tsx +55 -0
- package/examples/08-lozenge.tsx +29 -0
- package/package.json +20 -1
- package/report.api.md +463 -0
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +193 -0
- package/scripts/__tests__/codegen.test.tsx +20 -0
- package/scripts/codegen-styles.tsx +47 -0
- package/scripts/color-codegen-template.tsx +105 -0
- package/scripts/spacing-codegen-template.tsx +52 -0
- package/scripts/utils.tsx +22 -0
- package/src/components/__tests__/unit/box.test.tsx +20 -0
- package/src/components/__tests__/unit/inline.test.tsx +43 -0
- package/src/components/__tests__/unit/stack.test.tsx +31 -0
- package/src/components/__tests__/unit/text.test.tsx +17 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-basic-example-should-match-production-example-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-alignment-should-match-snapshot-1-snap.png +3 -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 +3 -0
- 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
- 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
- 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
- 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
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +3 -0
- 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
- 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
- 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
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/box-snapshot-test.tsx +33 -0
- package/src/components/__tests__/visual-regression/inline-snapshot-test.tsx +28 -0
- package/src/components/__tests__/visual-regression/stack-snapshot-test.tsx +28 -0
- package/src/components/__tests__/visual-regression/text-snapshot-test.tsx +31 -0
- package/src/components/box.partial.tsx +456 -0
- package/src/components/inline.partial.tsx +117 -0
- package/src/components/stack.partial.tsx +101 -0
- package/src/components/text.partial.tsx +194 -0
- package/src/components/types.tsx +15 -0
- package/src/constants.tsx +15 -0
- package/src/index.tsx +4 -1
- package/tsconfig.json +3 -1
- package/dist/cjs/components/box.js +0 -27
- package/dist/cjs/components/inline.js +0 -29
- package/dist/cjs/components/stack.js +0 -29
- package/dist/cjs/components/text.js +0 -25
- package/dist/es2019/components/box.js +0 -18
- package/dist/es2019/components/inline.js +0 -18
- package/dist/es2019/components/stack.js +0 -18
- package/dist/es2019/components/text.js +0 -17
- package/dist/esm/components/box.js +0 -18
- package/dist/esm/components/inline.js +0 -17
- package/dist/esm/components/stack.js +0 -17
- package/dist/esm/components/text.js +0 -16
- package/dist/types/components/box.d.ts +0 -15
- package/dist/types/components/inline.d.ts +0 -14
- package/dist/types/components/stack.d.ts +0 -14
- package/dist/types/components/text.d.ts +0 -13
- package/src/components/box.tsx +0 -22
- package/src/components/inline.tsx +0 -23
- package/src/components/stack.tsx +0 -23
- package/src/components/text.tsx +0 -19
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getExampleUrl,
|
|
3
|
+
loadPage,
|
|
4
|
+
takeElementScreenShot,
|
|
5
|
+
} from '@atlaskit/visual-regression/helper';
|
|
6
|
+
|
|
7
|
+
describe('Inline', () => {
|
|
8
|
+
it.each(['spacing', 'alignment'])(
|
|
9
|
+
`%s example should match snapshot`,
|
|
10
|
+
async (selector) => {
|
|
11
|
+
const url = getExampleUrl(
|
|
12
|
+
'design-system',
|
|
13
|
+
'ds-explorations',
|
|
14
|
+
'inline',
|
|
15
|
+
global.__BASEURL__,
|
|
16
|
+
);
|
|
17
|
+
const { page } = global;
|
|
18
|
+
|
|
19
|
+
await loadPage(page, url);
|
|
20
|
+
|
|
21
|
+
const image = await takeElementScreenShot(
|
|
22
|
+
page,
|
|
23
|
+
`[data-testid="inline-${selector}"]`,
|
|
24
|
+
);
|
|
25
|
+
expect(image).toMatchProdImageSnapshot();
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getExampleUrl,
|
|
3
|
+
loadPage,
|
|
4
|
+
takeElementScreenShot,
|
|
5
|
+
} from '@atlaskit/visual-regression/helper';
|
|
6
|
+
|
|
7
|
+
describe('Stack', () => {
|
|
8
|
+
it.each(['spacing', 'alignment'])(
|
|
9
|
+
`%s example should match snapshot`,
|
|
10
|
+
async (selector) => {
|
|
11
|
+
const url = getExampleUrl(
|
|
12
|
+
'design-system',
|
|
13
|
+
'ds-explorations',
|
|
14
|
+
'stack',
|
|
15
|
+
global.__BASEURL__,
|
|
16
|
+
);
|
|
17
|
+
const { page } = global;
|
|
18
|
+
|
|
19
|
+
await loadPage(page, url);
|
|
20
|
+
|
|
21
|
+
const image = await takeElementScreenShot(
|
|
22
|
+
page,
|
|
23
|
+
`[data-testid="stack-${selector}"]`,
|
|
24
|
+
);
|
|
25
|
+
expect(image).toMatchProdImageSnapshot();
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import __noop from '@atlaskit/ds-lib/noop';
|
|
2
|
+
import {
|
|
3
|
+
getExampleUrl,
|
|
4
|
+
loadPage,
|
|
5
|
+
takeElementScreenShot,
|
|
6
|
+
} from '@atlaskit/visual-regression/helper';
|
|
7
|
+
|
|
8
|
+
describe('Text', () => {
|
|
9
|
+
['font-sizes', 'font-weights', 'line-heights', 'testing'].forEach(
|
|
10
|
+
(testId) => {
|
|
11
|
+
it(`example with ${testId} should match snapshot`, async () => {
|
|
12
|
+
const url = getExampleUrl(
|
|
13
|
+
'design-system',
|
|
14
|
+
'ds-explorations',
|
|
15
|
+
'text',
|
|
16
|
+
global.__BASEURL__,
|
|
17
|
+
);
|
|
18
|
+
const { page } = global;
|
|
19
|
+
|
|
20
|
+
await loadPage(page, url);
|
|
21
|
+
|
|
22
|
+
const image = await takeElementScreenShot(
|
|
23
|
+
page,
|
|
24
|
+
`[data-testid="${testId}"]`,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(image).toMatchProdImageSnapshot();
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
});
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import {
|
|
3
|
+
CSSProperties,
|
|
4
|
+
ElementType,
|
|
5
|
+
forwardRef,
|
|
6
|
+
HTMLAttributes,
|
|
7
|
+
ReactNode,
|
|
8
|
+
} from 'react';
|
|
9
|
+
|
|
10
|
+
import { css, jsx } from '@emotion/core';
|
|
11
|
+
|
|
12
|
+
import { token } from '@atlaskit/tokens';
|
|
13
|
+
|
|
14
|
+
import { GlobalSpacingToken, SPACING_SCALE } from '../constants';
|
|
15
|
+
|
|
16
|
+
import { BasePrimitiveProps } from './types';
|
|
17
|
+
|
|
18
|
+
export interface BoxProps
|
|
19
|
+
extends Omit<HTMLAttributes<HTMLElement>, 'style'>,
|
|
20
|
+
BasePrimitiveProps {
|
|
21
|
+
/**
|
|
22
|
+
* The DOM element to render as the Box. Defaults to `div`.
|
|
23
|
+
*/
|
|
24
|
+
as?: ElementType;
|
|
25
|
+
/**
|
|
26
|
+
* Elements to be rendered inside the Box.
|
|
27
|
+
*/
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Token representing background color with a fallback.
|
|
31
|
+
*/
|
|
32
|
+
backgroundColor?: [BackgroundColor, string];
|
|
33
|
+
/**
|
|
34
|
+
* Defines border style.
|
|
35
|
+
*/
|
|
36
|
+
borderStyle?: BorderStyle;
|
|
37
|
+
/**
|
|
38
|
+
* Defines border width.
|
|
39
|
+
*/
|
|
40
|
+
borderWidth?: BorderWidth;
|
|
41
|
+
/**
|
|
42
|
+
* Token representing border color with a fallback.
|
|
43
|
+
*/
|
|
44
|
+
borderColor?: [BorderColor, string];
|
|
45
|
+
/**
|
|
46
|
+
* Defines border radius.
|
|
47
|
+
*/
|
|
48
|
+
borderRadius?: BorderRadius;
|
|
49
|
+
/**
|
|
50
|
+
* Defines the main axis direction.
|
|
51
|
+
*/
|
|
52
|
+
flexDirection?: FlexDirection;
|
|
53
|
+
/**
|
|
54
|
+
* Used to align children along the cross axis.
|
|
55
|
+
*/
|
|
56
|
+
alignItems?: FlexAlignItems;
|
|
57
|
+
/**
|
|
58
|
+
* Used to align children along the main axis.
|
|
59
|
+
*/
|
|
60
|
+
justifyContent?: FlexJustifyContent;
|
|
61
|
+
/**
|
|
62
|
+
* Shorthand for `paddingBlock` and `paddingInline` together.
|
|
63
|
+
*
|
|
64
|
+
* @see paddingBlock
|
|
65
|
+
* @see paddingInline
|
|
66
|
+
*/
|
|
67
|
+
padding?: GlobalSpacingToken;
|
|
68
|
+
/**
|
|
69
|
+
* Token representing CSS `padding-block`.
|
|
70
|
+
*/
|
|
71
|
+
paddingBlock?: GlobalSpacingToken;
|
|
72
|
+
/**
|
|
73
|
+
* Token representing CSS `padding-inline`.
|
|
74
|
+
*/
|
|
75
|
+
paddingInline?: GlobalSpacingToken;
|
|
76
|
+
/**
|
|
77
|
+
* Token representing width.
|
|
78
|
+
*/
|
|
79
|
+
width?: GlobalSpacingToken;
|
|
80
|
+
/**
|
|
81
|
+
* Token representing height.
|
|
82
|
+
*/
|
|
83
|
+
height?: GlobalSpacingToken;
|
|
84
|
+
/**
|
|
85
|
+
* Defines display type and layout. Defaults to `flex`.
|
|
86
|
+
*/
|
|
87
|
+
display?: Display;
|
|
88
|
+
}
|
|
89
|
+
|
|
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
|
+
/**
|
|
147
|
+
* __Box__
|
|
148
|
+
*
|
|
149
|
+
* Box is a primitive component that has the design decisions of the Atlassian Design System baked in.
|
|
150
|
+
* Renders a `div` by default.
|
|
151
|
+
*
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
const Box = forwardRef<HTMLElement, BoxProps>(
|
|
155
|
+
(
|
|
156
|
+
{
|
|
157
|
+
children,
|
|
158
|
+
as: Component = 'div',
|
|
159
|
+
display = 'flex',
|
|
160
|
+
flexDirection,
|
|
161
|
+
alignItems,
|
|
162
|
+
justifyContent,
|
|
163
|
+
backgroundColor: backgroundColorTuple,
|
|
164
|
+
borderColor: borderColorTuple,
|
|
165
|
+
borderStyle,
|
|
166
|
+
borderWidth,
|
|
167
|
+
borderRadius,
|
|
168
|
+
padding,
|
|
169
|
+
paddingBlock,
|
|
170
|
+
paddingInline,
|
|
171
|
+
height,
|
|
172
|
+
width,
|
|
173
|
+
UNSAFE_style,
|
|
174
|
+
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
|
+
...htmlAttributes
|
|
182
|
+
},
|
|
183
|
+
ref,
|
|
184
|
+
) => {
|
|
185
|
+
const [backgroundColor, backgroundColorFallback] =
|
|
186
|
+
backgroundColorTuple || [];
|
|
187
|
+
const [borderColor, borderColorFallback] = borderColorTuple || [];
|
|
188
|
+
return (
|
|
189
|
+
<Component
|
|
190
|
+
style={{
|
|
191
|
+
...UNSAFE_style,
|
|
192
|
+
...(backgroundColorFallback &&
|
|
193
|
+
({ '--ds-bg-fb': backgroundColorFallback } as CSSProperties)),
|
|
194
|
+
...(borderColorFallback &&
|
|
195
|
+
({ '--ds-bo-fb': borderColorFallback } as CSSProperties)),
|
|
196
|
+
}}
|
|
197
|
+
ref={ref}
|
|
198
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
199
|
+
{...htmlAttributes}
|
|
200
|
+
css={[
|
|
201
|
+
baseStyles,
|
|
202
|
+
display && displayMap[display],
|
|
203
|
+
padding && paddingMap[padding],
|
|
204
|
+
paddingBlock && paddingBlockMap[paddingBlock],
|
|
205
|
+
paddingInline && paddingInlineMap[paddingInline],
|
|
206
|
+
alignItems && flexAlignItemsMap[alignItems],
|
|
207
|
+
justifyContent && flexJustifyContentMap[justifyContent],
|
|
208
|
+
backgroundColor && backgroundColorMap[backgroundColor],
|
|
209
|
+
borderColor && borderColorMap[borderColor],
|
|
210
|
+
borderStyle && borderStyleMap[borderStyle],
|
|
211
|
+
borderWidth && borderWidthMap[borderWidth],
|
|
212
|
+
borderRadius && borderRadiusMap[borderRadius],
|
|
213
|
+
flexDirection && flexDirectionMap[flexDirection],
|
|
214
|
+
width && widthMap[width],
|
|
215
|
+
height && heightMap[height],
|
|
216
|
+
]}
|
|
217
|
+
data-testid={testId}
|
|
218
|
+
>
|
|
219
|
+
{children}
|
|
220
|
+
</Component>
|
|
221
|
+
);
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
export default Box;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
229
|
+
* @codegen <<SignedSource::c20a27ff33adec8c016044959564409d>>
|
|
230
|
+
* @codegenId spacing
|
|
231
|
+
* @codegenCommand yarn codegen-styles
|
|
232
|
+
* @codegenParams ["padding", "paddingBlock", "paddingInline", "width", "height"]
|
|
233
|
+
*/
|
|
234
|
+
const paddingMap = {
|
|
235
|
+
'sp-0': css({ padding: SPACING_SCALE['sp-0'] }),
|
|
236
|
+
'sp-25': css({ padding: SPACING_SCALE['sp-25'] }),
|
|
237
|
+
'sp-50': css({ padding: SPACING_SCALE['sp-50'] }),
|
|
238
|
+
'sp-75': css({ padding: SPACING_SCALE['sp-75'] }),
|
|
239
|
+
'sp-100': css({ padding: SPACING_SCALE['sp-100'] }),
|
|
240
|
+
'sp-200': css({ padding: SPACING_SCALE['sp-200'] }),
|
|
241
|
+
'sp-300': css({ padding: SPACING_SCALE['sp-300'] }),
|
|
242
|
+
'sp-400': css({ padding: SPACING_SCALE['sp-400'] }),
|
|
243
|
+
'sp-500': css({ padding: SPACING_SCALE['sp-500'] }),
|
|
244
|
+
'sp-600': css({ padding: SPACING_SCALE['sp-600'] }),
|
|
245
|
+
'sp-800': css({ padding: SPACING_SCALE['sp-800'] }),
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const paddingBlockMap = {
|
|
249
|
+
'sp-0': css({ paddingBlock: SPACING_SCALE['sp-0'] }),
|
|
250
|
+
'sp-25': css({ paddingBlock: SPACING_SCALE['sp-25'] }),
|
|
251
|
+
'sp-50': css({ paddingBlock: SPACING_SCALE['sp-50'] }),
|
|
252
|
+
'sp-75': css({ paddingBlock: SPACING_SCALE['sp-75'] }),
|
|
253
|
+
'sp-100': css({ paddingBlock: SPACING_SCALE['sp-100'] }),
|
|
254
|
+
'sp-200': css({ paddingBlock: SPACING_SCALE['sp-200'] }),
|
|
255
|
+
'sp-300': css({ paddingBlock: SPACING_SCALE['sp-300'] }),
|
|
256
|
+
'sp-400': css({ paddingBlock: SPACING_SCALE['sp-400'] }),
|
|
257
|
+
'sp-500': css({ paddingBlock: SPACING_SCALE['sp-500'] }),
|
|
258
|
+
'sp-600': css({ paddingBlock: SPACING_SCALE['sp-600'] }),
|
|
259
|
+
'sp-800': css({ paddingBlock: SPACING_SCALE['sp-800'] }),
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const paddingInlineMap = {
|
|
263
|
+
'sp-0': css({ paddingInline: SPACING_SCALE['sp-0'] }),
|
|
264
|
+
'sp-25': css({ paddingInline: SPACING_SCALE['sp-25'] }),
|
|
265
|
+
'sp-50': css({ paddingInline: SPACING_SCALE['sp-50'] }),
|
|
266
|
+
'sp-75': css({ paddingInline: SPACING_SCALE['sp-75'] }),
|
|
267
|
+
'sp-100': css({ paddingInline: SPACING_SCALE['sp-100'] }),
|
|
268
|
+
'sp-200': css({ paddingInline: SPACING_SCALE['sp-200'] }),
|
|
269
|
+
'sp-300': css({ paddingInline: SPACING_SCALE['sp-300'] }),
|
|
270
|
+
'sp-400': css({ paddingInline: SPACING_SCALE['sp-400'] }),
|
|
271
|
+
'sp-500': css({ paddingInline: SPACING_SCALE['sp-500'] }),
|
|
272
|
+
'sp-600': css({ paddingInline: SPACING_SCALE['sp-600'] }),
|
|
273
|
+
'sp-800': css({ paddingInline: SPACING_SCALE['sp-800'] }),
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const widthMap = {
|
|
277
|
+
'sp-0': css({ width: SPACING_SCALE['sp-0'] }),
|
|
278
|
+
'sp-25': css({ width: SPACING_SCALE['sp-25'] }),
|
|
279
|
+
'sp-50': css({ width: SPACING_SCALE['sp-50'] }),
|
|
280
|
+
'sp-75': css({ width: SPACING_SCALE['sp-75'] }),
|
|
281
|
+
'sp-100': css({ width: SPACING_SCALE['sp-100'] }),
|
|
282
|
+
'sp-200': css({ width: SPACING_SCALE['sp-200'] }),
|
|
283
|
+
'sp-300': css({ width: SPACING_SCALE['sp-300'] }),
|
|
284
|
+
'sp-400': css({ width: SPACING_SCALE['sp-400'] }),
|
|
285
|
+
'sp-500': css({ width: SPACING_SCALE['sp-500'] }),
|
|
286
|
+
'sp-600': css({ width: SPACING_SCALE['sp-600'] }),
|
|
287
|
+
'sp-800': css({ width: SPACING_SCALE['sp-800'] }),
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const heightMap = {
|
|
291
|
+
'sp-0': css({ height: SPACING_SCALE['sp-0'] }),
|
|
292
|
+
'sp-25': css({ height: SPACING_SCALE['sp-25'] }),
|
|
293
|
+
'sp-50': css({ height: SPACING_SCALE['sp-50'] }),
|
|
294
|
+
'sp-75': css({ height: SPACING_SCALE['sp-75'] }),
|
|
295
|
+
'sp-100': css({ height: SPACING_SCALE['sp-100'] }),
|
|
296
|
+
'sp-200': css({ height: SPACING_SCALE['sp-200'] }),
|
|
297
|
+
'sp-300': css({ height: SPACING_SCALE['sp-300'] }),
|
|
298
|
+
'sp-400': css({ height: SPACING_SCALE['sp-400'] }),
|
|
299
|
+
'sp-500': css({ height: SPACING_SCALE['sp-500'] }),
|
|
300
|
+
'sp-600': css({ height: SPACING_SCALE['sp-600'] }),
|
|
301
|
+
'sp-800': css({ height: SPACING_SCALE['sp-800'] }),
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @codegenEnd
|
|
306
|
+
*/
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
310
|
+
* @codegen <<SignedSource::e3f27406477352f51168b4108558f051>>
|
|
311
|
+
* @codegenId colors
|
|
312
|
+
* @codegenCommand yarn codegen-styles
|
|
313
|
+
* @codegenParams ["border", "background"]
|
|
314
|
+
*/
|
|
315
|
+
const borderColorMap = {
|
|
316
|
+
'color.border': css({
|
|
317
|
+
borderColor: token('color.border', 'var(--ds-bo-fb)'),
|
|
318
|
+
}),
|
|
319
|
+
bold: css({
|
|
320
|
+
borderColor: token('color.border.bold', 'var(--ds-bo-fb)'),
|
|
321
|
+
}),
|
|
322
|
+
inverse: css({
|
|
323
|
+
borderColor: token('color.border.inverse', 'var(--ds-bo-fb)'),
|
|
324
|
+
}),
|
|
325
|
+
focused: css({
|
|
326
|
+
borderColor: token('color.border.focused', 'var(--ds-bo-fb)'),
|
|
327
|
+
}),
|
|
328
|
+
input: css({
|
|
329
|
+
borderColor: token('color.border.input', 'var(--ds-bo-fb)'),
|
|
330
|
+
}),
|
|
331
|
+
disabled: css({
|
|
332
|
+
borderColor: token('color.border.disabled', 'var(--ds-bo-fb)'),
|
|
333
|
+
}),
|
|
334
|
+
brand: css({
|
|
335
|
+
borderColor: token('color.border.brand', 'var(--ds-bo-fb)'),
|
|
336
|
+
}),
|
|
337
|
+
selected: css({
|
|
338
|
+
borderColor: token('color.border.selected', 'var(--ds-bo-fb)'),
|
|
339
|
+
}),
|
|
340
|
+
danger: css({
|
|
341
|
+
borderColor: token('color.border.danger', 'var(--ds-bo-fb)'),
|
|
342
|
+
}),
|
|
343
|
+
warning: css({
|
|
344
|
+
borderColor: token('color.border.warning', 'var(--ds-bo-fb)'),
|
|
345
|
+
}),
|
|
346
|
+
success: css({
|
|
347
|
+
borderColor: token('color.border.success', 'var(--ds-bo-fb)'),
|
|
348
|
+
}),
|
|
349
|
+
discovery: css({
|
|
350
|
+
borderColor: token('color.border.discovery', 'var(--ds-bo-fb)'),
|
|
351
|
+
}),
|
|
352
|
+
information: css({
|
|
353
|
+
borderColor: token('color.border.information', 'var(--ds-bo-fb)'),
|
|
354
|
+
}),
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
type BorderColor = keyof typeof borderColorMap;
|
|
358
|
+
|
|
359
|
+
const backgroundColorMap = {
|
|
360
|
+
disabled: css({
|
|
361
|
+
backgroundColor: token('color.background.disabled', 'var(--ds-bg-fb)'),
|
|
362
|
+
}),
|
|
363
|
+
'inverse.subtle': css({
|
|
364
|
+
backgroundColor: token(
|
|
365
|
+
'color.background.inverse.subtle',
|
|
366
|
+
'var(--ds-bg-fb)',
|
|
367
|
+
),
|
|
368
|
+
}),
|
|
369
|
+
input: css({
|
|
370
|
+
backgroundColor: token('color.background.input', 'var(--ds-bg-fb)'),
|
|
371
|
+
}),
|
|
372
|
+
neutral: css({
|
|
373
|
+
backgroundColor: token('color.background.neutral', 'var(--ds-bg-fb)'),
|
|
374
|
+
}),
|
|
375
|
+
'neutral.subtle': css({
|
|
376
|
+
backgroundColor: token(
|
|
377
|
+
'color.background.neutral.subtle',
|
|
378
|
+
'var(--ds-bg-fb)',
|
|
379
|
+
),
|
|
380
|
+
}),
|
|
381
|
+
'neutral.bold': css({
|
|
382
|
+
backgroundColor: token('color.background.neutral.bold', 'var(--ds-bg-fb)'),
|
|
383
|
+
}),
|
|
384
|
+
'brand.bold': css({
|
|
385
|
+
backgroundColor: token('color.background.brand.bold', 'var(--ds-bg-fb)'),
|
|
386
|
+
}),
|
|
387
|
+
selected: css({
|
|
388
|
+
backgroundColor: token('color.background.selected', 'var(--ds-bg-fb)'),
|
|
389
|
+
}),
|
|
390
|
+
'selected.bold': css({
|
|
391
|
+
backgroundColor: token('color.background.selected.bold', 'var(--ds-bg-fb)'),
|
|
392
|
+
}),
|
|
393
|
+
danger: css({
|
|
394
|
+
backgroundColor: token('color.background.danger', 'var(--ds-bg-fb)'),
|
|
395
|
+
}),
|
|
396
|
+
'danger.bold': css({
|
|
397
|
+
backgroundColor: token('color.background.danger.bold', 'var(--ds-bg-fb)'),
|
|
398
|
+
}),
|
|
399
|
+
warning: css({
|
|
400
|
+
backgroundColor: token('color.background.warning', 'var(--ds-bg-fb)'),
|
|
401
|
+
}),
|
|
402
|
+
'warning.bold': css({
|
|
403
|
+
backgroundColor: token('color.background.warning.bold', 'var(--ds-bg-fb)'),
|
|
404
|
+
}),
|
|
405
|
+
success: css({
|
|
406
|
+
backgroundColor: token('color.background.success', 'var(--ds-bg-fb)'),
|
|
407
|
+
}),
|
|
408
|
+
'success.bold': css({
|
|
409
|
+
backgroundColor: token('color.background.success.bold', 'var(--ds-bg-fb)'),
|
|
410
|
+
}),
|
|
411
|
+
discovery: css({
|
|
412
|
+
backgroundColor: token('color.background.discovery', 'var(--ds-bg-fb)'),
|
|
413
|
+
}),
|
|
414
|
+
'discovery.bold': css({
|
|
415
|
+
backgroundColor: token(
|
|
416
|
+
'color.background.discovery.bold',
|
|
417
|
+
'var(--ds-bg-fb)',
|
|
418
|
+
),
|
|
419
|
+
}),
|
|
420
|
+
information: css({
|
|
421
|
+
backgroundColor: token('color.background.information', 'var(--ds-bg-fb)'),
|
|
422
|
+
}),
|
|
423
|
+
'information.bold': css({
|
|
424
|
+
backgroundColor: token(
|
|
425
|
+
'color.background.information.bold',
|
|
426
|
+
'var(--ds-bg-fb)',
|
|
427
|
+
),
|
|
428
|
+
}),
|
|
429
|
+
'color.blanket': css({
|
|
430
|
+
backgroundColor: token('color.blanket', 'var(--ds-bg-fb)'),
|
|
431
|
+
}),
|
|
432
|
+
'color.blanket.selected': css({
|
|
433
|
+
backgroundColor: token('color.blanket.selected', 'var(--ds-bg-fb)'),
|
|
434
|
+
}),
|
|
435
|
+
'color.blanket.danger': css({
|
|
436
|
+
backgroundColor: token('color.blanket.danger', 'var(--ds-bg-fb)'),
|
|
437
|
+
}),
|
|
438
|
+
'elevation.surface': css({
|
|
439
|
+
backgroundColor: token('elevation.surface', 'var(--ds-bg-fb)'),
|
|
440
|
+
}),
|
|
441
|
+
'elevation.surface.sunken': css({
|
|
442
|
+
backgroundColor: token('elevation.surface.sunken', 'var(--ds-bg-fb)'),
|
|
443
|
+
}),
|
|
444
|
+
'elevation.surface.raised': css({
|
|
445
|
+
backgroundColor: token('elevation.surface.raised', 'var(--ds-bg-fb)'),
|
|
446
|
+
}),
|
|
447
|
+
'elevation.surface.overlay': css({
|
|
448
|
+
backgroundColor: token('elevation.surface.overlay', 'var(--ds-bg-fb)'),
|
|
449
|
+
}),
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
type BackgroundColor = keyof typeof backgroundColorMap;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @codegenEnd
|
|
456
|
+
*/
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Children, forwardRef, Fragment, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { css, jsx } from '@emotion/core';
|
|
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
|
+
export default Inline;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
96
|
+
* @codegen <<SignedSource::ac3192fbc453a94ab5e720d0273556ef>>
|
|
97
|
+
* @codegenId spacing
|
|
98
|
+
* @codegenCommand yarn codegen-styles
|
|
99
|
+
* @codegenParams ["gap"]
|
|
100
|
+
*/
|
|
101
|
+
const gapMap = {
|
|
102
|
+
'sp-0': css({ gap: SPACING_SCALE['sp-0'] }),
|
|
103
|
+
'sp-25': css({ gap: SPACING_SCALE['sp-25'] }),
|
|
104
|
+
'sp-50': css({ gap: SPACING_SCALE['sp-50'] }),
|
|
105
|
+
'sp-75': css({ gap: SPACING_SCALE['sp-75'] }),
|
|
106
|
+
'sp-100': css({ gap: SPACING_SCALE['sp-100'] }),
|
|
107
|
+
'sp-200': css({ gap: SPACING_SCALE['sp-200'] }),
|
|
108
|
+
'sp-300': css({ gap: SPACING_SCALE['sp-300'] }),
|
|
109
|
+
'sp-400': css({ gap: SPACING_SCALE['sp-400'] }),
|
|
110
|
+
'sp-500': css({ gap: SPACING_SCALE['sp-500'] }),
|
|
111
|
+
'sp-600': css({ gap: SPACING_SCALE['sp-600'] }),
|
|
112
|
+
'sp-800': css({ gap: SPACING_SCALE['sp-800'] }),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @codegenEnd
|
|
117
|
+
*/
|