Skip to content

Commit 7a53794

Browse files
committed
[add] Product Card & Comment Box components
[add] Evaluation form modal [fix] missing Main Navigator links
1 parent e7d9c95 commit 7a53794

8 files changed

Lines changed: 254 additions & 132 deletions

File tree

components/Activity/CommentBox.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
import { FC } from 'react';
2-
import { Card } from 'react-bootstrap';
1+
import Giscus from '@giscus/react';
2+
import { observer } from 'mobx-react';
3+
import { useContext } from 'react';
4+
5+
import { I18nContext } from '../../models/Translation';
6+
7+
export const CommentBox = observer(() => {
8+
const { currentLanguage } = useContext(I18nContext);
39

4-
export const CommentBox: FC = () => {
510
return (
6-
<Card className="mt-4">
7-
<Card.Body>
8-
<h3 className="h5">Comments</h3>
9-
<p className="text-muted">Comment functionality coming soon...</p>
10-
</Card.Body>
11-
</Card>
11+
<Giscus
12+
repo="Open-Source-Bazaar/Open-Source-Bazaar.github.io"
13+
repoId="R_kgDOGzCrLg"
14+
category="Comments"
15+
categoryId="DIC_kwDOGzCrLs4C0g_6"
16+
mapping="pathname"
17+
strict="0"
18+
reactionsEnabled="1"
19+
emitMetadata="0"
20+
inputPosition="bottom"
21+
theme="preferred_color_scheme"
22+
lang={currentLanguage.startsWith('zh-') ? currentLanguage : currentLanguage.split('-')[0]}
23+
/>
1224
);
13-
};
25+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { observer } from 'mobx-react';
2+
import { FilePreview } from 'mobx-restful-table';
3+
import { FC } from 'react';
4+
import { CardProps, Card, Button } from 'react-bootstrap';
5+
import { formatDate } from 'web-utility';
6+
7+
import { Product } from '../../models/Hackathon';
8+
9+
export type ProductCardProps = Product & Omit<CardProps, 'id' | 'title'>;
10+
11+
export const ProductCard: FC<ProductCardProps> = observer(
12+
({ className = '', id, createdAt, name, sourceLink, link = sourceLink, summary, ...props }) => (
13+
<Card className={`border-success ${className}`} {...props}>
14+
<Card.Body className="d-flex flex-column">
15+
<Card.Title
16+
as="a"
17+
className="text-primary"
18+
title={name as string}
19+
target="_blank"
20+
href={link as string}
21+
>
22+
{(name || link) as string}
23+
</Card.Title>
24+
<p className="border-bottom p-2 text-muted text-truncate">{summary as string}</p>
25+
<div className="border-bottom py-2 my-2 flex-fill">
26+
<FilePreview className="w-100" path={link as string} />
27+
28+
{sourceLink && (
29+
<Button variant="success" size="sm" href={sourceLink as string}>
30+
🔗 Git
31+
</Button>
32+
)}
33+
</div>
34+
<time
35+
className="d-block p-2 text-truncate"
36+
dateTime={new Date(createdAt as number).toJSON()}
37+
>
38+
📅
39+
{formatDate(createdAt as number)}
40+
</time>
41+
</Card.Body>
42+
</Card>
43+
),
44+
);

components/Navigator/MainNavigator.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { textJoin } from 'mobx-i18n';
12
import { observer } from 'mobx-react';
23
import dynamic from 'next/dynamic';
34
import { useRouter } from 'next/router';
@@ -39,11 +40,24 @@ const topNavBarMenu = ({ t }: typeof i18n): MenuItem[] => [
3940
subs: [
4041
{ href: '/project', title: t('open_source_projects') },
4142
{ href: '/issue', title: 'GitHub issues' },
43+
{ href: '/license-filter', title: t('license_filter') },
44+
],
45+
},
46+
{
47+
title: t('hackathon'),
48+
subs: [
4249
{
4350
href: 'https://github.com/Open-Source-Bazaar/Git-Hackathon-scaffold',
44-
title: t('hackathon'),
51+
title: textJoin('GitHub', t('hackathon')),
52+
},
53+
{
54+
href: '/search/activity?keywords=Hackathon',
55+
title: textJoin('Lark', t('hackathon')),
56+
},
57+
{
58+
href: 'https://test.hackathon.fcc-cd.dev/open-source',
59+
title: textJoin(t('hackathon'), t('open_source_projects')),
4560
},
46-
{ href: '/license-filter', title: t('license_filter') },
4761
],
4862
},
4963
{

models/Hackathon.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
normalizeText,
77
TableCellRelation,
88
TableCellText,
9+
TableCellUser,
910
TableCellValue,
1011
TableRecord,
1112
} from 'mobx-lark';
@@ -24,7 +25,7 @@ export class AgendaModel extends BiDataTable<Agenda>() {
2425
return {
2526
...meta,
2627
...fields,
27-
summary: normalizeText(summary as TableCellText),
28+
summary: (summary as TableCellText[])!.map(normalizeText),
2829
};
2930
}
3031
}
@@ -149,10 +150,16 @@ export class MemberModel extends BiDataTable<Member>() {
149150

150151
queryOptions: BiDataQueryOptions = { text_field_as_array: false };
151152

152-
extractFields({ fields: { githubAccount, ...fields }, ...meta }: TableRecord<Member>) {
153+
extractFields({
154+
fields: { summary, person, skills, githubAccount, ...fields },
155+
...meta
156+
}: TableRecord<Member>) {
153157
return {
154158
...meta,
155159
...fields,
160+
person: (person as TableCellUser[])?.[0],
161+
summary: (summary as TableCellText[])!.map(normalizeText),
162+
skills: skills?.toString().split(/\s*,\s*/) || [],
156163
githubAccount: normalizeText(githubAccount as TableCellText),
157164
};
158165
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"test": "lint-staged && tsc --noEmit"
1515
},
1616
"dependencies": {
17+
"@giscus/react": "^3.1.0",
1718
"@koa/router": "^15.1.1",
1819
"@mdx-js/loader": "^3.1.1",
1920
"@mdx-js/react": "^3.1.1",

pages/hackathon/[id].tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BiTableSchema, TableCellLocation, TableCellUser } from 'mobx-lark';
22
import { observer } from 'mobx-react';
3+
import Link from 'next/link';
34
import { cache, compose, errorLogger } from 'next-ssr-middleware';
45
import { FC, useContext } from 'react';
56
import { Badge, Card, Col, Container, Row } from 'react-bootstrap';
@@ -199,11 +200,18 @@ const HackathonDetail: FC<HackathonDetailProps> = observer(({ activity, hackatho
199200
<h2 className={styles.sectionTitle}>💡 {t('projects')}</h2>
200201

201202
<Row as="ul" className="list-unstyled mt-4 g-3" md={2} lg={3} xl={4}>
202-
{projects.map(({ name, score, summary, createdBy, members }) => (
203+
{projects.map(({ id, name, score, summary, createdBy, members }) => (
203204
<Col as="li" key={name as string}>
204205
<Card className={styles.projectCard} body>
205206
<div className="d-flex justify-content-between align-items-start mb-3">
206-
<h6 className="text-white flex-grow-1">{name as string}</h6>
207+
<h6 className="text-white flex-grow-1">
208+
<Link
209+
className="stretched-link"
210+
href={`${ActivityModel.getLink(activity)}/team/${id}`}
211+
>
212+
{name as string}
213+
</Link>
214+
</h6>
207215
<div className={styles.scoreCircle}>{score as number}</div>
208216
</div>
209217
<p className="text-white-50 small mb-3">{summary as string}</p>

0 commit comments

Comments
 (0)