ExpandOrContractButton.tsx 880 B

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