Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 745x 184x 184x 184x 184x 41x 9x 9x 184x 184x 184x 184x 184x 178x 184x 184x 184x | import { Card, CardContent, CardMedia, Chip, styled, Typography, } from "@mui/material"; import { eventImagePlaceholderUrl } from "appConstants"; import Divider from "components/Divider"; import FlagButton from "features/FlagButton"; import { useTranslation } from "i18n"; import { COMMUNITIES } from "i18n/namespaces"; import Link from "next/link"; import { Event } from "proto/events_pb"; import { useMemo } from "react"; import { routeToEvent } from "routes"; import { timestamp2Date } from "utils/date"; import dayjs from "utils/dayjs"; import stripMarkdown from "utils/stripMarkdown"; const StyledCard = styled(Card, { shouldForwardProp: (prop) => prop !== "isCancelled", })<{ isCancelled?: boolean }>(({ theme, isCancelled }) => ({ position: "relative", "&:hover": { backgroundColor: theme.palette.grey[50], }, ...(isCancelled && { opacity: 0.6, backgroundColor: theme.palette.grey[200], }), })); const Title = styled(Typography)(({ theme }) => ({ display: "-webkit-box", WebkitBoxOrient: "vertical", WebkitLineClamp: 2, overflow: "hidden", })); const EventTime = styled(Typography)(({ theme }) => ({ display: "-webkit-box", WebkitBoxOrient: "vertical", WebkitLineClamp: 2, overflow: "hidden", [theme.breakpoints.up("sm")]: { WebkitLineClamp: 1, }, })); const Content = styled(Typography)(({ theme }) => ({ display: "-webkit-box", WebkitBoxOrient: "vertical", WebkitLineClamp: 5, overflow: "hidden", })); const CancelledChip = styled(Chip)(({ theme }) => ({ backgroundColor: theme.palette.error.main, color: theme.palette.common.white, fontWeight: "bold", })); const FlagButtonWrapper = styled("div")({ position: "absolute", bottom: 8, right: 8, display: "flex", flexDirection: "column", alignItems: "center", "& svg": { fontSize: 16, }, }); export const EVENT_CARD_TEST_ID = "event-card"; export interface EventCardProps { event: Event.AsObject; className?: string; } export default function EventCard({ event, className }: EventCardProps) { const { t } = useTranslation([COMMUNITIES]); const startTime = dayjs(timestamp2Date(event.startTime!)); const endTime = dayjs(timestamp2Date(event.endTime!)); const strippedContent = useMemo( () => stripMarkdown(event.content), [event.content], ); const formattedEventDates = `${startTime.format("llll")} - ${endTime.format( endTime.isSame(startTime, "day") ? "LT" : "llll", )}`; const eventImageSrc = event.photoUrl || eventImagePlaceholderUrl; return ( <StyledCard className={className} isCancelled={event.isCancelled} data-testid={EVENT_CARD_TEST_ID} > <Link href={routeToEvent(event.eventId, event.slug)}> <CardMedia component="div" sx={{ padding: 1, backgroundColor: (theme) => theme.palette.grey[200], height: { xs: 80, sm: 100, md: 120 }, backgroundImage: `url(${eventImageSrc})`, backgroundSize: eventImageSrc === eventImagePlaceholderUrl ? "contain" : "cover", backgroundRepeat: "no-repeat", backgroundPosition: "center", }} > {event.onlineInformation && ( <Chip size="medium" label={t("communities:online")} sx={{ borderRadius: 1, fontWeight: "bold" }} /> )} </CardMedia> <CardContent> <EventTime variant="body2" color="textSecondary" gutterBottom title={formattedEventDates} > {formattedEventDates} </EventTime> <Title variant="h3" gutterBottom> {event.title} </Title> <Typography noWrap variant="body2" gutterBottom> {event.offlineInformation ? event.offlineInformation.address : t("communities:virtual_event_location_placeholder")} </Typography> {event.isCancelled && ( <CancelledChip label={t("communities:cancelled")} /> )} <Divider spacing={1} /> <div> <Content variant="body1" paragraph> {strippedContent} </Content> <Typography variant="body2" color="textSecondary"> {t("communities:attendees_count", { count: event.goingCount + event.maybeCount, })} </Typography> </div> </CardContent> </Link> <FlagButtonWrapper> <FlagButton contentRef={`event/${event.eventId}`} authorUser={event.creatorUserId} /> </FlagButtonWrapper> </StyledCard> ); } |