From 6dc2be997e08d1b52df80aef662fd19eb7935c10 Mon Sep 17 00:00:00 2001 From: isrark005 Date: Sun, 17 Nov 2024 22:36:30 +0530 Subject: [PATCH] optimized aporach for adding size --- src/App.tsx | 18 +++++++++--------- src/components/ui/Button.tsx | 16 +++++++++------- src/icons/PlusIcon.tsx | 4 ++-- src/icons/ShareIcon.tsx | 4 ++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 8839c2f..2b9d0fc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,26 +9,26 @@ function App() { <> diff --git a/src/components/ui/Button.tsx b/src/components/ui/Button.tsx index 06ba4fc..0dddea6 100644 --- a/src/components/ui/Button.tsx +++ b/src/components/ui/Button.tsx @@ -1,4 +1,4 @@ -import { ReactElement } from "react"; +import React, { ReactElement } from "react"; interface ButtonInterface { title: string; @@ -19,15 +19,17 @@ const variantStyles = { "secondary": "bg-purple-400 text-purple-600", } -export function Button(props: ButtonInterface) { +export function Button({startIcon, size, endIcon, title, variant}: ButtonInterface) { + const StartIconWithProps = startIcon ? React.cloneElement(startIcon, { size }) : null; + const EndIconWithProps = endIcon ? React.cloneElement(endIcon, { size }) : null; - return } diff --git a/src/icons/PlusIcon.tsx b/src/icons/PlusIcon.tsx index b4beaef..8347966 100644 --- a/src/icons/PlusIcon.tsx +++ b/src/icons/PlusIcon.tsx @@ -1,6 +1,6 @@ interface PlusIconProps { - size: "sm" | "md" | "lg" + size?: "sm" | "md" | "lg" } const sizeVariants = { @@ -10,7 +10,7 @@ const sizeVariants = { } export function PlusIcon(props: PlusIconProps) { - return + return } \ No newline at end of file diff --git a/src/icons/ShareIcon.tsx b/src/icons/ShareIcon.tsx index 45b3b72..1cec0df 100644 --- a/src/icons/ShareIcon.tsx +++ b/src/icons/ShareIcon.tsx @@ -1,6 +1,6 @@ interface ShareIconProps { - size: "sm" | "md" | "lg" + size?: "sm" | "md" | "lg" } const sizeVariants = { @@ -11,7 +11,7 @@ const sizeVariants = { export function ShareIcon(props: ShareIconProps) { - return + return