2023-04-04 18:48:04 +02:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
|
|
|
import Box from '../../ui/box/box';
|
|
|
|
|
2023-05-25 22:53:31 +02:00
|
|
|
import { IconColor, Display } from '../../../helpers/constants/design-system';
|
2023-04-04 18:48:04 +02:00
|
|
|
|
|
|
|
import { IconProps, IconSize } from './icon.types';
|
|
|
|
|
|
|
|
export const Icon = ({
|
|
|
|
name,
|
|
|
|
size = IconSize.Md,
|
|
|
|
color = IconColor.inherit,
|
|
|
|
className = '',
|
|
|
|
style,
|
|
|
|
...props
|
|
|
|
}: IconProps) => (
|
|
|
|
<Box
|
|
|
|
className={classnames(className, 'mm-icon', `mm-icon--size-${size}`)}
|
|
|
|
as="span"
|
2023-05-25 22:53:31 +02:00
|
|
|
display={Display.InlineBlock}
|
2023-04-04 18:48:04 +02:00
|
|
|
color={color}
|
|
|
|
style={{
|
|
|
|
/**
|
|
|
|
* To reduce the possibility of injection attacks
|
|
|
|
* the icon component uses mask-image instead of rendering
|
|
|
|
* the svg directly.
|
|
|
|
*/
|
|
|
|
maskImage: `url('./images/icons/${String(name)}.svg')`,
|
|
|
|
WebkitMaskImage: `url('./images/icons/${String(name)}.svg')`,
|
|
|
|
...style,
|
|
|
|
}}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|