diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-14 13:24:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 13:24:58 +0200 |
commit | fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e (patch) | |
tree | 10caa332d957421e982c7ddd0c94623d5d62314d /src/components/ui/Button.js | |
parent | chore: convert various JS to TS (#2062) (diff) | |
download | ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.gz ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.zst ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.zip |
chore: convert files to TS (#2066)
Diffstat (limited to 'src/components/ui/Button.js')
-rw-r--r-- | src/components/ui/Button.js | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/src/components/ui/Button.js b/src/components/ui/Button.js deleted file mode 100644 index 67c801d98..000000000 --- a/src/components/ui/Button.js +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer, inject } from 'mobx-react'; | ||
4 | import Loader from 'react-loader'; | ||
5 | import classnames from 'classnames'; | ||
6 | |||
7 | @inject('stores') | ||
8 | @observer | ||
9 | class Button extends Component { | ||
10 | static propTypes = { | ||
11 | className: PropTypes.string, | ||
12 | label: PropTypes.string.isRequired, | ||
13 | disabled: PropTypes.bool, | ||
14 | onClick: PropTypes.func, | ||
15 | type: PropTypes.string, | ||
16 | buttonType: PropTypes.string, | ||
17 | loaded: PropTypes.bool, | ||
18 | htmlForm: PropTypes.string, | ||
19 | stores: PropTypes.shape({ | ||
20 | settings: PropTypes.shape({ | ||
21 | app: PropTypes.shape({ | ||
22 | accentColor: PropTypes.string.isRequired, | ||
23 | }).isRequired, | ||
24 | }).isRequired, | ||
25 | }).isRequired, | ||
26 | }; | ||
27 | |||
28 | static defaultProps = { | ||
29 | className: null, | ||
30 | disabled: false, | ||
31 | onClick: () => {}, | ||
32 | type: 'button', | ||
33 | buttonType: '', | ||
34 | loaded: true, | ||
35 | htmlForm: '', | ||
36 | }; | ||
37 | |||
38 | element = null; | ||
39 | |||
40 | render() { | ||
41 | const { | ||
42 | label, | ||
43 | className, | ||
44 | disabled, | ||
45 | onClick, | ||
46 | type, | ||
47 | buttonType, | ||
48 | loaded, | ||
49 | htmlForm, | ||
50 | } = this.props; | ||
51 | |||
52 | const buttonProps = { | ||
53 | className: classnames({ | ||
54 | 'franz-form__button': true, | ||
55 | [`franz-form__button--${buttonType}`]: buttonType, | ||
56 | [`${className}`]: className, | ||
57 | }), | ||
58 | type, | ||
59 | }; | ||
60 | |||
61 | if (disabled) { | ||
62 | buttonProps.disabled = true; | ||
63 | } | ||
64 | |||
65 | if (onClick) { | ||
66 | buttonProps.onClick = onClick; | ||
67 | } | ||
68 | |||
69 | if (htmlForm) { | ||
70 | buttonProps.form = htmlForm; | ||
71 | } | ||
72 | |||
73 | return ( | ||
74 | // disabling rule as button has type defined in `buttonProps` | ||
75 | /* eslint-disable react/button-has-type */ | ||
76 | <button {...buttonProps}> | ||
77 | <Loader | ||
78 | loaded={loaded} | ||
79 | lines={10} | ||
80 | scale={0.4} | ||
81 | color={ | ||
82 | buttonType !== 'secondary' | ||
83 | ? '#FFF' | ||
84 | : this.props.stores.settings.app.accentColor | ||
85 | } | ||
86 | component="span" | ||
87 | /> | ||
88 | {label} | ||
89 | </button> | ||
90 | /* eslint-enable react/button-has-type */ | ||
91 | ); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | export default Button; | ||