about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/report/components/status_check_box.jsx
blob: 6d976582be7d92da89934c532a010c8ef3648d0b (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
import PureRenderMixin from 'react-addons-pure-render-mixin';
import ImmutablePropTypes from 'react-immutable-proptypes';
import emojify from '../../../emoji';
import Toggle from 'react-toggle';

const StatusCheckBox = React.createClass({

  propTypes: {
    status: ImmutablePropTypes.map.isRequired,
    checked: React.PropTypes.bool,
    onToggle: React.PropTypes.func.isRequired,
    disabled: React.PropTypes.bool
  },

  mixins: [PureRenderMixin],

  render () {
    const { status, checked, onToggle, disabled } = this.props;
    const content = { __html: emojify(status.get('content')) };

    if (status.get('reblog')) {
      return null;
    }

    return (
      <div className='status-check-box' style={{ display: 'flex' }}>
        <div
          className='status__content'
          style={{ flex: '1 1 auto', padding: '10px' }}
          dangerouslySetInnerHTML={content}
        />

        <div style={{ flex: '0 0 auto', padding: '10px', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
          <Toggle checked={checked} onChange={onToggle} disabled={disabled} />
        </div>
      </div>
    );
  }

});

export default StatusCheckBox;