@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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* Adapted straight from react-mui, with a small change.
|
|
4
|
+
* @see https://www.unpkg.com/browse/react-gui@0.2.1/src/modules/getAccessibilityElementWithSideEffect.js
|
|
5
|
+
*/
|
|
6
|
+
declare const roleToElementType: {
|
|
7
|
+
readonly article: "article";
|
|
8
|
+
readonly banner: "header";
|
|
9
|
+
readonly blockquote: "blockquote";
|
|
10
|
+
readonly button: "button";
|
|
11
|
+
readonly code: "code";
|
|
12
|
+
readonly complementary: "aside";
|
|
13
|
+
readonly contentinfo: "footer";
|
|
14
|
+
readonly deletion: "del";
|
|
15
|
+
readonly emphasis: "em";
|
|
16
|
+
readonly figure: "figure";
|
|
17
|
+
readonly insertion: "ins";
|
|
18
|
+
readonly form: "form";
|
|
19
|
+
readonly link: "a";
|
|
20
|
+
readonly list: "ul";
|
|
21
|
+
readonly listitem: "li";
|
|
22
|
+
readonly main: "main";
|
|
23
|
+
readonly navigation: "nav";
|
|
24
|
+
readonly region: "section";
|
|
25
|
+
readonly strong: "strong";
|
|
26
|
+
readonly presentation: "div";
|
|
27
|
+
readonly group: "fieldset";
|
|
28
|
+
};
|
|
29
|
+
declare type RoleMap = typeof roleToElementType;
|
|
30
|
+
export declare type Role = keyof RoleMap;
|
|
31
|
+
export declare type SupportedElements = RoleMap[Role] & keyof JSX.IntrinsicElements;
|
|
32
|
+
export default roleToElementType;
|
package/examples/02-text.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
import Heading from '@atlaskit/heading';
|
|
4
|
+
|
|
3
5
|
import {
|
|
4
6
|
UNSAFE_Box as Box,
|
|
5
7
|
UNSAFE_Inline as Inline,
|
|
@@ -10,21 +12,31 @@ import {
|
|
|
10
12
|
export default () => {
|
|
11
13
|
return (
|
|
12
14
|
<Stack gap="sp-200">
|
|
13
|
-
<
|
|
15
|
+
<Heading as="h2" level="h100">
|
|
16
|
+
Font size
|
|
17
|
+
</Heading>
|
|
14
18
|
<Inline gap="sp-200" testId="font-sizes">
|
|
15
|
-
{(['
|
|
16
|
-
<Text
|
|
19
|
+
{(['11px', '12px', '14px'] as const).map((fontSize) => (
|
|
20
|
+
<Text key={fontSize} fontSize={fontSize}>
|
|
21
|
+
fontSize {fontSize}
|
|
22
|
+
</Text>
|
|
17
23
|
))}
|
|
18
24
|
</Inline>
|
|
19
25
|
|
|
20
|
-
<
|
|
26
|
+
<Heading as="h2" level="h100">
|
|
27
|
+
Font weight
|
|
28
|
+
</Heading>
|
|
21
29
|
<Inline gap="sp-200" testId="font-weights">
|
|
22
30
|
{(['400', '500'] as const).map((fontWeight) => (
|
|
23
|
-
<Text
|
|
31
|
+
<Text key={fontWeight} fontWeight={fontWeight}>
|
|
32
|
+
fontWeight {fontWeight}
|
|
33
|
+
</Text>
|
|
24
34
|
))}
|
|
25
35
|
</Inline>
|
|
26
36
|
|
|
27
|
-
<
|
|
37
|
+
<Heading as="h2" level="h100">
|
|
38
|
+
Line height
|
|
39
|
+
</Heading>
|
|
28
40
|
<Inline gap="sp-200" testId="line-heights" alignItems="center">
|
|
29
41
|
{([
|
|
30
42
|
'12px',
|
|
@@ -35,26 +47,35 @@ export default () => {
|
|
|
35
47
|
'32px',
|
|
36
48
|
'40px',
|
|
37
49
|
] as const).map((lineHeight) => (
|
|
38
|
-
<Box
|
|
50
|
+
<Box
|
|
51
|
+
key={lineHeight}
|
|
52
|
+
display="inlineFlex"
|
|
53
|
+
backgroundColor={['neutral', 'lightgrey']}
|
|
54
|
+
>
|
|
39
55
|
<Text lineHeight={lineHeight}>lineHeight {lineHeight}</Text>
|
|
40
56
|
</Box>
|
|
41
57
|
))}
|
|
42
58
|
</Inline>
|
|
43
59
|
|
|
44
|
-
<
|
|
45
|
-
|
|
60
|
+
<Heading as="h2" level="h100">
|
|
61
|
+
Testing
|
|
62
|
+
</Heading>
|
|
63
|
+
<Stack gap="sp-200" testId="testing">
|
|
64
|
+
<Text as="p">Paragraph</Text>
|
|
65
|
+
<Text as="div">A div</Text>
|
|
46
66
|
<Text>Basic</Text>
|
|
47
|
-
<Text as="h1">Heading 1</Text>
|
|
48
|
-
<Text as="a">Link</Text>
|
|
49
67
|
<Text
|
|
50
68
|
color={['brand', 'blue']}
|
|
51
|
-
fontSize="
|
|
69
|
+
fontSize="14px"
|
|
52
70
|
lineHeight="16px"
|
|
53
71
|
fontWeight="500"
|
|
54
72
|
>
|
|
55
73
|
Text with various props
|
|
56
74
|
</Text>
|
|
57
|
-
|
|
75
|
+
<Box UNSAFE_style={{ width: '200px' }}>
|
|
76
|
+
<Text shouldTruncate>Long truncated text that is cut off.</Text>
|
|
77
|
+
</Box>
|
|
78
|
+
</Stack>
|
|
58
79
|
</Stack>
|
|
59
80
|
);
|
|
60
81
|
};
|
package/examples/05-badge.tsx
CHANGED
package/examples/07-comment.tsx
CHANGED
package/examples/08-lozenge.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
3
|
|
|
4
4
|
import Lozenge from '@atlaskit/lozenge';
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ export default () => {
|
|
|
20
20
|
paddingInline="sp-50"
|
|
21
21
|
>
|
|
22
22
|
{/* textTransform: uppercase, font-weight: 700 */}
|
|
23
|
-
<Text fontSize="
|
|
23
|
+
<Text fontSize="11px" color={['color.text', 'grey']}>
|
|
24
24
|
Default
|
|
25
25
|
</Text>
|
|
26
26
|
</Box>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
import Button from '@atlaskit/button';
|
|
5
|
+
import { Code } from '@atlaskit/code';
|
|
6
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
7
|
+
import Heading from '@atlaskit/heading';
|
|
8
|
+
import WarningIcon from '@atlaskit/icon/glyph/warning';
|
|
9
|
+
import Textfield from '@atlaskit/textfield';
|
|
10
|
+
import { token } from '@atlaskit/tokens';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
UNSAFE_Box as Box,
|
|
14
|
+
UNSAFE_Inline as Inline,
|
|
15
|
+
UNSAFE_InteractionSurface as InteractionSurface,
|
|
16
|
+
UNSAFE_Stack as Stack,
|
|
17
|
+
UNSAFE_Text as Text,
|
|
18
|
+
} from '../src';
|
|
19
|
+
|
|
20
|
+
const fieldsetStyles = css({
|
|
21
|
+
flex: '1 1 100%',
|
|
22
|
+
':hover': {
|
|
23
|
+
backgroundColor: token('color.background.input.hovered', '#bbb'),
|
|
24
|
+
},
|
|
25
|
+
':invalid': {
|
|
26
|
+
borderColor: token('color.border.danger', 'red'),
|
|
27
|
+
},
|
|
28
|
+
':focus, :focus-within': {
|
|
29
|
+
backgroundColor: token('color.background.input'),
|
|
30
|
+
borderColor: token('color.border.focused', 'blue'),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export default () => {
|
|
35
|
+
return (
|
|
36
|
+
<Box width="sp-800" padding="sp-100" testId="all">
|
|
37
|
+
<Stack gap="sp-200">
|
|
38
|
+
<Heading level="h400">Current ADS Buttons</Heading>
|
|
39
|
+
<Inline gap="sp-200">
|
|
40
|
+
<Button appearance="primary">brand.bold</Button>
|
|
41
|
+
<Button appearance="default">neutral</Button>
|
|
42
|
+
<Button appearance="warning">warning.bold</Button>
|
|
43
|
+
</Inline>
|
|
44
|
+
<Heading level="h400">
|
|
45
|
+
Buttons with <Code>InteractionSurface</Code>
|
|
46
|
+
</Heading>
|
|
47
|
+
<Inline gap="sp-200" testId="buttons">
|
|
48
|
+
{(['brand.bold', 'neutral', 'warning.bold'] as const).map((app) => (
|
|
49
|
+
<FocusRing key={app}>
|
|
50
|
+
<Box
|
|
51
|
+
as="button"
|
|
52
|
+
onClick={() => console.log('hello')}
|
|
53
|
+
borderRadius="normal"
|
|
54
|
+
position="relative"
|
|
55
|
+
paddingInline="sp-150"
|
|
56
|
+
backgroundColor={[app, '']}
|
|
57
|
+
>
|
|
58
|
+
<InteractionSurface />
|
|
59
|
+
<Text
|
|
60
|
+
textAlign="center"
|
|
61
|
+
fontSize="14px"
|
|
62
|
+
lineHeight="32px"
|
|
63
|
+
fontWeight="500"
|
|
64
|
+
>
|
|
65
|
+
{app}
|
|
66
|
+
</Text>
|
|
67
|
+
</Box>
|
|
68
|
+
</FocusRing>
|
|
69
|
+
))}
|
|
70
|
+
</Inline>
|
|
71
|
+
<Heading level="h400">
|
|
72
|
+
Icon Buttons with <Code>InteractionSurface</Code>
|
|
73
|
+
</Heading>
|
|
74
|
+
<Inline gap="sp-200" testId="icon-buttons">
|
|
75
|
+
<FocusRing>
|
|
76
|
+
<Box
|
|
77
|
+
as="button"
|
|
78
|
+
backgroundColor={['brand.bold', 'pink']}
|
|
79
|
+
onClick={() => console.log('hello')}
|
|
80
|
+
borderRadius="normal"
|
|
81
|
+
position="relative"
|
|
82
|
+
padding="sp-50"
|
|
83
|
+
>
|
|
84
|
+
<InteractionSurface />
|
|
85
|
+
<WarningIcon
|
|
86
|
+
label="icon button"
|
|
87
|
+
primaryColor={token('color.icon.inverse')}
|
|
88
|
+
secondaryColor={token('color.background.brand.bold')}
|
|
89
|
+
/>
|
|
90
|
+
</Box>
|
|
91
|
+
</FocusRing>
|
|
92
|
+
<FocusRing>
|
|
93
|
+
<Box
|
|
94
|
+
as="button"
|
|
95
|
+
backgroundColor={['neutral', 'pink']}
|
|
96
|
+
onClick={() => console.log('hello')}
|
|
97
|
+
borderRadius="normal"
|
|
98
|
+
position="relative"
|
|
99
|
+
padding="sp-50"
|
|
100
|
+
>
|
|
101
|
+
<InteractionSurface />
|
|
102
|
+
|
|
103
|
+
<WarningIcon label="icon button" />
|
|
104
|
+
</Box>
|
|
105
|
+
</FocusRing>
|
|
106
|
+
<FocusRing>
|
|
107
|
+
<Box
|
|
108
|
+
as="button"
|
|
109
|
+
backgroundColor={['warning.bold', 'pink']}
|
|
110
|
+
onClick={() => console.log('hello')}
|
|
111
|
+
borderRadius="normal"
|
|
112
|
+
position="relative"
|
|
113
|
+
padding="sp-50"
|
|
114
|
+
>
|
|
115
|
+
<InteractionSurface />
|
|
116
|
+
<WarningIcon
|
|
117
|
+
label="icon button"
|
|
118
|
+
primaryColor={token('color.icon.warning.inverse')}
|
|
119
|
+
secondaryColor={token('color.background.warning.bold')}
|
|
120
|
+
/>
|
|
121
|
+
</Box>
|
|
122
|
+
</FocusRing>
|
|
123
|
+
</Inline>
|
|
124
|
+
<Heading level="h400">
|
|
125
|
+
Progress Indicator with <Code>InteractionSurface</Code>
|
|
126
|
+
</Heading>
|
|
127
|
+
<Inline gap="sp-200" testId="progress-indicators">
|
|
128
|
+
{(['brand.bold', 'neutral', 'warning.bold'] as const).map((app) => (
|
|
129
|
+
<FocusRing>
|
|
130
|
+
<Box
|
|
131
|
+
key={app}
|
|
132
|
+
as="button"
|
|
133
|
+
backgroundColor={[app, 'pink']}
|
|
134
|
+
onClick={() => console.log('hello')}
|
|
135
|
+
borderRadius="rounded"
|
|
136
|
+
position="relative"
|
|
137
|
+
padding="sp-50"
|
|
138
|
+
>
|
|
139
|
+
<InteractionSurface />
|
|
140
|
+
</Box>
|
|
141
|
+
</FocusRing>
|
|
142
|
+
))}
|
|
143
|
+
</Inline>
|
|
144
|
+
<Heading level="h400">Textfield / input spikes</Heading>
|
|
145
|
+
<Inline gap="sp-200">
|
|
146
|
+
<Textfield />
|
|
147
|
+
<Box
|
|
148
|
+
as="fieldset"
|
|
149
|
+
borderRadius="normal"
|
|
150
|
+
borderStyle="solid"
|
|
151
|
+
borderWidth="2px"
|
|
152
|
+
padding="sp-100"
|
|
153
|
+
tabIndex={-1}
|
|
154
|
+
borderColor={['color.border', '#ddd']}
|
|
155
|
+
backgroundColor={['input', '#eee']}
|
|
156
|
+
css={fieldsetStyles}
|
|
157
|
+
>
|
|
158
|
+
<input
|
|
159
|
+
id="textfield"
|
|
160
|
+
pattern="[\d+]"
|
|
161
|
+
style={{
|
|
162
|
+
padding: 0,
|
|
163
|
+
border: 'none',
|
|
164
|
+
fontSize: 14,
|
|
165
|
+
background: 'transparent',
|
|
166
|
+
appearance: 'none',
|
|
167
|
+
outline: 'none',
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
</Box>
|
|
171
|
+
</Inline>
|
|
172
|
+
</Stack>
|
|
173
|
+
</Box>
|
|
174
|
+
);
|
|
175
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/ds-explorations",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "An experimental package for exploration and validation of spacing / typography foundations.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "Design System Team",
|
|
8
8
|
"inPublicMirror": false,
|
|
9
|
-
"releaseModel": "
|
|
9
|
+
"releaseModel": "scheduled"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/tokens": "^0.10.3",
|
|
31
31
|
"@babel/runtime": "^7.0.0",
|
|
32
|
-
"@emotion/
|
|
32
|
+
"@emotion/react": "^11.7.1",
|
|
33
|
+
"tiny-invariant": "^1.2.0"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"react": "^16.8.0"
|
|
@@ -38,13 +39,16 @@
|
|
|
38
39
|
"@af/codegen": "*",
|
|
39
40
|
"@atlaskit/badge": "*",
|
|
40
41
|
"@atlaskit/button": "*",
|
|
42
|
+
"@atlaskit/code": "*",
|
|
41
43
|
"@atlaskit/docs": "*",
|
|
42
44
|
"@atlaskit/ds-lib": "*",
|
|
45
|
+
"@atlaskit/focus-ring": "*",
|
|
43
46
|
"@atlaskit/heading": "*",
|
|
44
47
|
"@atlaskit/icon": "*",
|
|
45
48
|
"@atlaskit/lozenge": "*",
|
|
46
49
|
"@atlaskit/section-message": "*",
|
|
47
50
|
"@atlaskit/ssr": "*",
|
|
51
|
+
"@atlaskit/textfield": "*",
|
|
48
52
|
"@atlaskit/visual-regression": "*",
|
|
49
53
|
"@atlaskit/webdriver-runner": "*",
|
|
50
54
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
@@ -70,7 +74,6 @@
|
|
|
70
74
|
],
|
|
71
75
|
"ui-components": "lite-mode",
|
|
72
76
|
"analytics": "analytics-next",
|
|
73
|
-
"theming": "tokens",
|
|
74
77
|
"deprecation": "no-deprecated-imports"
|
|
75
78
|
}
|
|
76
79
|
},
|
|
@@ -94,7 +94,7 @@ exports[`@atlaskit/design-system-explorations bg styles are generated correctly
|
|
|
94
94
|
}),
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
type BackgroundColor = keyof typeof backgroundColorMap;
|
|
97
|
+
export type BackgroundColor = keyof typeof backgroundColorMap;
|
|
98
98
|
"
|
|
99
99
|
`;
|
|
100
100
|
|
|
@@ -141,7 +141,168 @@ exports[`@atlaskit/design-system-explorations border styles are generated correc
|
|
|
141
141
|
}),
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
type BorderColor = keyof typeof borderColorMap;
|
|
144
|
+
export type BorderColor = keyof typeof borderColorMap;
|
|
145
|
+
"
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
exports[`@atlaskit/design-system-explorations border styles are generated correctly 2`] = `
|
|
149
|
+
"const backgroundActiveColorMap = {
|
|
150
|
+
'inverse.subtle': css({
|
|
151
|
+
':active': {
|
|
152
|
+
backgroundColor: token('color.background.inverse.subtle.pressed'),
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
input: css({
|
|
156
|
+
':active': { backgroundColor: token('color.background.input.pressed') },
|
|
157
|
+
}),
|
|
158
|
+
neutral: css({
|
|
159
|
+
':active': { backgroundColor: token('color.background.neutral.pressed') },
|
|
160
|
+
}),
|
|
161
|
+
'neutral.subtle': css({
|
|
162
|
+
':active': {
|
|
163
|
+
backgroundColor: token('color.background.neutral.subtle.pressed'),
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
'neutral.bold': css({
|
|
167
|
+
':active': {
|
|
168
|
+
backgroundColor: token('color.background.neutral.bold.pressed'),
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
171
|
+
'brand.bold': css({
|
|
172
|
+
':active': {
|
|
173
|
+
backgroundColor: token('color.background.brand.bold.pressed'),
|
|
174
|
+
},
|
|
175
|
+
}),
|
|
176
|
+
selected: css({
|
|
177
|
+
':active': { backgroundColor: token('color.background.selected.pressed') },
|
|
178
|
+
}),
|
|
179
|
+
'selected.bold': css({
|
|
180
|
+
':active': {
|
|
181
|
+
backgroundColor: token('color.background.selected.bold.pressed'),
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
danger: css({
|
|
185
|
+
':active': { backgroundColor: token('color.background.danger.pressed') },
|
|
186
|
+
}),
|
|
187
|
+
'danger.bold': css({
|
|
188
|
+
':active': {
|
|
189
|
+
backgroundColor: token('color.background.danger.bold.pressed'),
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
warning: css({
|
|
193
|
+
':active': { backgroundColor: token('color.background.warning.pressed') },
|
|
194
|
+
}),
|
|
195
|
+
'warning.bold': css({
|
|
196
|
+
':active': {
|
|
197
|
+
backgroundColor: token('color.background.warning.bold.pressed'),
|
|
198
|
+
},
|
|
199
|
+
}),
|
|
200
|
+
success: css({
|
|
201
|
+
':active': { backgroundColor: token('color.background.success.pressed') },
|
|
202
|
+
}),
|
|
203
|
+
'success.bold': css({
|
|
204
|
+
':active': {
|
|
205
|
+
backgroundColor: token('color.background.success.bold.pressed'),
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
208
|
+
discovery: css({
|
|
209
|
+
':active': { backgroundColor: token('color.background.discovery.pressed') },
|
|
210
|
+
}),
|
|
211
|
+
'discovery.bold': css({
|
|
212
|
+
':active': {
|
|
213
|
+
backgroundColor: token('color.background.discovery.bold.pressed'),
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
information: css({
|
|
217
|
+
':active': {
|
|
218
|
+
backgroundColor: token('color.background.information.pressed'),
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
'information.bold': css({
|
|
222
|
+
':active': {
|
|
223
|
+
backgroundColor: token('color.background.information.bold.pressed'),
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const backgroundHoverColorMap = {
|
|
229
|
+
'inverse.subtle': css({
|
|
230
|
+
':hover': {
|
|
231
|
+
backgroundColor: token('color.background.inverse.subtle.hovered'),
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
input: css({
|
|
235
|
+
':hover': { backgroundColor: token('color.background.input.hovered') },
|
|
236
|
+
}),
|
|
237
|
+
neutral: css({
|
|
238
|
+
':hover': { backgroundColor: token('color.background.neutral.hovered') },
|
|
239
|
+
}),
|
|
240
|
+
'neutral.subtle': css({
|
|
241
|
+
':hover': {
|
|
242
|
+
backgroundColor: token('color.background.neutral.subtle.hovered'),
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
'neutral.bold': css({
|
|
246
|
+
':hover': {
|
|
247
|
+
backgroundColor: token('color.background.neutral.bold.hovered'),
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
'brand.bold': css({
|
|
251
|
+
':hover': { backgroundColor: token('color.background.brand.bold.hovered') },
|
|
252
|
+
}),
|
|
253
|
+
selected: css({
|
|
254
|
+
':hover': { backgroundColor: token('color.background.selected.hovered') },
|
|
255
|
+
}),
|
|
256
|
+
'selected.bold': css({
|
|
257
|
+
':hover': {
|
|
258
|
+
backgroundColor: token('color.background.selected.bold.hovered'),
|
|
259
|
+
},
|
|
260
|
+
}),
|
|
261
|
+
danger: css({
|
|
262
|
+
':hover': { backgroundColor: token('color.background.danger.hovered') },
|
|
263
|
+
}),
|
|
264
|
+
'danger.bold': css({
|
|
265
|
+
':hover': {
|
|
266
|
+
backgroundColor: token('color.background.danger.bold.hovered'),
|
|
267
|
+
},
|
|
268
|
+
}),
|
|
269
|
+
warning: css({
|
|
270
|
+
':hover': { backgroundColor: token('color.background.warning.hovered') },
|
|
271
|
+
}),
|
|
272
|
+
'warning.bold': css({
|
|
273
|
+
':hover': {
|
|
274
|
+
backgroundColor: token('color.background.warning.bold.hovered'),
|
|
275
|
+
},
|
|
276
|
+
}),
|
|
277
|
+
success: css({
|
|
278
|
+
':hover': { backgroundColor: token('color.background.success.hovered') },
|
|
279
|
+
}),
|
|
280
|
+
'success.bold': css({
|
|
281
|
+
':hover': {
|
|
282
|
+
backgroundColor: token('color.background.success.bold.hovered'),
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
discovery: css({
|
|
286
|
+
':hover': { backgroundColor: token('color.background.discovery.hovered') },
|
|
287
|
+
}),
|
|
288
|
+
'discovery.bold': css({
|
|
289
|
+
':hover': {
|
|
290
|
+
backgroundColor: token('color.background.discovery.bold.hovered'),
|
|
291
|
+
},
|
|
292
|
+
}),
|
|
293
|
+
information: css({
|
|
294
|
+
':hover': {
|
|
295
|
+
backgroundColor: token('color.background.information.hovered'),
|
|
296
|
+
},
|
|
297
|
+
}),
|
|
298
|
+
'information.bold': css({
|
|
299
|
+
':hover': {
|
|
300
|
+
backgroundColor: token('color.background.information.bold.hovered'),
|
|
301
|
+
},
|
|
302
|
+
}),
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
type InteractionBackgroundColor = keyof typeof backgroundHoverColorMap;
|
|
145
306
|
"
|
|
146
307
|
`;
|
|
147
308
|
|
|
@@ -188,6 +349,6 @@ exports[`@atlaskit/design-system-explorations text styles are generated correctl
|
|
|
188
349
|
}),
|
|
189
350
|
};
|
|
190
351
|
|
|
191
|
-
type TextColor = keyof typeof textColorMap;
|
|
352
|
+
export type TextColor = keyof typeof textColorMap;
|
|
192
353
|
"
|
|
193
354
|
`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createColorStylesFromTemplate } from '../color-codegen-template';
|
|
2
|
+
import { createInteractionStylesFromTemplate } from '../interaction-codegen';
|
|
2
3
|
describe('@atlaskit/design-system-explorations', () => {
|
|
3
4
|
test('text styles are generated correctly', () => {
|
|
4
5
|
expect(createColorStylesFromTemplate('text')).toMatchSnapshot();
|
|
@@ -12,6 +13,10 @@ describe('@atlaskit/design-system-explorations', () => {
|
|
|
12
13
|
expect(createColorStylesFromTemplate('border')).toMatchSnapshot();
|
|
13
14
|
});
|
|
14
15
|
|
|
16
|
+
test('border styles are generated correctly', () => {
|
|
17
|
+
expect(createInteractionStylesFromTemplate('background')).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
15
20
|
test('incorrect config throws', () => {
|
|
16
21
|
expect(() =>
|
|
17
22
|
createColorStylesFromTemplate('fizzbuzz' as any),
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
2
3
|
import { join } from 'path';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { createPartialSignedArtifact } from '@af/codegen';
|
|
5
|
+
import { createPartialSignedArtifact, createSignedArtifact } from '@af/codegen';
|
|
7
6
|
|
|
8
7
|
import { createColorStylesFromTemplate } from './color-codegen-template';
|
|
8
|
+
import { createColorMapTemplate } from './color-map-template';
|
|
9
|
+
import { createInteractionStylesFromTemplate } from './interaction-codegen';
|
|
9
10
|
import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
|
|
10
11
|
|
|
12
|
+
writeFile(
|
|
13
|
+
join(__dirname, '../', 'src', 'internal', 'color-map.tsx'),
|
|
14
|
+
createSignedArtifact(
|
|
15
|
+
createColorMapTemplate(),
|
|
16
|
+
'yarn codegen-styles',
|
|
17
|
+
'Some artifact',
|
|
18
|
+
),
|
|
19
|
+
).then(() => console.log('color-map.tsx written!'));
|
|
20
|
+
|
|
11
21
|
// generate colors
|
|
12
22
|
Promise.all(
|
|
13
23
|
[{ target: 'text.partial.tsx' }, { target: 'box.partial.tsx' }].map(
|
|
@@ -25,23 +35,45 @@ Promise.all(
|
|
|
25
35
|
);
|
|
26
36
|
},
|
|
27
37
|
),
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
)
|
|
39
|
+
.then(() => {
|
|
40
|
+
// generate spacing values
|
|
41
|
+
return Promise.all(
|
|
42
|
+
[
|
|
43
|
+
{ target: 'box.partial.tsx' },
|
|
44
|
+
{ target: 'stack.partial.tsx' },
|
|
45
|
+
{ target: 'inline.partial.tsx' },
|
|
46
|
+
].map(({ target }) => {
|
|
47
|
+
const targetPath = join(__dirname, '../', 'src', 'components', target);
|
|
48
|
+
|
|
49
|
+
const source = createPartialSignedArtifact(
|
|
50
|
+
(options) => options.map(createSpacingStylesFromTemplate).join('\n'),
|
|
51
|
+
'yarn codegen-styles',
|
|
52
|
+
{ id: 'spacing', absoluteFilePath: targetPath },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return writeFile(targetPath, source).then(() =>
|
|
56
|
+
console.log(`${targetPath} written!`),
|
|
57
|
+
);
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
})
|
|
61
|
+
.then(() => {
|
|
62
|
+
const targetPath = join(
|
|
63
|
+
__dirname,
|
|
64
|
+
'../',
|
|
65
|
+
'src',
|
|
66
|
+
'components',
|
|
67
|
+
'interaction-surface.partial.tsx',
|
|
68
|
+
);
|
|
36
69
|
|
|
37
70
|
const source = createPartialSignedArtifact(
|
|
38
|
-
(options) => options.map(
|
|
71
|
+
(options) => options.map(createInteractionStylesFromTemplate).join('\n'),
|
|
39
72
|
'yarn codegen-styles',
|
|
40
|
-
{ id: '
|
|
73
|
+
{ id: 'interactions', absoluteFilePath: targetPath },
|
|
41
74
|
);
|
|
42
75
|
|
|
43
76
|
return writeFile(targetPath, source).then(() =>
|
|
44
77
|
console.log(`${targetPath} written!`),
|
|
45
78
|
);
|
|
46
79
|
});
|
|
47
|
-
});
|