ExpandOrContractButton.tsx 802 B

1234567891011121314151617181920212223242526272829303132333435
  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={`btn ${isWindowExpanded ? 'icon-size-actual' : 'icon-size-fullscreen'}`}
  23. onClick={isWindowExpanded ? clickContractButtonHandler : clickExpandButtonHandler}
  24. >
  25. </button>
  26. );
  27. };
  28. export default ExpandOrContractButton;