Skip to content

Commit

Permalink
allow icon sizes as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyvc authored and DavieReid committed Oct 5, 2023
1 parent fd2d055 commit 5d31c31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 9 additions & 2 deletions packages/components/src/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
Expand All @@ -35,9 +41,10 @@ export const Icon: React.FC<React.PropsWithChildren<IconProps>> = ({
throw new Error(`icon ${currentIconName} is not supported`);
}
const IconComponent = icons[currentIconName];
const iconSize = typeof size === 'string' ? iconSizeMap[size] : size;
return (
<span className={className} {...rest}>
<IconComponent size={size} />
<IconComponent size={iconSize} />
</span>
);
};
8 changes: 1 addition & 7 deletions packages/components/src/Tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export interface TagProps {
size?: Size;
}

const iconSizeMap = {
small: 1,
medium: 2,
large: 3
};

/**
* Renders a Tag.
* @example
Expand Down Expand Up @@ -59,7 +53,7 @@ export const Tag: React.FC<React.PropsWithChildren<TagProps>> = ({
>
{iconName && (
<span className={styles.icon}>
<Icon name={iconName} size={iconSizeMap[size]} />
<Icon name={iconName} size={size} />
</span>
)}
{label}
Expand Down

1 comment on commit 5d31c31

@vercel
Copy link

@vercel vercel bot commented on 5d31c31 Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mosaic – ./

mosaic-git-main-mosaic-dev-team.vercel.app
mosaic-mosaic-dev-team.vercel.app

Please sign in to comment.