Skip to content

Commit

Permalink
feat: add github contributors (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnugent authored Oct 30, 2023
1 parent 2768ed3 commit b1421c0
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 29 deletions.
21 changes: 12 additions & 9 deletions src/app/components/FinancialContributors.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import { getSummaryReport } from '@/js/graphql/opencollective'
import { FinancialBackerAccountType } from '@/js/types'
import { DonateButton } from './LandingCTA'

import { SectionContainer, Width } from './ui/SectionContainer'
/**
* List financial contributors
*/
export const FinancialContributors: React.FC = async () => {
const { donors, totalRaised } = await getSummaryReport()

return (
<div className='rounded-box bg-accent/80 block w-full p-4 xl:p-10 mx-auto max-w-5xl xl:max-w-7xl'>
<div className='flex items-center gap-6'>
<h2>Financial Contributors</h2>
<span className='mt-0.5 text-sm'>Total: {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(totalRaised)}</span>
</div>
<hr className='mb-6 border-2 border-base-content' />
<SectionContainer
width={Width.compact}
className='bg-accent/80 rounded-box'
header={
<div className='flex items-center gap-6'>
<h2>Financial Contributors</h2>
<span className='mt-0.5 text-sm'>Total: {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(totalRaised)}</span>
</div>
}
>
<div className='columns-3xs'>
{donors.map(donor => <Donor key={donor.account.id} donor={donor} />)}
</div>

<div className='mt-6'><DonateButton /></div>
</div>
</SectionContainer>
)
}

Expand Down
13 changes: 7 additions & 6 deletions src/app/components/LandingCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ const Card4Coders: React.FC = () => {
<li>☑️ Use OpenBeta API & data in your projects.</li>
</ul>
}
action={
<>
<a href='https://docs.openbeta.io/how-to-contribute/overview' className='text-sm underline'>Dev onboarding</a>
<a className='btn btn-primary btn-sm btn-outline' href='https://github.com/orgs/OpenBeta/'>GitHub</a>
</>
}
action={<CodeContributorsAction />}
/>
)
}

export const CodeContributorsAction: React.FC = () => (
<>
<a href='https://docs.openbeta.io/how-to-contribute/overview' className='text-sm underline'>Dev onboarding</a>
<a className='btn btn-primary btn-sm btn-outline' href='https://github.com/orgs/OpenBeta/'>GitHub</a>
</>)

const Card4All: React.FC = () => {
return (
<Card
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/LandingHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ export const LandingHero: React.FC = () => {
return (
<section className='w-full px-6'>
<h1 className='text-2xl tracking-tighter font-semibold'>Share your climbing route knowledge!</h1>
<div className='font-medium text-neutral/80'>Join OpenBeta and help build a community resource for climbers</div>
<div className='font-medium text-neutral/80'>
Join us to help improve this comprehensive climbing resource for the community.
</div>
<hr className='mt-3 border-2 border-base-content w-full' />
</section>
)
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/RecentEdits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const RecentEdits: React.FC = async () => {
return (
<section className='px-4 w-full'>
<div className='flex items-center justify-between'>
<h2>Recent edits</h2>
<h3>Latest contributions </h3>
<Link href='/edit' className='text-sm hover:underline'>See more</Link>
</div>
<hr className='mb-6 border-2 border-base-content' />
<hr className='mb-6 border-1 border-base-content' />
<div className='mt-4 flex justify-center flex-row flex-wrap gap-y-10 gap-x-4'>
{history.splice(0, 10).map(changetset =>
<ChangesetCard key={changetset.id} changeset={changetset} />
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/RecentTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const RecentTags: React.FC = async () => {
return (
<section className='w-full '>
<div className='px-4 2xl:px-0 mx-auto max-w-5xl xl:max-w-7xl'>
<h2>Recent Tags</h2>
<h2>Latest Photos</h2>
</div>

<div className='overflow-hidden bg-base-200/20'>
Expand Down
63 changes: 63 additions & 0 deletions src/app/components/Volunteers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { CodeContributorsAction } from './LandingCTA'
import { SectionContainer, Width } from './ui/SectionContainer'

const url = 'https://raw.githubusercontent.com/OpenBeta/open-tacos/develop/.all-contributorsrc'

/**
* Abbreviated GH profile
*/
interface GithubProfile {
login: string
name: string
avatar_url: string
profile: string
contributions: string[]
}
/**
* List code contributors & volunteers by loading contributor list
* managed by all-contributors bot.
*/
export const Volunteers: React.FC = async () => {
const res = await fetch(url, { cache: 'no-store' })
const { contributors }: { contributors: GithubProfile[] } = await res.json()
return (
<SectionContainer
width={Width.compact}
className='border rounded-box bg-base-200/20'
header={
<div className='flex items-center gap-6'>
<h2 className='text-base-content'>Volunteers</h2>
<span className='mt-0.5 text-sm'>Total: {new Intl.NumberFormat().format(contributors.length)}</span>
</div>
}
>
<div className='mb-8 max-w-lg'>
As an open source project, OpenBeta's success is thanks to a diverse group of volunteer contributors, many of whom are not even rock climbers. We deeply appreciate their vital role in shaping OpenBeta.
</div>
<div className='columns-3xs gap-x-4'>
{contributors.reverse().map(profile => <Profile key={profile.login} {...profile} />)}
</div>
<div className='pt-8 lg:pt-12 flex items-center gap-6'>
<CodeContributorsAction />
</div>
</SectionContainer>
)
}

const Profile: React.FC<GithubProfile> = ({
name,
/* eslint-disable-next-line */
avatar_url,
login
}) => (
<a
className='flex items-center gap-2 mb-4 rounded-box overflow-hidden border w-fit bg-base-100 shadow'
href={`https://github.com/${login}`}
>
<div className='avatar'>
<div className='w-8 rounded-box'>
<img src={avatar_url} alt={name} />
</div>
</div>
<div className='text-sm uppercase text-base-content pr-4'>{name}</div>
</a>)
28 changes: 19 additions & 9 deletions src/app/components/ui/SectionContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { ReactNode } from 'react'
import clx from 'classnames'

export enum Width {
wide = '2xl:p-0',
compact = 'xl:p-10'
}

interface Props {
header: ReactNode
children: ReactNode
className?: string
width?: Width
}
export const SectionContainer: React.FC<Props> = ({ header, children }) => {
return (
<section className='block w-full px-4 2xl:px-0 mx-auto max-w-5xl xl:max-w-7xl'>
{header}
<hr className='mb-6 border-2 border-base-content' />
{children}
</section>
)
}

/**
* Reusable wide-screen container for root page
*/
export const SectionContainer: React.FC<Props> = ({ header, children, className = '', width = Width.wide }) => (
<section className={clx('block w-full p-4 mx-auto max-w-5xl xl:max-w-7xl', width, className)}>
{header}
<hr className='mb-6 border-2 border-base-content' />
{children}
</section>
)
4 changes: 4 additions & 0 deletions src/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ h2 {
@apply text-base-content text-xl font-bold tracking-tight leading-loose;
}

h3 {
@apply text-base-content text-lg font-semibold tracking-tight leading-loose;
}

.card-body {
@apply sm:px-0 border-0 !important;
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FinancialContributors } from './components/FinancialContributors'
import { RecentTags } from './components/RecentTags'
import { USAToC } from './components/USAToC'
import { InternationalToC } from './components/InternationalToC'
import { Volunteers } from './components/Volunteers'

/**
* Cache duration in seconds
Expand Down Expand Up @@ -33,7 +34,10 @@ export default async function Home (): Promise<any> {
<RecentTags />
<InternationalToC />
<USAToC />
<FinancialContributors />
<div className='flex flex-col gap-10'>
<FinancialContributors />
<Volunteers />
</div>
</div>
)
}
Expand Down

1 comment on commit b1421c0

@vercel
Copy link

@vercel vercel bot commented on b1421c0 Oct 30, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.