-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] Activity Forum detail page & Timeline component (#348)
- Loading branch information
Showing
7 changed files
with
367 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
.timeline { | ||
position: relative; | ||
margin: 0 auto; | ||
max-width: 50%; | ||
@media (max-width: 991px) { | ||
max-width: 100%; | ||
} | ||
&::after { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 10px; | ||
margin-left: -3px; | ||
background-color: #fff; | ||
width: 3px; | ||
content: ''; | ||
} | ||
} | ||
.timelineItem { | ||
position: relative; | ||
background-color: inherit; | ||
width: 100%; | ||
|
||
&::after { | ||
position: absolute; | ||
top: 18px; | ||
right: 1px; | ||
z-index: 1; | ||
border-radius: 50%; | ||
background-color: #fff; | ||
width: 17px; | ||
height: 17px; | ||
content: ''; | ||
} | ||
} | ||
.right { | ||
left: auto; | ||
padding: 0px 0px 20px 40px; | ||
|
||
&::before { | ||
position: absolute; | ||
top: 18px; | ||
left: 30px; | ||
z-index: 1; | ||
border: medium solid #fff; | ||
border-width: 10px 10px 10px 0; | ||
border-color: transparent #fff transparent transparent; | ||
content: ' '; | ||
} | ||
&::after { | ||
left: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { TableCellValue } from 'mobx-lark'; | ||
import { FC } from 'react'; | ||
import { Card } from 'react-bootstrap'; | ||
|
||
import { Agenda } from '../../../models/Activity/Agenda'; | ||
import { blobURLOf } from '../../../models/Base'; | ||
import { TimeRange } from '../../Base/TimeRange'; | ||
import { ActivityPeople } from '../People'; | ||
import styles from './Timeline.module.less'; | ||
|
||
export interface ForumTimelineProps { | ||
activityId: TableCellValue; | ||
agendas: Agenda[]; | ||
} | ||
|
||
/** | ||
* @see {@link https://mdbootstrap.com/docs/standard/extended/timeline/#section-timeline-gradient-bg} | ||
*/ | ||
const ForumTimeline: FC<ForumTimelineProps> = ({ activityId, agendas }) => ( | ||
<div className={styles.timeline}> | ||
{agendas.map( | ||
({ id, title, startTime, endTime, summary, mentors, mentorAvatars }) => ( | ||
<div | ||
key={id as string} | ||
className={`position-relative ${styles.timelineItem} ${styles.right}`} | ||
> | ||
<Card> | ||
<Card.Body className="p-4"> | ||
<h3 className="h5"> | ||
<a | ||
className="text-decoration-none stretched-link" | ||
href={`/activity/${activityId}/agenda/${id}`} | ||
> | ||
{title as string} | ||
</a> | ||
</h3> | ||
<span className="small text-muted"> | ||
<TimeRange {...{ startTime, endTime }} /> | ||
</span> | ||
<ActivityPeople | ||
names={mentors as string[]} | ||
avatars={(mentorAvatars as TableCellValue[])?.map(file => | ||
blobURLOf([file] as TableCellValue), | ||
)} | ||
/> | ||
<p className="mt-2 mb-0">{summary as string}</p> | ||
</Card.Body> | ||
</Card> | ||
</div> | ||
), | ||
)} | ||
</div> | ||
); | ||
export default ForumTimeline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { ShareBox } from 'idea-react'; | ||
import { TableCellLocation } from 'mobx-lark'; | ||
import { observer } from 'mobx-react'; | ||
import { cache, compose, errorLogger, router } from 'next-ssr-middleware'; | ||
import { QRCodeSVG } from 'qrcode.react'; | ||
import { Component } from 'react'; | ||
import { Container } from 'react-bootstrap'; | ||
|
||
import ForumTimeline from '../../../../components/Activity/Forum/Timeline'; | ||
import { PageHead } from '../../../../components/Layout/PageHead'; | ||
import { Activity, ActivityModel } from '../../../../models/Activity'; | ||
import { Agenda } from '../../../../models/Activity/Agenda'; | ||
import { Forum } from '../../../../models/Activity/Forum'; | ||
import { API_Host } from '../../../../models/Base'; | ||
import { t } from '../../../../models/Base/Translation'; | ||
import { fileURLOf } from '../../../api/lark/file/[id]'; | ||
|
||
interface ForumPageProps { | ||
activity: Activity; | ||
forum: Forum; | ||
agendas: Agenda[]; | ||
} | ||
|
||
export const getServerSideProps = compose< | ||
Record<'id' | 'forumId', string>, | ||
ForumPageProps | ||
>(cache(), router, errorLogger, async ({ params: { id, forumId } = {} }) => { | ||
const activityStore = new ActivityModel(); | ||
|
||
const activity = await activityStore.getOne(id!); | ||
const forum = await activityStore.currentForum!.getOne(forumId!); | ||
const agendas = await activityStore.currentAgenda!.getAll({ | ||
forum: forum.name, | ||
}); | ||
|
||
return { | ||
props: JSON.parse(JSON.stringify({ activity, forum, agendas })), | ||
}; | ||
}); | ||
|
||
@observer | ||
export default class ForumPage extends Component<ForumPageProps> { | ||
sharedURL = `${API_Host}/activity/${this.props.activity.id}/forum/${this.props.forum.id}`; | ||
|
||
renderContent() { | ||
const { activity, forum, agendas } = this.props, | ||
{ sharedURL } = this; | ||
const { id: activityId, name, city, location, image, cardImage } = activity, | ||
{ name: forumName, location: room } = forum; | ||
|
||
return ( | ||
<Container | ||
className={`d-flex flex-column justify-content-around align-items-center text-center py-5`} | ||
style={{ | ||
backgroundImage: `url(${fileURLOf(cardImage || image)})`, | ||
backgroundSize: 'cover', | ||
}} | ||
> | ||
<header className="d-flex flex-column align-items-center gap-4"> | ||
<h1>{name as string}</h1> | ||
<h2>{forumName as string}</h2> | ||
|
||
<ul className="list-unstyled d-flex flex-column align-items-center gap-4"> | ||
<li>🏙{city as string}</li> | ||
<li>🗺{(location as TableCellLocation)?.full_address}</li> | ||
<li>🚪{room as string}</li> | ||
</ul> | ||
</header> | ||
<section className="p-3"> | ||
<ForumTimeline {...{ activityId, agendas }} /> | ||
</section> | ||
<footer className="d-flex flex-column align-items-center gap-4"> | ||
<QRCodeSVG value={sharedURL} /> | ||
|
||
<div>{t('press_to_share')}</div> | ||
</footer> | ||
</Container> | ||
); | ||
} | ||
|
||
render() { | ||
const { activity, forum } = this.props, | ||
{ sharedURL } = this; | ||
const { name } = activity, | ||
{ name: forumName, summary } = forum; | ||
const pageTitle = `${forumName} - ${name}`; | ||
|
||
return ( | ||
<> | ||
<PageHead title={pageTitle} /> | ||
|
||
<ShareBox title={pageTitle} text={summary as string} url={sharedURL}> | ||
{this.renderContent()} | ||
</ShareBox> | ||
</> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
bca8589
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for kaiyuanshe ready!
✅ Preview
https://kaiyuanshe-2d2po0p3m-techquerys-projects.vercel.app
Built with commit bca8589.
This pull request is being automatically deployed with vercel-action