-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDefaultComponent.tsx
More file actions
105 lines (96 loc) · 2.5 KB
/
DefaultComponent.tsx
File metadata and controls
105 lines (96 loc) · 2.5 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { VariantProps } from "class-variance-authority";
import Image from "next/image";
import { ReactNode } from "react";
import { cn } from "@/utils/function/cn";
import getPastTime from "@/utils/function/getPastTime";
import setMoneyUnitString from "@/utils/function/setMoneyUnitString";
import { productStateVariants } from "./ProductCard.variants";
interface DefaultProps {
children?: ReactNode;
className?: string;
}
interface CardImageProps extends DefaultProps {
titleImage: string;
width: number;
height: number;
priority?: boolean;
}
interface CardTitleProps extends DefaultProps {
width?: number;
}
interface CardIPriceProps extends DefaultProps {
price: number;
}
interface CardTagProps
extends DefaultProps,
VariantProps<typeof productStateVariants> {}
interface CardDateProps extends DefaultProps {
date: string | Date;
}
export const CardImage = ({
children,
width,
height,
titleImage,
className,
priority = false
}: CardImageProps) => {
return (
<div
className={cn("relative", className)}
style={{ width: `${width}px`, height: `${height}px` }}>
{titleImage ? (
<Image
src={titleImage}
className="bg-slate-100 object-cover group-hover:scale-125 transition-transform"
alt="titleImage"
fill
priority={priority}
/>
) : (
<span
className={`border-[0.05rem] border-black rounded-sm bg-slate-200 w-[${width}px] h-[${height}px]`}></span>
)}
{children}
</div>
);
};
export const CardTitle = ({ children, className, width }: CardTitleProps) => {
return (
<div
className={cn(
"h-auto text-left text-2xl overflow-hidden text-ellipsis whitespace-nowrap",
className
)}
style={{ width: `${width}px` }}>
{children}
</div>
);
};
export const CardPrice = ({ children, className, price }: CardIPriceProps) => {
return (
<p className={cn("text-base text-left", className)}>
현재 입찰가 : <strong>{setMoneyUnitString(price)}원</strong>
{children}
</p>
);
};
export const CardTag = ({ className, tradeState }: CardTagProps) => {
return (
<>
{tradeState && (
<span className={cn(productStateVariants({ tradeState }), className)}>
{tradeState}
</span>
)}
</>
);
};
export const CardDate = ({ children, date }: CardDateProps) => {
return (
<p className="text-[11px] text-[#ABABAB] text-left">
{getPastTime(date)}
{children}
</p>
);
};