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.

DropdownButton.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // @flow
  2. import { withStyles } from '@material-ui/styles';
  3. import React from 'react';
  4. import { Icon } from '../../base/icons';
  5. type Props = {
  6. /**
  7. * The css classes generated from theme.
  8. */
  9. classes: Object,
  10. /**
  11. * Attribute used in automated testing.
  12. */
  13. dataTestId: string,
  14. /**
  15. * The button's icon.
  16. */
  17. icon: HTMLElement,
  18. /**
  19. * The button's label.
  20. */
  21. label: string,
  22. /**
  23. * Function to be called when button is clicked.
  24. */
  25. onButtonClick: Function,
  26. /**
  27. * Function to be called on key pressed.
  28. */
  29. onKeyPressed: Function,
  30. /**
  31. * Used for translation.
  32. */
  33. t: Function
  34. };
  35. /**
  36. * Creates the styles for the component.
  37. *
  38. * @param {Object} theme - The current UI theme.
  39. *
  40. * @returns {Object}
  41. */
  42. const styles = theme => {
  43. return {
  44. prejoinPreviewDropdownBtn: {
  45. alignItems: 'center',
  46. color: '#1C2025',
  47. cursor: 'pointer',
  48. display: 'flex',
  49. height: 40,
  50. fontSize: 15,
  51. lineHeight: '24px',
  52. padding: '0 16px',
  53. backgroundColor: theme.palette.field02,
  54. '&:hover': {
  55. backgroundColor: theme.palette.field02Hover
  56. }
  57. },
  58. prejoinPreviewDropdownIcon: {
  59. display: 'inline-block',
  60. marginRight: 16,
  61. '& > svg': {
  62. fill: '#1C2025'
  63. }
  64. }
  65. };
  66. };
  67. /**
  68. * Buttons used for pre meeting actions.
  69. *
  70. * @returns {ReactElement}
  71. */
  72. const DropdownButton = ({
  73. classes,
  74. dataTestId,
  75. icon,
  76. onButtonClick,
  77. onKeyPressed,
  78. label
  79. }: Props) => (
  80. <div
  81. className = { classes.prejoinPreviewDropdownBtn }
  82. data-testid = { dataTestId }
  83. onClick = { onButtonClick }
  84. onKeyPress = { onKeyPressed }
  85. role = 'button'
  86. tabIndex = { 0 }>
  87. <Icon
  88. className = { classes.prejoinPreviewDropdownIcon }
  89. size = { 24 }
  90. src = { icon } />
  91. {label}
  92. </div>
  93. );
  94. export default withStyles(styles)(DropdownButton);