blob: ee3268b164c459fb4d65a6cc92609550ade8974f (
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
48
49
|
import classnames from 'classnames';
import { Classes } from 'jss';
import { observer } from 'mobx-react';
import React, { Component } from 'react';
import injectSheet from 'react-jss';
import { IFormField } from '../typings/generic';
import styles from './styles';
interface ILabel extends IFormField, React.LabelHTMLAttributes<HTMLLabelElement> {
classes: Classes;
}
@observer
class LabelComponent extends Component<ILabel> {
static defaultProps = {
showLabel: true,
};
render() {
const {
title,
showLabel,
classes,
className,
children,
htmlFor,
} = this.props;
return (
<label
className={classnames({
[`${className}`]: className,
})}
htmlFor={htmlFor}
>
{showLabel && (
<span className={classes.label}>{title}</span>
)}
<div className={classes.content}>
{children}
</div>
</label>
);
}
}
export const Label = injectSheet(styles)(LabelComponent);
|