@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.
- package/CHANGELOG.md +32 -0
- package/dist/cjs/components/box.partial.js +355 -185
- package/dist/cjs/components/inline.partial.js +124 -0
- package/dist/cjs/components/interaction-surface.partial.js +253 -0
- package/dist/cjs/components/stack.partial.js +116 -0
- package/dist/cjs/components/surface-provider.js +31 -0
- package/dist/cjs/components/text.partial.js +152 -49
- package/dist/cjs/components/types.js +5 -0
- package/dist/cjs/constants.js +3 -0
- package/dist/cjs/index.js +50 -3
- 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 +259 -113
- package/dist/es2019/components/inline.partial.js +111 -0
- package/dist/es2019/components/interaction-surface.partial.js +243 -0
- package/dist/es2019/components/stack.partial.js +106 -0
- package/dist/es2019/components/surface-provider.js +20 -0
- package/dist/es2019/components/text.partial.js +122 -35
- package/dist/es2019/components/types.js +1 -0
- package/dist/es2019/constants.js +3 -0
- package/dist/es2019/index.js +6 -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 +274 -109
- package/dist/esm/components/inline.partial.js +110 -0
- package/dist/esm/components/interaction-surface.partial.js +242 -0
- package/dist/esm/components/stack.partial.js +105 -0
- package/dist/esm/components/surface-provider.js +20 -0
- package/dist/esm/components/text.partial.js +132 -34
- package/dist/esm/components/types.js +1 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/index.js +6 -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 +157 -76
- package/dist/types/components/inline.partial.d.ts +52 -0
- package/dist/types/components/interaction-surface.partial.d.ts +45 -0
- package/dist/types/components/stack.partial.d.ts +47 -0
- package/dist/types/components/surface-provider.d.ts +15 -0
- package/dist/types/components/text.partial.d.ts +100 -28
- package/dist/types/components/types.d.ts +13 -0
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/types/internal/color-map.d.ts +34 -0
- package/dist/types/internal/role-to-element.d.ts +32 -0
- package/examples/00-basic.tsx +18 -1
- package/examples/01-box.tsx +126 -2
- package/examples/02-text.tsx +76 -2
- package/examples/03-stack.tsx +125 -0
- package/examples/04-inline.tsx +134 -0
- package/examples/{03-badge.tsx → 05-badge.tsx} +4 -4
- package/examples/{04-section-message.tsx → 06-section-message.tsx} +6 -6
- package/examples/{05-comment.tsx → 07-comment.tsx} +11 -9
- package/examples/08-lozenge.tsx +29 -0
- package/examples/99-interactions.tsx +175 -0
- package/package.json +8 -5
- package/report.api.md +457 -4
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +244 -50
- package/scripts/__tests__/codegen.test.tsx +5 -0
- package/scripts/codegen-styles.tsx +46 -10
- package/scripts/color-codegen-template.tsx +34 -12
- package/scripts/color-map-template.tsx +52 -0
- package/scripts/interaction-codegen.tsx +109 -0
- package/scripts/spacing-codegen-template.tsx +9 -1
- package/scripts/utils.tsx +5 -1
- package/src/components/__tests__/unit/box.test.tsx +50 -0
- package/src/components/__tests__/unit/inline.test.tsx +43 -0
- package/src/components/__tests__/unit/interaction-suface.test.tsx +70 -0
- package/src/components/__tests__/unit/stack.test.tsx +31 -0
- package/src/components/__tests__/unit/text.test.tsx +33 -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 +305 -127
- package/src/components/inline.partial.tsx +120 -0
- package/src/components/interaction-surface.partial.tsx +237 -0
- package/src/components/stack.partial.tsx +104 -0
- package/src/components/surface-provider.tsx +25 -0
- package/src/components/text.partial.tsx +149 -38
- package/src/components/types.tsx +15 -0
- package/src/constants.tsx +3 -0
- package/src/index.tsx +8 -1
- package/src/internal/color-map.tsx +34 -0
- package/src/internal/role-to-element.tsx +34 -0
- package/dist/cjs/components/inline.js +0 -45
- package/dist/cjs/components/stack.js +0 -33
- package/dist/es2019/components/inline.js +0 -31
- package/dist/es2019/components/stack.js +0 -22
- package/dist/esm/components/inline.js +0 -30
- package/dist/esm/components/stack.js +0 -21
- package/dist/types/components/inline.d.ts +0 -19
- package/dist/types/components/stack.d.ts +0 -16
- package/src/components/inline.tsx +0 -49
- package/src/components/stack.tsx +0 -30
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Fragment, useContext } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { SurfaceContext } from './surface-provider';
|
|
5
|
+
const baseStyles = css({
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
borderRadius: 'inherit',
|
|
8
|
+
cursor: 'pointer',
|
|
9
|
+
inset: 0,
|
|
10
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
11
|
+
'~ *': {
|
|
12
|
+
position: 'relative',
|
|
13
|
+
pointerEvents: 'none'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* // a minimal icon button
|
|
22
|
+
* <Box as="button">
|
|
23
|
+
* <InteractionSurface />
|
|
24
|
+
* <WarningIcon label="icon button" />
|
|
25
|
+
* </Box>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const InteractionSurface = ({
|
|
29
|
+
appearance,
|
|
30
|
+
children,
|
|
31
|
+
testId
|
|
32
|
+
}) => {
|
|
33
|
+
const defaultSurface = useContext(SurfaceContext);
|
|
34
|
+
let surface = appearance || defaultSurface; // This case will occur if the Box has not set a bg color and the ancestor surface
|
|
35
|
+
// is an elevation. An alternative would be to throw an error here as it may be better
|
|
36
|
+
// to ensure correct predictable behaviour based on user specification.
|
|
37
|
+
|
|
38
|
+
if (!(surface in backgroundActiveColorMap)) {
|
|
39
|
+
surface = 'neutral';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return jsx(Fragment, null, jsx("span", {
|
|
43
|
+
"data-testid": testId,
|
|
44
|
+
css: [baseStyles, surface && backgroundHoverColorMap[surface], surface && backgroundActiveColorMap[surface]]
|
|
45
|
+
}), children);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default InteractionSurface;
|
|
49
|
+
/**
|
|
50
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
51
|
+
* @codegen <<SignedSource::45000716488a9f41306a232c1f4c9f8d>>
|
|
52
|
+
* @codegenId interactions
|
|
53
|
+
* @codegenCommand yarn codegen-styles
|
|
54
|
+
* @codegenParams ["background"]
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
const backgroundActiveColorMap = {
|
|
58
|
+
'inverse.subtle': css({
|
|
59
|
+
':active': {
|
|
60
|
+
backgroundColor: "var(--ds-background-inverse-subtle-pressed, #00000052)"
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
input: css({
|
|
64
|
+
':active': {
|
|
65
|
+
backgroundColor: "var(--ds-background-input-pressed, #FFFFFF)"
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
neutral: css({
|
|
69
|
+
':active': {
|
|
70
|
+
backgroundColor: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
'neutral.subtle': css({
|
|
74
|
+
':active': {
|
|
75
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
'neutral.bold': css({
|
|
79
|
+
':active': {
|
|
80
|
+
backgroundColor: "var(--ds-background-neutral-bold-pressed, #172B4D)"
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
'brand.bold': css({
|
|
84
|
+
':active': {
|
|
85
|
+
backgroundColor: "var(--ds-background-brand-bold-pressed, #09326C)"
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
selected: css({
|
|
89
|
+
':active': {
|
|
90
|
+
backgroundColor: "var(--ds-background-selected-pressed, #85B8FF)"
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
'selected.bold': css({
|
|
94
|
+
':active': {
|
|
95
|
+
backgroundColor: "var(--ds-background-selected-bold-pressed, #09326C)"
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
danger: css({
|
|
99
|
+
':active': {
|
|
100
|
+
backgroundColor: "var(--ds-background-danger-pressed, #FF9C8F)"
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
'danger.bold': css({
|
|
104
|
+
':active': {
|
|
105
|
+
backgroundColor: "var(--ds-background-danger-bold-pressed, #601E16)"
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
warning: css({
|
|
109
|
+
':active': {
|
|
110
|
+
backgroundColor: "var(--ds-background-warning-pressed, #F5CD47)"
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
'warning.bold': css({
|
|
114
|
+
':active': {
|
|
115
|
+
backgroundColor: "var(--ds-background-warning-bold-pressed, #B38600)"
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
118
|
+
success: css({
|
|
119
|
+
':active': {
|
|
120
|
+
backgroundColor: "var(--ds-background-success-pressed, #7EE2B8)"
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
'success.bold': css({
|
|
124
|
+
':active': {
|
|
125
|
+
backgroundColor: "var(--ds-background-success-bold-pressed, #164B35)"
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
discovery: css({
|
|
129
|
+
':active': {
|
|
130
|
+
backgroundColor: "var(--ds-background-discovery-pressed, #B8ACF6)"
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
'discovery.bold': css({
|
|
134
|
+
':active': {
|
|
135
|
+
backgroundColor: "var(--ds-background-discovery-bold-pressed, #352C63)"
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
information: css({
|
|
139
|
+
':active': {
|
|
140
|
+
backgroundColor: "var(--ds-background-information-pressed, #85B8FF)"
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
'information.bold': css({
|
|
144
|
+
':active': {
|
|
145
|
+
backgroundColor: "var(--ds-background-information-bold-pressed, #09326C)"
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
};
|
|
149
|
+
const backgroundHoverColorMap = {
|
|
150
|
+
'inverse.subtle': css({
|
|
151
|
+
':hover': {
|
|
152
|
+
backgroundColor: "var(--ds-background-inverse-subtle-hovered, #0000003D)"
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
input: css({
|
|
156
|
+
':hover': {
|
|
157
|
+
backgroundColor: "var(--ds-background-input-hovered, #F7F8F9)"
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
neutral: css({
|
|
161
|
+
':hover': {
|
|
162
|
+
backgroundColor: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
'neutral.subtle': css({
|
|
166
|
+
':hover': {
|
|
167
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
168
|
+
}
|
|
169
|
+
}),
|
|
170
|
+
'neutral.bold': css({
|
|
171
|
+
':hover': {
|
|
172
|
+
backgroundColor: "var(--ds-background-neutral-bold-hovered, #2C3E5D)"
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
'brand.bold': css({
|
|
176
|
+
':hover': {
|
|
177
|
+
backgroundColor: "var(--ds-background-brand-bold-hovered, #0055CC)"
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
selected: css({
|
|
181
|
+
':hover': {
|
|
182
|
+
backgroundColor: "var(--ds-background-selected-hovered, #CCE0FF)"
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
'selected.bold': css({
|
|
186
|
+
':hover': {
|
|
187
|
+
backgroundColor: "var(--ds-background-selected-bold-hovered, #0055CC)"
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
danger: css({
|
|
191
|
+
':hover': {
|
|
192
|
+
backgroundColor: "var(--ds-background-danger-hovered, #FFD2CC)"
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
'danger.bold': css({
|
|
196
|
+
':hover': {
|
|
197
|
+
backgroundColor: "var(--ds-background-danger-bold-hovered, #AE2A19)"
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
warning: css({
|
|
201
|
+
':hover': {
|
|
202
|
+
backgroundColor: "var(--ds-background-warning-hovered, #F8E6A0)"
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
'warning.bold': css({
|
|
206
|
+
':hover': {
|
|
207
|
+
backgroundColor: "var(--ds-background-warning-bold-hovered, #CF9F02)"
|
|
208
|
+
}
|
|
209
|
+
}),
|
|
210
|
+
success: css({
|
|
211
|
+
':hover': {
|
|
212
|
+
backgroundColor: "var(--ds-background-success-hovered, #BAF3DB)"
|
|
213
|
+
}
|
|
214
|
+
}),
|
|
215
|
+
'success.bold': css({
|
|
216
|
+
':hover': {
|
|
217
|
+
backgroundColor: "var(--ds-background-success-bold-hovered, #216E4E)"
|
|
218
|
+
}
|
|
219
|
+
}),
|
|
220
|
+
discovery: css({
|
|
221
|
+
':hover': {
|
|
222
|
+
backgroundColor: "var(--ds-background-discovery-hovered, #DFD8FD)"
|
|
223
|
+
}
|
|
224
|
+
}),
|
|
225
|
+
'discovery.bold': css({
|
|
226
|
+
':hover': {
|
|
227
|
+
backgroundColor: "var(--ds-background-discovery-bold-hovered, #5E4DB2)"
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
information: css({
|
|
231
|
+
':hover': {
|
|
232
|
+
backgroundColor: "var(--ds-background-information-hovered, #CCE0FF)"
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
235
|
+
'information.bold': css({
|
|
236
|
+
':hover': {
|
|
237
|
+
backgroundColor: "var(--ds-background-information-bold-hovered, #0055CC)"
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* @codegenEnd
|
|
243
|
+
*/
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { SPACING_SCALE } from '../constants';
|
|
5
|
+
const flexAlignItemsMap = {
|
|
6
|
+
center: css({
|
|
7
|
+
alignItems: 'center'
|
|
8
|
+
}),
|
|
9
|
+
baseline: css({
|
|
10
|
+
alignItems: 'baseline'
|
|
11
|
+
}),
|
|
12
|
+
flexStart: css({
|
|
13
|
+
alignItems: 'flex-start'
|
|
14
|
+
}),
|
|
15
|
+
flexEnd: css({
|
|
16
|
+
alignItems: 'flex-end'
|
|
17
|
+
})
|
|
18
|
+
};
|
|
19
|
+
const flexJustifyContentMap = {
|
|
20
|
+
center: css({
|
|
21
|
+
justifyContent: 'center'
|
|
22
|
+
}),
|
|
23
|
+
flexStart: css({
|
|
24
|
+
justifyContent: 'flex-start'
|
|
25
|
+
}),
|
|
26
|
+
flexEnd: css({
|
|
27
|
+
justifyContent: 'flex-end'
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
const baseStyles = css({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
boxSizing: 'border-box',
|
|
33
|
+
flexDirection: 'column'
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* __Stack__
|
|
37
|
+
*
|
|
38
|
+
* Stack is a primitive component based on flexbox that manages the vertical layout of direct children.
|
|
39
|
+
* Renders a `div` by default.
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const Stack = /*#__PURE__*/forwardRef(({
|
|
44
|
+
gap,
|
|
45
|
+
alignItems,
|
|
46
|
+
justifyContent,
|
|
47
|
+
children,
|
|
48
|
+
testId
|
|
49
|
+
}, ref) => {
|
|
50
|
+
return jsx("div", {
|
|
51
|
+
css: [baseStyles, gap && gapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent]],
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
ref: ref
|
|
54
|
+
}, children);
|
|
55
|
+
});
|
|
56
|
+
Stack.displayName = 'Stack';
|
|
57
|
+
export default Stack;
|
|
58
|
+
/**
|
|
59
|
+
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
60
|
+
* @codegen <<SignedSource::36d00b5586593733c7f84e9a10ddb7fd>>
|
|
61
|
+
* @codegenId spacing
|
|
62
|
+
* @codegenCommand yarn codegen-styles
|
|
63
|
+
* @codegenParams ["gap"]
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
const gapMap = {
|
|
67
|
+
'sp-0': css({
|
|
68
|
+
gap: SPACING_SCALE['sp-0']
|
|
69
|
+
}),
|
|
70
|
+
'sp-25': css({
|
|
71
|
+
gap: SPACING_SCALE['sp-25']
|
|
72
|
+
}),
|
|
73
|
+
'sp-50': css({
|
|
74
|
+
gap: SPACING_SCALE['sp-50']
|
|
75
|
+
}),
|
|
76
|
+
'sp-75': css({
|
|
77
|
+
gap: SPACING_SCALE['sp-75']
|
|
78
|
+
}),
|
|
79
|
+
'sp-100': css({
|
|
80
|
+
gap: SPACING_SCALE['sp-100']
|
|
81
|
+
}),
|
|
82
|
+
'sp-150': css({
|
|
83
|
+
gap: SPACING_SCALE['sp-150']
|
|
84
|
+
}),
|
|
85
|
+
'sp-200': css({
|
|
86
|
+
gap: SPACING_SCALE['sp-200']
|
|
87
|
+
}),
|
|
88
|
+
'sp-300': css({
|
|
89
|
+
gap: SPACING_SCALE['sp-300']
|
|
90
|
+
}),
|
|
91
|
+
'sp-400': css({
|
|
92
|
+
gap: SPACING_SCALE['sp-400']
|
|
93
|
+
}),
|
|
94
|
+
'sp-500': css({
|
|
95
|
+
gap: SPACING_SCALE['sp-500']
|
|
96
|
+
}),
|
|
97
|
+
'sp-600': css({
|
|
98
|
+
gap: SPACING_SCALE['sp-600']
|
|
99
|
+
}),
|
|
100
|
+
'sp-800': css({
|
|
101
|
+
gap: SPACING_SCALE['sp-800']
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* @codegenEnd
|
|
106
|
+
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* __Surface context__
|
|
5
|
+
*
|
|
6
|
+
* A surface context provides context information on the current background (if set).
|
|
7
|
+
*/
|
|
8
|
+
export const SurfaceContext = /*#__PURE__*/createContext('elevation.surface');
|
|
9
|
+
/**
|
|
10
|
+
* __useSurface__
|
|
11
|
+
*
|
|
12
|
+
* Return the current surface. If no parent sets a surface color it falls back to the default surface.
|
|
13
|
+
*
|
|
14
|
+
* @see SurfaceContext
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const useSurface = () => {
|
|
18
|
+
return useContext(SurfaceContext);
|
|
19
|
+
};
|
|
20
|
+
SurfaceContext.displayName = 'SurfaceProvider';
|
|
@@ -1,100 +1,187 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { css, jsx } from '@emotion/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import invariant from 'tiny-invariant';
|
|
4
|
+
import { colorMap } from '../internal/color-map';
|
|
5
|
+
import { useSurface } from './surface-provider';
|
|
6
|
+
const asAllowlist = ['span', 'div', 'p'];
|
|
7
7
|
const fontFamily = `-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif`;
|
|
8
8
|
const fontSizeMap = {
|
|
9
|
-
|
|
10
|
-
fontSize:
|
|
9
|
+
'11px': css({
|
|
10
|
+
fontSize: '11px'
|
|
11
11
|
}),
|
|
12
|
-
|
|
13
|
-
fontSize:
|
|
12
|
+
'12px': css({
|
|
13
|
+
fontSize: '12px'
|
|
14
14
|
}),
|
|
15
|
-
|
|
16
|
-
fontSize
|
|
15
|
+
'14px': css({
|
|
16
|
+
fontSize: '14px'
|
|
17
17
|
})
|
|
18
18
|
};
|
|
19
|
+
// NOTE: can't use numbers as keys or Constellation won't build. Weird one.
|
|
19
20
|
const fontWeightMap = {
|
|
20
|
-
400: css({
|
|
21
|
+
'400': css({
|
|
21
22
|
fontWeight: 400
|
|
22
23
|
}),
|
|
23
|
-
500: css({
|
|
24
|
+
'500': css({
|
|
24
25
|
fontWeight: 500
|
|
26
|
+
}),
|
|
27
|
+
'700': css({
|
|
28
|
+
fontWeight: 700
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
const lineHeightMap = {
|
|
32
|
+
'12px': css({
|
|
33
|
+
lineHeight: '12px'
|
|
34
|
+
}),
|
|
35
|
+
'16px': css({
|
|
36
|
+
lineHeight: '16px'
|
|
37
|
+
}),
|
|
38
|
+
'20px': css({
|
|
39
|
+
lineHeight: '20px'
|
|
40
|
+
}),
|
|
41
|
+
'24px': css({
|
|
42
|
+
lineHeight: '24px'
|
|
43
|
+
}),
|
|
44
|
+
'28px': css({
|
|
45
|
+
lineHeight: '28px'
|
|
46
|
+
}),
|
|
47
|
+
'32px': css({
|
|
48
|
+
lineHeight: '32px'
|
|
49
|
+
}),
|
|
50
|
+
'40px': css({
|
|
51
|
+
lineHeight: '40px'
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
const textAlignMap = {
|
|
55
|
+
center: css({
|
|
56
|
+
textAlign: 'center'
|
|
57
|
+
}),
|
|
58
|
+
end: css({
|
|
59
|
+
textAlign: 'end'
|
|
60
|
+
}),
|
|
61
|
+
start: css({
|
|
62
|
+
textAlign: 'start'
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
const textTransformMap = {
|
|
66
|
+
none: css({
|
|
67
|
+
textTransform: 'none'
|
|
68
|
+
}),
|
|
69
|
+
lowercase: css({
|
|
70
|
+
textTransform: 'lowercase'
|
|
71
|
+
}),
|
|
72
|
+
uppercase: css({
|
|
73
|
+
textTransform: 'uppercase'
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
const verticalAlignMap = {
|
|
77
|
+
top: css({
|
|
78
|
+
verticalAlign: 'top'
|
|
79
|
+
}),
|
|
80
|
+
middle: css({
|
|
81
|
+
verticalAlign: 'middle'
|
|
82
|
+
}),
|
|
83
|
+
bottom: css({
|
|
84
|
+
verticalAlign: 'bottom'
|
|
25
85
|
})
|
|
26
86
|
};
|
|
27
87
|
const baseStyles = css({
|
|
88
|
+
boxSizing: 'border-box',
|
|
28
89
|
fontFamily
|
|
29
90
|
});
|
|
91
|
+
const truncateStyles = css({
|
|
92
|
+
overflow: 'hidden',
|
|
93
|
+
textOverflow: 'ellipsis',
|
|
94
|
+
whiteSpace: 'nowrap'
|
|
95
|
+
});
|
|
30
96
|
/**
|
|
31
97
|
* __Text__
|
|
32
98
|
*
|
|
33
|
-
*
|
|
99
|
+
* Text is a primitive component that has the Atlassian Design System's design guidelines baked in.
|
|
100
|
+
* This includes considerations for text attributes such as color, font size, font weight, and line height.
|
|
101
|
+
* It renders a `span` by default.
|
|
34
102
|
*
|
|
35
103
|
* @internal
|
|
36
104
|
*/
|
|
37
105
|
|
|
38
|
-
|
|
106
|
+
const Text = ({
|
|
39
107
|
as: Component = 'span',
|
|
40
108
|
children,
|
|
41
|
-
color,
|
|
109
|
+
color: colorTuple,
|
|
42
110
|
fontSize,
|
|
43
|
-
fontWeight
|
|
44
|
-
|
|
111
|
+
fontWeight,
|
|
112
|
+
lineHeight,
|
|
113
|
+
shouldTruncate = false,
|
|
114
|
+
textAlign,
|
|
115
|
+
textTransform,
|
|
116
|
+
verticalAlign,
|
|
117
|
+
testId,
|
|
118
|
+
UNSAFE_style
|
|
119
|
+
}) => {
|
|
120
|
+
var _colorMap$surface;
|
|
121
|
+
|
|
122
|
+
const surface = useSurface(); // @ts-ignore
|
|
123
|
+
|
|
124
|
+
const [color = (_colorMap$surface = colorMap[surface]) !== null && _colorMap$surface !== void 0 ? _colorMap$surface : 'color.text', fallback] = colorTuple || [];
|
|
125
|
+
invariant(asAllowlist.includes(Component), `@atlaskit/ds-explorations: Text received an invalid "as" value of "${Component}"`);
|
|
45
126
|
return jsx(Component, {
|
|
46
|
-
|
|
127
|
+
style: { ...UNSAFE_style,
|
|
128
|
+
...(fallback && {
|
|
129
|
+
'--ds-co-fb': fallback
|
|
130
|
+
})
|
|
131
|
+
},
|
|
132
|
+
css: [baseStyles, color && textColorMap[color], fontSize && fontSizeMap[fontSize], fontWeight && fontWeightMap[fontWeight], lineHeight && lineHeightMap[lineHeight], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], textTransform && textTransformMap[textTransform], verticalAlign && verticalAlignMap[verticalAlign]],
|
|
133
|
+
"data-testid": testId
|
|
47
134
|
}, children);
|
|
48
|
-
}
|
|
135
|
+
};
|
|
49
136
|
|
|
50
137
|
export default Text;
|
|
51
138
|
/**
|
|
52
139
|
* THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
53
|
-
* @codegen <<SignedSource::
|
|
140
|
+
* @codegen <<SignedSource::140ffff6e1310c1c37e2067e2c232b92>>
|
|
54
141
|
* @codegenId colors
|
|
55
142
|
* @codegenCommand yarn codegen-styles
|
|
56
143
|
* @codegenParams ["text"]
|
|
57
144
|
*/
|
|
58
145
|
|
|
59
146
|
const textColorMap = {
|
|
60
|
-
|
|
61
|
-
color: "var(--ds-text,
|
|
147
|
+
'color.text': css({
|
|
148
|
+
color: "var(--ds-text, var(--ds-co-fb))"
|
|
62
149
|
}),
|
|
63
150
|
subtle: css({
|
|
64
|
-
color: "var(--ds-text-subtle,
|
|
151
|
+
color: "var(--ds-text-subtle, var(--ds-co-fb))"
|
|
65
152
|
}),
|
|
66
153
|
subtlest: css({
|
|
67
|
-
color: "var(--ds-text-subtlest,
|
|
154
|
+
color: "var(--ds-text-subtlest, var(--ds-co-fb))"
|
|
68
155
|
}),
|
|
69
156
|
disabled: css({
|
|
70
|
-
color: "var(--ds-text-disabled,
|
|
157
|
+
color: "var(--ds-text-disabled, var(--ds-co-fb))"
|
|
71
158
|
}),
|
|
72
159
|
inverse: css({
|
|
73
|
-
color: "var(--ds-text-inverse,
|
|
160
|
+
color: "var(--ds-text-inverse, var(--ds-co-fb))"
|
|
74
161
|
}),
|
|
75
162
|
brand: css({
|
|
76
|
-
color: "var(--ds-text-brand,
|
|
163
|
+
color: "var(--ds-text-brand, var(--ds-co-fb))"
|
|
77
164
|
}),
|
|
78
165
|
selected: css({
|
|
79
|
-
color: "var(--ds-text-selected,
|
|
166
|
+
color: "var(--ds-text-selected, var(--ds-co-fb))"
|
|
80
167
|
}),
|
|
81
168
|
danger: css({
|
|
82
|
-
color: "var(--ds-text-danger,
|
|
169
|
+
color: "var(--ds-text-danger, var(--ds-co-fb))"
|
|
83
170
|
}),
|
|
84
171
|
warning: css({
|
|
85
|
-
color: "var(--ds-text-warning,
|
|
172
|
+
color: "var(--ds-text-warning, var(--ds-co-fb))"
|
|
86
173
|
}),
|
|
87
174
|
'warning.inverse': css({
|
|
88
|
-
color: "var(--ds-text-warning-inverse,
|
|
175
|
+
color: "var(--ds-text-warning-inverse, var(--ds-co-fb))"
|
|
89
176
|
}),
|
|
90
177
|
success: css({
|
|
91
|
-
color: "var(--ds-text-success,
|
|
178
|
+
color: "var(--ds-text-success, var(--ds-co-fb))"
|
|
92
179
|
}),
|
|
93
180
|
discovery: css({
|
|
94
|
-
color: "var(--ds-text-discovery,
|
|
181
|
+
color: "var(--ds-text-discovery, var(--ds-co-fb))"
|
|
95
182
|
}),
|
|
96
183
|
information: css({
|
|
97
|
-
color: "var(--ds-text-information,
|
|
184
|
+
color: "var(--ds-text-information, var(--ds-co-fb))"
|
|
98
185
|
})
|
|
99
186
|
};
|
|
100
187
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/constants.js
CHANGED
package/dist/es2019/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export default
|
|
1
|
+
export { default as UNSAFE_Box } from './components/box.partial';
|
|
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';
|
|
5
|
+
export { default as UNSAFE_InteractionSurface } from './components/interaction-surface.partial';
|
|
6
|
+
export { SPACING_SCALE as UNSAFE_SPACING_SCALE } from './constants';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
*
|
|
4
|
+
* Some artifact
|
|
5
|
+
*
|
|
6
|
+
* @codegen <<SignedSource::8f568e4f0837f7af4a10429e060ad059>>
|
|
7
|
+
* @codegenCommand yarn codegen-styles
|
|
8
|
+
*/
|
|
9
|
+
export const colorMap = {
|
|
10
|
+
'neutral.bold': 'inverse',
|
|
11
|
+
'neutral.bold.hovered': 'inverse',
|
|
12
|
+
'neutral.bold.pressed': 'inverse',
|
|
13
|
+
'brand.bold': 'inverse',
|
|
14
|
+
'brand.bold.hovered': 'inverse',
|
|
15
|
+
'brand.bold.pressed': 'inverse',
|
|
16
|
+
'selected.bold': 'inverse',
|
|
17
|
+
'selected.bold.hovered': 'inverse',
|
|
18
|
+
'selected.bold.pressed': 'inverse',
|
|
19
|
+
'danger.bold': 'inverse',
|
|
20
|
+
'danger.bold.hovered': 'inverse',
|
|
21
|
+
'danger.bold.pressed': 'inverse',
|
|
22
|
+
'warning.bold': 'warning.inverse',
|
|
23
|
+
'warning.bold.hovered': 'warning.inverse',
|
|
24
|
+
'warning.bold.pressed': 'warning.inverse',
|
|
25
|
+
'success.bold': 'inverse',
|
|
26
|
+
'success.bold.hovered': 'inverse',
|
|
27
|
+
'success.bold.pressed': 'inverse',
|
|
28
|
+
'discovery.bold': 'inverse',
|
|
29
|
+
'discovery.bold.hovered': 'inverse',
|
|
30
|
+
'discovery.bold.pressed': 'inverse',
|
|
31
|
+
'information.bold': 'inverse',
|
|
32
|
+
'information.bold.hovered': 'inverse',
|
|
33
|
+
'information.bold.pressed': 'inverse'
|
|
34
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapted straight from react-mui, with a small change.
|
|
3
|
+
* @see https://www.unpkg.com/browse/react-gui@0.2.1/src/modules/getAccessibilityElementWithSideEffect.js
|
|
4
|
+
*/
|
|
5
|
+
const roleToElementType = {
|
|
6
|
+
article: 'article',
|
|
7
|
+
banner: 'header',
|
|
8
|
+
blockquote: 'blockquote',
|
|
9
|
+
button: 'button',
|
|
10
|
+
code: 'code',
|
|
11
|
+
complementary: 'aside',
|
|
12
|
+
contentinfo: 'footer',
|
|
13
|
+
deletion: 'del',
|
|
14
|
+
emphasis: 'em',
|
|
15
|
+
figure: 'figure',
|
|
16
|
+
insertion: 'ins',
|
|
17
|
+
form: 'form',
|
|
18
|
+
link: 'a',
|
|
19
|
+
list: 'ul',
|
|
20
|
+
listitem: 'li',
|
|
21
|
+
main: 'main',
|
|
22
|
+
navigation: 'nav',
|
|
23
|
+
region: 'section',
|
|
24
|
+
strong: 'strong',
|
|
25
|
+
presentation: 'div',
|
|
26
|
+
group: 'fieldset'
|
|
27
|
+
};
|
|
28
|
+
export default roleToElementType;
|
package/dist/es2019/version.json
CHANGED