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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // @flow
  2. import React from 'react';
  3. import { Icon, IconArrowDown } from '../../../base/icons';
  4. const classNameByType = {
  5. primary: 'prejoin-btn--primary',
  6. secondary: 'prejoin-btn--secondary',
  7. text: 'prejoin-btn--text'
  8. };
  9. type Props = {
  10. /**
  11. * Text of the button.
  12. */
  13. children: React$Node,
  14. /**
  15. * Text css class of the button.
  16. */
  17. className?: string,
  18. /**
  19. * If the button is disabled or not.
  20. */
  21. disabled?: boolean,
  22. /**
  23. * If the button has options.
  24. */
  25. hasOptions?: boolean,
  26. /**
  27. * The type of th button: primary, secondary, text.
  28. */
  29. type: string,
  30. /**
  31. * OnClick button handler.
  32. */
  33. onClick: Function,
  34. /**
  35. * Click handler for options.
  36. */
  37. onOptionsClick?: Function
  38. };
  39. /**
  40. * Button used for prejoin actions: Join/Join without audio/Join by phone.
  41. *
  42. * @returns {ReactElement}
  43. */
  44. function ActionButton({ children, className, disabled, hasOptions, type, onClick, onOptionsClick }: Props) {
  45. let ownClassName = 'prejoin-btn';
  46. let clickHandler = onClick;
  47. let optionsClickHandler = onOptionsClick;
  48. if (disabled) {
  49. clickHandler = null;
  50. optionsClickHandler = null;
  51. ownClassName = `${ownClassName} prejoin-btn--disabled`;
  52. } else {
  53. ownClassName = `${ownClassName} ${classNameByType[type]}`;
  54. }
  55. const cls = className ? `${className} ${ownClassName}` : ownClassName;
  56. return (
  57. <div
  58. className = { cls }
  59. onClick = { clickHandler }>
  60. {children}
  61. {hasOptions && <div
  62. className = 'prejoin-btn-options'
  63. onClick = { optionsClickHandler }>
  64. <Icon
  65. className = 'prejoin-btn-icon'
  66. size = { 14 }
  67. src = { IconArrowDown } />
  68. </div>
  69. }
  70. </div>
  71. );
  72. }
  73. export default ActionButton;