-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCard.tsx
More file actions
47 lines (39 loc) · 968 Bytes
/
Card.tsx
File metadata and controls
47 lines (39 loc) · 968 Bytes
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
import MyBookmarkCard from './MyBookmarkCard';
import RemindCard from './RemindCard';
type BaseProps = {
title: string;
content?: string;
category?: string;
imageUrl?: string;
onClick?: () => void;
onOptionsClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
};
type RemindProps = BaseProps & {
type: 'remind';
timeRemaining: string;
date?: never;
};
type BookmarkProps = BaseProps & {
type: 'bookmark';
date: string;
timeRemaining?: never;
};
export type CardProps = RemindProps | BookmarkProps;
const Card = (
props: CardProps & {
onOptionsClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
}
) => {
const { type, onOptionsClick } = props;
return (
<>
{type === 'remind' && (
<RemindCard {...props} onOptionsClick={onOptionsClick} />
)}
{type === 'bookmark' && (
<MyBookmarkCard {...props} onOptionsClick={onOptionsClick} />
)}
</>
);
};
export default Card;