From f11a906420975e833f278a08470d8f9783c76f73 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 9 Oct 2023 14:33:29 +0200
Subject: refactor(components): extract FlippingLogo from Branding component

---
 .../images/flipping-logo/flipping-logo.tsx         | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 src/components/molecules/images/flipping-logo/flipping-logo.tsx

(limited to 'src/components/molecules/images/flipping-logo/flipping-logo.tsx')

diff --git a/src/components/molecules/images/flipping-logo/flipping-logo.tsx b/src/components/molecules/images/flipping-logo/flipping-logo.tsx
new file mode 100644
index 0000000..e22feae
--- /dev/null
+++ b/src/components/molecules/images/flipping-logo/flipping-logo.tsx
@@ -0,0 +1,41 @@
+import {
+  forwardRef,
+  type ReactNode,
+  type ForwardRefRenderFunction,
+} from 'react';
+import { Flip, type FlipProps, FlipSide } from '../../../atoms';
+import styles from './flipping-logo.module.scss';
+
+type FlippingLogoProps = Omit<FlipProps, 'children'> & {
+  /**
+   * The back face.
+   */
+  back: ReactNode;
+  /**
+   * The front face.
+   */
+  front: ReactNode;
+};
+
+const FlippingLogoWithRef: ForwardRefRenderFunction<
+  HTMLDivElement,
+  FlippingLogoProps
+> = ({ back, className = '', front, ...props }, ref) => {
+  const wrapperClass = `${styles.wrapper} ${className}`;
+
+  return (
+    <Flip {...props} className={wrapperClass} ref={ref}>
+      <FlipSide className={styles.side}>{front}</FlipSide>
+      <FlipSide className={styles.side} isBack>
+        {back}
+      </FlipSide>
+    </Flip>
+  );
+};
+
+/**
+ * FlippingLogo component
+ *
+ * Renders a website logo with two faces.
+ */
+export const FlippingLogo = forwardRef(FlippingLogoWithRef);
-- 
cgit v1.2.3

