From f737dbf87f535969c74124841abbe8dc91ba3cc3 Mon Sep 17 00:00:00 2001 From: Rafael Youakeem Date: Tue, 17 Sep 2024 15:21:48 +0200 Subject: [PATCH] Pass props down and clean their types --- packages/ui/src/components/Card/Card.tsx | 38 +++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/ui/src/components/Card/Card.tsx b/packages/ui/src/components/Card/Card.tsx index fa220a0156..eac63ee8b3 100644 --- a/packages/ui/src/components/Card/Card.tsx +++ b/packages/ui/src/components/Card/Card.tsx @@ -6,36 +6,46 @@ import { Heading, Text } from 'ui' import { cardHeader, cardRoot } from './Card.css' type RootStyleProps = RecipeVariants -type RootProps = ComponentProps<'div'> & RootStyleProps +type RootProps = ComponentProps<'article'> & RootStyleProps -function CardRoot({ variant, size, className, children }: PropsWithChildren) { - return
{children}
+function CardRoot({ variant, size, className, children, ...props }: RootProps) { + return ( +
+ {children} +
+ ) } type HeaderProps = ComponentProps<'header'> -function CardHeader({ className, children }: PropsWithChildren) { - return
{children}
+function CardHeader({ className, children, ...props }: HeaderProps) { + return ( +
+ {children} +
+ ) } -type MediaProps = PropsWithChildren> - -function CardMedia({ children }: MediaProps) { +function CardMedia({ children }: PropsWithChildren) { // Slot ensures only one element is passed as children return {children} } type HeadingProps = ComponentProps<'div'> -function CardHeading({ className, children }: PropsWithChildren) { - return
{children}
+function CardHeading({ className, children, ...props }: HeadingProps) { + return ( +
+ {children} +
+ ) } type TitleProps = ComponentProps -function CardTitle({ className, children }: PropsWithChildren) { +function CardTitle({ className, children, ...props }: TitleProps) { return ( - + {children} ) @@ -43,9 +53,9 @@ function CardTitle({ className, children }: PropsWithChildren) { type SubtitleProps = ComponentProps -function CardSubtitle({ className, children }: PropsWithChildren) { +function CardSubtitle({ className, children, ...props }: SubtitleProps) { return ( - + {children} )