@bitrise/bitkit 13.118.0 → 13.119.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.118.0",
4
+ "version": "13.119.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -3,13 +3,17 @@ import Icon, { TypeIconName } from '../Icon/Icon';
3
3
  import { TooltipProps } from '../Tooltip/Tooltip';
4
4
  import Text, { TextProps } from '../Text/Text';
5
5
  import Label from '../Label/Label';
6
+ import Skeleton from '../Skeleton/Skeleton';
7
+ import SkeletonBox from '../Skeleton/SkeletonBox';
6
8
 
7
9
  export interface LabeledDataProps extends BoxProps {
8
10
  as?: 'div' | 'dl';
9
11
  data: string;
12
+ isLoading?: boolean;
10
13
  label: string;
11
14
  secondaryLabel?: string;
12
15
  size?: 'sm' | 'md' | 'lg';
16
+ skeleton?: React.ReactNode;
13
17
  tooltip?: Omit<TooltipProps, 'children'>;
14
18
  trend?: 'positive' | 'negative' | 'neutral';
15
19
  trendColorScheme?: 'red' | 'green' | 'grey';
@@ -19,9 +23,11 @@ export interface LabeledDataProps extends BoxProps {
19
23
  const LabeledData = ({
20
24
  as = 'div',
21
25
  data,
26
+ isLoading = false,
22
27
  label,
23
28
  secondaryLabel,
24
29
  size = 'sm',
30
+ skeleton,
25
31
  tooltip,
26
32
  trend,
27
33
  trendValue,
@@ -32,6 +38,23 @@ const LabeledData = ({
32
38
  const trendSign = trend === 'negative' ? '-' : '+';
33
39
  const labelColor = size === 'sm' ? 'text/primary' : 'text/secondary';
34
40
 
41
+ let dataSkeletonHeight;
42
+ let dataSkeletonPaddingY;
43
+ switch (size) {
44
+ case 'lg':
45
+ dataSkeletonHeight = '30px';
46
+ dataSkeletonPaddingY = '5';
47
+ break;
48
+ case 'md':
49
+ dataSkeletonHeight = '24';
50
+ dataSkeletonPaddingY = '6';
51
+ break;
52
+ case 'sm':
53
+ default:
54
+ dataSkeletonHeight = '16';
55
+ dataSkeletonPaddingY = '4';
56
+ }
57
+
35
58
  let trendIconName: TypeIconName | undefined;
36
59
  switch (trend) {
37
60
  case 'positive':
@@ -61,29 +84,42 @@ const LabeledData = ({
61
84
  trendIconColor = 'icon/tertiary';
62
85
  }
63
86
 
87
+ if (isLoading && skeleton) {
88
+ return <>{skeleton}</>;
89
+ }
90
+
64
91
  return (
65
- <Box as={as} display="flex" flexDirection="column" gap="4" {...rest}>
92
+ <Box as={as} display="flex" flexDirection="column" {...rest}>
66
93
  <Label as="dt" color={labelColor} tooltip={tooltip}>
67
94
  {label}
68
95
  </Label>
69
- <Box as="dd" display="flex" alignItems="center" gap="4" color="text/body" textStyle={`comp/data/${size}`}>
70
- {data}
71
- {trendIconName && trendValue && <Icon color={trendIconColor} name={trendIconName} size={trendIconSize} />}
72
- </Box>
73
- {((trendSign && trendValue) || !!secondaryLabel) && (
74
- <Box as="dd" display="flex" gap="4" color={trendColor} textStyle="body/md/regular">
75
- {trendSign && trendValue && (
76
- <>
77
- {trendSign}
78
- {trendValue}
79
- </>
80
- )}
81
- {secondaryLabel && (
82
- <Text as="span" color="text/tertiary">
83
- {secondaryLabel}
84
- </Text>
96
+ {isLoading ? (
97
+ <Skeleton isActive display="flex" flexDirection="column" gap="4">
98
+ <SkeletonBox height={dataSkeletonHeight} width="120px" marginY={dataSkeletonPaddingY} />
99
+ <SkeletonBox height="14" width="120px" marginY="3" />
100
+ </Skeleton>
101
+ ) : (
102
+ <>
103
+ <Box as="dd" display="flex" alignItems="center" gap="4" color="text/body" textStyle={`comp/data/${size}`}>
104
+ {data}
105
+ {trendIconName && trendValue && <Icon color={trendIconColor} name={trendIconName} size={trendIconSize} />}
106
+ </Box>
107
+ {((trendSign && trendValue) || !!secondaryLabel) && (
108
+ <Box as="dd" display="flex" gap="4" color={trendColor} textStyle="body/md/regular">
109
+ {trendSign && trendValue && (
110
+ <>
111
+ {trendSign}
112
+ {trendValue}
113
+ </>
114
+ )}
115
+ {secondaryLabel && (
116
+ <Text as="span" color="text/tertiary">
117
+ {secondaryLabel}
118
+ </Text>
119
+ )}
120
+ </Box>
85
121
  )}
86
- </Box>
122
+ </>
87
123
  )}
88
124
  </Box>
89
125
  );