@bitrise/bitkit 13.110.0 → 13.111.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.110.0",
4
+ "version": "13.111.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -0,0 +1,96 @@
1
+ import Box, { BoxProps } from '../Box/Box';
2
+ import Icon, { TypeIconName } from '../Icon/Icon';
3
+ import Tooltip, { TooltipProps } from '../Tooltip/Tooltip';
4
+ import Text, { TextProps } from '../Text/Text';
5
+
6
+ export interface LabeledDataProps extends BoxProps {
7
+ as?: 'div' | 'dl';
8
+ data: string;
9
+ label: string;
10
+ secondaryLabel?: string;
11
+ size?: 'sm' | 'md' | 'lg';
12
+ tooltip?: Omit<TooltipProps, 'children'>;
13
+ trend?: 'positive' | 'negative' | 'neutral';
14
+ trendColorScheme?: 'red' | 'green' | 'grey';
15
+ trendValue?: string;
16
+ }
17
+
18
+ const LabeledData = ({
19
+ as = 'div',
20
+ data,
21
+ label,
22
+ secondaryLabel,
23
+ size = 'sm',
24
+ tooltip,
25
+ trend,
26
+ trendValue,
27
+ trendColorScheme,
28
+ ...rest
29
+ }: LabeledDataProps): JSX.Element => {
30
+ const trendIconSize = size === 'sm' ? '16' : '24';
31
+ const trendSign = trend === 'negative' ? '-' : '+';
32
+ const labelColor = size === 'sm' ? 'text/primary' : 'text/secondary';
33
+
34
+ let trendIconName: TypeIconName | undefined;
35
+ switch (trend) {
36
+ case 'positive':
37
+ trendIconName = 'ArrowUp';
38
+ break;
39
+ case 'negative':
40
+ trendIconName = 'ArrowDown';
41
+ break;
42
+ case 'neutral':
43
+ trendIconName = 'MinusClose';
44
+ break;
45
+ }
46
+
47
+ let trendIconColor: string | undefined;
48
+ let trendColor: TextProps['color'] | undefined;
49
+ switch (trendColorScheme) {
50
+ case 'red':
51
+ trendColor = 'text/negative';
52
+ trendIconColor = 'icon/negative';
53
+ break;
54
+ case 'green':
55
+ trendIconColor = 'icon/positive';
56
+ trendColor = 'text/positive';
57
+ break;
58
+ default:
59
+ trendColor = 'text/secondary';
60
+ trendIconColor = 'icon/tertiary';
61
+ }
62
+
63
+ return (
64
+ <Box as={as} display="flex" flexDirection="column" gap="4" {...rest}>
65
+ <Box as="dt" display="flex" alignItems="center" gap="4" color={labelColor} textStyle="comp/input/label">
66
+ {label}
67
+ {tooltip && (
68
+ <Tooltip {...tooltip}>
69
+ <Icon color="icon.tertiary" name="InfoCircle" size="16" />
70
+ </Tooltip>
71
+ )}
72
+ </Box>
73
+ <Box as="dd" display="flex" alignItems="center" gap="4" color="text/body" textStyle={`comp/data/${size}`}>
74
+ {data}
75
+ {trendIconName && trendValue && <Icon color={trendIconColor} name={trendIconName} size={trendIconSize} />}
76
+ </Box>
77
+ {((trendSign && trendValue) || !!secondaryLabel) && (
78
+ <Box as="dd" display="flex" gap="4" color={trendColor} textStyle="body/md/regular">
79
+ {trendSign && trendValue && (
80
+ <>
81
+ {trendSign}
82
+ {trendValue}
83
+ </>
84
+ )}
85
+ {secondaryLabel && (
86
+ <Text as="span" color="text/tertiary">
87
+ {secondaryLabel}
88
+ </Text>
89
+ )}
90
+ </Box>
91
+ )}
92
+ </Box>
93
+ );
94
+ };
95
+
96
+ export default LabeledData;
@@ -0,0 +1,8 @@
1
+ import { forwardRef } from '@chakra-ui/react';
2
+ import Box, { BoxProps } from '../Box/Box';
3
+
4
+ const LabeledDataList = forwardRef<BoxProps, 'dl'>((props, ref) => {
5
+ return <Box as="dl" ref={ref} {...props} />;
6
+ });
7
+
8
+ export default LabeledDataList;
package/src/index.ts CHANGED
@@ -166,6 +166,9 @@ export { default as AccordionItem } from './Components/Accordion/AccordionItem';
166
166
  export type { LightBoxProps } from './Components/LightBox/LightBox';
167
167
  export { default as LightBox } from './Components/LightBox/LightBox';
168
168
 
169
+ export type { LabeledDataProps } from './Components/LabeledData/LabeledData';
170
+ export { default as LabeledData } from './Components/LabeledData/LabeledData';
171
+
169
172
  export type { AspectRatioProps } from './Components/AspectRatio/AspectRatio';
170
173
  export { default as AspectRatio } from './Components/AspectRatio/AspectRatio';
171
174