generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] GitHub contributors page (#22)
- Loading branch information
1 parent
946ffa3
commit 651bc4e
Showing
7 changed files
with
131 additions
and
0 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,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> | ||
); |
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,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> | ||
); |
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,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; |
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
651bc4e
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 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