Skip to content

Commit

Permalink
Update src/core/Icon/EncapsulatedIcon.tsx
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
jamiehenson and coderabbitai[bot] authored Oct 30, 2024
1 parent 3df125b commit 9967684
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/Icon/EncapsulatedIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ const EncapsulatedIcon = ({
baseTheme: "dark",
theme,
});
const ICON_SIZE_REDUCTION = 12;
const ICON_HEIGHT_REDUCTION = 2;

let computedIconSize = size,
computedIconHeight = size;

if (iconSize) {
computedIconSize = iconSize;
} else if (size.endsWith("px")) {
} else if (size.toString().endsWith("px")) {
const numericalSize = parseInt(size, 10);
computedIconSize = `${numericalSize - 12}px`;
computedIconHeight = `${numericalSize - 2}px`;
computedIconSize = `${numericalSize - ICON_SIZE_REDUCTION}px`;
computedIconHeight = `${numericalSize - ICON_HEIGHT_REDUCTION}px`;
} else {
console.warn(`EncapsulatedIcon: Non-pixel units might not behave as expected`);
}

return (
Expand Down

0 comments on commit 9967684

Please sign in to comment.