您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DropdownButton.tsx 2.1KB

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