2022-10-20 01:14:55 +00:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
|
|
|
import { Icon, IconProps } from '@@/Icon';
|
|
|
|
|
|
|
|
export type BadgeSize = 'md' | 'lg' | 'xl' | '2xl' | '3xl';
|
|
|
|
|
|
|
|
export interface Props extends IconProps {
|
|
|
|
size?: BadgeSize;
|
|
|
|
}
|
|
|
|
|
2022-11-28 02:00:28 +00:00
|
|
|
export function BadgeIcon({ icon, size = '3xl' }: Props) {
|
2022-10-20 01:14:55 +00:00
|
|
|
const sizeClasses = iconSizeToClasses(size);
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
sizeClasses,
|
|
|
|
`badge-icon
|
2023-02-12 21:04:24 +00:00
|
|
|
inline-flex items-center
|
|
|
|
justify-center rounded-full
|
|
|
|
bg-blue-3
|
|
|
|
text-blue-8 th-dark:bg-gray-9 th-dark:text-blue-3
|
2022-10-20 01:14:55 +00:00
|
|
|
`
|
|
|
|
)}
|
|
|
|
>
|
2022-11-28 02:00:28 +00:00
|
|
|
<Icon icon={icon} className="!flex" />
|
2022-10-20 01:14:55 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function iconSizeToClasses(size: BadgeSize) {
|
|
|
|
switch (size) {
|
|
|
|
case 'md':
|
|
|
|
return 'h-6 w-6 text-md';
|
|
|
|
case 'lg':
|
|
|
|
return 'h-8 w-8 text-lg';
|
|
|
|
case 'xl':
|
|
|
|
return 'h-10 w-10 text-xl';
|
|
|
|
case '2xl':
|
|
|
|
return 'h-12 w-12 text-2xl';
|
|
|
|
case '3xl':
|
|
|
|
return 'h-14 w-14 text-3xl';
|
|
|
|
default:
|
|
|
|
return 'h-14 w-14 text-3xl';
|
|
|
|
}
|
|
|
|
}
|