@bitrise/bitkit 9.13.1 → 9.14.0-alpha-chakra.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.13.1",
4
+ "version": "9.14.0-alpha-chakra.2",
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.3.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.0",
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.44",
86
- "@types/react-dom": "^17.0.16",
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.22.0",
92
- "@typescript-eslint/parser": "^5.22.0",
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.14.0",
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.3.1",
111
+ "eslint-plugin-testing-library": "^5.5.0",
111
112
  "fscreen": "^1.2.0",
112
- "glob": "^8.0.1",
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.0"
135
+ "webpack": "^5.72.1"
135
136
  },
136
137
  "files": [
137
138
  "src",
@@ -15,4 +15,5 @@ WithProps.args = sortObjectByKey({
15
15
  children: 'Button',
16
16
  isDanger: false,
17
17
  isDisabled: false,
18
+ isLoading: false,
18
19
  });
@@ -1,9 +1,37 @@
1
+ const disabledStates = {
2
+ primary: {
3
+ _disabled: {
4
+ bgGradient: 'linear(to-b, neutral.80, neutral.70)',
5
+ borderColor: 'neutral.70',
6
+ },
7
+ },
8
+ secondary: {
9
+ _disabled: {
10
+ bgGradient: 'linear(to-b, neutral.100, neutral.93)',
11
+ borderColor: 'neutral.90',
12
+ color: 'neutral.70',
13
+ },
14
+ },
15
+ tertiary: {
16
+ _disabled: {
17
+ background: 'transparent',
18
+ borderColor: 'transparent',
19
+ color: 'neutral.70',
20
+ },
21
+ },
22
+ };
23
+
1
24
  const ButtonTheme = {
2
25
  baseStyle: {
3
26
  border: '0.0625rem solid',
4
27
  borderRadius: '4',
5
28
  _disabled: {
6
- pointerEvents: 'none',
29
+ cursor: 'not-allowed',
30
+ },
31
+ _hover: {
32
+ _disabled: {
33
+ bg: 'initial',
34
+ },
7
35
  },
8
36
  },
9
37
  variants: {
@@ -14,14 +42,13 @@ const ButtonTheme = {
14
42
  fontWeight: 'bold',
15
43
  _hover: {
16
44
  bgGradient: 'linear(to-b, purple.30, purple.10)',
45
+ ...disabledStates.primary,
17
46
  },
18
47
  _active: {
19
48
  bgGradient: 'linear(to-b, purple.10, purple.10)',
49
+ ...disabledStates.primary,
20
50
  },
21
- _disabled: {
22
- bgGradient: 'linear(to-b, neutral.80, neutral.70)',
23
- borderColor: 'neutral.70',
24
- },
51
+ ...disabledStates.primary,
25
52
  },
26
53
  secondary: {
27
54
  bgGradient: 'linear(to-b, neutral.100, neutral.93)',
@@ -29,14 +56,14 @@ const ButtonTheme = {
29
56
  color: 'purple.10',
30
57
  _hover: {
31
58
  bgGradient: 'linear(to-b, neutral.93, neutral.93)',
59
+ ...disabledStates.secondary,
32
60
  },
33
61
  _active: {
34
62
  bgGradient: 'linear(to-b, neutral.90, neutral.90)',
35
63
  borderColor: 'neutral.80',
64
+ ...disabledStates.secondary,
36
65
  },
37
- _disabled: {
38
- color: 'neutral.70',
39
- },
66
+ ...disabledStates.secondary,
40
67
  },
41
68
  tertiary: {
42
69
  background: 'transparent',
@@ -45,14 +72,14 @@ const ButtonTheme = {
45
72
  _hover: {
46
73
  background: 'neutral.93',
47
74
  borderColor: 'neutral.93',
75
+ ...disabledStates.tertiary,
48
76
  },
49
77
  _active: {
50
78
  background: 'neutral.90',
51
79
  borderColor: 'neutral.90',
80
+ ...disabledStates.tertiary,
52
81
  },
53
- _disabled: {
54
- color: 'neutral.70',
55
- },
82
+ ...disabledStates.tertiary,
56
83
  },
57
84
  'primary--danger': {
58
85
  bgGradient: 'linear(to-b, red.50, red.30)',
@@ -62,15 +89,14 @@ const ButtonTheme = {
62
89
  _hover: {
63
90
  bgGradient: 'linear(to-b, red.40, red.20)',
64
91
  borderColor: 'red.40',
92
+ ...disabledStates.primary,
65
93
  },
66
94
  _active: {
67
95
  bgGradient: 'linear(to-b, red.20, red.20)',
68
96
  borderColor: 'red.20',
97
+ ...disabledStates.primary,
69
98
  },
70
- _disabled: {
71
- bgGradient: 'linear(to-b, neutral.80, neutral.70)',
72
- borderColor: 'neutral.70',
73
- },
99
+ ...disabledStates.primary,
74
100
  },
75
101
  'secondary--danger': {
76
102
  bgGradient: 'linear(to-b, neutral.100, neutral.93)',
@@ -79,14 +105,14 @@ const ButtonTheme = {
79
105
  _hover: {
80
106
  bgGradient: 'linear(to-b, red.93, red.93)',
81
107
  borderColor: 'red.70',
108
+ ...disabledStates.secondary,
82
109
  },
83
110
  _active: {
84
111
  bgGradient: 'linear(to-b, red.90, red.90)',
85
112
  borderColor: 'red.70',
113
+ ...disabledStates.secondary,
86
114
  },
87
- _disabled: {
88
- color: 'neutral.70',
89
- },
115
+ ...disabledStates.secondary,
90
116
  },
91
117
  'tertiary--danger': {
92
118
  background: 'transparent',
@@ -95,14 +121,14 @@ const ButtonTheme = {
95
121
  _hover: {
96
122
  background: 'red.93',
97
123
  borderColor: 'red.93',
124
+ ...disabledStates.tertiary,
98
125
  },
99
126
  _active: {
100
127
  background: 'red.90',
101
128
  borderColor: 'red.90',
129
+ ...disabledStates.tertiary,
102
130
  },
103
- _disabled: {
104
- color: 'neutral.70',
105
- },
131
+ ...disabledStates.tertiary,
106
132
  },
107
133
  },
108
134
  sizes: {
@@ -16,13 +16,17 @@ export interface ButtonProps extends ChakraButtonProps {
16
16
  * The Button component is used to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.
17
17
  */
18
18
  const Button = forwardRef<ButtonProps, 'button'>((props, ref) => {
19
- const { as, isDanger, leftIconName, rightIconName, size, variant, ...rest } = props;
19
+ const { as, isDanger, isDisabled, leftIconName, rightIconName, size, variant, ...rest } = props;
20
20
  const properties: ChakraButtonProps = {
21
21
  as,
22
+ isDisabled,
22
23
  size,
23
24
  variant: isDanger ? `${variant}--danger` : variant,
24
25
  ...rest,
25
26
  };
27
+ if (isDisabled) {
28
+ properties.as = 'button';
29
+ }
26
30
  if (leftIconName) {
27
31
  properties.leftIcon = <Icon name={leftIconName} />;
28
32
  }
@@ -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
- backgroundColor: 'neutral.100',
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
- backgroundColor: 'neutral.93',
18
+ bg: 'neutral.95',
19
19
  boxShadow: 'none',
20
20
  },
21
21
  _active: {
22
- backgroundColor: 'neutral.90',
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/index.ts CHANGED
@@ -28,3 +28,9 @@ export { default as Card } from './Components/Card/Card';
28
28
 
29
29
  export type { CardContentProps } from './Components/Card/CardContent';
30
30
  export { default as CardContent } from './Components/Card/CardContent';
31
+
32
+ export type { SelectProps } from './Components/Select/Select';
33
+ export { default as Select } from './Components/Select/Select';
34
+
35
+ export type { DropdownProps } from './Components/Dropdown/Dropdown';
36
+ export { default as Dropdown } from './Components/Dropdown/Dropdown';
package/src/old.ts CHANGED
@@ -61,9 +61,6 @@ export { default as DatePicker } from './Old/DatePicker/DatePicker';
61
61
  export type { Props as DotProps } from './Old/Dot/Dot';
62
62
  export { default as Dot } from './Old/Dot/Dot';
63
63
 
64
- export type { Props as DropdownProps } from './Old/Dropdown/Dropdown';
65
- export { default as Dropdown } from './Old/Dropdown/Dropdown';
66
-
67
64
  export type { Props as DropdownButtonProps } from './Old/Dropdown/DropdownButton';
68
65
  export { default as DropdownButton } from './Old/Dropdown/DropdownButton';
69
66
 
@@ -165,9 +162,6 @@ export { default as Portal } from './Old/Portal/Portal';
165
162
  export type { Props as ProgressBarProps } from './Old/Progress/ProgressBar';
166
163
  export { default as ProgressBar } from './Old/Progress/ProgressBar';
167
164
 
168
- export type { Props as ProgressButtonProps } from './Old/Progress/ProgressButton';
169
- export { default as ProgressButton } from './Old/Progress/ProgressButton';
170
-
171
165
  export type { Props as ProgressBitbotProps } from './Old/Progress/ProgressBitbot';
172
166
  export { default as ProgressBitbot } from './Old/Progress/ProgressBitbot';
173
167
 
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
  };