@trackunit/react-components 0.0.43 → 0.0.44
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/components/badge/Badge.d.ts +16 -16
- package/index.js +18 -9
- package/package.json +1 -1
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
-
|
|
3
|
+
import { Colors } from "../../constants/colors";
|
|
4
4
|
export declare type BadgeSize = "default" | "large";
|
|
5
5
|
declare type BadgeVariant = "badge" | "pill" | "tag";
|
|
6
6
|
export interface TagProps extends BaseBadgeProps {
|
|
7
7
|
/**
|
|
8
8
|
* The name of the variant.
|
|
9
9
|
*
|
|
10
|
-
* @type string}
|
|
11
10
|
* @memberof TagProps
|
|
12
11
|
*/
|
|
13
12
|
variant: "tag";
|
|
14
13
|
/**
|
|
15
14
|
* A handler for a click event triggered on x icon
|
|
16
15
|
* if not passed then x icon won't be visible
|
|
17
|
-
*
|
|
16
|
+
*
|
|
17
|
+
* @type () => void
|
|
18
18
|
* @memberof TagProps
|
|
19
19
|
*/
|
|
20
20
|
onClose?: () => void;
|
|
21
21
|
}
|
|
22
22
|
export interface BaseBadgeProps extends CommonProps {
|
|
23
23
|
/**
|
|
24
|
-
* The
|
|
24
|
+
* The color of the badge.
|
|
25
25
|
*
|
|
26
|
-
* @type
|
|
26
|
+
* @type "primary" | "accent" | "neutral" | "info" | "success" | "warning" | "danger" | "good" | "low" | "critical" | "working" | "idle" | "stopped" | "unknown"
|
|
27
27
|
* @memberof BadgeProps
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
color?: Colors;
|
|
30
30
|
/**
|
|
31
|
-
* Specifies whether the
|
|
31
|
+
* Specifies whether the badge is subtle or not.
|
|
32
|
+
* Subtle badges have a light background color wither a darker text color.
|
|
32
33
|
*
|
|
33
|
-
* @type
|
|
34
|
+
* @type boolean
|
|
34
35
|
* @memberof BadgeProps
|
|
35
36
|
*/
|
|
36
37
|
subtle?: boolean;
|
|
37
38
|
/**
|
|
38
|
-
* Whether badge should be displayed as a pill, tag or badge
|
|
39
|
-
* pill numeric values above 99 will be displayed as 99+.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Badge will use subtle intent by default.
|
|
39
|
+
* Whether badge should be displayed as a pill, tag or badge.
|
|
40
|
+
* For the pill variant, numeric values above 99 will be displayed as 99+.
|
|
41
|
+
* Tag will display x icon if you provide onClose handler.
|
|
42
|
+
* Badge is subtle by default.
|
|
43
43
|
*
|
|
44
|
-
* @type
|
|
44
|
+
* @type "badge" | "pill" | "tag"
|
|
45
45
|
* @memberof BadgeProps
|
|
46
46
|
*/
|
|
47
47
|
variant?: BadgeVariant;
|
|
@@ -64,11 +64,11 @@ export interface BaseBadgeProps extends CommonProps {
|
|
|
64
64
|
/**
|
|
65
65
|
* Size of the badge.
|
|
66
66
|
*
|
|
67
|
-
* @type
|
|
67
|
+
* @type "default" | "large"
|
|
68
68
|
* @memberof BadgeProps
|
|
69
69
|
*/
|
|
70
70
|
size?: BadgeSize;
|
|
71
71
|
}
|
|
72
72
|
export declare type BadgeProps = BaseBadgeProps | TagProps;
|
|
73
|
-
export declare const Badge: ({
|
|
73
|
+
export declare const Badge: ({ color, subtle, className, variant, dataTestId, children, size, ...rest }: BadgeProps) => JSX.Element;
|
|
74
74
|
export {};
|
package/index.js
CHANGED
|
@@ -697,7 +697,7 @@ const IconContainer = tw.div`
|
|
|
697
697
|
|
|
698
698
|
const Badge = _a => {
|
|
699
699
|
var {
|
|
700
|
-
|
|
700
|
+
color = "neutral",
|
|
701
701
|
subtle = false,
|
|
702
702
|
className,
|
|
703
703
|
variant = "badge",
|
|
@@ -705,14 +705,14 @@ const Badge = _a => {
|
|
|
705
705
|
children,
|
|
706
706
|
size = "default"
|
|
707
707
|
} = _a,
|
|
708
|
-
rest = __rest(_a, ["
|
|
708
|
+
rest = __rest(_a, ["color", "subtle", "className", "variant", "dataTestId", "children", "size"]);
|
|
709
709
|
|
|
710
710
|
const isPill = variant === "pill";
|
|
711
711
|
const tagProps = rest;
|
|
712
712
|
return jsxs(StyledText$2, Object.assign({
|
|
713
713
|
"$variant": variant,
|
|
714
714
|
className: className,
|
|
715
|
-
"$
|
|
715
|
+
"$color": color,
|
|
716
716
|
"$size": size,
|
|
717
717
|
"$subtle": subtle ? subtle : isPill,
|
|
718
718
|
"data-testid": dataTestId,
|
|
@@ -746,17 +746,26 @@ const getSizeModifierClass = () => ({
|
|
|
746
746
|
};
|
|
747
747
|
|
|
748
748
|
const getBadgeModifierClass = () => ({
|
|
749
|
-
$
|
|
749
|
+
$color,
|
|
750
750
|
$subtle
|
|
751
751
|
}) => {
|
|
752
|
-
const
|
|
752
|
+
const colorClasses = {
|
|
753
753
|
primary: $subtle ? tws`badge--primary-subtle` : tws`badge--primary`,
|
|
754
|
-
|
|
754
|
+
accent: $subtle ? tws`badge--accent-subtle` : tws`badge--accent`,
|
|
755
755
|
success: $subtle ? tws`badge--success-subtle` : tws`badge--success`,
|
|
756
756
|
danger: $subtle ? tws`badge--danger-subtle` : tws`badge--danger`,
|
|
757
|
-
warning: $subtle ? tws`badge--warning-subtle` : tws`badge--warning
|
|
757
|
+
warning: $subtle ? tws`badge--warning-subtle` : tws`badge--warning`,
|
|
758
|
+
info: $subtle ? tws`badge--info-subtle` : tws`badge--info`,
|
|
759
|
+
neutral: $subtle ? tws`badge--neutral-subtle` : tws`badge--neutral`,
|
|
760
|
+
good: $subtle ? tws`badge--good-subtle` : tws`badge--good`,
|
|
761
|
+
low: $subtle ? tws`badge--low-subtle` : tws`badge--low`,
|
|
762
|
+
critical: $subtle ? tws`badge--critical-subtle` : tws`badge--critical`,
|
|
763
|
+
working: $subtle ? tws`badge--working-subtle` : tws`badge--working`,
|
|
764
|
+
idle: $subtle ? tws`badge--idle-subtle` : tws`badge--idle`,
|
|
765
|
+
stopped: $subtle ? tws`badge--stopped-subtle` : tws`badge--stopped`,
|
|
766
|
+
unknown: $subtle ? tws`badge--unknown-subtle` : tws`badge--unknown`
|
|
758
767
|
};
|
|
759
|
-
return
|
|
768
|
+
return colorClasses[$color];
|
|
760
769
|
};
|
|
761
770
|
|
|
762
771
|
const StyledText$2 = tw.text`
|
|
@@ -3038,7 +3047,7 @@ const PageHeading = ({
|
|
|
3038
3047
|
}, {
|
|
3039
3048
|
children: title
|
|
3040
3049
|
})), badge && jsx(Badge, Object.assign({
|
|
3041
|
-
|
|
3050
|
+
color: "primary"
|
|
3042
3051
|
}, {
|
|
3043
3052
|
children: badge
|
|
3044
3053
|
}))]
|