@atlaskit/ds-explorations 2.3.2 → 2.4.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 (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/box/package.json +15 -0
  3. package/dist/cjs/components/box.partial.js +620 -0
  4. package/dist/cjs/components/inline.partial.js +182 -0
  5. package/dist/cjs/components/stack.partial.js +148 -0
  6. package/dist/cjs/index.js +21 -0
  7. package/dist/es2019/components/box.partial.js +614 -0
  8. package/dist/es2019/components/inline.partial.js +177 -0
  9. package/dist/es2019/components/stack.partial.js +144 -0
  10. package/dist/es2019/index.js +3 -0
  11. package/dist/esm/components/box.partial.js +617 -0
  12. package/dist/esm/components/inline.partial.js +177 -0
  13. package/dist/esm/components/stack.partial.js +143 -0
  14. package/dist/esm/index.js +3 -0
  15. package/dist/types/components/box.partial.d.ts +357 -0
  16. package/dist/types/components/inline.partial.d.ts +108 -0
  17. package/dist/types/components/stack.partial.d.ts +92 -0
  18. package/dist/types/components/surface-provider.d.ts +2 -2
  19. package/dist/types/index.d.ts +6 -0
  20. package/dist/types-ts4.5/components/box.partial.d.ts +357 -0
  21. package/dist/types-ts4.5/components/inline.partial.d.ts +108 -0
  22. package/dist/types-ts4.5/components/stack.partial.d.ts +92 -0
  23. package/dist/types-ts4.5/components/surface-provider.d.ts +2 -2
  24. package/dist/types-ts4.5/index.d.ts +6 -0
  25. package/examples/00-basic.tsx +22 -0
  26. package/examples/01-box.tsx +171 -0
  27. package/examples/02-text-advanced.tsx +20 -11
  28. package/examples/02-text.tsx +10 -15
  29. package/examples/03-stack.tsx +99 -0
  30. package/examples/04-inline.tsx +99 -0
  31. package/examples/05-badge.tsx +5 -9
  32. package/examples/06-section-message.tsx +4 -2
  33. package/examples/07-comment.tsx +3 -1
  34. package/examples/08-lozenge.tsx +4 -8
  35. package/examples/99-interactions.tsx +33 -49
  36. package/inline/package.json +15 -0
  37. package/package.json +5 -3
  38. package/report.api.md +465 -0
  39. package/scripts/codegen-styles.tsx +89 -16
  40. package/src/components/__tests__/unit/box.test.tsx +55 -0
  41. package/src/components/__tests__/unit/inline.test.tsx +43 -0
  42. package/src/components/__tests__/unit/interaction-suface.test.tsx +2 -2
  43. package/src/components/__tests__/unit/stack.test.tsx +31 -0
  44. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +3 -0
  45. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +3 -0
  46. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +3 -0
  47. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +3 -0
  48. package/src/components/__tests__/visual-regression/inline-snapshot-test.tsx +28 -0
  49. package/src/components/__tests__/visual-regression/stack-snapshot-test.tsx +28 -0
  50. package/src/components/__tests__/vr-tests/__snapshots__/box--default.png +0 -0
  51. package/src/components/__tests__/vr-tests/box-snapshot-test.vr.tsx +6 -0
  52. package/src/components/box.partial.tsx +706 -0
  53. package/src/components/inline.partial.tsx +218 -0
  54. package/src/components/stack.partial.tsx +174 -0
  55. package/src/components/surface-provider.tsx +1 -1
  56. package/src/index.tsx +6 -0
  57. package/stack/package.json +15 -0
  58. package/tmp/api-report-tmp.d.ts +451 -0
  59. package/tsconfig.app.json +0 -3
  60. package/tsconfig.dev.json +6 -0
@@ -0,0 +1,218 @@
1
+ /** @jsx jsx */
2
+ import { Children, FC, forwardRef, Fragment, memo, ReactNode } from 'react';
3
+
4
+ import { css, jsx } from '@emotion/react';
5
+
6
+ import { token } from '@atlaskit/tokens';
7
+
8
+ import type { BasePrimitiveProps } from './types';
9
+
10
+ /**
11
+ * @private
12
+ * @deprecated DSP-8009: This type is scheduled for deletion.
13
+ * Please use `Inline` from `@atlaskit/primitives` instead.
14
+ */
15
+ export interface InlineProps extends BasePrimitiveProps {
16
+ /**
17
+ * Used to align children along the cross axis.
18
+ */
19
+ alignItems?: FlexAlignItems;
20
+ /**
21
+ * Used to align children along the main axis.
22
+ */
23
+ justifyContent?: FlexJustifyContent;
24
+ /**
25
+ * Sets whether children are forced onto one line or can wrap onto multiple lines
26
+ */
27
+ flexWrap?: FlexWrap;
28
+ /**
29
+ * Token representing gap between children.
30
+ */
31
+ gap: ColumnGap;
32
+ /**
33
+ * Renders a divider between children.
34
+ * If a string is provided it will automatically be wrapped in a `<Text>` component.
35
+ */
36
+ divider?: ReactNode;
37
+ /**
38
+ * Elements to be rendered inside the Inline.
39
+ */
40
+ children: ReactNode;
41
+ }
42
+
43
+ type FlexAlignItems = keyof typeof flexAlignItemsMap;
44
+ const flexAlignItemsMap = {
45
+ center: css({ alignItems: 'center' }),
46
+ baseline: css({ alignItems: 'baseline' }),
47
+ flexStart: css({ alignItems: 'flex-start' }),
48
+ flexEnd: css({ alignItems: 'flex-end' }),
49
+ start: css({ alignItems: 'start' }),
50
+ end: css({ alignItems: 'end' }),
51
+ };
52
+
53
+ type FlexJustifyContent = keyof typeof flexJustifyContentMap;
54
+ const flexJustifyContentMap = {
55
+ center: css({ justifyContent: 'center' }),
56
+ flexStart: css({ justifyContent: 'flex-start' }),
57
+ 'space-between': css({ justifyContent: 'space-between' }),
58
+ flexEnd: css({ justifyContent: 'flex-end' }),
59
+ start: css({ justifyContent: 'start' }),
60
+ end: css({ justifyContent: 'end' }),
61
+ spaceBetween: css({ justifyContent: 'space-between' }),
62
+ };
63
+
64
+ type FlexWrap = keyof typeof flexWrapMap;
65
+ const flexWrapMap = {
66
+ wrap: css({ flexWrap: 'wrap' }),
67
+ };
68
+
69
+ const baseStyles = css({
70
+ display: 'flex',
71
+ boxSizing: 'border-box',
72
+ flexDirection: 'row',
73
+ });
74
+
75
+ const dividerStyles = css({
76
+ margin: `0 ${token('space.negative.025', '-2px')}`,
77
+ color: token('color.text.subtle', '#42526E'),
78
+ pointerEvents: 'none',
79
+ userSelect: 'none',
80
+ });
81
+
82
+ const Divider: FC<{ children: string }> = ({ children }) => (
83
+ <span css={dividerStyles}>{children}</span>
84
+ );
85
+
86
+ /**
87
+ * __Inline__
88
+ *
89
+ * Inline is a primitive component based on flexbox that manages the horizontal layout of direct children.
90
+ * Renders a `div` by default.
91
+ *
92
+ * @private
93
+ * @deprecated DSP-8009: This primitive is scheduled for deletion.
94
+ * Please use `Inline` from `@atlaskit/primitives` instead.
95
+ *
96
+ * @example
97
+ * ```tsx
98
+ * const App = () => (
99
+ * <Inline gap="space.100">
100
+ * <Button />
101
+ * <Button />
102
+ * </Inline>
103
+ * )
104
+ * ```
105
+ */
106
+ const Inline = memo(
107
+ forwardRef<HTMLDivElement, InlineProps>(
108
+ (
109
+ {
110
+ gap,
111
+ alignItems,
112
+ justifyContent,
113
+ flexWrap,
114
+ divider,
115
+ UNSAFE_style,
116
+ children: rawChildren,
117
+ testId,
118
+ },
119
+ ref,
120
+ ) => {
121
+ const dividerComponent =
122
+ typeof divider === 'string' ? <Divider>{divider}</Divider> : divider;
123
+
124
+ const children = divider
125
+ ? Children.toArray(rawChildren)
126
+ .filter(Boolean)
127
+ .map((child, index) => {
128
+ return (
129
+ <Fragment key={index}>
130
+ {divider && index > 0 ? dividerComponent : null}
131
+ {child}
132
+ </Fragment>
133
+ );
134
+ })
135
+ : rawChildren;
136
+
137
+ return (
138
+ <div
139
+ style={UNSAFE_style}
140
+ css={[
141
+ baseStyles,
142
+ gap && columnGapMap[gap],
143
+ alignItems && flexAlignItemsMap[alignItems],
144
+ justifyContent && flexJustifyContentMap[justifyContent],
145
+ flexWrap && flexWrapMap[flexWrap],
146
+ ]}
147
+ data-testid={testId}
148
+ ref={ref}
149
+ >
150
+ {children}
151
+ </div>
152
+ );
153
+ },
154
+ ),
155
+ );
156
+
157
+ Inline.displayName = 'Inline';
158
+
159
+ export default Inline;
160
+
161
+ /**
162
+ * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
163
+ * @codegen <<SignedSource::63747c8b92ba373ad2259fa1fff3f434>>
164
+ * @codegenId spacing
165
+ * @codegenCommand yarn codegen-styles
166
+ * @codegenParams ["columnGap"]
167
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::298080e8024fb3eb37589721413e0156>>
168
+ */
169
+ const columnGapMap = {
170
+ 'space.0': css({
171
+ columnGap: token('space.0', '0px'),
172
+ }),
173
+ 'space.025': css({
174
+ columnGap: token('space.025', '2px'),
175
+ }),
176
+ 'space.050': css({
177
+ columnGap: token('space.050', '4px'),
178
+ }),
179
+ 'space.075': css({
180
+ columnGap: token('space.075', '6px'),
181
+ }),
182
+ 'space.100': css({
183
+ columnGap: token('space.100', '8px'),
184
+ }),
185
+ 'space.1000': css({
186
+ columnGap: token('space.1000', '80px'),
187
+ }),
188
+ 'space.150': css({
189
+ columnGap: token('space.150', '12px'),
190
+ }),
191
+ 'space.200': css({
192
+ columnGap: token('space.200', '16px'),
193
+ }),
194
+ 'space.250': css({
195
+ columnGap: token('space.250', '20px'),
196
+ }),
197
+ 'space.300': css({
198
+ columnGap: token('space.300', '24px'),
199
+ }),
200
+ 'space.400': css({
201
+ columnGap: token('space.400', '32px'),
202
+ }),
203
+ 'space.500': css({
204
+ columnGap: token('space.500', '40px'),
205
+ }),
206
+ 'space.600': css({
207
+ columnGap: token('space.600', '48px'),
208
+ }),
209
+ 'space.800': css({
210
+ columnGap: token('space.800', '64px'),
211
+ }),
212
+ };
213
+
214
+ export type ColumnGap = keyof typeof columnGapMap;
215
+
216
+ /**
217
+ * @codegenEnd
218
+ */
@@ -0,0 +1,174 @@
1
+ /** @jsx jsx */
2
+ import { forwardRef, memo, ReactNode } from 'react';
3
+
4
+ import { css, jsx } from '@emotion/react';
5
+
6
+ import { token } from '@atlaskit/tokens';
7
+
8
+ import { BasePrimitiveProps } from './types';
9
+
10
+ /**
11
+ * @private
12
+ * @deprecated DSP-8009: This type is scheduled for deletion.
13
+ * Please use `Stack` from `@atlaskit/primitives` instead.
14
+ */
15
+ export interface StackProps extends BasePrimitiveProps {
16
+ /**
17
+ * Used to align children along the cross axis.
18
+ */
19
+ alignItems?: FlexAlignItems;
20
+ /**
21
+ * Used to align children along the main axis.
22
+ */
23
+ justifyContent?: FlexJustifyContent;
24
+ /**
25
+ * Sets whether children are forced onto one line or can wrap onto multiple lines
26
+ */
27
+ flexWrap?: FlexWrap;
28
+ /**
29
+ * Token representing gap between children.
30
+ */
31
+ gap: RowGap;
32
+ /**
33
+ * Elements to be rendered inside the Stack.
34
+ */
35
+ children: ReactNode;
36
+ }
37
+
38
+ type FlexAlignItems = keyof typeof flexAlignItemsMap;
39
+ const flexAlignItemsMap = {
40
+ center: css({ alignItems: 'center' }),
41
+ baseline: css({ alignItems: 'baseline' }),
42
+ flexStart: css({ alignItems: 'flex-start' }),
43
+ flexEnd: css({ alignItems: 'flex-end' }),
44
+ start: css({ alignItems: 'start' }),
45
+ end: css({ alignItems: 'end' }),
46
+ };
47
+
48
+ type FlexJustifyContent = keyof typeof flexJustifyContentMap;
49
+ const flexJustifyContentMap = {
50
+ center: css({ justifyContent: 'center' }),
51
+ flexStart: css({ justifyContent: 'flex-start' }),
52
+ flexEnd: css({ justifyContent: 'flex-end' }),
53
+ start: css({ justifyContent: 'start' }),
54
+ end: css({ justifyContent: 'end' }),
55
+ };
56
+
57
+ type FlexWrap = keyof typeof flexWrapMap;
58
+ const flexWrapMap = {
59
+ wrap: css({ flexWrap: 'wrap' }),
60
+ };
61
+
62
+ const baseStyles = css({
63
+ display: 'flex',
64
+ boxSizing: 'border-box',
65
+ flexDirection: 'column',
66
+ });
67
+
68
+ /**
69
+ * __Stack__
70
+ *
71
+ * Stack is a primitive component based on flexbox that manages the vertical layout of direct children.
72
+ * Renders a `div` by default.
73
+ *
74
+ * @private
75
+ * @deprecated DSP-8009: This primitive is scheduled for deletion.
76
+ * Please use `Stack` from `@atlaskit/primitives` instead.
77
+ *
78
+ */
79
+ const Stack = memo(
80
+ forwardRef<HTMLDivElement, StackProps>(
81
+ (
82
+ {
83
+ gap,
84
+ alignItems,
85
+ justifyContent,
86
+ flexWrap,
87
+ children,
88
+ UNSAFE_style,
89
+ testId,
90
+ },
91
+ ref,
92
+ ) => {
93
+ return (
94
+ <div
95
+ style={UNSAFE_style}
96
+ css={[
97
+ baseStyles,
98
+ gap && rowGapMap[gap],
99
+ alignItems && flexAlignItemsMap[alignItems],
100
+ justifyContent && flexJustifyContentMap[justifyContent],
101
+ flexWrap && flexWrapMap[flexWrap],
102
+ ]}
103
+ data-testid={testId}
104
+ ref={ref}
105
+ >
106
+ {children}
107
+ </div>
108
+ );
109
+ },
110
+ ),
111
+ );
112
+
113
+ Stack.displayName = 'Stack';
114
+
115
+ export default Stack;
116
+
117
+ /**
118
+ * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
119
+ * @codegen <<SignedSource::02ffa7c4ee52871441d288f44a054685>>
120
+ * @codegenId spacing
121
+ * @codegenCommand yarn codegen-styles
122
+ * @codegenParams ["rowGap"]
123
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::298080e8024fb3eb37589721413e0156>>
124
+ */
125
+ const rowGapMap = {
126
+ 'space.0': css({
127
+ rowGap: token('space.0', '0px'),
128
+ }),
129
+ 'space.025': css({
130
+ rowGap: token('space.025', '2px'),
131
+ }),
132
+ 'space.050': css({
133
+ rowGap: token('space.050', '4px'),
134
+ }),
135
+ 'space.075': css({
136
+ rowGap: token('space.075', '6px'),
137
+ }),
138
+ 'space.100': css({
139
+ rowGap: token('space.100', '8px'),
140
+ }),
141
+ 'space.1000': css({
142
+ rowGap: token('space.1000', '80px'),
143
+ }),
144
+ 'space.150': css({
145
+ rowGap: token('space.150', '12px'),
146
+ }),
147
+ 'space.200': css({
148
+ rowGap: token('space.200', '16px'),
149
+ }),
150
+ 'space.250': css({
151
+ rowGap: token('space.250', '20px'),
152
+ }),
153
+ 'space.300': css({
154
+ rowGap: token('space.300', '24px'),
155
+ }),
156
+ 'space.400': css({
157
+ rowGap: token('space.400', '32px'),
158
+ }),
159
+ 'space.500': css({
160
+ rowGap: token('space.500', '40px'),
161
+ }),
162
+ 'space.600': css({
163
+ rowGap: token('space.600', '48px'),
164
+ }),
165
+ 'space.800': css({
166
+ rowGap: token('space.800', '64px'),
167
+ }),
168
+ };
169
+
170
+ export type RowGap = keyof typeof rowGapMap;
171
+
172
+ /**
173
+ * @codegenEnd
174
+ */
@@ -1,6 +1,6 @@
1
1
  import { createContext, useContext } from 'react';
2
2
 
3
- import type { BackgroundColor } from '@atlaskit/primitives';
3
+ import type { BackgroundColor } from './box.partial';
4
4
 
5
5
  /**
6
6
  * __Surface context__
package/src/index.tsx CHANGED
@@ -1,3 +1,9 @@
1
+ export { default as UNSAFE_Box } from './components/box.partial';
1
2
  export { default as UNSAFE_Text } from './components/text.partial';
3
+ export { default as UNSAFE_Inline } from './components/inline.partial';
4
+ export { default as UNSAFE_Stack } from './components/stack.partial';
2
5
  export { default as UNSAFE_InteractionSurface } from './components/interaction-surface.partial';
6
+ export type { BoxProps as UNSAFE_BoxProps } from './components/box.partial';
3
7
  export type { TextProps as UNSAFE_TextProps } from './components/text.partial';
8
+ export type { InlineProps as UNSAFE_InlineProps } from './components/inline.partial';
9
+ export type { StackProps as UNSAFE_StackProps } from './components/stack.partial';
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/ds-explorations/stack",
3
+ "main": "../dist/cjs/components/stack.partial.js",
4
+ "module": "../dist/esm/components/stack.partial.js",
5
+ "module:es2019": "../dist/es2019/components/stack.partial.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/components/stack.partial.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/components/stack.partial.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }