aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/icon/index.tsx
blob: ad9f43730f937ef2d0be4d7353e84910850cab81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import MdiIcon from '@mdi/react';
import classnames from 'classnames';
import { Component, type ReactElement } from 'react';
import injectStyle, { type WithStylesProps } from 'react-jss';

import type { Theme } from '../../../themes';

const styles = (theme: Theme) => ({
  icon: {
    fill: theme.colorText,
  },
});

interface IProps extends WithStylesProps<typeof styles> {
  icon: string;
  size?: number;
  className?: string;
}

class IconComponent extends Component<IProps> {
  render(): ReactElement {
    const { classes, icon, size = 1, className } = this.props;

    if (!icon) {
      console.warn('No Icon specified');
    }

    return (
      <MdiIcon
        path={icon}
        size={size}
        className={classnames({
          [classes.icon]: true,
          [`${className}`]: className,
        })}
      />
    );
  }
}

export default injectStyle(styles, { injectTheme: true })(IconComponent);