aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/images/flipping-logo.tsx
blob: 1099d53ea91876a989cb6fdd536865896bd710a7 (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
46
47
48
49
50
51
52
53
54
55
import Logo, { type LogoProps } from '@components/atoms/images/logo';
import Image, { type ImageProps } from 'next/image';
import { ForwardedRef, forwardRef, ForwardRefRenderFunction } from 'react';
import styles from './flipping-logo.module.scss';

export type FlippingLogoProps = {
  /**
   * Set additional classnames to the logo wrapper.
   */
  className?: string;
  /**
   * Photo alternative text.
   */
  altText: string;
  /**
   * Logo image title.
   */
  logoTitle?: LogoProps['title'];
  /**
   * Photo url.
   */
  photo: ImageProps['src'];
};

/**
 * FlippingLogo component
 *
 * Render a logo and a photo with a flipping effect.
 */
const FlippingLogo: ForwardRefRenderFunction<
  HTMLDivElement,
  FlippingLogoProps
> = (
  { className = '', altText, logoTitle, photo, ...props },
  ref: ForwardedRef<HTMLDivElement>
) => {
  return (
    <div className={`${styles.logo} ${className}`} ref={ref}>
      <div className={styles.logo__front}>
        <Image
          src={photo}
          alt={altText}
          layout="fill"
          objectFit="cover"
          {...props}
        />
      </div>
      <div className={styles.logo__back}>
        <Logo title={logoTitle} />
      </div>
    </div>
  );
};

export default forwardRef(FlippingLogo);