You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ActionButton.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. * TestId of the button. Can be used to locate element when testing UI.
  23. */
  24. testId?: string,
  25. /**
  26. * The type of th button: primary, secondary, text.
  27. */
  28. type: string,
  29. /**
  30. * OnClick button handler.
  31. */
  32. onClick: Function,
  33. /**
  34. * Click handler for options.
  35. */
  36. onOptionsClick?: Function
  37. };
  38. /**
  39. * Button used for pre meeting actions.
  40. *
  41. * @returns {ReactElement}
  42. */
  43. function ActionButton({
  44. children,
  45. className = '',
  46. disabled,
  47. hasOptions,
  48. testId,
  49. type = 'primary',
  50. onClick,
  51. onOptionsClick
  52. }: Props) {
  53. return (
  54. <div
  55. className = { `action-btn ${className} ${type} ${disabled ? 'disabled' : ''}` }
  56. data-testid = { testId ? testId : undefined }
  57. onClick = { disabled ? undefined : onClick }>
  58. {children}
  59. {hasOptions && <div
  60. className = 'options'
  61. data-testid = 'prejoin.joinOptions'
  62. onClick = { disabled ? undefined : onOptionsClick }>
  63. <Icon
  64. className = 'icon'
  65. size = { 14 }
  66. src = { IconArrowDown } />
  67. </div>
  68. }
  69. </div>
  70. );
  71. }
  72. export default ActionButton;