ExpandOrContractButton.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { FC } from 'react';
  2. import React from 'react';
  3. import styles from './ExpandOrContractButton.module.scss';
  4. type Props = {
  5. isWindowExpanded: boolean,
  6. contractWindow?: () => void,
  7. expandWindow?: () => void,
  8. };
  9. const moduleClass = styles['btn-expand-or-contract'] ?? '';
  10. const ExpandOrContractButton: FC<Props> = (props: Props) => {
  11. const { isWindowExpanded, contractWindow, expandWindow } = props;
  12. const clickContractButtonHandler = (): void => {
  13. if (contractWindow != null) {
  14. contractWindow();
  15. }
  16. };
  17. const clickExpandButtonHandler = (): void => {
  18. if (expandWindow != null) {
  19. expandWindow();
  20. }
  21. };
  22. return (
  23. <button
  24. type="button"
  25. className={`btn ${moduleClass}`}
  26. onClick={isWindowExpanded ? clickContractButtonHandler : clickExpandButtonHandler}
  27. >
  28. <span className="material-symbols-outlined fw-bold">
  29. {isWindowExpanded ? 'close_fullscreen' : 'open_in_full'}
  30. </span>
  31. </button>
  32. );
  33. };
  34. export default ExpandOrContractButton;