aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/Infobox.js
diff options
context:
space:
mode:
authorLibravatar muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com>2022-11-01 06:42:12 +0530
committerLibravatar GitHub <noreply@github.com>2022-11-01 01:12:12 +0000
commit85d1aac4cd70e79d5ab64684dea09e92b17ed2c2 (patch)
treea006a2eb5c58b9351219d8a85d57a04c5c73787a /src/components/ui/Infobox.js
parentrefactor: convert global app to typescript (#723) (diff)
downloadferdium-app-85d1aac4cd70e79d5ab64684dea09e92b17ed2c2.tar.gz
ferdium-app-85d1aac4cd70e79d5ab64684dea09e92b17ed2c2.tar.zst
ferdium-app-85d1aac4cd70e79d5ab64684dea09e92b17ed2c2.zip
Transform ChangeServer components tree to typescript (#725)
Diffstat (limited to 'src/components/ui/Infobox.js')
-rw-r--r--src/components/ui/Infobox.js115
1 files changed, 0 insertions, 115 deletions
diff --git a/src/components/ui/Infobox.js b/src/components/ui/Infobox.js
deleted file mode 100644
index 8fb80d87f..000000000
--- a/src/components/ui/Infobox.js
+++ /dev/null
@@ -1,115 +0,0 @@
1import { Component } from 'react';
2import PropTypes from 'prop-types';
3import { observer } from 'mobx-react';
4import classnames from 'classnames';
5import Loader from 'react-loader';
6import { defineMessages, injectIntl } from 'react-intl';
7import { mdiAlert, mdiCheckboxMarkedCircleOutline, mdiClose } from '@mdi/js';
8import Icon from '../ui/icon';
9
10const icons = {
11 'checkbox-marked-circle-outline': mdiCheckboxMarkedCircleOutline,
12 alert: mdiAlert,
13};
14
15const messages = defineMessages({
16 dismiss: {
17 id: 'infobox.dismiss',
18 defaultMessage: 'Dismiss',
19 },
20});
21
22// Can this file be merged into the './infobox/index.tsx' file?
23class Infobox extends Component {
24 static propTypes = {
25 // eslint-disable-next-line react/forbid-prop-types
26 children: PropTypes.any.isRequired,
27 icon: PropTypes.string,
28 type: PropTypes.string,
29 ctaOnClick: PropTypes.func,
30 ctaLabel: PropTypes.string,
31 ctaLoading: PropTypes.bool,
32 dismissable: PropTypes.bool,
33 onDismiss: PropTypes.func,
34 onSeen: PropTypes.func,
35 };
36
37 static defaultProps = {
38 icon: '',
39 type: 'primary',
40 dismissable: false,
41 ctaOnClick: () => null,
42 ctaLabel: '',
43 ctaLoading: false,
44 onDismiss: () => null,
45 onSeen: () => null,
46 };
47
48 state = {
49 dismissed: false,
50 };
51
52 componentDidMount() {
53 const { onSeen } = this.props;
54 if (onSeen) onSeen();
55 }
56
57 render() {
58 const {
59 children,
60 icon,
61 type,
62 ctaLabel,
63 ctaLoading,
64 ctaOnClick,
65 dismissable,
66 onDismiss,
67 } = this.props;
68
69 const { intl } = this.props;
70
71 if (this.state.dismissed) {
72 return null;
73 }
74
75 return (
76 <div
77 className={classnames({
78 infobox: true,
79 [`infobox--${type}`]: type,
80 'infobox--default': !type,
81 })}
82 >
83 {icon && <Icon icon={icons[icon]} />}
84 <div className="infobox__content">{children}</div>
85 {ctaLabel && (
86 <button className="infobox__cta" onClick={ctaOnClick} type="button">
87 <Loader
88 loaded={!ctaLoading}
89 lines={10}
90 scale={0.3}
91 color="#FFF"
92 component="span"
93 />
94 {ctaLabel}
95 </button>
96 )}
97 {dismissable && (
98 <button
99 type="button"
100 onClick={() => {
101 this.setState({ dismissed: true });
102 if (onDismiss) onDismiss();
103 }}
104 className="infobox__delete"
105 aria-label={intl.formatMessage(messages.dismiss)}
106 >
107 <Icon icon={mdiClose} />
108 </button>
109 )}
110 </div>
111 );
112 }
113}
114
115export default injectIntl(observer(Infobox));