ExpandOrContractButton.tsx 898 B

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