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.3KB

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