aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Buttons/ButtonSearch/ButtonSearch.tsx
blob: be5a9bc67aea8afb9584833c6fff24b2650ee529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { CloseIcon, SearchIcon } from '@components/Icons';
import { t } from '@lingui/macro';
import { SetStateAction } from 'react';
import styles from '../Buttons.module.scss';

const ButtonSearch = ({
  isActivated,
  setIsActivated,
}: {
  isActivated: boolean;
  setIsActivated: (value: SetStateAction<boolean>) => void;
}) => {
  const btnClasses = isActivated
    ? `${styles.search} ${styles['search--opened']}`
    : styles.search;

  return (
    <button
      className={btnClasses}
      type="button"
      onClick={() => setIsActivated(!isActivated)}
    >
      <span className={styles.icon}>
        <span className={styles.front}>
          <SearchIcon />
        </span>
        <span className={styles.back}>
          <CloseIcon />
        </span>
      </span>
      {isActivated ? (
        <span className="screen-reader-text">{t`Close search`}</span>
      ) : (
        <span className="screen-reader-text">{t`Open search`}</span>
      )}
    </button>
  );
};

export default ButtonSearch;