2
0

ExpandOrContractButton.tsx 848 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import type { FC } from 'react';
  2. import React from 'react';
  3. type Props = {
  4. isWindowExpanded: boolean,
  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="btn material-symbols-outlined"
  24. onClick={isWindowExpanded ? clickContractButtonHandler : clickExpandButtonHandler}
  25. >
  26. {isWindowExpanded ? 'close_fullscreen' : 'open_in_full'}
  27. </button>
  28. );
  29. };
  30. export default ExpandOrContractButton;