diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-14 23:32:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 03:02:05 +0530 |
commit | 137555821f172e4eadc7cf099d4270ae8fc1374e (patch) | |
tree | 693882bbf7a6b2a24b5a727091d09586d0371007 /src/components/ui/Radio.js | |
parent | New translations en-US.json (Spanish) (#2072) (diff) | |
download | ferdium-app-137555821f172e4eadc7cf099d4270ae8fc1374e.tar.gz ferdium-app-137555821f172e4eadc7cf099d4270ae8fc1374e.tar.zst ferdium-app-137555821f172e4eadc7cf099d4270ae8fc1374e.zip |
chore: convert components to tsx (#2071)
Diffstat (limited to 'src/components/ui/Radio.js')
-rw-r--r-- | src/components/ui/Radio.js | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/components/ui/Radio.js b/src/components/ui/Radio.js deleted file mode 100644 index 5354dbfe1..000000000 --- a/src/components/ui/Radio.js +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer } from 'mobx-react'; | ||
4 | import { Field } from 'mobx-react-form'; | ||
5 | import classnames from 'classnames'; | ||
6 | |||
7 | @observer | ||
8 | class Radio extends Component { | ||
9 | static propTypes = { | ||
10 | field: PropTypes.instanceOf(Field).isRequired, | ||
11 | className: PropTypes.string, | ||
12 | focus: PropTypes.bool, | ||
13 | showLabel: PropTypes.bool, | ||
14 | }; | ||
15 | |||
16 | static defaultProps = { | ||
17 | className: null, | ||
18 | focus: false, | ||
19 | showLabel: true, | ||
20 | }; | ||
21 | |||
22 | inputElement = null; | ||
23 | |||
24 | componentDidMount() { | ||
25 | if (this.props.focus) { | ||
26 | this.focus(); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | focus() { | ||
31 | this.inputElement.focus(); | ||
32 | } | ||
33 | |||
34 | render() { | ||
35 | const { field, className, showLabel } = this.props; | ||
36 | |||
37 | return ( | ||
38 | <div | ||
39 | className={classnames({ | ||
40 | 'franz-form__field': true, | ||
41 | 'has-error': field.error, | ||
42 | [`${className}`]: className, | ||
43 | })} | ||
44 | > | ||
45 | {field.label && showLabel && ( | ||
46 | <label className="franz-form__label" htmlFor={field.name}> | ||
47 | {field.label} | ||
48 | </label> | ||
49 | )} | ||
50 | <div className="franz-form__radio-wrapper"> | ||
51 | {field.options.map(type => ( | ||
52 | <label | ||
53 | key={type.value} | ||
54 | htmlFor={`${field.id}-${type.value}`} | ||
55 | className={classnames({ | ||
56 | 'franz-form__radio': true, | ||
57 | 'is-selected': field.value === type.value, | ||
58 | })} | ||
59 | > | ||
60 | <input | ||
61 | id={`${field.id}-${type.value}`} | ||
62 | type="radio" | ||
63 | name="type" | ||
64 | value={type.value} | ||
65 | onChange={field.onChange} | ||
66 | checked={field.value === type.value} | ||
67 | /> | ||
68 | {type.label} | ||
69 | </label> | ||
70 | ))} | ||
71 | </div> | ||
72 | {field.error && <div className="franz-form__error">{field.error}</div>} | ||
73 | </div> | ||
74 | ); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | export default Radio; | ||