@bitrise/bitkit 11.4.2 → 11.6.0

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": "11.4.2",
4
+ "version": "11.6.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -4,7 +4,10 @@ import {
4
4
  usePrefersReducedMotion,
5
5
  } from '@chakra-ui/react';
6
6
 
7
- export type AccordionProps = Omit<ChakraAccordionProps, 'onChange' | 'defaultIndex'> & {
7
+ export type AccordionButtonSize = 'sm' | 'md';
8
+
9
+ export type AccordionProps = Omit<ChakraAccordionProps, 'defaultIndex'> & {
10
+ buttonSize?: AccordionButtonSize;
8
11
  defaultIndex: number[];
9
12
  };
10
13
 
@@ -13,12 +16,13 @@ export type AccordionProps = Omit<ChakraAccordionProps, 'onChange' | 'defaultInd
13
16
  */
14
17
  const Accordion = (props: AccordionProps) => {
15
18
  const prefersReducedMotion = usePrefersReducedMotion({ ssr: false });
16
- const { children, colorScheme, defaultIndex, variant, ...rest } = props;
19
+ const { buttonSize = 'md', children, colorScheme, defaultIndex, variant, ...rest } = props;
17
20
 
18
21
  return (
19
22
  <ChakraAccordion
20
23
  allowMultiple
21
24
  allowToggle
25
+ buttonSize={buttonSize}
22
26
  colorScheme={colorScheme}
23
27
  variant={variant}
24
28
  reduceMotion={prefersReducedMotion}
@@ -1,6 +1,7 @@
1
1
  import { StyleFunctionProps } from '@chakra-ui/styled-system';
2
2
  import type { ComponentStyleConfig } from '@chakra-ui/theme';
3
3
  import { CSSObject } from '@emotion/react';
4
+ import { AccordionButtonSize } from '../Accordion/Accordion';
4
5
 
5
6
  type ColorObj = {
6
7
  [key: string]: {
@@ -126,7 +127,12 @@ const LegacyBaseStyle: ({ colorScheme, variant }: Pick<StyleFunctionProps, 'colo
126
127
  },
127
128
  });
128
129
 
129
- const BaseStyle: () => CSSObject = () => ({
130
+ const buttonPaddingBlockSizes: Record<AccordionButtonSize, string> = {
131
+ sm: '12',
132
+ md: '20',
133
+ };
134
+
135
+ const BaseStyle: (buttonSize: AccordionButtonSize) => CSSObject = (buttonSize) => ({
130
136
  item: {
131
137
  borderTop: '1px solid',
132
138
  borderTopColor: 'neutral.90',
@@ -137,7 +143,7 @@ const BaseStyle: () => CSSObject = () => ({
137
143
  justifyContent: 'space-between',
138
144
  width: '100%',
139
145
  paddingInline: '16',
140
- paddingBlock: '20',
146
+ paddingBlock: buttonPaddingBlockSizes[buttonSize],
141
147
  borderColor: 'neutral.93',
142
148
  _hover: {
143
149
  background: 'neutral.93',
@@ -162,8 +168,10 @@ const BaseStyle: () => CSSObject = () => ({
162
168
  });
163
169
 
164
170
  const AccordionTheme: ComponentStyleConfig = {
165
- baseStyle: ({ colorScheme, variant }) => {
166
- return variant === 'legacy' || variant === 'flat' ? LegacyBaseStyle({ colorScheme, variant }) : BaseStyle();
171
+ baseStyle: ({ buttonSize, colorScheme, variant }) => {
172
+ return variant === 'legacy' || variant === 'flat'
173
+ ? LegacyBaseStyle({ colorScheme, variant })
174
+ : BaseStyle(buttonSize);
167
175
  },
168
176
  };
169
177
 
@@ -0,0 +1,18 @@
1
+ import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
2
+ import Box from '../../Box/Box';
3
+
4
+ const WarningColored = forwardRef<IconProps, 'svg'>((props, ref) => (
5
+ <Icon ref={ref} viewBox="0 0 16 16" {...props}>
6
+ <Box
7
+ as="path"
8
+ fillRule="evenodd"
9
+ clipRule="evenodd"
10
+ d="M14.5334 12.7348L9.20415 2.07627C8.87107 1.41011 8.07168 1.14364 7.40552 1.47672C7.20567 1.60995 7.00582 1.8098 6.87259 2.07627L1.47671 12.7348C1.14363 13.401 1.41009 14.2004 2.07625 14.5334C2.2761 14.6 2.47595 14.6667 2.67579 14.6667H13.3343C14.0671 14.6667 14.6666 14.0671 14.6666 13.3343C14.6666 13.1345 14.6 12.9347 14.5334 12.7348Z"
11
+ fill="yellow.80"
12
+ />
13
+ <Box as="path" d="M8.66563 5.33333H7.33331V10.0036H8.66563V5.33333Z" fill="purple.10" />
14
+ <Box as="path" d="M8.66563 11.3333V12.6656H7.33331V11.3333H8.66563Z" fill="purple.10" />
15
+ </Icon>
16
+ ));
17
+
18
+ export default WarningColored;
@@ -188,6 +188,7 @@ export { default as Twitter } from './Twitter';
188
188
  export { default as ValidateShield } from './ValidateShield';
189
189
  export { default as Video } from './Video';
190
190
  export { default as Warning } from './Warning';
191
+ export { default as WarningColored } from './WarningColored';
191
192
  export { default as WebUi } from './WebUi';
192
193
  export { default as Webhooks } from './Webhooks';
193
194
  export { default as Webinar } from './Webinar';
@@ -0,0 +1,18 @@
1
+ import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
2
+ import Box from '../../Box/Box';
3
+
4
+ const WarningColored = forwardRef<IconProps, 'svg'>((props, ref) => (
5
+ <Icon ref={ref} viewBox="0 0 24 24" {...props}>
6
+ <Box
7
+ as="path"
8
+ fillRule="evenodd"
9
+ clipRule="evenodd"
10
+ d="M21.8002 19.1022L13.8063 3.11441C13.3066 2.11517 12.1075 1.71547 11.1083 2.21509C10.8085 2.41494 10.5088 2.71471 10.3089 3.11441L2.21509 19.1022C1.71547 20.1014 2.11517 21.3005 3.11441 21.8002C3.41418 21.9001 3.71395 22 4.01372 22H20.0015C21.1007 22 22 21.1007 22 20.0015C22 19.7018 21.9001 19.402 21.8002 19.1022Z"
11
+ fill="yellow.80"
12
+ />
13
+ <Box as="path" d="M12.9985 8H11V15.0053H12.9985V8Z" fill="purple.10" />
14
+ <Box as="path" d="M12.9985 17V18.9985H11V17H12.9985Z" fill="purple.10" />
15
+ </Icon>
16
+ ));
17
+
18
+ export default WarningColored;
@@ -188,6 +188,7 @@ export { default as Twitter } from './Twitter';
188
188
  export { default as ValidateShield } from './ValidateShield';
189
189
  export { default as Video } from './Video';
190
190
  export { default as Warning } from './Warning';
191
+ export { default as WarningColored } from './WarningColored';
191
192
  export { default as WebUi } from './WebUi';
192
193
  export { default as Webhooks } from './Webhooks';
193
194
  export { default as Webinar } from './Webinar';
@@ -0,0 +1,37 @@
1
+ import { Button, TabProps as ChakraTabProps, forwardRef, useTab, useTabsStyles } from '@chakra-ui/react';
2
+ import { TypeColors } from 'src/Foundations/Colors/Colors';
3
+ import Box from '../Box/Box';
4
+ import Icon, { TypeIconName } from '../Icon/Icon';
5
+ import Text from '../Text/Text';
6
+
7
+ export interface ContainedTabProps extends ChakraTabProps {
8
+ id: string;
9
+ iconColor?: TypeColors | 'currentColor';
10
+ iconName?: TypeIconName;
11
+ isWarning?: boolean;
12
+ secondaryText?: string;
13
+ }
14
+
15
+ const ContainedTab = forwardRef<ContainedTabProps, 'button'>((props, ref) => {
16
+ const { iconColor = 'currentColor', iconName, isWarning, secondaryText, ...rest } = props;
17
+ const tabProps = useTab({ ...rest, ref });
18
+ const styles = useTabsStyles();
19
+ return (
20
+ <Button __css={styles.containedTab} {...tabProps}>
21
+ <Box display="flex" gap="16" justifyContent="space-between">
22
+ <Text as="span" fontWeight="bold" hasEllipsis>
23
+ {tabProps.children}
24
+ </Text>
25
+ {isWarning && <Icon name="WarningColored" />}
26
+ {!isWarning && iconName && <Icon color={iconColor} name={iconName} />}
27
+ </Box>
28
+ {secondaryText && (
29
+ <Text as="span" display="block" hasEllipsis size="2">
30
+ {secondaryText}
31
+ </Text>
32
+ )}
33
+ </Button>
34
+ );
35
+ });
36
+
37
+ export default ContainedTab;
@@ -1,11 +1,4 @@
1
- import {
2
- Button,
3
- Tab as ChakraTab,
4
- TabProps as ChakraTabProps,
5
- forwardRef,
6
- useMultiStyleConfig,
7
- useTab,
8
- } from '@chakra-ui/react';
1
+ import { Button, TabProps as ChakraTabProps, forwardRef, useTab, useTabsStyles } from '@chakra-ui/react';
9
2
  import Badge, { BadgeProps } from '../Badge/Badge';
10
3
  import Icon, { TypeIconName } from '../Icon/Icon';
11
4
 
@@ -17,13 +10,12 @@ export interface TabProps extends ChakraTabProps {
17
10
  rightIconName?: TypeIconName;
18
11
  }
19
12
 
20
- const CustomTab = forwardRef((props, ref) => {
13
+ const Tab = forwardRef<TabProps, 'button'>((props, ref) => {
21
14
  const { badge, leftIconName, rightIconName, ...rest } = props;
22
15
  const tabProps = useTab({ ...rest, ref });
23
- const styles = useMultiStyleConfig('Tabs', tabProps);
24
-
16
+ const styles = useTabsStyles();
25
17
  return (
26
- <Button __css={styles.tab} {...tabProps}>
18
+ <Button __css={styles.lineTab} {...tabProps}>
27
19
  {leftIconName && <Icon name={leftIconName} />}
28
20
  <span>{tabProps.children}</span>
29
21
  {badge?.children && <Badge {...badge} />}
@@ -32,13 +24,4 @@ const CustomTab = forwardRef((props, ref) => {
32
24
  );
33
25
  });
34
26
 
35
- const Tab = forwardRef<TabProps, 'div'>((props, ref) => {
36
- const { badge, leftIconName, rightIconName, ...rest } = props;
37
- const properties = rest;
38
- if (badge?.children || leftIconName || rightIconName) {
39
- return <CustomTab {...props} />;
40
- }
41
- return <ChakraTab {...properties} ref={ref} />;
42
- });
43
-
44
27
  export default Tab;
@@ -1,6 +1,52 @@
1
- const TextTheme = {
2
- baseStyle: {
3
- tab: {
1
+ import { defineStyle, defineStyleConfig, SystemStyleObject } from '@chakra-ui/styled-system';
2
+
3
+ const baseStyle = defineStyle(
4
+ ({ variant }): SystemStyleObject => ({
5
+ containedTab: {
6
+ backgroundColor: 'neutral.93',
7
+ paddingX: '16',
8
+ paddingY: '12',
9
+ color: 'neutral.40',
10
+ textAlign: 'left',
11
+ whiteSpace: 'nowrap',
12
+ boxShadow: 'inset 1px 0 0 var(--colors-neutral-80)',
13
+ _selected: {
14
+ backgroundColor: 'neutral.100',
15
+ borderRight: 0,
16
+ boxShadow: 'inset 0 2px var(--colors-purple-50)',
17
+ div: {
18
+ color: 'purple.50',
19
+ },
20
+ _first: {
21
+ boxShadow: 'inset 0 2px var(--colors-purple-50)',
22
+ },
23
+ '+ [role="tab"]': {
24
+ boxShadow: 'none',
25
+ },
26
+ _hover: {
27
+ backgroundColor: 'neutral.100',
28
+ },
29
+ },
30
+ _disabled: {
31
+ backgroundColor: 'neutral.90',
32
+ color: 'neutral.60',
33
+ cursor: 'not-allowed',
34
+ _hover: {
35
+ backgroundColor: 'neutral.90',
36
+ },
37
+ },
38
+ _hover: {
39
+ backgroundColor: 'neutral.95',
40
+ },
41
+ _focusVisible: {
42
+ backgroundColor: 'purple.95',
43
+ color: 'purple.50',
44
+ },
45
+ _first: {
46
+ boxShadow: 'none',
47
+ },
48
+ },
49
+ lineTab: {
4
50
  display: 'flex',
5
51
  alignItems: 'center',
6
52
  justifyContent: 'flex-start',
@@ -8,15 +54,16 @@ const TextTheme = {
8
54
  gap: '8',
9
55
  lineHeight: '1.5rem',
10
56
  paddingX: '16',
11
- paddingTop: '12',
12
- paddingBottom: '10px',
13
- borderBottom: '2px solid',
14
- borderBottomColor: 'transparent',
57
+ paddingY: '12',
15
58
  color: 'neutral.50',
16
59
  fontWeight: 'bold',
60
+ whiteSpace: 'nowrap',
17
61
  _selected: {
18
- borderBottomColor: 'purple.50',
19
62
  color: 'purple.50',
63
+ boxShadow: 'inset 0 -2px var(--colors-purple-50)',
64
+ _hover: {
65
+ backgroundColor: 'transparent',
66
+ },
20
67
  },
21
68
  _focusVisible: {
22
69
  backgroundColor: 'purple.95',
@@ -38,15 +85,22 @@ const TextTheme = {
38
85
  },
39
86
  },
40
87
  tablist: {
41
- borderBottom: '1px solid',
42
- borderBottomColor: 'separator.primary',
88
+ maxWidth: '100%',
89
+ overflow: 'hidden',
90
+ paddingLeft: variant === 'contained' ? '16' : undefined,
91
+ borderBottom: variant === 'line' ? '1px solid' : undefined,
92
+ borderBottomColor: variant === 'line' ? 'separator.primary' : undefined,
43
93
  },
44
94
  tabpanel: {
45
95
  _focusVisible: {
46
96
  boxShadow: 'none',
47
97
  },
48
98
  },
49
- },
50
- };
99
+ }),
100
+ );
101
+
102
+ const TabsTheme = defineStyleConfig({
103
+ baseStyle,
104
+ });
51
105
 
52
- export default TextTheme;
106
+ export default TabsTheme;
@@ -5,6 +5,7 @@ import { useHistory } from '../../hooks';
5
5
  export interface TabsProps extends ChakraTabsProps {
6
6
  defaultTab?: string;
7
7
  onChange?: (index: number, tabId?: string) => void;
8
+ variant?: 'contained' | 'line';
8
9
  withHistory?: boolean;
9
10
  }
10
11