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

PrimaryToolbar.web.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { getToolbarClassNames } from '../functions';
  5. import Toolbar from './Toolbar';
  6. declare var interfaceConfig: Object;
  7. /**
  8. * Implementation of PrimaryToolbar React Component.
  9. *
  10. * @class PrimaryToolbar
  11. * @extends Component
  12. */
  13. class PrimaryToolbar extends Component {
  14. static propTypes = {
  15. /**
  16. * Contains toolbar buttons for primary toolbar.
  17. */
  18. _primaryToolbarButtons: React.PropTypes.instanceOf(Map),
  19. /**
  20. * Shows whether toolbox is visible.
  21. */
  22. _visible: React.PropTypes.bool
  23. };
  24. state: Object;
  25. /**
  26. * Renders primary toolbar component.
  27. *
  28. * @returns {ReactElement}
  29. */
  30. render(): ReactElement<*> | null {
  31. const { _primaryToolbarButtons } = this.props;
  32. // The number of buttons to show in the toolbar isn't fixed, it depends
  33. // on the availability of features and configuration parameters. So
  34. // there may be nothing to render.
  35. if (_primaryToolbarButtons.size === 0) {
  36. return null;
  37. }
  38. const { primaryToolbarClassName } = getToolbarClassNames(this.props);
  39. const tooltipPosition
  40. = interfaceConfig.filmStripOnly ? 'left' : 'bottom';
  41. return (
  42. <Toolbar
  43. className = { primaryToolbarClassName }
  44. toolbarButtons = { _primaryToolbarButtons }
  45. tooltipPosition = { tooltipPosition } />
  46. );
  47. }
  48. }
  49. /**
  50. * Maps part of Redux store to React component props.
  51. *
  52. * @param {Object} state - Snapshot of Redux store.
  53. * @returns {{
  54. * _primaryToolbarButtons: Map,
  55. * _visible: boolean
  56. * }}
  57. * @private
  58. */
  59. function _mapStateToProps(state: Object): Object {
  60. const {
  61. primaryToolbarButtons,
  62. visible
  63. } = state['features/toolbox'];
  64. return {
  65. /**
  66. * Default toolbar buttons for primary toolbar.
  67. *
  68. * @private
  69. * @type {Map}
  70. */
  71. _primaryToolbarButtons: primaryToolbarButtons,
  72. /**
  73. * Shows whether toolbox is visible.
  74. *
  75. * @private
  76. * @type {boolean}
  77. */
  78. _visible: visible
  79. };
  80. }
  81. export default connect(_mapStateToProps)(PrimaryToolbar);