-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
186 additions
and
12 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 |
---|---|---|
@@ -1 +1 @@ | ||
[{"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/reportWebVitals.js":"1","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/index.js":"2","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/App.js":"3"},{"size":362,"mtime":1611800648683,"results":"4","hashOfConfig":"5"},{"size":1087,"mtime":1611937792406,"results":"6","hashOfConfig":"5"},{"size":385,"mtime":1611945364714,"results":"7","hashOfConfig":"5"},{"filePath":"8","messages":"9","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1tbblei",{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/reportWebVitals.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/index.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/App.js",[]] | ||
[{"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/reportWebVitals.js":"1","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/index.js":"2","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/App.js":"3","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/data/frameworks.js":"4","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/components/FrameworkCard/FrameworkCard.jsx":"5","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/api/api.js":"6","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/api/queries.js":"7","/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/components/FrameworkCard/GithubMetric/GithubMetric.jsx":"8"},{"size":362,"mtime":1611800648683,"results":"9","hashOfConfig":"10"},{"size":1204,"mtime":1611970362360,"results":"11","hashOfConfig":"10"},{"size":506,"mtime":1611968828468,"results":"12","hashOfConfig":"10"},{"size":677,"mtime":1611969204994,"results":"13","hashOfConfig":"10"},{"size":1876,"mtime":1611982249202,"results":"14","hashOfConfig":"10"},{"size":185,"mtime":1611948808927,"results":"15","hashOfConfig":"10"},{"size":377,"mtime":1611970738525,"results":"16","hashOfConfig":"10"},{"size":620,"mtime":1611981405569,"results":"17","hashOfConfig":"10"},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1tbblei",{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"26","messages":"27","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"28","messages":"29","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"32","messages":"33","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/reportWebVitals.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/index.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/App.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/data/frameworks.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/components/FrameworkCard/FrameworkCard.jsx",["34","35"],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/api/api.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/api/queries.js",[],"/Users/adamslaker/projects/software/launchpad-lab/framework-picker-dashboard/src/components/FrameworkCard/GithubMetric/GithubMetric.jsx",[],{"ruleId":"36","severity":1,"message":"37","line":9,"column":3,"nodeType":"38","messageId":"39","endLine":9,"endColumn":13},{"ruleId":"36","severity":1,"message":"40","line":13,"column":3,"nodeType":"38","messageId":"39","endLine":13,"endColumn":9},"no-unused-vars","'CardFooter' is defined but never used.","Identifier","unusedVar","'Button' is defined but never used."] |
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,18 @@ | ||
import { useQuery } from "react-query"; | ||
|
||
import { githubAPI } from "./api"; | ||
|
||
const DEFAULT_REFETCH_INTERVAL = 1000 * 15; | ||
|
||
export const useRepo = ({ name, repoUrl }) => { | ||
return useQuery( | ||
["github", name], | ||
async () => { | ||
const { data } = await githubAPI.get(repoUrl); | ||
return data; | ||
}, | ||
{ | ||
refetchInterval: DEFAULT_REFETCH_INTERVAL, | ||
} | ||
); | ||
}; |
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,68 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import * as numeral from "numeral"; | ||
|
||
// Grommet | ||
import { | ||
Card, | ||
CardBody, | ||
CardHeader, | ||
CardFooter, | ||
Heading, | ||
Box, | ||
Image, | ||
Button, | ||
} from "grommet"; | ||
import { Star, View, Archive } from "grommet-icons"; | ||
|
||
// Components | ||
import GithubMetric from "./GithubMetric/GithubMetric"; | ||
|
||
// Queries | ||
import { useRepo } from "../../api/queries"; | ||
|
||
const FrameworkCard = ({ display, name, imgSrc, repoUrl }) => { | ||
const { data } = useRepo({ name, repoUrl }); | ||
const [cardData, setCardData] = useState({ | ||
subscribers_count: 0, | ||
stargazers_count: 0, | ||
open_issues_count: 0, | ||
}); | ||
|
||
useEffect(() => { | ||
if (data) { | ||
const { subscribers_count, stargazers_count, open_issues_count } = data; | ||
setCardData({ | ||
stargazers_count, | ||
subscribers_count, | ||
open_issues_count, | ||
}); | ||
} | ||
}, [data]); | ||
|
||
return ( | ||
<Card height="medium" width="medium" background="light-1"> | ||
<CardHeader pad="medium" justify="between" gap="10px"> | ||
<Heading level="2">{display}</Heading> | ||
<Box height="xsmall" width="xsmall"> | ||
<Image fit="cover" src={imgSrc} /> | ||
</Box> | ||
</CardHeader> | ||
<CardBody pad="medium" direction="row" align="center"> | ||
<GithubMetric title="Number of Github stars"> | ||
<Star />{" "} | ||
<span>{numeral(cardData.stargazers_count).format("Oa")}</span> | ||
</GithubMetric> | ||
<GithubMetric title="Number of people watching the repo"> | ||
<View />{" "} | ||
<span>{numeral(cardData.subscribers_count).format("Oa")}</span> | ||
</GithubMetric> | ||
<GithubMetric title="Number of open issues and pull requests"> | ||
<Archive />{" "} | ||
<span>{numeral(cardData.open_issues_count).format("Oa")}</span> | ||
</GithubMetric> | ||
</CardBody> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default FrameworkCard; |
34 changes: 34 additions & 0 deletions
34
src/components/FrameworkCard/GithubMetric/GithubMetric.jsx
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,34 @@ | ||
import React from "react"; | ||
import { Box } from "grommet"; | ||
|
||
const GithubMetric = ({ children, title }) => { | ||
return ( | ||
<Box | ||
width="small" | ||
height="xsmall" | ||
direction="column" | ||
justify="center" | ||
align="center" | ||
gap="small" | ||
title={title} | ||
border={[ | ||
{ | ||
color: "border", | ||
size: "small", | ||
style: "solid", | ||
side: "right", | ||
}, | ||
{ | ||
color: "border", | ||
size: "small", | ||
style: "solid", | ||
side: "left", | ||
}, | ||
]} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default GithubMetric; |
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,26 @@ | ||
export const frameworks = [ | ||
{ | ||
name: "angular", | ||
display: "Angular", | ||
imgSrc: "https://angular.io/assets/images/logos/angular/angular.svg", | ||
repoUrl: "/repos/angular/angular", | ||
}, | ||
{ | ||
name: "react", | ||
display: "React", | ||
imgSrc: "https://angular.io/assets/images/logos/angular/angular.svg", | ||
repoUrl: "/repos/facebook/react", | ||
}, | ||
{ | ||
name: "vue", | ||
display: "Vue", | ||
imgSrc: "https://angular.io/assets/images/logos/angular/angular.svg", | ||
repoUrl: "/repos/vuejs/vue", | ||
}, | ||
{ | ||
name: "ember", | ||
display: "Ember", | ||
imgSrc: "https://angular.io/assets/images/logos/angular/angular.svg", | ||
repoUrl: "/repos/emberjs/ember.js", | ||
}, | ||
]; |
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