Skip to content

Commit

Permalink
feat: Add item count meta data to Highlight Card (#254)
Browse files Browse the repository at this point in the history
* Added item count to each highlight card.

* Added humanize number function to percentage label.
  • Loading branch information
chadstewart committed Aug 23, 2022
1 parent 20df419 commit 693479e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions components/organisms/Dashboard/dashboard.tsx
Expand Up @@ -2,9 +2,10 @@ import useDashBoardData from "lib/hooks/useDashboardData";
import Card from "../../atoms/Card/card";
import ScatterChart from "components/molecules/ScatterChart/scatter-chart";
import HighlightCard from "components/molecules/HighlightCard/highlight-card";
import humanizeNumber from "lib/utils/humanizeNumber";

export const Dashboard = (): JSX.Element => {
const { scatterOptions } = useDashBoardData();
const { scatterOptions, repoListMetaData, isLoading } = useDashBoardData();

return (
<div className="flex flex-col w-full gap-4">
Expand All @@ -17,7 +18,7 @@ export const Dashboard = (): JSX.Element => {
increased={true}
numChanged={38}
percentage={40}
percentageLabel="of 49,999"
percentageLabel={isLoading ? "Loading..." : `of ${humanizeNumber(repoListMetaData.itemCount)}`}
/>
<HighlightCard
url="/hacktoberfest/pull%20requests"
Expand All @@ -27,7 +28,7 @@ export const Dashboard = (): JSX.Element => {
increased={true}
numChanged={98}
percentage={80}
percentageLabel="of 49,999"
percentageLabel={isLoading ? "Loading..." : `of ${humanizeNumber(repoListMetaData.itemCount)}`}
/>
<HighlightCard
url="/hacktoberfest/pull%20requests"
Expand All @@ -37,7 +38,7 @@ export const Dashboard = (): JSX.Element => {
increased={false}
numChanged={38}
percentage={37}
percentageLabel="of 49,999"
percentageLabel={isLoading ? "Loading..." : `of ${humanizeNumber(repoListMetaData.itemCount)}`}
/>
<HighlightCard
url="/hacktoberfest/pull%20requests"
Expand All @@ -47,7 +48,7 @@ export const Dashboard = (): JSX.Element => {
increased={false}
numChanged={85}
percentage={77}
percentageLabel="of 49,999"
percentageLabel={isLoading ? "Loading..." : `of ${humanizeNumber(repoListMetaData.itemCount)}`}
/>
</section>
<section className="flex flex-col lg:flex-row max-w-full gap-4 mb-6">
Expand Down
9 changes: 8 additions & 1 deletion lib/hooks/useDashboardData.ts
@@ -1,3 +1,5 @@
import { useRepositoriesList } from "lib/hooks/useRepositoriesList";

const useDashBoardData = () => {
const scatterOptions = {
xAxis: {},
Expand Down Expand Up @@ -60,9 +62,14 @@ const useDashBoardData = () => {
]
};

const { repoList, isLoading } = useRepositoriesList();
const repoListMetaData = repoList.meta;

return {
scatterOptions,
areaChartOptions
areaChartOptions,
repoListMetaData,
isLoading
};
};

Expand Down

0 comments on commit 693479e

Please sign in to comment.