Skip to content

Commit 998b219

Browse files
BIA3IAtoto04
andauthored
feat: add CardSplit component (#64)
* feat: add CardSplit component to enhance layout options * feat: refactor CardSplit component to use new props structure and separate content components --------- Co-authored-by: Tommaso Morganti <tommaso.morganti01@gmail.com>
1 parent 27bfa48 commit 998b219

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Glass } from "@/components/glass"
2+
import { cn } from "@/lib/utils"
3+
import { CardSplitPrimaryContent } from "./primary-content"
4+
import { CardSplitSecondaryContent } from "./secondary-content"
5+
import type { CardSplitProps } from "./types"
6+
7+
export function CardSplit({ textPrimary, textSecondary, textSecondarySmall, className }: CardSplitProps) {
8+
const hasPrimaryContent = Boolean(textPrimary)
9+
const hasSecondaryContent = Boolean(textSecondary || textSecondarySmall)
10+
11+
return (
12+
<Glass
13+
className={cn(
14+
"inline-flex max-w-full overflow-hidden rounded-rectangles border-white/50 bg-background-blur p-0 text-card-foreground",
15+
className
16+
)}
17+
>
18+
<div className="flex flex-col gap-10 px-10 py-5 sm:grid sm:grid-cols-[auto_auto] sm:items-center">
19+
{textPrimary ? <CardSplitPrimaryContent text={textPrimary} /> : null}
20+
21+
{hasSecondaryContent && (
22+
<CardSplitSecondaryContent
23+
textSecondary={textSecondary}
24+
textSecondarySmall={textSecondarySmall}
25+
hasPrimaryContent={hasPrimaryContent}
26+
/>
27+
)}
28+
</div>
29+
</Glass>
30+
)
31+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function CardSplitPrimaryContent({ text }: { text: string }) {
2+
return (
3+
<p className="typo-display-medium bg-linear-to-b from-blue-secondary to-blue-primary bg-clip-text font-normal text-transparent">
4+
{text}
5+
</p>
6+
)
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { cn } from "@/lib/utils"
2+
3+
type CardSplitSecondaryContentProps = {
4+
textSecondary?: string
5+
textSecondarySmall?: string
6+
hasPrimaryContent: boolean
7+
}
8+
9+
export function CardSplitSecondaryContent({
10+
textSecondary,
11+
textSecondarySmall,
12+
hasPrimaryContent,
13+
}: CardSplitSecondaryContentProps) {
14+
return (
15+
<div className={cn("flex flex-col gap-1", hasPrimaryContent ? "sm:min-w-fit" : "")}>
16+
{textSecondary && <p className="typo-headline-small text-text-primary">{textSecondary}</p>}
17+
{textSecondarySmall && <p className="typo-body-medium text-text-primary">{textSecondarySmall}</p>}
18+
</div>
19+
)
20+
}

src/components/card-split/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type CardSplitProps = {
2+
textPrimary?: string
3+
textSecondary?: string
4+
textSecondarySmall?: string
5+
className?: string
6+
}

0 commit comments

Comments
 (0)