@bitrise/bitkit 9.14.0 → 9.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.14.0",
4
+ "version": "9.15.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.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",
@@ -0,0 +1,69 @@
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
+ args: {
9
+ isDisabled: false,
10
+ isLoading: false,
11
+ },
12
+ argTypes: {
13
+ onChange: {
14
+ action: 'onChange event',
15
+ },
16
+ size: {
17
+ options: ['small', 'medium'],
18
+ control: {
19
+ type: 'radio',
20
+ },
21
+ },
22
+ },
23
+ } as ComponentMeta<typeof Dropdown>;
24
+
25
+ const buildStatusOptions = [
26
+ { value: 'all', label: 'All status' },
27
+ { value: 'successful', label: 'Successful' },
28
+ { value: 'failed', label: 'Failed' },
29
+ { value: 'aborted', label: 'Aborted' },
30
+ {
31
+ value: 'on_hold',
32
+ label:
33
+ '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',
34
+ },
35
+ ];
36
+
37
+ const flavorOptions = [
38
+ { value: 'vanilla', label: 'Vanilla' },
39
+ { value: 'chocolate', label: 'Chocolate' },
40
+ { value: 'strawberry', label: 'Strawberry' },
41
+ { value: 'salted-caramel', label: 'Salted Caramel' },
42
+ ];
43
+
44
+ const groupedOptions = [
45
+ {
46
+ label: 'Build status',
47
+ options: buildStatusOptions,
48
+ },
49
+ {
50
+ label: 'Flavours',
51
+ options: flavorOptions,
52
+ },
53
+ ];
54
+
55
+ const Template: ComponentStory<typeof Dropdown> = (props) => <Dropdown {...props} />;
56
+
57
+ export const WithProps = Template.bind({});
58
+ WithProps.args = sortObjectByKey({
59
+ ...Dropdown.defaultProps,
60
+ options: buildStatusOptions,
61
+ placeholder: 'Select build status',
62
+ });
63
+
64
+ export const WithOptionGroups = Template.bind({});
65
+ WithOptionGroups.args = sortObjectByKey({
66
+ ...Dropdown.defaultProps,
67
+ options: groupedOptions,
68
+ placeholder: 'Select something 🤔',
69
+ });
@@ -0,0 +1,82 @@
1
+ import { ChakraStylesConfig } from 'chakra-react-select';
2
+ import type { SystemStyleObject } from '@chakra-ui/theme-tools';
3
+ import SelectTheme from '../Select/Select.theme';
4
+
5
+ const controlTextStyle = {
6
+ cursor: 'default',
7
+ maxWidth: 'calc(100% - 3rem)',
8
+ overflow: 'hidden',
9
+ position: 'absolute',
10
+ textOverflow: 'ellipsis',
11
+ top: '50%',
12
+ transform: 'translateY(-50%)',
13
+ whiteSpace: 'nowrap',
14
+ };
15
+
16
+ const getDropdownStyles = (size: 'small' | 'medium', additionalStyle?: SystemStyleObject): ChakraStylesConfig => ({
17
+ container: (_provided, state) => ({
18
+ borderRadius: '4',
19
+ boxShadow: state.isFocused ? 'outline' : 'none',
20
+ position: 'relative',
21
+ zIndex: state.isFocused ? '1' : '0',
22
+ ...additionalStyle,
23
+ }),
24
+ control: () => ({
25
+ display: 'flex',
26
+ ...SelectTheme.baseStyle.field,
27
+ ...SelectTheme.sizes[size].field,
28
+ paddingRight: '8',
29
+ }),
30
+ groupHeading: () => ({
31
+ display: 'flex',
32
+ alignItems: 'center',
33
+ gap: '16',
34
+ color: 'neutral.50',
35
+ fontSize: '2',
36
+ lineHeight: '3',
37
+ paddingX: '16',
38
+ paddingY: '12',
39
+ textTransform: 'uppercase',
40
+ _after: {
41
+ content: `''`,
42
+ flex: 1,
43
+ height: '1px',
44
+ bg: 'neutral.90',
45
+ },
46
+ }),
47
+ indicatorsContainer: (provided) => ({
48
+ ...provided,
49
+ width: '100%',
50
+ alignItems: 'center',
51
+ justifyContent: 'flex-end',
52
+ }),
53
+ loadingIndicator: () => ({
54
+ color: 'neutral.70',
55
+ width: '16',
56
+ height: '16',
57
+ marginRight: '8',
58
+ }),
59
+ menu: () => ({
60
+ position: 'absolute',
61
+ transform: 'translateY(8px)',
62
+ width: '100%',
63
+ }),
64
+ menuList: (provided) => ({
65
+ ...provided,
66
+ borderRadius: '4',
67
+ }),
68
+ option: (provided) => ({
69
+ ...provided,
70
+ padding: '12',
71
+ }),
72
+ placeholder: () => ({
73
+ ...controlTextStyle,
74
+ }),
75
+ singleValue: () => controlTextStyle,
76
+ valueContainer: () => ({
77
+ display: 'flex',
78
+ alignItems: 'center',
79
+ }),
80
+ });
81
+
82
+ export default getDropdownStyles;
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { chakraComponents, ChakraStylesConfig, DropdownIndicatorProps, Props, Select } from 'chakra-react-select';
3
+ import type { SystemStyleObject } from '@chakra-ui/theme-tools';
4
+ import Icon from '../../Old/Icon/Icon';
5
+ import getDropdownStyles from './Dropdown.styles';
6
+
7
+ export type DropdownProps = Omit<Props, 'defaultValue' | 'onChange'> & {
8
+ defaultValue?: any;
9
+ onChange?: ((newValue: any) => void) | undefined;
10
+ size?: 'small' | 'medium';
11
+ style?: SystemStyleObject;
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, isDisabled, isLoading, onChange, options, placeholder, size = 'medium', style } = props;
26
+ const chakraStyles: ChakraStylesConfig = getDropdownStyles(size, style);
27
+
28
+ const defaultValueWithLabel = defaultValue;
29
+
30
+ if (!defaultValue?.label && defaultValue?.text) {
31
+ defaultValueWithLabel.label = defaultValue.text;
32
+ }
33
+
34
+ const mappedOptions = options?.map((opt: any) => {
35
+ if (!opt.label && opt.text) {
36
+ return {
37
+ ...opt,
38
+ label: opt.text,
39
+ };
40
+ }
41
+ return opt;
42
+ });
43
+
44
+ const properties: Props = {
45
+ chakraStyles,
46
+ components,
47
+ defaultValue,
48
+ isDisabled: isDisabled || isLoading,
49
+ isLoading,
50
+ isSearchable: false,
51
+ onChange,
52
+ options: mappedOptions,
53
+ placeholder,
54
+ selectedOptionStyle: 'check',
55
+ };
56
+
57
+ return <Select {...properties} />;
58
+ };
59
+
60
+ Dropdown.defaultProps = {
61
+ size: 'medium',
62
+ } as DropdownProps;
63
+
64
+ 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;
@@ -4,7 +4,7 @@ import './Base.css';
4
4
 
5
5
  export type TypeBorderRadius = 'x1' | 'x2' | 'x4' | 'rounded';
6
6
 
7
- const newToOld = {
7
+ export const newToOld = {
8
8
  'neutral.100': 'white',
9
9
  'neutral.10': 'black',
10
10
  'neutral.95': 'gray-1',
@@ -54,7 +54,7 @@ const newToOld = {
54
54
  'red.95': 'red-95',
55
55
  'orange-3': 'orange-3',
56
56
  'turquoise.40': 'turquoise-40',
57
- };
57
+ } as const;
58
58
 
59
59
  export type TypeColors = keyof typeof newToOld;
60
60
 
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { colorMap } from '../variables';
4
- import Base, { Props as BaseProps, TypeColors } from '../Base/Base';
4
+ import Base, { newToOld, Props as BaseProps, TypeColors } from '../Base/Base';
5
5
  import './ProgressBar.css';
6
6
 
7
7
  export interface Props extends BaseProps {
@@ -37,9 +37,7 @@ const ProgressBar: React.FunctionComponent<Props> = (props: Props) => {
37
37
  height={height}
38
38
  style={{
39
39
  '--ProgressBar--height': height,
40
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
- /* @ts-ignore */
42
- '--ProgressBar--stripe-color': stripeColor ? colorMap[stripeColor] : '',
40
+ '--ProgressBar--stripe-color': stripeColor ? colorMap[newToOld[stripeColor]] : '',
43
41
  }}
44
42
  >
45
43
  <Base
@@ -17,11 +17,11 @@
17
17
  background:
18
18
  linear-gradient(
19
19
  to left,
20
- rgba(var(--Skeleton--color), 0),
21
- rgba(var(--Skeleton--color), 0.63) 35%,
22
- rgba(var(--Skeleton--color), 1) 48%,
23
- rgba(var(--Skeleton--color), 0.57) 55%,
24
- rgba(var(--Skeleton--color), 0)
20
+ rgba(255,255, 255, 0),
21
+ rgba(255,255, 255, 0.63) 35%,
22
+ rgba(255,255, 255, 1) 48%,
23
+ rgba(255,255, 255, 0.57) 55%,
24
+ rgba(255,255, 255, 0)
25
25
  );
26
26
  pointer-events: none;
27
27
  }
@@ -1,14 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import classnames from 'classnames';
3
- import Base, { Props as BaseProps, TypeColors } from '../Base/Base';
4
- import { rgbMap } from '../variables';
3
+ import Base, { Props as BaseProps } from '../Base/Base';
5
4
  import './Skeleton.css';
6
5
 
7
6
  export interface Props extends BaseProps {
8
7
  /** Flag to enable/disable the loading behaviour */
9
8
  active?: boolean;
10
- /** Color of the Skeleton */
11
- color?: TypeColors;
12
9
  }
13
10
 
14
11
  /**
@@ -17,19 +14,12 @@ export interface Props extends BaseProps {
17
14
  * it is not restricted to just skeleton components.
18
15
  */
19
16
  const Skeleton: React.FunctionComponent<Props> = (props: Props) => {
20
- const { active, color = 'neutral.100', ...rest } = props;
21
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
- /* @ts-ignore */
23
- const rgb = rgbMap[color];
17
+ const { active, ...rest } = props;
24
18
  const classes = classnames('Skeleton', {
25
19
  'Skeleton--active': active,
26
20
  });
27
21
 
28
- return <Base {...rest} className={classes} style={{ '--Skeleton--color': rgb.toString() }} />;
29
- };
30
-
31
- Skeleton.defaultProps = {
32
- color: 'neutral.100',
22
+ return <Base {...rest} className={classes} />;
33
23
  };
34
24
 
35
25
  export default Skeleton;
@@ -1,3 +1,4 @@
1
+ import colors from '../Foundations/Colors/Colors';
1
2
  import { IconList } from './Icon/tsx';
2
3
 
3
4
  export const colorWhite = '#FFFFFF';
@@ -204,7 +205,11 @@ export const colorMap = {
204
205
  'violet-3': colorViolet3,
205
206
  'violet-4': colorViolet4,
206
207
  'violet-5': colorViolet5,
207
- };
208
+
209
+ 'blue-95': colors.blue[95],
210
+ 'red-95': colors.red[95],
211
+ 'turquoise-40': colors.turquoise[40],
212
+ } as const;
208
213
 
209
214
  export const rgbMap = {
210
215
  white: rgbWhite,
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,8 +61,7 @@ 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';
64
+ export type { Props as OldDropdownProps } from './Old/Dropdown/Dropdown';
66
65
 
67
66
  export type { Props as DropdownButtonProps } from './Old/Dropdown/DropdownButton';
68
67
  export { default as DropdownButton } from './Old/Dropdown/DropdownButton';
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
  };