forked from TypeCellOS/BlockNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcards.tsx
More file actions
136 lines (129 loc) · 3.42 KB
/
cards.tsx
File metadata and controls
136 lines (129 loc) · 3.42 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import cn from "clsx";
import Image from "next/image";
import NextLink from "next/link";
import type { ComponentProps, CSSProperties, ReactNode } from "react";
const classes = {
cards: cn(
"nextra-cards nx-mt-4 nx-gap-4 nx-grid",
"nx-not-prose", // for nextra-theme-docs
),
card: cn(
"nextra-card nx-group nx-flex nx-flex-col nx-justify-between nx-overflow-hidden nx-rounded-lg nx-border nx-border-gray-200",
"nx-text-current nx-no-underline dark:nx-shadow-none",
"hover:nx-shadow-gray-100 dark:hover:nx-shadow-none nx-shadow-gray-100",
"active:nx-shadow-sm active:nx-shadow-gray-200",
"nx-transition-all nx-duration-200 hover:nx-border-gray-300",
),
title: cn(
"nx-flex nx-font-semibold nx-items-start nx-text-gray-700 hover:nx-text-gray-900",
),
};
const arrowEl = (
<span className="nx-transition-transform nx-duration-75 group-hover:nx-translate-x-[2px]">
→
</span>
);
export function Card({
children,
title,
icon,
image,
arrow,
href,
authorImage,
authorName,
...props
}: {
children?: ReactNode;
title: string;
icon?: ReactNode;
image?: boolean;
arrow?: boolean;
href: string;
authorImage?: string;
authorName?: string;
}) {
const animatedArrow = arrow ? arrowEl : null;
if (image) {
return (
<NextLink
href={href}
className={cn(
classes.card,
"nx-bg-gray-100 nx-shadow dark:nx-border-neutral-700 dark:nx-bg-neutral-800 dark:nx-text-gray-50 hover:nx-shadow-lg dark:hover:nx-border-neutral-500 dark:hover:nx-bg-neutral-700",
)}
{...props}>
{children}
<span
className={cn(
classes.title,
"dark:nx-text-gray-300 dark:hover:nx-text-gray-100",
)}>
{icon}
<span className="nx-flex nx-gap-1">
{title}
{animatedArrow}
</span>
</span>
</NextLink>
);
}
return (
<NextLink
href={href}
className={cn(
classes.card,
"nx-bg-transparent nx-shadow-sm dark:nx-border-neutral-800 hover:nx-bg-slate-50 hover:nx-shadow-md dark:hover:nx-border-neutral-700 dark:hover:nx-bg-neutral-900",
"nx-flex nx-items-start nx-gap-2 nx-p-4 nx-text-gray-700",
)}
{...props}>
<span
className={cn(
classes.title,
"dark:nx-text-neutral-200 dark:hover:nx-text-neutral-50 nx-flex nx-items-center",
)}>
{title}
{icon}
{animatedArrow}
</span>
{/* <div className="hover:nx-text-gray-900 nx-items-right">test</div> */}
<div className="nx-flex nx-items-center nx-gap-2 text-xs">
{authorImage && (
<Image
className="size-5 rounded-md"
width={50}
height={50}
src={authorImage}
alt={authorName + " profile image"}
/>
)}{" "}
{authorName && <span>{authorName}</span>}
{/* <span>·</span>
<span>💖</span> */}
</div>
{/* {children} */}
</NextLink>
);
}
function _Cards({
children,
num = 3,
className,
style,
...props
}: { num?: number } & ComponentProps<"div">) {
return (
<div
className={cn(classes.cards, className)}
{...props}
style={
{
...style,
"--rows": num,
} as CSSProperties
}>
{children}
</div>
);
}
export const Cards = Object.assign(_Cards, { displayName: "Cards", Card });