Skip to content

Commit

Permalink
fix: Fix backwards compatibility for hover state colors in System Icon (
Browse files Browse the repository at this point in the history
#2764)

Fixes: #2763 

Support for v10 System Icon colors has been lost.

[category:Components]
  • Loading branch information
RayRedGoose committed Jun 10, 2024
1 parent 2c181bb commit 3570f7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion modules/react/icon/lib/Svg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ export const svgStencil = createStencil({
/** @deprecated */
export const transformColorNameToToken = (color?: string) => {
if (color && color in base) {
return base[color as keyof typeof base];
return cssVar(base[color as keyof typeof base]);
}

if (color?.startsWith('--')) {
return cssVar(color);
}

return color;
};

Expand Down
11 changes: 7 additions & 4 deletions modules/react/icon/lib/SystemIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ export const SystemIcon = createComponent('span')({
backgroundColor: transformColorNameToToken(background),
}),
{
[deprecatedSystemIconVars.colorHover]: colorHover && cssVar(colorHover),
[deprecatedSystemIconVars.fillHover]: fillHover && cssVar(fillHover),
[deprecatedSystemIconVars.accentHover]: accentHover && cssVar(accentHover),
[deprecatedSystemIconVars.backgroundHover]: backgroundHover && cssVar(backgroundHover),
[deprecatedSystemIconVars.colorHover]:
colorHover && transformColorNameToToken(colorHover),
[deprecatedSystemIconVars.fillHover]: fillHover && transformColorNameToToken(fillHover),
[deprecatedSystemIconVars.accentHover]:
accentHover && transformColorNameToToken(accentHover),
[deprecatedSystemIconVars.backgroundHover]:
backgroundHover && transformColorNameToToken(backgroundHover),
},
])}
/>
Expand Down

0 comments on commit 3570f7c

Please sign in to comment.