Skip to content

Commit 6a72e27

Browse files
committed
feat: optional gradient
1 parent e40ed5c commit 6a72e27

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

src/components/ui/card.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
3535
)
3636
}
3737

38-
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
38+
function CardTitle({ gradient = true, className, ...props }: React.ComponentProps<"div"> & { gradient?: boolean }) {
3939
return (
4040
<div
4141
data-slot="card-title"
4242
className={cn(
43-
"bg-linear-to-b from-blue-secondary to-blue-primary bg-clip-text font-medium text-[1.5rem] text-transparent leading-snug group-data-[size=sm]/card:text-base",
43+
`${gradient ? "bg-linear-to-b from-blue-secondary to-blue-primary bg-clip-text" : ""} font-medium text-[1.5rem] leading-snug group-data-[size=sm]/card:text-base`,
4444
className
4545
)}
4646
{...props}
@@ -56,8 +56,9 @@ function CardAction({
5656
className,
5757
icon: Icon,
5858
iconSize = "normal",
59+
gradient = true,
5960
...props
60-
}: React.ComponentProps<"div"> & { icon: IconType; iconSize: "small" | "normal" | "large" }) {
61+
}: React.ComponentProps<"div"> & { icon: IconType; iconSize: "small" | "normal" | "large"; gradient?: boolean }) {
6162
const gradientId = React.useId()
6263

6364
return (
@@ -66,18 +67,20 @@ function CardAction({
6667
className={cn("col-start-2 row-span-2 row-start-1 self-auto justify-self-end", className)}
6768
{...props}
6869
>
69-
<svg width="0" height="0" className="absolute">
70-
<title>Icon gradient helper</title>
71-
<linearGradient id={gradientId} x1="0%" y1="100%" x2="0%" y2="0%">
72-
<stop offset="0%" className="text-blue-secondary" stopColor="currentColor" />
73-
<stop offset="100%" className="text-blue-primary" stopColor="currentColor" />
74-
</linearGradient>
75-
</svg>
70+
{gradient && (
71+
<svg width="0" height="0" className="absolute">
72+
<title>Icon gradient helper</title>
73+
<linearGradient id={gradientId} x1="0%" y1="100%" x2="0%" y2="0%">
74+
<stop offset="0%" className="text-blue-secondary" stopColor="currentColor" />
75+
<stop offset="100%" className="text-blue-primary" stopColor="currentColor" />
76+
</linearGradient>
77+
</svg>
78+
)}
7679

7780
<Icon
7881
size={iconSize === "small" ? "1.125rem" : iconSize === "normal" ? "2rem" : "3.5rem"}
79-
fill={`url(#${gradientId})`}
80-
stroke={`url(#${gradientId})`}
82+
fill={gradient ? `url(#${gradientId})` : "currentColor"}
83+
stroke={gradient ? `url(#${gradientId})` : "currentColor"}
8184
/>
8285
</div>
8386
)

0 commit comments

Comments
 (0)