forked from bvaughn/react-virtualized
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLabeledInput.js
46 lines (43 loc) · 1 KB
/
LabeledInput.js
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
import PropTypes from 'prop-types';
import * as React from 'react';
import clsx from 'clsx';
import styles from './LabeledInput.css';
export function LabeledInput({
disabled,
label,
name,
onChange,
placeholder,
value,
}) {
const labelClassName = clsx(styles.Label, {
[styles.LabelDisabled]: disabled,
});
return (
<div className={styles.LabeledInput}>
<label className={labelClassName} title={label}>
{label}
</label>
<input
aria-label={label}
className={styles.Input}
name={name}
placeholder={placeholder}
onChange={onChange}
value={value}
disabled={disabled}
/>
</div>
);
}
LabeledInput.propTypes = {
disabled: PropTypes.bool,
label: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
placeholder: PropTypes.string,
value: PropTypes.any,
};
export function InputRow({children}) {
return <div className={styles.InputRow}>{children}</div>;
}