|
| 1 | +import { HorizontalMarqueeBox, text2color } from 'idea-react'; |
| 2 | +import { TableCellAttachment } from 'mobx-lark'; |
| 3 | +import { observer } from 'mobx-react'; |
| 4 | +import dynamic from 'next/dynamic'; |
| 5 | +import { Component } from 'react'; |
| 6 | +import { Badge, Carousel, Col, Container, Row } from 'react-bootstrap'; |
| 7 | + |
| 8 | +import { LarkImage } from '../../Base/LarkImage'; |
| 9 | +import { ScoreBar } from '../../Base/ScoreBar'; |
| 10 | +import { TimeRange } from '../../Base/TimeRange'; |
| 11 | +import { ActivityPeople } from '../People'; |
| 12 | +import { AgendaToolbarProps } from './Toolbar'; |
| 13 | + |
| 14 | +const AgendaToolbar = dynamic(() => import('./Toolbar'), { ssr: false }); |
| 15 | + |
| 16 | +@observer |
| 17 | +export class AgendaCard extends Component<AgendaToolbarProps> { |
| 18 | + renderCardImage = (file: TableCellAttachment) => ( |
| 19 | + <LarkImage |
| 20 | + key={file.attachmentToken} |
| 21 | + className="m-auto object-fit-cover" |
| 22 | + style={{ width: '6rem', height: '6rem' }} |
| 23 | + src={[file]} |
| 24 | + roundedCircle |
| 25 | + /> |
| 26 | + ); |
| 27 | + |
| 28 | + renderAvatarImages() { |
| 29 | + const { type, mentors, mentorAvatars, organizationLogos } = this.props; |
| 30 | + const images = (type === 'Booth' && organizationLogos) || mentorAvatars; |
| 31 | + |
| 32 | + return (mentors as string[])?.[1] ? ( |
| 33 | + <Carousel indicators={false}> |
| 34 | + {(images as TableCellAttachment[])?.map(file => ( |
| 35 | + <Carousel.Item key={file.attachmentToken}>{this.renderCardImage(file)}</Carousel.Item> |
| 36 | + ))} |
| 37 | + </Carousel> |
| 38 | + ) : ( |
| 39 | + <ActivityPeople size={5} avatars={images} /> |
| 40 | + ); |
| 41 | + } |
| 42 | + |
| 43 | + render() { |
| 44 | + const { |
| 45 | + activityId, |
| 46 | + id, |
| 47 | + type, |
| 48 | + title, |
| 49 | + mentors, |
| 50 | + mentorOrganizations, |
| 51 | + mentorPositions, |
| 52 | + startTime, |
| 53 | + endTime, |
| 54 | + score, |
| 55 | + } = this.props; |
| 56 | + |
| 57 | + return ( |
| 58 | + <Container |
| 59 | + className="h-100" |
| 60 | + style={{ contentVisibility: 'auto', containIntrinsicHeight: '13rem' }} |
| 61 | + > |
| 62 | + <Row className="border shadow-sm rounded h-100"> |
| 63 | + <Col xs={4} className="d-flex flex-column justify-content-around align-items-center"> |
| 64 | + <Badge bg={text2color(type + '', ['light'])}> |
| 65 | + <HorizontalMarqueeBox maxWidth="80px" height="12px"> |
| 66 | + {type + ''} |
| 67 | + </HorizontalMarqueeBox> |
| 68 | + </Badge> |
| 69 | + |
| 70 | + {this.renderAvatarImages()} |
| 71 | + </Col> |
| 72 | + |
| 73 | + <Col xs={8} className="d-flex flex-column py-3"> |
| 74 | + <h3 className="fs-5"> |
| 75 | + <a |
| 76 | + className="text-decoration-none text-secondary" |
| 77 | + href={`/activity/${activityId}/agenda/${id}`} |
| 78 | + title={title as string} |
| 79 | + > |
| 80 | + <HorizontalMarqueeBox duration="20s" maxWidth="330px" height="24px"> |
| 81 | + {title as string} |
| 82 | + </HorizontalMarqueeBox> |
| 83 | + </a> |
| 84 | + </h3> |
| 85 | + <ul className="list-unstyled flex-fill d-flex flex-column justify-content-between gap-2"> |
| 86 | + <li> |
| 87 | + <TimeRange {...{ startTime, endTime }} /> |
| 88 | + </li> |
| 89 | + {(mentors as string[])?.map((name, index) => ( |
| 90 | + <li key={name}> |
| 91 | + {name} {(mentorOrganizations as string[])?.[index]}{' '} |
| 92 | + {(mentorPositions as string[])?.[index]} |
| 93 | + </li> |
| 94 | + ))} |
| 95 | + {score && ( |
| 96 | + <li> |
| 97 | + <ScoreBar value={score + ''} /> |
| 98 | + </li> |
| 99 | + )} |
| 100 | + <AgendaToolbar |
| 101 | + as="li" |
| 102 | + className="justify-content-end" |
| 103 | + {...{ ...this.props, activityId }} |
| 104 | + /> |
| 105 | + </ul> |
| 106 | + </Col> |
| 107 | + </Row> |
| 108 | + </Container> |
| 109 | + ); |
| 110 | + } |
| 111 | +} |
0 commit comments