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

DesktopPickerPane.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import DesktopSourcePreview from './DesktopSourcePreview';
  4. /**
  5. * React component for showing a grid of DesktopSourcePreviews.
  6. *
  7. * @extends Component
  8. */
  9. class DesktopPickerPane extends Component {
  10. /**
  11. * DesktopPickerPane component's property types.
  12. *
  13. * @static
  14. */
  15. static propTypes = {
  16. /**
  17. * The handler to be invoked when a DesktopSourcePreview is clicked.
  18. */
  19. onClick: PropTypes.func,
  20. /**
  21. * The handler to be invoked when a DesktopSourcePreview is double
  22. * clicked.
  23. */
  24. onDoubleClick: PropTypes.func,
  25. /**
  26. * The id of the DesktopCapturerSource that is currently selected.
  27. */
  28. selectedSourceId: PropTypes.string,
  29. /**
  30. * An array of DesktopCapturerSources.
  31. */
  32. sources: PropTypes.array,
  33. /**
  34. * The source type of the DesktopCapturerSources to display.
  35. */
  36. type: PropTypes.string
  37. };
  38. /**
  39. * Implements React's {@link Component#render()}.
  40. *
  41. * @inheritdoc
  42. * @returns {ReactElement}
  43. */
  44. render() {
  45. const {
  46. onClick,
  47. onDoubleClick,
  48. selectedSourceId,
  49. sources,
  50. type
  51. } = this.props;
  52. const classNames
  53. = `desktop-picker-pane default-scrollbar source-type-${type}`;
  54. const previews
  55. = sources.map(
  56. source =>
  57. // eslint-disable-next-line react/jsx-wrap-multilines
  58. <DesktopSourcePreview
  59. key = { source.id }
  60. onClick = { onClick }
  61. onDoubleClick = { onDoubleClick }
  62. selected = { source.id === selectedSourceId }
  63. source = { source }
  64. type = { type } />);
  65. return (
  66. <div className = { classNames }>
  67. { previews }
  68. </div>
  69. );
  70. }
  71. }
  72. export default DesktopPickerPane;