@bitrise/bitkit 13.64.0 → 13.64.3-alpha.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": "13.64.0",
4
+ "version": "13.64.3-alpha.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -1,12 +1,101 @@
1
+ import { SystemStyleObject } from '@chakra-ui/styled-system';
2
+ import { BadgeColorScheme, BadgeProps } from './Badge';
3
+
4
+ const baseStyle: SystemStyleObject = {
5
+ borderRadius: '4',
6
+ display: 'inline-flex',
7
+ gap: '4',
8
+ padding: '4',
9
+ textStyle: 'comp/badge/sm',
10
+ };
11
+
12
+ type ColorsType = Record<'bold' | 'subtle', Record<BadgeColorScheme, Record<'color' | 'backgroundColor', string>>>;
13
+
14
+ const colors: ColorsType = {
15
+ subtle: {
16
+ progress: {
17
+ backgroundColor: 'sys/interactive/subtle',
18
+ color: 'sys/interactive/strong',
19
+ },
20
+ neutral: {
21
+ backgroundColor: 'sys/neutral/subtle',
22
+ color: 'sys/neutral/strong',
23
+ },
24
+ info: {
25
+ backgroundColor: 'sys/info/subtle',
26
+ color: 'sys/info/strong',
27
+ },
28
+ positive: {
29
+ backgroundColor: 'sys/success/subtle',
30
+ color: 'sys/success/strong',
31
+ },
32
+ negative: {
33
+ backgroundColor: 'sys/critical/subtle',
34
+ color: 'sys/critical/strong',
35
+ },
36
+ warning: {
37
+ backgroundColor: 'sys/warning/subtle',
38
+ color: 'sys/warning/strong',
39
+ },
40
+ orange: {
41
+ backgroundColor: 'sys/orange/subtle',
42
+ color: 'sys/orange/strong',
43
+ },
44
+ turquoise: {
45
+ backgroundColor: 'sys/turquoise/subtle',
46
+ color: 'sys/turquoise/strong',
47
+ },
48
+ },
49
+ bold: {
50
+ progress: {
51
+ backgroundColor: 'sys/interactive/bold',
52
+ color: 'text/on-color',
53
+ },
54
+ neutral: {
55
+ backgroundColor: 'sys/neutral/bold',
56
+ color: 'text/on-color',
57
+ },
58
+ info: {
59
+ backgroundColor: 'sys/info/bold',
60
+ color: 'text/on-color',
61
+ },
62
+ positive: {
63
+ backgroundColor: 'sys/success/bold',
64
+ color: 'text/on-color',
65
+ },
66
+ negative: {
67
+ backgroundColor: 'sys/critical/bold',
68
+ color: 'text/on-color',
69
+ },
70
+ warning: {
71
+ backgroundColor: 'sys/warning/muted',
72
+ color: 'text/primary',
73
+ },
74
+ orange: {
75
+ backgroundColor: 'sys/orange/bold',
76
+ color: 'text/on-color',
77
+ },
78
+ turquoise: {
79
+ backgroundColor: 'sys/turquoise/bold',
80
+ color: 'text/on-color',
81
+ },
82
+ },
83
+ };
84
+
85
+ const getVariant = (props: BadgeProps) => {
86
+ const { colorScheme, variant } = props;
87
+ return colors[variant || 'subtle'][colorScheme || 'neutral'];
88
+ };
89
+
1
90
  const BadgeTheme = {
2
- baseStyle: {
3
- borderRadius: '4',
4
- display: 'inline-block',
5
- paddingX: '8',
6
- paddingY: '4',
7
- textStyle: 'comp/badge/sm',
8
- color: 'text/on-color',
9
- backgroundColor: 'sys/primary/base',
91
+ baseStyle,
92
+ variants: {
93
+ bold: getVariant,
94
+ subtle: getVariant,
95
+ },
96
+ defaultProps: {
97
+ variant: 'subtle',
98
+ colorScheme: 'neutral',
10
99
  },
11
100
  };
12
101
 
@@ -1,10 +1,38 @@
1
1
  import { Badge as ChakraBadge, BadgeProps as ChakraBadgeProps, forwardRef } from '@chakra-ui/react';
2
+ import Icon, { TypeIconName } from '../Icon/Icon';
3
+ import Text from '../Text/Text';
2
4
 
3
- export type BadgeProps = ChakraBadgeProps;
5
+ export type BadgeColorScheme =
6
+ | 'neutral'
7
+ | 'info'
8
+ | 'positive'
9
+ | 'negative'
10
+ | 'warning'
11
+ | 'progress'
12
+ | 'orange'
13
+ | 'turquoise';
14
+ export interface BadgeProps extends ChakraBadgeProps {
15
+ children?: string | number;
16
+ colorScheme?: BadgeColorScheme;
17
+ iconName?: TypeIconName;
18
+ variant?: 'bold' | 'subtle';
19
+ }
4
20
 
5
21
  /**
6
22
  * Badges are used to highlight an item's status for quick recognition.
7
23
  */
8
- const Badge = forwardRef<BadgeProps, 'span'>((props, ref) => <ChakraBadge {...props} ref={ref} />);
24
+ const Badge = forwardRef<BadgeProps, 'span'>((props, ref) => {
25
+ const { children, iconName, ...rest } = props;
26
+ return (
27
+ <ChakraBadge {...rest} ref={ref} paddingInlineStart={iconName ? '4' : '8'} paddingInlineEnd={children ? '8' : '4'}>
28
+ {!!iconName && <Icon size="16" name={iconName} />}
29
+ {!!children && (
30
+ <Text hasEllipsis as="span">
31
+ {children}
32
+ </Text>
33
+ )}
34
+ </ChakraBadge>
35
+ );
36
+ });
9
37
 
10
38
  export default Badge;
@@ -45,10 +45,7 @@ const FilterTheme = defineMultiStyleConfig({
45
45
  padding: '16',
46
46
  },
47
47
  formBadge: {
48
- backgroundColor: 'neutral.93',
49
- color: 'neutral.40',
50
48
  fontVariantNumeric: 'tabular-nums',
51
- fontWeight: 'bold',
52
49
  },
53
50
  formButtonGroup: {
54
51
  display: 'flex',
@@ -117,7 +117,11 @@ const FilterForm = (props: FilterFormProps) => {
117
117
  <Text as="h5" sx={filterStyle.formTitle}>
118
118
  {categoryName || category}
119
119
  </Text>
120
- {isMultiple && <Badge sx={filterStyle.formBadge}>{selected[0] === '' ? '0' : selected.length}</Badge>}
120
+ {isMultiple && (
121
+ <Badge variant="subtle" colorScheme="neutral" sx={filterStyle.formBadge}>
122
+ {selected[0] === '' ? '0' : selected.length}
123
+ </Badge>
124
+ )}
121
125
  </Box>
122
126
  {(withSearch || isAsync) && (
123
127
  <SearchInput