aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/modals/search-modal.tsx
blob: be9d489defd0e3a2779c1e63aa9c5125a1d27f31 (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
41
42
43
44
45
import { forwardRef, type ForwardRefRenderFunction } from 'react';
import { useIntl } from 'react-intl';
import { Heading } from '../../atoms';
import { Modal, type ModalProps } from '../../molecules';
import { SearchForm, type SearchFormProps } from '../forms';
import styles from './search-modal.module.scss';

export type SearchModalProps = SearchFormProps & {
  /**
   * Set additional classnames to modal wrapper.
   */
  className?: ModalProps['className'];
};

const SearchModalWithRef: ForwardRefRenderFunction<
  HTMLInputElement,
  SearchModalProps
> = ({ className, searchPage }, ref) => {
  const intl = useIntl();
  const modalTitle = intl.formatMessage({
    defaultMessage: 'Search',
    description: 'SearchModal: modal title',
    id: 'G+Twgm',
  });

  return (
    <Modal
      className={`${styles.wrapper} ${className}`}
      heading={
        <Heading isFake level={3}>
          {modalTitle}
        </Heading>
      }
    >
      <SearchForm isLabelHidden ref={ref} searchPage={searchPage} />
    </Modal>
  );
};

/**
 * SearchModal
 *
 * Render a search form modal.
 */
export const SearchModal = forwardRef(SearchModalWithRef);