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.

DesktopPickerPane.js 2.0KB

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