Skip to content

Commit

Permalink
Merge pull request #29 from antoniolofiego/dev
Browse files Browse the repository at this point in the history
[#10] Add leaderboard page and components
  • Loading branch information
antoniolofiego authored Aug 6, 2020
2 parents 634fb44 + 6897841 commit 21a7799
Show file tree
Hide file tree
Showing 9 changed files with 9,179 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/components/AccountDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function AccountDropdown() {
: 'hidden '
}
tabindex="-1"
aria-label="Exit dropdown menu"
/>
<div
className={
Expand Down
5 changes: 4 additions & 1 deletion src/components/ArticleThumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export default function ArticleThumbnail(props) {
<div className="absolute ml-2 mt-2 bg-gray-100 rounded-lg">
{Provider && <Provider size={64} />}
</div>
<img src="https://images.unsplash.com/photo-1528642474498-1af0c17fd8c3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80" />
<img
src="https://images.unsplash.com/photo-1528642474498-1af0c17fd8c3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80"
alt="Article"
/>
</div>
<div>
<p className="text-2xl text-bold">An article title</p>
Expand Down
15 changes: 10 additions & 5 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ export default function Header(props) {
return (
<div className="pt-10 max-w-8xl m-auto">
<div className="flex items-center justify-between">
<img
className="h-32"
src="./banner.png"
alt="#100DaysOfCloud Logo"
/>
<Link to="/">
<img
className="h-32"
src="./banner.png"
alt="#100DaysOfCloud Logo"
/>
</Link>
<div className="flex items-center">
<Link to="/journeyers" className="ml-10 text-xl">
Journeyers
</Link>
<Link to="/leaderboard" className="ml-10 text-xl">
Leaderboard
</Link>
<Link to="/blog" className="ml-10 text-xl">
Blog
</Link>
Expand Down
31 changes: 31 additions & 0 deletions src/components/Leaderboard.js
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>
);
}
92 changes: 92 additions & 0 deletions src/components/LeaderboardEntry.js
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>
);
}
8 changes: 6 additions & 2 deletions src/components/ProfileBadge/ProfileComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const NameAndHandle = (props) => {
if (props.size === 'small') {
nameImagePadding = '4';
}

if (props.contactDirection === 'right') {
textMargin = 'ml-';
}
Expand Down Expand Up @@ -38,7 +38,11 @@ const ProfileImage = (props) => {
imageSize
}
>
<img src={props.avatar} alt="" className="h-full w-full" />
<img
src={props.avatar}
alt={`This is ${props.name}!`}
className="h-full w-full"
/>
</div>
);
};
Expand Down
4,505 changes: 4,504 additions & 1 deletion src/data/users1.json

Large diffs are not rendered by default.

4,505 changes: 4,504 additions & 1 deletion src/data/users2.json

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/pages/leaderboard.js
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>
);
}

0 comments on commit 21a7799

Please sign in to comment.