summaryrefslogtreecommitdiffstats
path: root/src/components/Widgets/CVPreview/CVPreview.module.scss
blob: 6ddd696442d8b59ae011f895c259eb8ce1f99a77 (plain)
1
2
3
4
5
6
.preview {
  position: relative;
  width: 100%;
  height: 20rem;
  margin-bottom: var(--spacing-sm);
}
* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
import Checkbox, { type CheckboxProps } from '@components/atoms/forms/checkbox';
import Label from '@components/atoms/forms/label';
import MagnifyingGlass from '@components/atoms/icons/magnifying-glass';
import { forwardRef, ForwardRefRenderFunction } from 'react';
import { useIntl } from 'react-intl';
import SearchModal, { type SearchModalProps } from '../modals/search-modal';
import searchStyles from './search.module.scss';
import sharedStyles from './toolbar-items.module.scss';

export type SearchProps = {
  /**
   * Set additional classnames to the modal wrapper.
   */
  className?: SearchModalProps['className'];
  /**
   * The button state.
   */
  isActive: CheckboxProps['value'];
  /**
   * A callback function to execute search.
   */
  searchPage: SearchModalProps['searchPage'];
  /**
   * A callback function to handle button state.
   */
  setIsActive: CheckboxProps['setValue'];
};

const Search: ForwardRefRenderFunction<HTMLDivElement, SearchProps> = (
  { className = '', isActive, searchPage, setIsActive },
  ref
) => {
  const intl = useIntl();
  const label = isActive
    ? intl.formatMessage({
        defaultMessage: 'Close search',
        id: 'LDDUNO',
        description: 'Search: Close label',
      })
    : intl.formatMessage({
        defaultMessage: 'Open search',
        id: 'Xj+WXB',
        description: 'Search: Open label',
      });

  return (
    <div className={`${sharedStyles.item} ${searchStyles.item}`} ref={ref}>
      <Checkbox
        id="search-button"
        name="search-button"
        value={isActive}
        setValue={setIsActive}
        className={`${sharedStyles.checkbox} ${searchStyles.checkbox}`}
      />
      <Label
        htmlFor="search-button"
        aria-label={label}
        className={`${sharedStyles.label} ${searchStyles.label}`}
      >
        <MagnifyingGlass />
      </Label>
      <SearchModal
        searchPage={searchPage}
        className={`${sharedStyles.modal} ${searchStyles.modal} ${className}`}
      />
    </div>
  );
};

export default forwardRef(Search);