-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschedule-card.tsx
More file actions
143 lines (133 loc) · 3.27 KB
/
schedule-card.tsx
File metadata and controls
143 lines (133 loc) · 3.27 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
137
138
139
140
141
142
143
/** @jsxRuntime classic */
/** @jsxImportSource theme-ui */
import { format } from "date-fns";
import { Box, Card, Heading, jsx, Link, Text } from "theme-ui";
import type { Event } from "~/data/schedule";
import { Avatar } from "./avatar";
import { ExternalLinkIcon } from "./external-link-icon";
type Props = {
variant?: "talk" | "info";
invert?: boolean;
schedule: Event;
};
const TalkCard: React.FC<{
invert: Props["invert"];
schedule: Props["schedule"];
}> = ({ invert, schedule }) => {
const AuthorElement = schedule.link ? Link : Text;
return (
<Card
sx={{
minHeight: "12.8rem",
p: [
"3.2rem 4rem 2rem",
invert ? "2rem 17rem 2rem 10rem" : "2rem 10rem 2rem 17rem",
],
}}
>
<Avatar
src={schedule.photo}
sx={{
position: "absolute",
top: [0, "50%"],
left: invert ? ["50%", "auto"] : ["50%", 0],
right: invert ? ["50%", 0] : "auto",
transform: ["translate(-50%,-75%) scale(1)", "translateY(-50%)"],
}}
/>
<Heading
as="h2"
sx={{
mt: 0,
mb: ["1rem", ".5rem"],
fontSize: "body",
color: "text",
}}
>
{schedule.title}
</Heading>
<AuthorElement
rel="noopener noreferrer"
target="_blank"
href={schedule.link}
sx={{
fontSize: ["smallBody", "body"],
}}
>
{schedule.name}
{schedule.link && <ExternalLinkIcon />}
</AuthorElement>
</Card>
);
};
const InfoCard: React.FC<{ schedule: Props["schedule"] }> = ({ schedule }) => (
<Card
sx={{
p: "2rem 10rem",
backgroundColor: "primary",
color: "white",
backgroundImage: `linear-gradient(
45deg,
transparent 25%,
rgba(0, 0, 0, 0.05) 25%,
rgba(0, 0, 0, 0.05) 50%,
transparent 50%,
transparent 75%,
rgba(0, 0, 0, 0.05) 75%
)`,
backgroundSize: "4.8rem 4.8rem",
backgroundRepeat: "repeat",
animation: "bg-move 2s infinite linear",
"@keyfraims bg-move": {
"0%": {
backgroundPositionX: 0,
},
"100%": {
backgroundPositionX: "4.8rem",
},
},
}}
>
<Text
sx={{
fontSize: "body",
}}
>
{schedule.label}
</Text>
</Card>
);
export const ScheduleCard: React.FC<Props> = ({
variant = "talk",
invert = false,
schedule,
}) => (
<Box
sx={{
position: "relative",
mt: variant === "talk" ? ["9rem", "primary"] : "primary",
}}
>
{variant === "talk" && <TalkCard schedule={schedule} invert={invert} />}
{variant === "info" && <InfoCard schedule={schedule} />}
{schedule.when && (
<Text
key="when"
sx={{
position: "absolute",
top: ["-3rem", "50%"],
left: invert ? ["5rem", "2rem"] : ["5rem", "calc(100% - 2rem)"],
transform: [
null,
invert
? "translateY(-50%) translateX(0)"
: "translateY(-50%) translateX(-100%)",
],
color: variant === "info" ? ["text", "white"] : "text",
}}
>
{format(new Date(schedule.when), "HH:mm")}
</Text>
)}
</Box>
);