summaryrefslogtreecommitdiffstats
path: root/src/components/organisms/modals/search-modal.test.tsx
blob: 249c5235c0b47440e7de706f852ebd47f07b30df (plain)
1
2
3
4
5
6
7
8
9
import { render, screen } from '@test-utils';
import SearchModal from './search-modal';

describe('SearchModal', () => {
  it('renders a search modal', () => {
    render(<SearchModal />);
    expect(screen.getByText('Search')).toBeInTheDocument();
  });
});
nt-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* 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 Heading from '@components/atoms/headings/heading';
import useStyles from '@utils/hooks/use-styles';
import Link from 'next/link';
import { FC, useRef } from 'react';
import { useIntl } from 'react-intl';
import FlippingLogo, { type FlippingLogoProps } from '../images/flipping-logo';
import styles from './branding.module.scss';

export type BrandingProps = Pick<FlippingLogoProps, 'photo'> & {
  /**
   * The Branding baseline.
   */
  baseline?: string;
  /**
   * Use H1 if the current page is homepage. Default: false.
   */
  isHome?: boolean;
  /**
   * The Branding title;
   */
  title: string;
  /**
   * Wraps the title with a link to homepage. Default: false.
   */
  withLink?: boolean;
};

/**
 * Branding component
 *
 * Render the branding logo, title and optional baseline.
 */
const Branding: FC<BrandingProps> = ({
  baseline,
  isHome = false,
  photo,
  title,
  withLink = false,
  ...props
}) => {
  const baselineRef = useRef<HTMLParagraphElement>(null);
  const logoRef = useRef<HTMLDivElement>(null);
  const titleRef = useRef<HTMLHeadingElement | HTMLParagraphElement>(null);
  const intl = useIntl();
  const altText = intl.formatMessage(
    {
      defaultMessage: '{website} picture',
      description: 'Branding: photo alternative text',
      id: 'dDK5oc',
    },
    { website: title }
  );
  const logoTitle = intl.formatMessage(
    {
      defaultMessage: '{website} logo',
      description: 'Branding: logo title',
      id: 'x55qsD',
    },
    { website: title }
  );

  useStyles({
    property: '--typing-animation',
    styles: 'blink 0.7s ease-in-out 0s 2, typing 4.3s linear 0s 1',
    target: titleRef,
  });
  useStyles({
    property: '--typing-animation',
    styles:
      'hide-text 4.25s linear 0s 1, blink 0.8s ease-in-out 4.25s 2, typing 3.8s linear 4.25s 1',
    target: baselineRef,
  });
  useStyles({
    property: 'animation',
    styles: 'flip-logo 9s ease-in 0s 1',
    target: logoRef,
  });

  return (
    <div className={styles.wrapper}>
      <FlippingLogo
        className={styles.logo}
        altText={altText}
        logoTitle={logoTitle}
        photo={photo}
        ref={logoRef}
        {...props}
      />
      <Heading
        isFake={!isHome}
        level={1}
        withMargin={false}
        className={styles.title}
        ref={titleRef}
      >
        {withLink ? (
          <Link href="/">
            <a className={styles.link}>{title}</a>
          </Link>
        ) : (
          title
        )}
      </Heading>
      {baseline && (
        <Heading
          isFake={true}
          level={4}
          withMargin={false}
          className={styles.baseline}
          ref={baselineRef}
        >
          {baseline}
        </Heading>
      )}
    </div>
  );
};

export default Branding;