ExpandOrContractButton.jsx 885 B

123456789101112131415161718192021222324252627282930313233
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. function ExpandOrContractButton(props) {
  4. const { isWindowExpanded, contractWindow, expandWindow } = props;
  5. const clickContractButtonHandler = () => {
  6. if (contractWindow != null) {
  7. contractWindow();
  8. }
  9. };
  10. const clickExpandButtonHandler = () => {
  11. if (expandWindow != null) {
  12. expandWindow();
  13. }
  14. };
  15. return (
  16. <button type="button" className="close" onClick={isWindowExpanded ? clickContractButtonHandler : clickExpandButtonHandler}>
  17. <i className={`${isWindowExpanded ? 'icon-size-actual' : 'icon-size-fullscreen'}`} style={{ fontSize: '0.8em' }} aria-hidden="true"></i>
  18. </button>
  19. );
  20. }
  21. ExpandOrContractButton.propTypes = {
  22. isWindowExpanded: PropTypes.bool,
  23. contractWindow: PropTypes.func,
  24. expandWindow: PropTypes.func,
  25. };
  26. export default ExpandOrContractButton;