Skip to content

Commit 661cd85

Browse files
authored
fix(Tag): map semantic _20 colors in Pentaho theme (#4863)
1 parent e003751 commit 661cd85

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/core/src/Tag/Tag.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { cloneElement, forwardRef, isValidElement } from "react";
22
import {
33
mergeStyles,
44
useDefaultProps,
5+
useTheme,
56
type ExtractNames,
67
} from "@hitachivantara/uikit-react-utils";
78
import {
89
getColor,
910
theme,
11+
type HvColor,
1012
type HvColorAny,
1113
type HvSize,
1214
} from "@hitachivantara/uikit-styles";
@@ -23,6 +25,13 @@ export { staticClasses as tagClasses };
2325

2426
export type HvTagClasses = ExtractNames<typeof useClasses>;
2527

28+
const colorMap: Partial<Record<HvColorAny, HvColor>> = {
29+
positive_20: "positive",
30+
negative_20: "negative",
31+
warning_20: "warning",
32+
neutral_20: "info",
33+
};
34+
2635
export interface HvTagProps
2736
extends Omit<
2837
HvButtonBaseProps,
@@ -89,7 +98,7 @@ export const HvTag = forwardRef<
8998
selected,
9099
defaultSelected = false,
91100
showSelectIcon = selectable,
92-
color,
101+
color: colorProp,
93102
icon: iconProp,
94103
deleteIcon: deleteIconProp,
95104
onDelete,
@@ -101,6 +110,7 @@ export const HvTag = forwardRef<
101110
...others
102111
} = useDefaultProps("HvTag", props);
103112
const { classes, cx } = useClasses(classesProp);
113+
const { activeTheme } = useTheme();
104114

105115
const [isSelected, setIsSelected] = useControlled(
106116
selected,
@@ -113,6 +123,9 @@ export const HvTag = forwardRef<
113123
onDelete?.(event);
114124
};
115125

126+
const color =
127+
(activeTheme?.name === "pentahoPlus" && colorMap[colorProp!]) || colorProp;
128+
116129
const tagColor =
117130
// backwards-compatibility for `type` prop
118131
(type === "categorical" && theme.alpha(color || "cat1", 0.2)) ||

0 commit comments

Comments
 (0)