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

DesktopPickerPane.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 ? sources.map(
  57. source =>
  58. // eslint-disable-next-line react/jsx-wrap-multilines
  59. <DesktopSourcePreview
  60. key = { source.id }
  61. onClick = { onClick }
  62. onDoubleClick = { onDoubleClick }
  63. selected = { source.id === selectedSourceId }
  64. source = { source }
  65. type = { type } />)
  66. : ( // eslint-disable-line no-extra-parens
  67. <div className = 'desktop-picker-pane-spinner'>
  68. <Spinner
  69. isCompleting = { false }
  70. size = 'medium' />
  71. </div>
  72. );
  73. return (
  74. <div className = { classNames }>
  75. { previews }
  76. </div>
  77. );
  78. }
  79. }
  80. export default DesktopPickerPane;