-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from antoniolofiego/dev
[#10] Add leaderboard page and components
- Loading branch information
Showing
9 changed files
with
9,179 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import LeaderboardEntry from './LeaderboardEntry'; | ||
|
||
import { users } from '../data/users1.json'; | ||
|
||
export default function Leaderboard() { | ||
return ( | ||
<div> | ||
<div className="grid grid-cols-12 items-center justify-center relative text-md font-bold"> | ||
<div className="col-span-9"></div> | ||
<p className="col-span-1 mx-auto">GitHub Streak</p> | ||
<p className="col-span-1 mx-auto">Twitter Streak</p> | ||
<p className="col-span-1 mx-auto">Total Score</p> | ||
</div> | ||
{users.map((user, index) => { | ||
return ( | ||
<LeaderboardEntry | ||
key={ | ||
user.github_username | ||
? user.github_username | ||
: user.twitter_username | ||
} | ||
index={index} | ||
user={user} | ||
/> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
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,92 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { ProfileImage } from './ProfileBadge/ProfileComponents'; | ||
|
||
import { FaTwitter, FaGithub, FaLinkedin } from 'react-icons/fa'; | ||
|
||
export default function LeaderboardEntry(props) { | ||
const [tooltipShown, setTooltipShown] = useState(false); | ||
|
||
const { | ||
name, | ||
githubProfile, | ||
githubScore, | ||
githubStreak, | ||
twitterProfile, | ||
twitterScore, | ||
twitterStreak, | ||
linkedinProfile, | ||
avatarImage, | ||
} = props.user; | ||
|
||
const index = props.index; | ||
|
||
const totalScore = githubScore + twitterScore; | ||
|
||
return ( | ||
<div className="grid grid-cols-12 items-center justify-center relative text-2xl"> | ||
<div className="col-span-1">#{index + 1}</div> | ||
<div className="mx-auto col-span-2"> | ||
<ProfileImage | ||
avatar={avatarImage} | ||
name={name} | ||
size={index === 0 ? '' : 'small'} | ||
/> | ||
</div> | ||
<div className="mx-auto text-2xl col-span-3">{name}</div> | ||
<div className="flex mx-auto col-span-3"> | ||
<a | ||
href={`https://github.com/${githubProfile}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
className="mx-4" | ||
> | ||
<FaGithub size={32} /> | ||
</a> | ||
<a | ||
href={`https://twitter.com/${twitterProfile}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
className="mx-4" | ||
> | ||
<FaTwitter size={32} /> | ||
</a> | ||
<a | ||
href={linkedinProfile} | ||
target="_blank" | ||
rel="noreferrer" | ||
className="mx-4" | ||
> | ||
<FaLinkedin size={32} /> | ||
</a> | ||
</div> | ||
<div className="col-span-3"> | ||
<div className="grid grid-cols-3"> | ||
<div className="mx-auto">{githubStreak}</div> | ||
<div className="mx-auto">{twitterStreak}</div> | ||
<div className="mx-auto"> | ||
<div | ||
role="presentation" | ||
onMouseEnter={() => setTooltipShown(true)} | ||
onMouseLeave={() => setTooltipShown(false)} | ||
> | ||
{totalScore} | ||
{tooltipShown && ( | ||
<div className="absolute z-10 right-0 mt-5 bg-gray-500 rounded-lg p-4"> | ||
<div> | ||
<p className="mx-auto"> | ||
GitHub Score: {githubScore} | ||
</p> | ||
<p className="mx-auto"> | ||
Twitter Score: {twitterScore} | ||
</p> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,27 @@ | ||
import React from 'react'; | ||
|
||
import Header from '../components/Header'; | ||
import Footer from '../components/Footer'; | ||
import Leaderboard from '../components/Leaderboard'; | ||
|
||
export default function Home() { | ||
return ( | ||
<div className="max-w-8xl m-auto"> | ||
<Header /> | ||
<div className="flex text-2xl font-bold justify-between border-b-2 border-gray-900 mb-4"> | ||
<h2>Top Journeyers</h2> | ||
<div className="flex"> | ||
<button className="px-2 text-2xl font-bold"> | ||
This Week | ||
</button> | ||
| | ||
<button className="px-2 text-2xl font-bold"> | ||
All Time | ||
</button> | ||
</div> | ||
</div> | ||
<Leaderboard /> | ||
<Footer /> | ||
</div> | ||
); | ||
} |