@bitrise/bitkit 9.13.2 → 9.14.0-alpha-chakra.1
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/package.json +12 -11
- package/src/Components/Dropdown/Dropdown.stories.tsx +59 -0
- package/src/Components/Dropdown/Dropdown.styles.ts +73 -0
- package/src/Components/Dropdown/Dropdown.tsx +46 -0
- package/src/Components/Menu/Menu.theme.ts +3 -3
- package/src/Components/Select/Select.stories.tsx +38 -0
- package/src/Components/Select/Select.theme.ts +51 -0
- package/src/Components/Select/Select.tsx +17 -0
- package/src/theme.ts +2 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit",
|
|
3
3
|
"description": "Bitrise React component library",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.14.0-alpha-chakra.1",
|
|
5
5
|
"repository": "git@github.com:bitrise-io/bitkit.git",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"@juggle/resize-observer": "^3.3.1",
|
|
39
39
|
"@popperjs/core": "^2.11.5",
|
|
40
40
|
"@types/react-transition-group": "^4.4.4",
|
|
41
|
+
"chakra-react-select": "3.3.3",
|
|
41
42
|
"classnames": "^2.3.1",
|
|
42
43
|
"clipboard": "^2.0.11",
|
|
43
44
|
"framer-motion": "^6.3.3",
|
|
44
|
-
"luxon": "^2.
|
|
45
|
+
"luxon": "^2.4.0",
|
|
45
46
|
"react": "^17.0.2",
|
|
46
47
|
"react-dom": "^17.0.2",
|
|
47
48
|
"react-popper": "^2.3.0",
|
|
@@ -77,19 +78,19 @@
|
|
|
77
78
|
"@types/clipboard": "^2.0.1",
|
|
78
79
|
"@types/enzyme": "^3.10.12",
|
|
79
80
|
"@types/fscreen": "^1.0.1",
|
|
80
|
-
"@types/jest": "^27.5.
|
|
81
|
+
"@types/jest": "^27.5.1",
|
|
81
82
|
"@types/lodash.sample": "^4.2.7",
|
|
82
83
|
"@types/lodash.shuffle": "^4.2.7",
|
|
83
84
|
"@types/luxon": "^2.3.2",
|
|
84
85
|
"@types/prismjs": "^1.26.0",
|
|
85
|
-
"@types/react": "17.0.
|
|
86
|
-
"@types/react-dom": "^17.0.
|
|
86
|
+
"@types/react": "17.0.45",
|
|
87
|
+
"@types/react-dom": "^17.0.17",
|
|
87
88
|
"@types/react-router": "^5.1.18",
|
|
88
89
|
"@types/react-router-dom": "^5.3.3",
|
|
89
90
|
"@types/react-transition-group": "^4.4.4",
|
|
90
91
|
"@types/vfile-message": "^2.0.0",
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
92
|
-
"@typescript-eslint/parser": "^5.
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
|
93
|
+
"@typescript-eslint/parser": "^5.23.0",
|
|
93
94
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
|
|
94
95
|
"axios": "^0.27.2",
|
|
95
96
|
"babel-eslint": "^10.0.1",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
"concurrently": "^7.1.0",
|
|
100
101
|
"enzyme": "^3.11.0",
|
|
101
102
|
"enzyme-to-json": "^3.6.2",
|
|
102
|
-
"eslint": "^8.
|
|
103
|
+
"eslint": "^8.15.0",
|
|
103
104
|
"eslint-plugin-import": "^2.26.0",
|
|
104
105
|
"eslint-plugin-jest": "^26.1.5",
|
|
105
106
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
@@ -107,9 +108,9 @@
|
|
|
107
108
|
"eslint-plugin-react": "^7.29.4",
|
|
108
109
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
109
110
|
"eslint-plugin-storybook": "^0.5.11",
|
|
110
|
-
"eslint-plugin-testing-library": "^5.
|
|
111
|
+
"eslint-plugin-testing-library": "^5.5.0",
|
|
111
112
|
"fscreen": "^1.2.0",
|
|
112
|
-
"glob": "^8.0.
|
|
113
|
+
"glob": "^8.0.2",
|
|
113
114
|
"husky": "^7.0.4",
|
|
114
115
|
"identity-obj-proxy": "^3.0.0",
|
|
115
116
|
"jest": "^27.5.1",
|
|
@@ -131,7 +132,7 @@
|
|
|
131
132
|
"ts-node": "^10.7.0",
|
|
132
133
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
133
134
|
"typescript": "^4.6.4",
|
|
134
|
-
"webpack": "^5.72.
|
|
135
|
+
"webpack": "^5.72.1"
|
|
135
136
|
},
|
|
136
137
|
"files": [
|
|
137
138
|
"src",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { sortObjectByKey } from '../../utils/storyUtils';
|
|
3
|
+
import Dropdown from './Dropdown';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Dropdown',
|
|
7
|
+
component: Dropdown,
|
|
8
|
+
argTypes: {
|
|
9
|
+
onChange: {
|
|
10
|
+
action: 'onChange event',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
} as ComponentMeta<typeof Dropdown>;
|
|
14
|
+
|
|
15
|
+
const buildStatusOptions = [
|
|
16
|
+
{ value: 'all', label: 'All status' },
|
|
17
|
+
{ value: 'successful', label: 'Successful' },
|
|
18
|
+
{ value: 'failed', label: 'Failed' },
|
|
19
|
+
{ value: 'aborted', label: 'Aborted' },
|
|
20
|
+
{
|
|
21
|
+
value: 'on_hold',
|
|
22
|
+
label:
|
|
23
|
+
'On hold, but has a really long label text for test blah blah lorem ipsum dolor sit amet blah blah lorem ipsum dolor sit amet blah blah lorem ipsum dolor sit amet blah blah lorem ipsum dolor sit amet blah blah lorem ipsum dolor sit amet',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const flavorOptions = [
|
|
28
|
+
{ value: 'vanilla', label: 'Vanilla' },
|
|
29
|
+
{ value: 'chocolate', label: 'Chocolate' },
|
|
30
|
+
{ value: 'strawberry', label: 'Strawberry' },
|
|
31
|
+
{ value: 'salted-caramel', label: 'Salted Caramel' },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const groupedOptions = [
|
|
35
|
+
{
|
|
36
|
+
label: 'Build status',
|
|
37
|
+
options: buildStatusOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: 'Flavours',
|
|
41
|
+
options: flavorOptions,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const Template: ComponentStory<typeof Dropdown> = (props) => <Dropdown {...props} />;
|
|
46
|
+
|
|
47
|
+
export const WithProps = Template.bind({});
|
|
48
|
+
WithProps.args = sortObjectByKey({
|
|
49
|
+
...Dropdown.defaultProps,
|
|
50
|
+
options: buildStatusOptions,
|
|
51
|
+
placeholder: 'Select build status',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const WithOptionGroups = Template.bind({});
|
|
55
|
+
WithOptionGroups.args = sortObjectByKey({
|
|
56
|
+
...Dropdown.defaultProps,
|
|
57
|
+
options: groupedOptions,
|
|
58
|
+
placeholder: 'Select something 🤔',
|
|
59
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ChakraStylesConfig } from 'chakra-react-select';
|
|
2
|
+
import SelectTheme from '../Select/Select.theme';
|
|
3
|
+
|
|
4
|
+
const controlTextStyle = {
|
|
5
|
+
cursor: 'default',
|
|
6
|
+
maxWidth: 'calc(100% - 3rem)',
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
textOverflow: 'ellipsis',
|
|
10
|
+
top: '50%',
|
|
11
|
+
transform: 'translateY(-50%)',
|
|
12
|
+
whiteSpace: 'nowrap',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getDropdownStyles = (size: 'small' | 'medium'): ChakraStylesConfig => ({
|
|
16
|
+
container: (_provided, state) => ({
|
|
17
|
+
borderRadius: '4',
|
|
18
|
+
boxShadow: state.isFocused ? 'outline' : 'none',
|
|
19
|
+
position: 'relative',
|
|
20
|
+
}),
|
|
21
|
+
control: () => ({
|
|
22
|
+
display: 'flex',
|
|
23
|
+
...SelectTheme.baseStyle.field,
|
|
24
|
+
...SelectTheme.sizes[size].field,
|
|
25
|
+
}),
|
|
26
|
+
dropdownIndicator: () => ({
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
right: '7px',
|
|
29
|
+
top: '50%',
|
|
30
|
+
transform: 'translateY(-50%)',
|
|
31
|
+
}),
|
|
32
|
+
groupHeading: () => ({
|
|
33
|
+
display: 'flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
gap: '16',
|
|
36
|
+
color: 'neutral.50',
|
|
37
|
+
fontSize: '2',
|
|
38
|
+
lineHeight: '3',
|
|
39
|
+
paddingX: '16',
|
|
40
|
+
paddingY: '12',
|
|
41
|
+
textTransform: 'uppercase',
|
|
42
|
+
_after: {
|
|
43
|
+
content: `''`,
|
|
44
|
+
flex: 1,
|
|
45
|
+
height: '1px',
|
|
46
|
+
bg: 'neutral.90',
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
menu: () => ({
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
transform: 'translateY(8px)',
|
|
52
|
+
width: '100%',
|
|
53
|
+
}),
|
|
54
|
+
menuList: (provided) => ({
|
|
55
|
+
...provided,
|
|
56
|
+
borderRadius: '4',
|
|
57
|
+
}),
|
|
58
|
+
option: (provided) => ({
|
|
59
|
+
...provided,
|
|
60
|
+
padding: '12',
|
|
61
|
+
}),
|
|
62
|
+
placeholder: () => ({
|
|
63
|
+
color: 'text.secondary',
|
|
64
|
+
...controlTextStyle,
|
|
65
|
+
}),
|
|
66
|
+
singleValue: () => controlTextStyle,
|
|
67
|
+
valueContainer: () => ({
|
|
68
|
+
display: 'flex',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export default getDropdownStyles;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { chakraComponents, ChakraStylesConfig, DropdownIndicatorProps, OptionProps, Select } from 'chakra-react-select';
|
|
3
|
+
import Icon from '@/Old/Icon/Icon';
|
|
4
|
+
import getDropdownStyles from './Dropdown.styles';
|
|
5
|
+
|
|
6
|
+
export interface DropdownProps {
|
|
7
|
+
defaultValue?: OptionProps;
|
|
8
|
+
options: OptionProps[];
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
onChange?: () => void;
|
|
11
|
+
size?: 'small' | 'medium';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const components = {
|
|
15
|
+
DropdownIndicator: (props: DropdownIndicatorProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<chakraComponents.DropdownIndicator {...props}>
|
|
18
|
+
<Icon name="DropdownArrows" />
|
|
19
|
+
</chakraComponents.DropdownIndicator>
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Dropdown = (props: DropdownProps) => {
|
|
25
|
+
const { defaultValue, onChange, options, placeholder, size = 'medium' } = props;
|
|
26
|
+
const chakraStyles: ChakraStylesConfig = getDropdownStyles(size);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Select
|
|
30
|
+
chakraStyles={chakraStyles}
|
|
31
|
+
components={components}
|
|
32
|
+
defaultValue={defaultValue}
|
|
33
|
+
isSearchable={false}
|
|
34
|
+
onChange={onChange}
|
|
35
|
+
options={options}
|
|
36
|
+
placeholder={placeholder}
|
|
37
|
+
selectedOptionStyle="check"
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Dropdown.defaultProps = {
|
|
43
|
+
size: 'medium',
|
|
44
|
+
} as DropdownProps;
|
|
45
|
+
|
|
46
|
+
export default Dropdown;
|
|
@@ -3,7 +3,7 @@ import type { SystemStyleObject } from '@chakra-ui/theme-tools';
|
|
|
3
3
|
const MenuTheme: SystemStyleObject = {
|
|
4
4
|
baseStyle: {
|
|
5
5
|
list: {
|
|
6
|
-
|
|
6
|
+
bg: 'neutral.100',
|
|
7
7
|
border: '1px solid',
|
|
8
8
|
borderColor: 'neutral.93',
|
|
9
9
|
borderRadius: '4',
|
|
@@ -15,11 +15,11 @@ const MenuTheme: SystemStyleObject = {
|
|
|
15
15
|
padding: '12',
|
|
16
16
|
paddingRight: '16',
|
|
17
17
|
_focus: {
|
|
18
|
-
|
|
18
|
+
bg: 'neutral.95',
|
|
19
19
|
boxShadow: 'none',
|
|
20
20
|
},
|
|
21
21
|
_active: {
|
|
22
|
-
|
|
22
|
+
bg: 'neutral.93',
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
},
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { sortObjectByKey } from '../../utils/storyUtils';
|
|
3
|
+
import Select from './Select';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Select',
|
|
7
|
+
component: Select,
|
|
8
|
+
argTypes: {
|
|
9
|
+
onChange: {
|
|
10
|
+
action: 'onChange event',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
} as ComponentMeta<typeof Select>;
|
|
14
|
+
|
|
15
|
+
const args = {
|
|
16
|
+
...Select.defaultProps,
|
|
17
|
+
isDisabled: false,
|
|
18
|
+
isInvalid: false,
|
|
19
|
+
isRequired: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const children = (
|
|
23
|
+
<>
|
|
24
|
+
<option value="all">All status</option>
|
|
25
|
+
<option value="successful">Successful</option>
|
|
26
|
+
<option value="failed">Failed</option>
|
|
27
|
+
<option value="aborted">Aborted</option>
|
|
28
|
+
<option value="on_hold">On hold</option>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const Template: ComponentStory<typeof Select> = (props) => <Select {...props}>{children}</Select>;
|
|
33
|
+
|
|
34
|
+
export const WithProps = Template.bind({});
|
|
35
|
+
WithProps.args = sortObjectByKey({
|
|
36
|
+
...args,
|
|
37
|
+
placeholder: 'Select build status',
|
|
38
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const SelectTheme = {
|
|
2
|
+
baseStyle: {
|
|
3
|
+
field: {
|
|
4
|
+
appearance: 'none',
|
|
5
|
+
bgGradient: 'linear(to-b, neutral.100, neutral.93)',
|
|
6
|
+
border: '0.0625rem solid',
|
|
7
|
+
borderColor: 'neutral.90',
|
|
8
|
+
borderRadius: '4',
|
|
9
|
+
color: 'purple.10',
|
|
10
|
+
position: 'relative',
|
|
11
|
+
width: '100%',
|
|
12
|
+
_hover: {
|
|
13
|
+
bgGradient: 'linear(to-b, neutral.93, neutral.93)',
|
|
14
|
+
},
|
|
15
|
+
_active: {
|
|
16
|
+
bgGradient: 'linear(to-b, neutral.90, neutral.90)',
|
|
17
|
+
borderColor: 'neutral.80',
|
|
18
|
+
},
|
|
19
|
+
_disabled: {
|
|
20
|
+
color: 'neutral.70',
|
|
21
|
+
pointerEvents: 'none',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
icon: {
|
|
25
|
+
right: '8',
|
|
26
|
+
_disabled: {
|
|
27
|
+
opacity: '0.2',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
sizes: {
|
|
32
|
+
small: {
|
|
33
|
+
field: {
|
|
34
|
+
height: '32',
|
|
35
|
+
fontSize: '2',
|
|
36
|
+
paddingLeft: '12',
|
|
37
|
+
paddingRight: '32',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
medium: {
|
|
41
|
+
field: {
|
|
42
|
+
height: '48',
|
|
43
|
+
fontSize: '3',
|
|
44
|
+
paddingLeft: '16',
|
|
45
|
+
paddingRight: '32',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default SelectTheme;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Select as ChakraSelect, SelectProps as ChakraSelectProps } from '@chakra-ui/react';
|
|
3
|
+
import Icon from '@/Old/Icon/Icon';
|
|
4
|
+
|
|
5
|
+
export interface SelectProps extends ChakraSelectProps {
|
|
6
|
+
size?: 'small' | 'medium';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Select = (props: SelectProps) => {
|
|
10
|
+
return <ChakraSelect icon={<Icon name="DropdownArrows" />} variant="select" {...props} />;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
Select.defaultProps = {
|
|
14
|
+
size: 'medium',
|
|
15
|
+
} as SelectProps;
|
|
16
|
+
|
|
17
|
+
export default Select;
|
package/src/theme.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Card from './Components/Card/Card.theme';
|
|
|
3
3
|
import Divider from './Components/Divider/Divider.theme';
|
|
4
4
|
import Link from './Components/Link/Link.theme';
|
|
5
5
|
import Menu from './Components/Menu/Menu.theme';
|
|
6
|
+
import Select from './Components/Select/Select.theme';
|
|
6
7
|
import Text from './Components/Text/Text.theme';
|
|
7
8
|
|
|
8
9
|
import colors from './Foundations/Colors/Colors';
|
|
@@ -50,6 +51,7 @@ const theme = {
|
|
|
50
51
|
Divider,
|
|
51
52
|
Link,
|
|
52
53
|
Menu,
|
|
54
|
+
Select,
|
|
53
55
|
Text,
|
|
54
56
|
},
|
|
55
57
|
};
|