|
1
|
import React from "react" |
|
2
|
import { CardProps } from "@/components/Card" |
|
3
|
import { useIsExternalLink } from "@/hooks/use-is-external-link" |
|
4
|
import clsx from "clsx" |
|
5
|
import { ArrowUpRightOnBox, TriangleRightMini } from "@medusajs/icons" |
|
6
|
import Link from "next/link" |
|
7
|
|
|
8
|
export const CardLargeLayout = ({ |
|
9
|
title, |
|
10
|
text, |
|
11
|
image, |
|
12
|
icon, |
|
13
|
href, |
|
14
|
className, |
|
15
|
onClick, |
|
16
|
}: CardProps) => { |
|
17
|
const isExternal = useIsExternalLink({ href }) |
|
18
|
const IconComponent = icon |
|
19
|
|
|
20
|
return ( |
|
21
|
<div |
|
22
|
className={clsx( |
|
23
|
"relative flex flex-col gap-docs_0.75", |
|
24
|
"justify-start group", |
|
25
|
className |
|
26
|
)} |
|
27
|
> |
|
28
|
<div |
|
29
|
className={clsx( |
|
30
|
"rounded-docs_DEFAULT bg-medusa-bg-component w-[290px] h-[144px]", |
|
31
|
"shadow-elevation-card-rest dark:shadow-elevation-card-rest-dark", |
|
32
|
href && |
|
33
|
"group-hover:shadow-elevation-card-hover group-hover:dark:shadow-elevation-card-hover-dark", |
|
34
|
"px-docs_0.75 py-docs_0.5 flex justify-center items-center w-full" |
|
35
|
)} |
|
36
|
> |
|
37
|
{IconComponent && ( |
|
38
|
<IconComponent |
|
39
|
className="text-medusa-fg-subtle" |
|
40
|
width={32} |
|
41
|
height={32} |
|
42
|
viewBox="0 0 32 32" |
|
43
|
/> |
|
44
|
)} |
|
45
|
{image && ( |
|
46
|
<img src={image} alt={title || text || ""} className="w-[144px]" /> |
|
47
|
)} |
|
48
|
</div> |
|
49
|
<div className="flex flex-col"> |
|
50
|
<div className="flex gap-docs_0.25 items-center text-medusa-fg-base"> |
|
51
|
{title && ( |
|
52
|
<span className="text-compact-small-plus" data-testid="title"> |
|
53
|
{title} |
|
54
|
</span> |
|
55
|
)} |
|
56
|
{href && isExternal && ( |
|
57
|
<ArrowUpRightOnBox data-testid="external-icon" /> |
|
58
|
)} |
|
59
|
{href && !isExternal && ( |
|
60
|
<TriangleRightMini |
|
61
|
className="group-hover:translate-x-docs_0.125 transition-transform" |
|
62
|
data-testid="internal-icon" |
|
63
|
/> |
|
64
|
)} |
|
65
|
</div> |
|
66
|
{text && ( |
|
67
|
<span |
|
68
|
className="text-small-plus text-medusa-fg-subtle" |
|
69
|
data-testid="text" |
|
70
|
> |
|
71
|
{text} |
|
72
|
</span> |
|
73
|
)} |
|
74
|
</div> |
|
75
|
{href && ( |
|
76
|
<Link |
|
77
|
href={href} |
|
78
|
className="absolute left-0 top-0 h-full w-full rounded" |
|
79
|
prefetch={false} |
|
80
|
rel={isExternal ? "noopener noreferrer" : undefined} |
|
81
|
target={isExternal ? "_blank" : undefined} |
|
82
|
aria-label={title} |
|
83
|
onClick={onClick} |
|
84
|
/> |
|
85
|
)} |
|
86
|
</div> |
|
87
|
) |
|
88
|
} |