aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/ServiceIcon.tsx
blob: 03a345c23d0024f6fe713a5696f3be73af57c0db (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
42
43
44
45
46
47
48
49
50
51
52
import classnames from 'classnames';
import { observer } from 'mobx-react';
import { Component, type ReactNode } from 'react';
import withStyles, { type WithStylesProps } from 'react-jss';
import type ServiceModel from '../../models/Service';

const styles = theme => ({
  root: {
    height: 'auto',
  },
  icon: {
    width: theme.serviceIcon.width,
  },
  isCustomIcon: {
    width: theme.serviceIcon.isCustom.width,
    border: theme.serviceIcon.isCustom.border,
    borderRadius: theme.serviceIcon.isCustom.borderRadius,
  },
  isDisabled: {
    filter: 'grayscale(100%)',
    opacity: '.5',
  },
});

interface IProps extends WithStylesProps<typeof styles> {
  service: ServiceModel;
  className?: string;
}

// TODO: [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'?
@observer
class ServiceIcon extends Component<IProps> {
  render(): ReactNode {
    const { classes, className = '', service } = this.props;

    return (
      <div className={classnames([classes.root, className])}>
        <img
          src={service.icon}
          className={classnames([
            classes.icon,
            service.isEnabled ? null : classes.isDisabled,
            service.hasCustomIcon ? classes.isCustomIcon : null,
          ])}
          alt=""
        />
      </div>
    );
  }
}

export default withStyles(styles, { injectTheme: true })(ServiceIcon);