aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/images/flipping-logo.tsx
blob: 64e69ca33ee93756195b015688667fbae2d650ac (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
56
import Image, { type ImageProps } from 'next/image';
import { ForwardedRef, forwardRef, ForwardRefRenderFunction } from 'react';
import { Logo, type LogoProps } from '../../atoms';
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'];
};

const FlippingLogoWithRef: 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
          {...props}
          alt={altText}
          height="100"
          src={photo}
          style={{ objectFit: 'cover' }}
          width="100"
        />
      </div>
      <div className={styles.logo__back}>
        <Logo title={logoTitle} />
      </div>
    </div>
  );
};

/**
 * FlippingLogo component
 *
 * Render a logo and a photo with a flipping effect.
 */
export const FlippingLogo = forwardRef(FlippingLogoWithRef);