Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] GitHub contributors page #22

Merged
merged 9 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions components/PersonCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { FC } from 'react';
import { Badge, Card, Col } from 'react-bootstrap';

export type PersonCardProps = {
avatar: string;
name: string;
link?: string;
position?: string;
count?: number;
};

export const PersonCard: FC<PersonCardProps> = ({
avatar,
name,
link,
position,
count,
}) => (
<Col as="li" className="my-3 d-flex justify-content-center">
<Card className="border-0 align-items-center position-relative">
{count != null && (
<Badge className="fs-6 position-absolute top-0 end-0" pill bg="danger">
{count}
</Badge>
)}
<Card.Img
className="rounded-circle"
style={{ width: '8rem' }}
variant="top"
src={avatar}
alt={name}
/>
<Card.Body>
<Card.Title
as="a"
className="fs-6 text-decoration-none stretched-link"
href={link || '#'}
>
{name}
</Card.Title>
<Card.Subtitle className="fw-light mt-2">{position}</Card.Subtitle>
</Card.Body>
</Card>
</Col>
);
19 changes: 19 additions & 0 deletions components/SectionTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { FC, HTMLAttributes, PropsWithChildren } from 'react';
import { Badge } from 'react-bootstrap';

export type SectionTitleProps = PropsWithChildren<
HTMLAttributes<HTMLHeadingElement> & { count?: number }
>;

export const SectionTitle: FC<SectionTitleProps> = ({
className = '',
count,
children,
}) => (
<h2 className={`d-flex align-items-center gap-2 ${className}`}>
{children}
<Badge className="fs-6" pill bg="danger">
{count}
</Badge>
</h2>
);
4 changes: 4 additions & 0 deletions components/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ export const MainRoutes: () => Link[] = () => [
title: t('source_code'),
path: 'https://github.com/kaiyuanshe/OSS-toolbox',
},
{
title: t('volunteer'),
path: '/volunteer',
},
];
53 changes: 53 additions & 0 deletions pages/volunteer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Contributor } from 'mobx-github';
import { InferGetServerSidePropsType } from 'next';
import { cache, compose, errorLogger } from 'next-ssr-middleware';
import { FC } from 'react';
import { Container, Row } from 'react-bootstrap';

import { PageHead } from '../components/PageHead';
import { PersonCard } from '../components/PersonCard';
import { SectionTitle } from '../components/SectionTitle';
import { repositoryStore } from '../models/Repository';
import { i18n } from '../models/Translation';

const { t } = i18n;

export const getServerSideProps = compose(cache(), errorLogger, async () => {
const contributors: Contributor[] =
// @ts-ignore
await repositoryStore.getAllContributors();
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved

return { props: { contributors } };
});

const Organizer: FC<InferGetServerSidePropsType<typeof getServerSideProps>> = ({
contributors,
}) => (
<Container>
<PageHead title={t('volunteer')} />
<h1 className="py-5 text-center text-md-start ps-md-4">{t('volunteer')}</h1>

<SectionTitle count={contributors.length}>
{t('online_volunteer')}
</SectionTitle>
<Row
as="ul"
className="list-unstyled justify-content-center text-center"
xs={2}
sm={5}
md={6}
>
{contributors.map(({ login, html_url, contributions }) => (
<PersonCard
key={login}
name={login!}
avatar={`https://github.com/${login}.png`}
link={html_url}
count={contributions}
/>
))}
</Row>
</Container>
);

export default Organizer;
4 changes: 4 additions & 0 deletions translation/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@ export default {
select_compatible_browser: 'select Compatible Browser',
select_features: 'select features',
search_feature: 'search Feature',

//volunteer page
volunteer: 'volunteer',
online_volunteer: 'online volunteer',
} as const;
4 changes: 4 additions & 0 deletions translation/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,8 @@ export default {
select_compatible_browser: '选择兼容浏览器',
select_features: '选择特性',
search_feature: '搜索特性',

//volunteer page
volunteer: '志愿者',
online_volunteer: '线上志愿者',
luojiyin1987 marked this conversation as resolved.
Show resolved Hide resolved
} as const;
4 changes: 4 additions & 0 deletions translation/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,8 @@ export default {
select_compatible_browser: '選擇相容瀏覽器',
select_features: '選擇特性',
search_feature: '搜尋特性',

//volunteer page
volunteer: '志願者',
online_volunteer: '線上志願者',
} as const;