您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PollAnswer.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import { Checkbox } from '@atlaskit/checkbox';
  3. import React from 'react';
  4. import { isSubmitAnswerDisabled } from '../../functions';
  5. import AbstractPollAnswer from '../AbstractPollAnswer';
  6. import type { AbstractProps } from '../AbstractPollAnswer';
  7. const PollAnswer = (props: AbstractProps) => {
  8. const {
  9. checkBoxStates,
  10. poll,
  11. setCheckbox,
  12. skipAnswer,
  13. submitAnswer,
  14. t
  15. } = props;
  16. return (
  17. <div className = 'poll-answer'>
  18. <div className = 'poll-header'>
  19. <div className = 'poll-question'>
  20. <span>{ poll.question }</span>
  21. </div>
  22. </div>
  23. <ol className = 'poll-answer-list'>
  24. {
  25. poll.answers.map((answer, index) => (
  26. <li
  27. className = 'poll-answer-container'
  28. key = { index }>
  29. <Checkbox
  30. isChecked = { checkBoxStates[index] }
  31. key = { index }
  32. label = { <span>{ answer.name }</span> }
  33. // eslint-disable-next-line react/jsx-no-bind
  34. onChange = { ev => setCheckbox(index, ev.target.checked) }
  35. size = 'large' />
  36. </li>
  37. ))
  38. }
  39. </ol>
  40. <div className = { 'poll-footer' }>
  41. <button
  42. aria-label = { t('polls.answer.skip') }
  43. className = { 'poll-small-secondary-button' }
  44. onClick = { skipAnswer } >
  45. <span>{t('polls.answer.skip')}</span>
  46. </button>
  47. <button
  48. aria-label = { t('polls.answer.submit') }
  49. className = 'poll-small-primary-button'
  50. disabled = { isSubmitAnswerDisabled(checkBoxStates) }
  51. onClick = { submitAnswer }>
  52. <span>{t('polls.answer.submit')}</span>
  53. </button>
  54. </div>
  55. </div>
  56. );
  57. };
  58. /*
  59. * We apply AbstractPollAnswer to fill in the AbstractProps common
  60. * to both the web and native implementations.
  61. */
  62. // eslint-disable-next-line new-cap
  63. export default AbstractPollAnswer(PollAnswer);