-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement Contributor Card Component (#245)
* Initial commit for contributor card. * Starting to work on contributor card component. Made quick hook that'll give component all the data it needs. * Completed as much as possible with current components. Left markers for where other components would need to be added. * Added horizontal bar to contributor card. * Added contributor table and completed contributor card. * Updated contributor card component to take in props to build contributor card rather than use hook to build the contributor card. * Updating contributor hook and line chart options based on code review feedback.
- Loading branch information
1 parent
0a2b1ca
commit 3bd55ea
Showing
9 changed files
with
365 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
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,69 @@ | ||
import Button from "components/atoms/Button/button"; | ||
import Card from "components/atoms/Card/card"; | ||
import Text from "components/atoms/Typography/text"; | ||
import CardHorizontalBarChart, { LanguageObject } from "components/molecules/CardHorizontalBarChart/card-horizontal-bar-chart"; | ||
import CardLineChart from "components/molecules/CardLineChart/card-line-chart"; | ||
import CardProfile from "components/molecules/CardProfile/card-profile"; | ||
import CardRepoList, { RepoList } from "components/molecules/CardRepoList/card-repo-list"; | ||
import ContributorTable, { PRs } from "components/molecules/ContributorTable/contributor-table"; | ||
import { useState } from "react"; | ||
|
||
/* | ||
Use this hook in the Contributor Page componenttbecause it has all the mock data: | ||
import useContributorCard from "lib/hooks/useContributorCard"; | ||
*/ | ||
interface ContributorObject { | ||
profile: { | ||
githubAvatar: string; | ||
githubName: string; | ||
totalPRs: number; | ||
dateOfFirstPR: string; | ||
}; | ||
repoList: RepoList[]; | ||
lineChartOption: object; | ||
languagesUsed: LanguageObject[]; | ||
prList: PRs[]; | ||
} | ||
|
||
interface ContributorCardProps { | ||
className?: string; | ||
contributor: ContributorObject; | ||
} | ||
|
||
const ContributorCard = ({ className, contributor }: ContributorCardProps) => { | ||
const { profile, repoList, lineChartOption, languagesUsed, prList } = contributor; | ||
const [ showPRs, setShowPRs ] = useState(false); | ||
|
||
return ( | ||
<Card className={className} > | ||
<div className="flex flex-col gap-2"> | ||
<div className="flex w-full justify-between gap-2"> | ||
<CardProfile {...profile} /> | ||
<div className="w-32"> | ||
<CardHorizontalBarChart languagesUsed={languagesUsed} /> | ||
</div> | ||
</div> | ||
<CardLineChart lineChartOption={lineChartOption}/> | ||
<CardRepoList repoList={repoList}/> | ||
{showPRs ? | ||
<div className="p-4"> | ||
<ContributorTable prList={prList} /> | ||
</div> | ||
|
||
: | ||
|
||
null | ||
} | ||
<div className="flex w-full py-3 justify-center"> | ||
<Button onClick={() => setShowPRs(prevState => !prevState)} type="link"> | ||
<Text className="!text-xs !text-light-slate-11 font-medium"> | ||
{showPRs ? "Hide" : "Show"} latest pull requests | ||
</Text> | ||
</Button> | ||
</div> | ||
</div> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default ContributorCard; |
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,137 @@ | ||
import TestRepoAvatar from "public/icons/test-repo-avatar.svg"; | ||
|
||
const useContributorData = () => { | ||
const lineChart = { | ||
xAxis: { | ||
type: "category", | ||
boundaryGap: false, | ||
axisLabel: { | ||
fontSize: 14, | ||
fontWeight: "bold", | ||
color: "darkgray" | ||
}, | ||
data: ["Jan 2022", "Mar 2022", "Jun 2022"] | ||
}, | ||
yAxis: { | ||
type: "value", | ||
splitNumber: 1, | ||
axisLabel: { | ||
show: false | ||
}, | ||
splitLine: { | ||
lineStyle: { | ||
type: "dashed" | ||
} | ||
} | ||
}, | ||
series: [ | ||
{ | ||
data: [820, 932, 901, 934, 1290, 1330, 1320], | ||
type: "line", | ||
smooth: true, | ||
showSymbol: false, | ||
lineStyle: { | ||
color: "#ff9800" | ||
}, | ||
areaStyle: { | ||
color: "#FFB74D", | ||
opacity: 0.6 | ||
} | ||
} | ||
] | ||
}; | ||
|
||
const profile = { | ||
githubAvatar: "https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1064&q=80", | ||
githubName: "ChadStewart", | ||
totalPRs: 4, | ||
dateOfFirstPR: "3mo" | ||
}; | ||
|
||
const repoList = [ | ||
{ | ||
repoName: "test", | ||
repoIcon: TestRepoAvatar | ||
}, | ||
{ | ||
repoName: "test2", | ||
repoIcon: TestRepoAvatar | ||
}, | ||
{ | ||
repoName: "test3", | ||
repoIcon: TestRepoAvatar | ||
}, | ||
{ | ||
repoName: "test4", | ||
repoIcon: TestRepoAvatar | ||
}, | ||
{ | ||
repoName: "test5", | ||
repoIcon: TestRepoAvatar | ||
}, | ||
{ | ||
repoName: "test6", | ||
repoIcon: TestRepoAvatar | ||
} | ||
]; | ||
|
||
const languageList = [ | ||
{ | ||
languageName: "TypeScript", | ||
percentageUsed: 50 | ||
}, | ||
{ | ||
languageName: "JavaScript", | ||
percentageUsed: 20 | ||
}, | ||
{ | ||
languageName: "Rust", | ||
percentageUsed: 30 | ||
} | ||
]; | ||
|
||
const listOfPRs = [ | ||
{ | ||
prName: "Merging some work", | ||
prStatus: "merged", | ||
prIssuedTime: "2mo", | ||
prClosedTime: "2mo", | ||
noOfFilesChanged: 13, | ||
noOfLinesChanged: 837 | ||
}, | ||
{ | ||
prName: "Merging some work", | ||
prStatus: "closed", | ||
prIssuedTime: "2mo", | ||
prClosedTime: "2mo", | ||
noOfFilesChanged: 13, | ||
noOfLinesChanged: 837 | ||
}, | ||
{ | ||
prName: "Merging some work", | ||
prStatus: "open", | ||
prIssuedTime: "2mo", | ||
prClosedTime: "2mo", | ||
noOfFilesChanged: 13, | ||
noOfLinesChanged: 837 | ||
}, | ||
{ | ||
prName: "Merging some work", | ||
prStatus: "draft", | ||
prIssuedTime: "2mo", | ||
prClosedTime: "2mo", | ||
noOfFilesChanged: 13, | ||
noOfLinesChanged: 837 | ||
} | ||
]; | ||
|
||
return { | ||
lineChart, | ||
profile, | ||
repoList, | ||
languageList, | ||
listOfPRs | ||
}; | ||
}; | ||
|
||
export default useContributorData; |
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
Oops, something went wrong.