Skip to content

Commit

Permalink
[add] GitHub contributors page (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
luojiyin1987 authored Aug 6, 2024
1 parent 946ffa3 commit 651bc4e
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 0 deletions.
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',
},
];
51 changes: 51 additions & 0 deletions pages/volunteer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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[] =
await repositoryStore.getAllContributors();
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: '线上志愿者',
} 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;

1 comment on commit 651bc4e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for oss-toolbox ready!

✅ Preview
https://oss-toolbox-o56pl0tfx-techquerys-projects.vercel.app

Built with commit 651bc4e.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.