bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/checkbox/component.jsx

44 lines
1.2 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import PropTypes from 'prop-types';
2017-01-27 23:41:11 +08:00
import Icon from '../icon/component';
import styles from './styles';
import cx from 'classnames';
2017-01-27 23:41:11 +08:00
export default class Checkbox extends Component {
constructor(props) {
super(props);
2017-02-16 02:49:40 +08:00
this.onChange = props.onChange;
this.handleChange = this.handleChange.bind(this);
}
handleChange() {
this.onChange();
2017-01-27 23:41:11 +08:00
}
render() {
const { ariaLabel, ariaLabelledBy, ariaDesc, ariaDescribedBy } = this.props;
2017-04-25 10:08:18 +08:00
2017-01-27 23:41:11 +08:00
return (
<div className={styles.container}>
2017-01-27 23:41:11 +08:00
<input
2017-06-03 03:25:02 +08:00
type="checkbox"
2017-01-27 23:41:11 +08:00
onChange={this.handleChange}
checked={this.props.checked}
2017-04-25 10:08:18 +08:00
className={styles.input}
aria-labelledby={ariaLabelledBy}
2017-05-04 04:51:17 +08:00
aria-describedby={ariaDescribedBy}
2017-06-03 03:25:02 +08:00
/>
<div onClick={this.handleChange}>
{ this.props.checked ?
2017-06-03 03:25:02 +08:00
<Icon iconName="check" className={cx(styles.icon, styles.checked)} /> :
<Icon iconName="circle" className={styles.icon} />
2017-02-16 02:49:40 +08:00
}
2017-01-27 23:41:11 +08:00
</div>
2017-04-25 10:08:18 +08:00
<div id={ariaLabelledBy} hidden>{ariaLabel}</div>
<div id={ariaDescribedBy} hidden>{ariaDesc}</div>
2017-01-27 23:41:11 +08:00
</div>
);
}
}