|
| 1 | +import { TimeDistance } from 'idea-react'; |
| 2 | +import { TableCellLocation } from 'mobx-lark'; |
| 3 | +import type { FC } from 'react'; |
| 4 | +import { Card, Col, Row } from 'react-bootstrap'; |
| 5 | + |
| 6 | +import { type Activity, ActivityModel } from '../../models/Activity'; |
| 7 | +import { LarkImage } from '../LarkImage'; |
| 8 | +import { TimeOption } from '../data'; |
| 9 | +import { BadgeBar } from 'mobx-restful-table'; |
| 10 | + |
| 11 | +export interface ActivityCardProps extends Activity { |
| 12 | + className?: string; |
| 13 | +} |
| 14 | + |
| 15 | +export const ActivityCard: FC<ActivityCardProps> = ({ |
| 16 | + className = '', |
| 17 | + id, |
| 18 | + host, |
| 19 | + name, |
| 20 | + startTime, |
| 21 | + city, |
| 22 | + location, |
| 23 | + image, |
| 24 | + ...activity |
| 25 | +}) => ( |
| 26 | + <Card |
| 27 | + className={`shadow-sm ${className}`} |
| 28 | + style={{ contentVisibility: 'auto', containIntrinsicHeight: '23rem' }} |
| 29 | + > |
| 30 | + <div className="position-relative w-100" style={{ paddingBottom: '56%' }}> |
| 31 | + <div className="position-absolute top-0 left-0 w-100 h-100"> |
| 32 | + <LarkImage |
| 33 | + className="card-img-top h-100 object-fit-cover" |
| 34 | + style={{ objectPosition: 'top left' }} |
| 35 | + src={image} |
| 36 | + /> |
| 37 | + </div> |
| 38 | + </div> |
| 39 | + <Card.Body className="d-flex flex-column"> |
| 40 | + <Card.Title as="h3" className="h5 flex-fill"> |
| 41 | + <a |
| 42 | + className="text-decoration-none text-secondary text-truncate-lines" |
| 43 | + href={ActivityModel.getLink({ id, ...activity })} |
| 44 | + > |
| 45 | + {name as string} |
| 46 | + </a> |
| 47 | + </Card.Title> |
| 48 | + |
| 49 | + <Row className="mt-2 flex-fill"> |
| 50 | + <Col className="text-start"> |
| 51 | + <Card.Text |
| 52 | + className="mt-1 text-truncate" |
| 53 | + title={(location as TableCellLocation)?.full_address} |
| 54 | + > |
| 55 | + <span className="me-1">{city as string}</span> |
| 56 | + |
| 57 | + {(location as TableCellLocation)?.full_address} |
| 58 | + </Card.Text> |
| 59 | + </Col> |
| 60 | + </Row> |
| 61 | + <Row as="footer" className="flex-fill small mt-1"> |
| 62 | + <Col xs={8}> |
| 63 | + <BadgeBar |
| 64 | + list={(host as string[]).map(text => ({ |
| 65 | + text, |
| 66 | + link: `/search/activity?keywords=${text}`, |
| 67 | + }))} |
| 68 | + /> |
| 69 | + </Col> |
| 70 | + <Col className="text-end" xs={4}> |
| 71 | + <TimeDistance {...TimeOption} date={startTime as number} /> |
| 72 | + </Col> |
| 73 | + </Row> |
| 74 | + </Card.Body> |
| 75 | + </Card> |
| 76 | +); |
0 commit comments