-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBannerCard.tsx
More file actions
64 lines (58 loc) · 1.66 KB
/
Copy pathBannerCard.tsx
File metadata and controls
64 lines (58 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { GearIcon } from '@shared/assets/icons/banner';
import { Button } from '@shared/ui/Button/Button';
import { bannerCardVariants } from './BannerCard.variants';
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
import type { VariantProps } from 'tailwind-variants';
const { base, frame, textWrapper, title, description, imageWrapper, image } = bannerCardVariants();
export type BannerCardProps = Omit<ComponentPropsWithoutRef<'div'>, 'title'> &
VariantProps<typeof bannerCardVariants> & {
title: ReactNode;
description: string;
buttonText?: string;
onClick?: () => void;
};
export const BannerCard = ({
title: titleContent = (
<>
중고 전자기기
<br />
구매하기
</>
),
description: descriptionText = '설명 최대 길이 2줄',
buttonText = '바로가기',
onClick,
className,
...props
}: BannerCardProps) => {
return (
<div
data-testid="banner-card"
className={base({ className })}
role="button"
aria-label="banner-card"
tabIndex={0}
onClick={onClick}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
onClick?.();
}
}}
{...props}
>
<div className={frame()}>
<div className={textWrapper()}>
<p className={title()}>{titleContent}</p>
<p className={description()}>{descriptionText}</p>
<Button size="auto" className="w-[104px]">
{buttonText}
</Button>
</div>
</div>
<div className={imageWrapper()}>
<img src={GearIcon} alt="" className={image()} />
</div>
</div>
);
};