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

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