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.

ActionButton.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import React from 'react';
  3. import { Icon, IconArrowDown } from '../../../icons';
  4. type Props = {
  5. /**
  6. * Text of the button.
  7. */
  8. children: React$Node,
  9. /**
  10. * Text css class of the button.
  11. */
  12. className?: string,
  13. /**
  14. * If the button is disabled or not.
  15. */
  16. disabled?: boolean,
  17. /**
  18. * If the button has options.
  19. */
  20. hasOptions?: boolean,
  21. /**
  22. * Icon to display in the options section.
  23. */
  24. OptionsIcon?: React$Node,
  25. /**
  26. * TestId of the button. Can be used to locate element when testing UI.
  27. */
  28. testId?: string,
  29. /**
  30. * The type of th button: primary, secondary, text.
  31. */
  32. type: string,
  33. /**
  34. * OnClick button handler.
  35. */
  36. onClick: Function,
  37. /**
  38. * Click handler for options.
  39. */
  40. onOptionsClick?: Function
  41. };
  42. /**
  43. * Button used for pre meeting actions.
  44. *
  45. * @returns {ReactElement}
  46. */
  47. function ActionButton({
  48. children,
  49. className = '',
  50. disabled,
  51. hasOptions,
  52. OptionsIcon = IconArrowDown,
  53. testId,
  54. type = 'primary',
  55. onClick,
  56. onOptionsClick
  57. }: Props) {
  58. return (
  59. <div
  60. className = { `action-btn ${className} ${type} ${disabled ? 'disabled' : ''}` }
  61. data-testid = { testId ? testId : undefined }
  62. onClick = { disabled ? undefined : onClick }>
  63. {children}
  64. {hasOptions && <div
  65. className = 'options'
  66. data-testid = 'prejoin.joinOptions'
  67. onClick = { disabled ? undefined : onOptionsClick }>
  68. <Icon
  69. className = 'icon'
  70. size = { 14 }
  71. src = { OptionsIcon } />
  72. </div>
  73. }
  74. </div>
  75. );
  76. }
  77. export default ActionButton;