The code powering m.abunchtell.com https://m.abunchtell.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

56 lignes
1.3 KiB

  1. import React from 'react';
  2. import IconButton from '../../../components/icon_button';
  3. import PropTypes from 'prop-types';
  4. import { defineMessages, injectIntl } from 'react-intl';
  5. const messages = defineMessages({
  6. add_poll: { id: 'poll_button.add_poll', defaultMessage: 'Add a poll' },
  7. remove_poll: { id: 'poll_button.remove_poll', defaultMessage: 'Remove poll' },
  8. });
  9. const iconStyle = {
  10. height: null,
  11. lineHeight: '27px',
  12. };
  13. export default
  14. @injectIntl
  15. class PollButton extends React.PureComponent {
  16. static propTypes = {
  17. disabled: PropTypes.bool,
  18. unavailable: PropTypes.bool,
  19. active: PropTypes.bool,
  20. onClick: PropTypes.func.isRequired,
  21. intl: PropTypes.object.isRequired,
  22. };
  23. handleClick = () => {
  24. this.props.onClick();
  25. }
  26. render () {
  27. const { intl, active, unavailable, disabled } = this.props;
  28. if (unavailable) {
  29. return null;
  30. }
  31. return (
  32. <div className='compose-form__poll-button'>
  33. <IconButton
  34. icon='tasks'
  35. title={intl.formatMessage(active ? messages.remove_poll : messages.add_poll)}
  36. disabled={disabled}
  37. onClick={this.handleClick}
  38. className={`compose-form__poll-button-icon ${active ? 'active' : ''}`}
  39. size={18}
  40. inverted
  41. style={iconStyle}
  42. />
  43. </div>
  44. );
  45. }
  46. }