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.tsx 2.1KB

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