@bitrise/bitkit 12.19.0 → 12.20.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": "12.19.0",
4
+ "version": "12.20.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -39,6 +39,7 @@ const DrawerTheme = defineMultiStyleConfig({
39
39
  fontSize: '1',
40
40
  lineHeight: '1rem',
41
41
  textTransform: 'uppercase',
42
+ fontWeight: 'bold',
42
43
  },
43
44
  footer: {
44
45
  marginTop: 'auto',
@@ -0,0 +1,104 @@
1
+ import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
2
+ import { rem } from '../../utils/utils';
3
+
4
+ const { defineMultiStyleConfig, definePartsStyle } = createMultiStyleConfigHelpers([
5
+ 'container',
6
+ 'icon',
7
+ 'label',
8
+ 'closeButton',
9
+ 'skeleton',
10
+ ]);
11
+
12
+ const sizes = {
13
+ sm: definePartsStyle({
14
+ container: {
15
+ paddingX: rem(7),
16
+ paddingY: rem(1),
17
+ },
18
+ label: {
19
+ fontSize: '1',
20
+ lineHeight: rem(16),
21
+ },
22
+ closeButton: {
23
+ height: '20',
24
+ width: '20',
25
+ marginRight: rem(-6),
26
+ },
27
+ }),
28
+ md: definePartsStyle({
29
+ container: {
30
+ paddingX: rem(11),
31
+ paddingY: rem(3),
32
+ },
33
+ label: {
34
+ fontSize: '2',
35
+ lineHeight: rem(24),
36
+ },
37
+ closeButton: {
38
+ height: '24',
39
+ width: '24',
40
+ marginRight: rem(-7),
41
+ },
42
+ }),
43
+ };
44
+
45
+ const baseStyle = definePartsStyle(({ colorScheme }) => {
46
+ const scheme = {
47
+ color: `${colorScheme}.40`,
48
+ backgroundColor: `${colorScheme}.93`,
49
+ borderColor: `${colorScheme}.80`,
50
+ };
51
+ if (colorScheme === 'neutral') {
52
+ scheme.color = 'purple.10';
53
+ }
54
+ return {
55
+ container: {
56
+ border: '1px solid',
57
+ borderRadius: '4',
58
+ ...scheme,
59
+ _disabled: {
60
+ cursor: 'not-allowed',
61
+ backgroundColor: 'neutral.95',
62
+ borderColor: 'neutral.90',
63
+ color: 'neutral.80',
64
+ },
65
+ _loading: {
66
+ cursor: 'wait',
67
+ backgroundColor: 'neutral.93',
68
+ borderColor: 'neutral.93',
69
+ color: 'neutral.60',
70
+ },
71
+ },
72
+ icon: {
73
+ marginInlineEnd: '4',
74
+ },
75
+ label: {
76
+ display: 'inline',
77
+ },
78
+ closeButton: {
79
+ marginInlineStart: '4',
80
+ borderRadius: rem(2),
81
+ _hover: {
82
+ backgroundColor: `${colorScheme}.90`,
83
+ },
84
+ _focus: {
85
+ boxShadow: '0 0 0 1px var(--colors-purple-70) inset',
86
+ },
87
+ _disabled: {
88
+ pointerEvents: 'none',
89
+ },
90
+ },
91
+ skeleton: {
92
+ minWidth: '32',
93
+ height: '8',
94
+ backgroundColor: 'neutral.80',
95
+ },
96
+ };
97
+ });
98
+
99
+ const TagTheme = defineMultiStyleConfig({
100
+ baseStyle,
101
+ sizes,
102
+ });
103
+
104
+ export default TagTheme;
@@ -0,0 +1,56 @@
1
+ import { Tag as ChakraTag, TagCloseButton, TagProps as ChakraTagProps, useMultiStyleConfig } from '@chakra-ui/react';
2
+ import Icon from '../Icon/Icon';
3
+ import Skeleton from '../Skeleton/Skeleton';
4
+ import SkeletonBox from '../Skeleton/SkeletonBox';
5
+ import Text from '../Text/Text';
6
+ import Tooltip from '../Tooltip/Tooltip';
7
+
8
+ export interface TagProps extends Omit<ChakraTagProps, 'colorScheme' | 'size' | 'variant'> {
9
+ closeButtonTooltip?: string;
10
+ colorScheme?: 'neutral' | 'blue' | 'green' | 'red' | 'yellow' | 'purple';
11
+ isDisabled?: boolean;
12
+ isLoading?: boolean;
13
+ onClose?: () => void;
14
+ size?: 'sm' | 'md';
15
+ withIcon?: boolean;
16
+ }
17
+
18
+ const Tag = (props: TagProps) => {
19
+ const { children, closeButtonTooltip, isDisabled, isLoading, onClose, withIcon, ...tagProps } = props;
20
+ const style = useMultiStyleConfig('Tag', tagProps);
21
+
22
+ return (
23
+ <ChakraTag
24
+ aria-disabled={isDisabled}
25
+ data-disabled={isDisabled || undefined}
26
+ aria-busy={isLoading}
27
+ data-loading={isLoading || undefined}
28
+ {...tagProps}
29
+ >
30
+ {withIcon && <Icon name="Tick" size={tagProps.size === 'sm' ? '16' : '24'} __css={style.icon} />}
31
+ <Text as="span" hasEllipsis sx={style.label}>
32
+ {isLoading ? (
33
+ <Skeleton isActive>
34
+ <SkeletonBox sx={style.skeleton} />
35
+ </Skeleton>
36
+ ) : (
37
+ children
38
+ )}
39
+ </Text>
40
+ {!!onClose && (
41
+ <Tooltip isDisabled={!closeButtonTooltip} label={closeButtonTooltip}>
42
+ <TagCloseButton isDisabled={isDisabled || isLoading} onClick={onClose}>
43
+ <Icon name="CloseSmall" size="16" />
44
+ </TagCloseButton>
45
+ </Tooltip>
46
+ )}
47
+ </ChakraTag>
48
+ );
49
+ };
50
+
51
+ Tag.defaultProps = {
52
+ colorScheme: 'neutral',
53
+ size: 'md',
54
+ };
55
+
56
+ export default Tag;
package/src/index.ts CHANGED
@@ -282,3 +282,6 @@ export { default as ClickableRow } from './Components/Table/ClickableRow';
282
282
 
283
283
  export type { SelectableRowProps } from './Components/Table/SelectableRow';
284
284
  export { default as SelectableRow } from './Components/Table/SelectableRow';
285
+
286
+ export type { TagProps } from './Components/Tag/Tag';
287
+ export { default as Tag } from './Components/Tag/Tag';
package/src/theme.ts CHANGED
@@ -35,6 +35,7 @@ import Slider from './Components/Slider/Slider.theme';
35
35
  import Sidebar from './Components/Sidebar/Sidebar.theme';
36
36
  import SidebarItem from './Components/Sidebar/SidebarItem.theme';
37
37
  import ContentSwitcher from './Components/ContentSwitcher/ContentSwitcher.theme';
38
+ import Tag from './Components/Tag/Tag.theme';
38
39
 
39
40
  import breakpoints from './Foundations/Breakpoints/Breakpoints';
40
41
  import colors from './Foundations/Colors/Colors';
@@ -117,6 +118,7 @@ const theme = {
117
118
  Progress: ProgressBar,
118
119
  Slider,
119
120
  ContentSwitcher,
121
+ Tag,
120
122
  },
121
123
  };
122
124