From c153f93dc8691a71dc76aad3dd618298da9d238a Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 17 Oct 2023 19:46:08 +0200
Subject: refactor(components): rewrite Card component

* make the component more generic
* merge `<Summary />` and `<Comment />` styles into card component
to avoid repeating the same structure
* remove most of the props to use composition

However the CSS is a bit complex because of the two variants...

Also, the component should be refactored when the CSS pseudo-class
`:has` has enough support: the provider and the `cover` and `meta`
props should be removed.
---
 src/components/molecules/card/card-title.tsx | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 src/components/molecules/card/card-title.tsx

(limited to 'src/components/molecules/card/card-title.tsx')

diff --git a/src/components/molecules/card/card-title.tsx b/src/components/molecules/card/card-title.tsx
new file mode 100644
index 0000000..09d61ea
--- /dev/null
+++ b/src/components/molecules/card/card-title.tsx
@@ -0,0 +1,27 @@
+import { type ForwardRefRenderFunction, forwardRef } from 'react';
+import { Heading, type HeadingProps } from '../../atoms';
+import styles from './card.module.scss';
+
+export type CardTitleProps = Omit<HeadingProps, 'level'> & {
+  /**
+   * The title level (between 1 and 6).
+   *
+   * @default 2
+   */
+  level?: HeadingProps['level'];
+};
+
+const CardTitleWithRef: ForwardRefRenderFunction<
+  HTMLHeadingElement,
+  CardTitleProps
+> = ({ children, className = '', level = 2, ...props }, ref) => {
+  const headingClass = `${styles.title} ${className}`;
+
+  return (
+    <Heading {...props} className={headingClass} level={level} ref={ref}>
+      {children}
+    </Heading>
+  );
+};
+
+export const CardTitle = forwardRef(CardTitleWithRef);
-- 
cgit v1.2.3

