From 5d31c317c3d72fd57b91ec5181c3735562020925 Mon Sep 17 00:00:00 2001 From: R662301 Date: Thu, 5 Oct 2023 13:23:19 +0100 Subject: [PATCH] allow icon sizes as strings --- packages/components/src/Icon/index.tsx | 11 +++++++++-- packages/components/src/Tag/index.tsx | 8 +------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/components/src/Icon/index.tsx b/packages/components/src/Icon/index.tsx index 88129acd..01cb2d2c 100644 --- a/packages/components/src/Icon/index.tsx +++ b/packages/components/src/Icon/index.tsx @@ -7,9 +7,15 @@ export interface IconProps { /** Name of the icon */ name: IconNames; /** Size of Icon */ - size?: number; + size?: number | 'small' | 'medium' | 'large'; } +const iconSizeMap = { + small: 1, + medium: 2, + large: 3 +}; + const deprecatedIcons = { tick: 'successTick' }; @@ -35,9 +41,10 @@ export const Icon: React.FC> = ({ throw new Error(`icon ${currentIconName} is not supported`); } const IconComponent = icons[currentIconName]; + const iconSize = typeof size === 'string' ? iconSizeMap[size] : size; return ( - + ); }; diff --git a/packages/components/src/Tag/index.tsx b/packages/components/src/Tag/index.tsx index 1e818a69..9101cfbd 100644 --- a/packages/components/src/Tag/index.tsx +++ b/packages/components/src/Tag/index.tsx @@ -18,12 +18,6 @@ export interface TagProps { size?: Size; } -const iconSizeMap = { - small: 1, - medium: 2, - large: 3 -}; - /** * Renders a Tag. * @example @@ -59,7 +53,7 @@ export const Tag: React.FC> = ({ > {iconName && ( - + )} {label}