aboutsummaryrefslogtreecommitdiffstats
path: root/client/js/app/src/app/components/icon/icon.jsx
blob: edc86250b014b5571fce530bc901617d6a1d2593 (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
import React from 'react';
import { library } from '@fortawesome/fontawesome-svg-core';
import { Box } from '@mantine/core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
  faArrowsToDot,
  faChartGantt,
  faCheck,
  faCircleMinus,
  faCopy,
  faDownload,
  faPaste,
  faPlus,
  faXmark,
  faInfo,
  faExclamation,
} from '@fortawesome/free-solid-svg-icons';

// TODO: use dynamic import

library.add(
  faArrowsToDot,
  faChartGantt,
  faCircleMinus,
  faPlus,
  faPaste,
  faDownload,
  faCopy,
  faCheck,
  faXmark,
  faInfo,
  faExclamation
);

export function Icon({ name, type = 'solid', color, ...rest }) {
  const icon = `fa-${type} fa-${name}`;
  return (
    <Box
      sx={(theme) => ({
        ...(color && { color: theme.cr.getSolidBackground(color) }),
      })}
      component={FontAwesomeIcon}
      icon={icon}
      {...rest}
    />
  );
}