@gobolt/genesis 0.2.19 → 0.2.21
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/dist/components/Badge/Badge.cjs +19 -6
- package/dist/components/Badge/Badge.d.ts +7 -2
- package/dist/components/Badge/Badge.js +19 -6
- package/dist/components/Badge/__stories__/Badge.stories.d.ts +2 -0
- package/dist/components/Badge/styles.cjs +20 -6
- package/dist/components/Badge/styles.d.ts +3 -1
- package/dist/components/Badge/styles.js +20 -6
- package/dist/utils/icon-util.cjs +5 -2
- package/dist/utils/icon-util.d.ts +1 -1
- package/dist/utils/icon-util.js +5 -2
- package/package.json +1 -1
|
@@ -11,8 +11,14 @@ const Badge = ({
|
|
|
11
11
|
state = "info",
|
|
12
12
|
isDisabled,
|
|
13
13
|
hasClose = false,
|
|
14
|
-
onClick
|
|
14
|
+
onClick = () => {
|
|
15
|
+
},
|
|
15
16
|
size = "normal",
|
|
17
|
+
hasIcon = true,
|
|
18
|
+
customIcon = null,
|
|
19
|
+
backgroundColor = null,
|
|
20
|
+
textColor = null,
|
|
21
|
+
hasHover = true,
|
|
16
22
|
...rest
|
|
17
23
|
}) => {
|
|
18
24
|
const { theme } = useGenesis.useGenesis();
|
|
@@ -28,6 +34,7 @@ const Badge = ({
|
|
|
28
34
|
style: {
|
|
29
35
|
padding: "4px 4px"
|
|
30
36
|
},
|
|
37
|
+
$hasHover: hasHover,
|
|
31
38
|
...rest,
|
|
32
39
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
40
|
"div",
|
|
@@ -39,8 +46,10 @@ const Badge = ({
|
|
|
39
46
|
},
|
|
40
47
|
children: iconUtil.getBadgeStateIcon(
|
|
41
48
|
state,
|
|
42
|
-
theme.colors.status[state].onsurface,
|
|
43
|
-
isBadgeIconFilled
|
|
49
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
50
|
+
isBadgeIconFilled,
|
|
51
|
+
hasIcon,
|
|
52
|
+
customIcon
|
|
44
53
|
)
|
|
45
54
|
}
|
|
46
55
|
)
|
|
@@ -56,18 +65,22 @@ const Badge = ({
|
|
|
56
65
|
state,
|
|
57
66
|
disabled: isDisabled,
|
|
58
67
|
style: { cursor: role === "button" ? "pointer" : "default" },
|
|
68
|
+
$backgroundColor: backgroundColor,
|
|
69
|
+
$hasHover: hasHover,
|
|
59
70
|
...rest,
|
|
60
71
|
children: [
|
|
61
72
|
iconUtil.getBadgeStateIcon(
|
|
62
73
|
state,
|
|
63
|
-
theme.colors.status[state].onsurface,
|
|
64
|
-
isBadgeIconFilled
|
|
74
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
75
|
+
isBadgeIconFilled,
|
|
76
|
+
hasIcon,
|
|
77
|
+
customIcon
|
|
65
78
|
),
|
|
66
79
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
67
80
|
Typography,
|
|
68
81
|
{
|
|
69
82
|
variant: size === "small" ? "label3" : "label2",
|
|
70
|
-
color: isDisabled ? theme.colors.status.disabled.default : theme.colors.status[state].onsurface,
|
|
83
|
+
color: isDisabled ? theme.colors.status.disabled.default : textColor || theme.colors.status[state].onsurface,
|
|
71
84
|
isDisabled,
|
|
72
85
|
children: label
|
|
73
86
|
}
|
|
@@ -4,8 +4,13 @@ export interface BadgeProps {
|
|
|
4
4
|
isDisabled?: boolean;
|
|
5
5
|
state?: State;
|
|
6
6
|
hasClose?: boolean;
|
|
7
|
+
hasIcon?: boolean;
|
|
8
|
+
customIcon?: React.ReactNode | null;
|
|
7
9
|
size?: "small" | "normal" | "large";
|
|
8
|
-
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
textColor?: string;
|
|
12
|
+
onClick?: () => void | null;
|
|
13
|
+
hasHover?: boolean;
|
|
9
14
|
}
|
|
10
|
-
declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, hasIcon, customIcon, backgroundColor, textColor, hasHover, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export default Badge;
|
|
@@ -10,8 +10,14 @@ const Badge = ({
|
|
|
10
10
|
state = "info",
|
|
11
11
|
isDisabled,
|
|
12
12
|
hasClose = false,
|
|
13
|
-
onClick
|
|
13
|
+
onClick = () => {
|
|
14
|
+
},
|
|
14
15
|
size = "normal",
|
|
16
|
+
hasIcon = true,
|
|
17
|
+
customIcon = null,
|
|
18
|
+
backgroundColor = null,
|
|
19
|
+
textColor = null,
|
|
20
|
+
hasHover = true,
|
|
15
21
|
...rest
|
|
16
22
|
}) => {
|
|
17
23
|
const { theme } = useGenesis();
|
|
@@ -27,6 +33,7 @@ const Badge = ({
|
|
|
27
33
|
style: {
|
|
28
34
|
padding: "4px 4px"
|
|
29
35
|
},
|
|
36
|
+
$hasHover: hasHover,
|
|
30
37
|
...rest,
|
|
31
38
|
children: /* @__PURE__ */ jsx(
|
|
32
39
|
"div",
|
|
@@ -38,8 +45,10 @@ const Badge = ({
|
|
|
38
45
|
},
|
|
39
46
|
children: getBadgeStateIcon(
|
|
40
47
|
state,
|
|
41
|
-
theme.colors.status[state].onsurface,
|
|
42
|
-
isBadgeIconFilled
|
|
48
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
49
|
+
isBadgeIconFilled,
|
|
50
|
+
hasIcon,
|
|
51
|
+
customIcon
|
|
43
52
|
)
|
|
44
53
|
}
|
|
45
54
|
)
|
|
@@ -55,18 +64,22 @@ const Badge = ({
|
|
|
55
64
|
state,
|
|
56
65
|
disabled: isDisabled,
|
|
57
66
|
style: { cursor: role === "button" ? "pointer" : "default" },
|
|
67
|
+
$backgroundColor: backgroundColor,
|
|
68
|
+
$hasHover: hasHover,
|
|
58
69
|
...rest,
|
|
59
70
|
children: [
|
|
60
71
|
getBadgeStateIcon(
|
|
61
72
|
state,
|
|
62
|
-
theme.colors.status[state].onsurface,
|
|
63
|
-
isBadgeIconFilled
|
|
73
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
74
|
+
isBadgeIconFilled,
|
|
75
|
+
hasIcon,
|
|
76
|
+
customIcon
|
|
64
77
|
),
|
|
65
78
|
/* @__PURE__ */ jsx(
|
|
66
79
|
Typography,
|
|
67
80
|
{
|
|
68
81
|
variant: size === "small" ? "label3" : "label2",
|
|
69
|
-
color: isDisabled ? theme.colors.status.disabled.default : theme.colors.status[state].onsurface,
|
|
82
|
+
color: isDisabled ? theme.colors.status.disabled.default : textColor || theme.colors.status[state].onsurface,
|
|
70
83
|
isDisabled,
|
|
71
84
|
children: label
|
|
72
85
|
}
|
|
@@ -6,8 +6,8 @@ const getBorderColor = (theme, state) => {
|
|
|
6
6
|
}
|
|
7
7
|
return theme.colors.status[state].surface;
|
|
8
8
|
};
|
|
9
|
-
const getGenesisClass = (theme, state, label, disabled) => `
|
|
10
|
-
display: flex;
|
|
9
|
+
const getGenesisClass = (theme, state, label, disabled, $backgroundColor, $hasHover) => `
|
|
10
|
+
display: inline-flex; // inline-flex is used to prevent the badge from taking up the full width of the container
|
|
11
11
|
gap: 4px;
|
|
12
12
|
justify-content: center;
|
|
13
13
|
align-items: center;
|
|
@@ -18,10 +18,10 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
18
18
|
padding-right: ${theme.components.badge["right-padding"]}px;
|
|
19
19
|
border-radius: ${theme.components.badge.radius}px;
|
|
20
20
|
border: 1px solid ${getBorderColor(theme, state)};
|
|
21
|
-
background-color: ${theme.colors.status[state].surface};
|
|
21
|
+
background-color: ${$backgroundColor || theme.colors.status[state].surface};
|
|
22
22
|
|
|
23
23
|
&:not(:disabled):hover {
|
|
24
|
-
background-color: ${theme.colors.status[state]["surface-hover"]}
|
|
24
|
+
${$hasHover ? `background-color: ${theme.colors.status[state]["surface-hover"]};` : ""}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
${disabled ? `
|
|
@@ -36,8 +36,22 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
36
36
|
` : ""}
|
|
37
37
|
`;
|
|
38
38
|
const Badge = styled.div`
|
|
39
|
-
${({
|
|
40
|
-
|
|
39
|
+
${({
|
|
40
|
+
theme,
|
|
41
|
+
state,
|
|
42
|
+
label,
|
|
43
|
+
disabled,
|
|
44
|
+
$backgroundColor,
|
|
45
|
+
$hasHover
|
|
46
|
+
}) => {
|
|
47
|
+
return getGenesisClass(
|
|
48
|
+
theme,
|
|
49
|
+
state,
|
|
50
|
+
label,
|
|
51
|
+
disabled,
|
|
52
|
+
$backgroundColor,
|
|
53
|
+
$hasHover
|
|
54
|
+
);
|
|
41
55
|
}}
|
|
42
56
|
`;
|
|
43
57
|
exports.Badge = Badge;
|
|
@@ -5,7 +5,9 @@ interface StyledBadgeProps {
|
|
|
5
5
|
state?: State;
|
|
6
6
|
label?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
$backgroundColor?: string;
|
|
9
|
+
$hasHover?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean) => string;
|
|
11
|
+
export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean, $backgroundColor?: string, $hasHover?: boolean) => string;
|
|
10
12
|
export declare const Badge: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledBadgeProps>> & string;
|
|
11
13
|
export {};
|
|
@@ -5,8 +5,8 @@ const getBorderColor = (theme, state) => {
|
|
|
5
5
|
}
|
|
6
6
|
return theme.colors.status[state].surface;
|
|
7
7
|
};
|
|
8
|
-
const getGenesisClass = (theme, state, label, disabled) => `
|
|
9
|
-
display: flex;
|
|
8
|
+
const getGenesisClass = (theme, state, label, disabled, $backgroundColor, $hasHover) => `
|
|
9
|
+
display: inline-flex; // inline-flex is used to prevent the badge from taking up the full width of the container
|
|
10
10
|
gap: 4px;
|
|
11
11
|
justify-content: center;
|
|
12
12
|
align-items: center;
|
|
@@ -17,10 +17,10 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
17
17
|
padding-right: ${theme.components.badge["right-padding"]}px;
|
|
18
18
|
border-radius: ${theme.components.badge.radius}px;
|
|
19
19
|
border: 1px solid ${getBorderColor(theme, state)};
|
|
20
|
-
background-color: ${theme.colors.status[state].surface};
|
|
20
|
+
background-color: ${$backgroundColor || theme.colors.status[state].surface};
|
|
21
21
|
|
|
22
22
|
&:not(:disabled):hover {
|
|
23
|
-
background-color: ${theme.colors.status[state]["surface-hover"]}
|
|
23
|
+
${$hasHover ? `background-color: ${theme.colors.status[state]["surface-hover"]};` : ""}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
${disabled ? `
|
|
@@ -35,8 +35,22 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
35
35
|
` : ""}
|
|
36
36
|
`;
|
|
37
37
|
const Badge = styled.div`
|
|
38
|
-
${({
|
|
39
|
-
|
|
38
|
+
${({
|
|
39
|
+
theme,
|
|
40
|
+
state,
|
|
41
|
+
label,
|
|
42
|
+
disabled,
|
|
43
|
+
$backgroundColor,
|
|
44
|
+
$hasHover
|
|
45
|
+
}) => {
|
|
46
|
+
return getGenesisClass(
|
|
47
|
+
theme,
|
|
48
|
+
state,
|
|
49
|
+
label,
|
|
50
|
+
disabled,
|
|
51
|
+
$backgroundColor,
|
|
52
|
+
$hasHover
|
|
53
|
+
);
|
|
40
54
|
}}
|
|
41
55
|
`;
|
|
42
56
|
export {
|
package/dist/utils/icon-util.cjs
CHANGED
|
@@ -44,10 +44,13 @@ const getIconColor = (state, theme) => {
|
|
|
44
44
|
return theme.colors.status.info.onsurface;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
const getBadgeStateIcon = (state, color, isFilled = true) => {
|
|
48
|
-
if (!state) {
|
|
47
|
+
const getBadgeStateIcon = (state, color, isFilled = true, hasIcon = true, customIcon = null) => {
|
|
48
|
+
if (!state || !hasIcon) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
+
if (customIcon) {
|
|
52
|
+
return customIcon;
|
|
53
|
+
}
|
|
51
54
|
if (!isFilled) {
|
|
52
55
|
switch (state) {
|
|
53
56
|
// isFilled is false
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const getIcon: (name: string) => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export declare const getIconColor: (state: any, theme: any) => any;
|
|
3
|
-
export declare const getBadgeStateIcon: (state: any, color: any, isFilled?: boolean) =>
|
|
3
|
+
export declare const getBadgeStateIcon: (state: any, color: any, isFilled?: boolean, hasIcon?: boolean, customIcon?: any) => any;
|
package/dist/utils/icon-util.js
CHANGED
|
@@ -43,10 +43,13 @@ const getIconColor = (state, theme) => {
|
|
|
43
43
|
return theme.colors.status.info.onsurface;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
const getBadgeStateIcon = (state, color, isFilled = true) => {
|
|
47
|
-
if (!state) {
|
|
46
|
+
const getBadgeStateIcon = (state, color, isFilled = true, hasIcon = true, customIcon = null) => {
|
|
47
|
+
if (!state || !hasIcon) {
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
|
+
if (customIcon) {
|
|
51
|
+
return customIcon;
|
|
52
|
+
}
|
|
50
53
|
if (!isFilled) {
|
|
51
54
|
switch (state) {
|
|
52
55
|
// isFilled is false
|