forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.tsx
More file actions
62 lines (56 loc) 路 1.36 KB
/
Copy pathCard.tsx
File metadata and controls
62 lines (56 loc) 路 1.36 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
'use client';
import { ReactNode } from 'react';
type Shadow = 'none' | 'sm' | 'md' | 'lg';
interface CardProps {
children: ReactNode;
header?: ReactNode;
footer?: ReactNode;
shadow?: Shadow;
clickable?: boolean;
onClick?: () => void;
className?: string;
}
const shadowClasses: Record<Shadow, string> = {
none: '',
sm: 'shadow-sm',
md: 'shadow-md',
lg: 'shadow-lg',
};
export default function Card({
children,
header,
footer,
shadow = 'sm',
clickable = false,
onClick,
className = '',
}: CardProps) {
const Tag = clickable ? 'button' : 'div';
return (
<Tag
onClick={onClick}
className={[
'w-full rounded-xl border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900 text-left',
shadowClasses[shadow],
clickable
? 'cursor-pointer transition-shadow hover:shadow-md focus:outline-none focus:ring-2 focus:ring-brand focus:ring-offset-2'
: '',
className,
]
.filter(Boolean)
.join(' ')}
>
{header && (
<div className="border-b border-gray-200 px-5 py-3 dark:border-gray-700">
{header}
</div>
)}
<div className="px-5 py-4">{children}</div>
{footer && (
<div className="border-t border-gray-200 px-5 py-3 dark:border-gray-700">
{footer}
</div>
)}
</Tag>
);
}