Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
npm run format
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougie committed Apr 1, 2024
1 parent bc1cc46 commit 426c355
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 76 deletions.
17 changes: 13 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ console.log(
╚██████╔╝██║ ███████╗██║ ╚████║ ███████║██║ ██║╚██████╔╝╚██████╗███████╗██████╔╝
╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚══════╝╚═════╝%c v${getAppVersion()}`,
"color:#f6d82b",
"color:green;font-weight:bold"
"color:green;font-weight:bold",
);

const App = (): JSX.Element => {
Expand Down Expand Up @@ -52,11 +52,20 @@ const App = (): JSX.Element => {
<HotRepositories />

<Routes>
<Route element={<RecentRepoListWrap />} path="/" />
<Route
element={<RecentRepoListWrap />}
path="/"
/>

<Route element={<RecentRepoListWrap />} path="recent" />
<Route
element={<RecentRepoListWrap />}
path="recent"
/>

<Route element={<RepoListWrap />} path="*" />
<Route
element={<RepoListWrap />}
path="*"
/>
</Routes>
</div>

Expand Down
60 changes: 40 additions & 20 deletions src/components/HotRepoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { useEffect, useState } from "react";
import { RiCheckboxCircleFill } from "react-icons/ri";
import { FaArrowAltCircleUp } from "react-icons/fa";
import { AiOutlineStar } from "react-icons/ai";
import { BiGitPullRequest } from "react-icons/bi";
import { VscIssues } from "react-icons/vsc";
Expand Down Expand Up @@ -30,11 +27,11 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
<div className="flex justify-center">
<a
className="bg-cheesyYellow text-grey rounded-xl font-bold hover:text-saucyRed transition-all duration-300 mr-3 p-2 flex w-5/6 h-fit justify-center"
href={`${String(
`${bugReportLink} repo not found [${repoName}]&body=Please take a look why this ${repoName} not founded`
)}`}
rel="noreferrer"
target="_blank"
href={`${String(
`${bugReportLink} repo not found [${repoName}]&body=Please take a look why this ${repoName} not founded`,
)}`}
>
Report a bug
</a>
Expand All @@ -46,22 +43,30 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
if (isLoading) {
return (
<div className="p-4 border rounded-2xl bg-white w-full space-y-1 relative">
<Skeleton enableAnimation count={5} />
<Skeleton
enableAnimation
count={5}
/>
</div>
);
}

const { id, full_name, name, description, issues, stars } = repo!;
const repo_id = parseInt(`${id}`);
const { full_name, name, description, issues, stars } = repo!;
const owner = full_name.replace(`/${String(name)}`, "").trim();

return (
<div className="p-4 border rounded-2xl bg-white w-full space-y-1 relative">
<div className="flex justify-between w-full">
<div className="flex space-x-1 items-center">
<img alt="Hot Repo Icon" className="h-4 w-4 rounded-md overflow-hidden" src={getAvatarLink(owner)} />

<span className="text-sm font-medium text-lightSlate11">{owner}</span>
<img
alt="Hot Repo Icon"
className="h-4 w-4 rounded-md overflow-hidden"
src={getAvatarLink(owner)}
/>

<span className="text-sm font-medium text-lightSlate11">
{owner}
</span>
</div>
</div>

Expand All @@ -75,25 +80,40 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
{name}
</a>

<p className="text-gray-500 font-medium text-xs w-5/6">{description}</p>
<p className="text-gray-500 font-medium text-xs w-5/6">
{description}
</p>
</div>

<div className="flex items-center justify-between absolute bottom-3 inset-x-0 px-4">
<div className="flex space-x-3 text-xs">
<div className="flex text-sm space-x-1 justify-center items-center">
<VscIssues className="fill-lightSlate10" size={16} />

<span className="text-lightSlate11">{humanizeNumber(issues)}</span>
<VscIssues
className="fill-lightSlate10"
size={16}
/>

<span className="text-lightSlate11">
{humanizeNumber(issues)}
</span>
</div>

<div className="flex text-sm space-x-1 justify-center items-center">
<AiOutlineStar className="fill-lightSlate10" size={16} />

<span className="text-lightSlate11">{humanizeNumber(stars)}</span>
<AiOutlineStar
className="fill-lightSlate10"
size={16}
/>

<span className="text-lightSlate11">
{humanizeNumber(stars)}
</span>
</div>

<div className="flex text-sm space-x-1 justify-center items-center">
<BiGitPullRequest className="fill-lightSlate10" size={16} />
<BiGitPullRequest
className="fill-lightSlate10"
size={16}
/>

<span className="text-lightSlate11">0</span>
</div>
Expand Down
104 changes: 56 additions & 48 deletions src/components/RecentRepoListWrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,31 @@ const RecentRepoListWrap = (): JSX.Element => {
const [older, setOlder] = useState<DbRepo[] | null>(null);

useEffect(() => {
const lastSunday = new Date();
const lastSunday = (new Date);

lastSunday.setDate(lastSunday.getDate() - lastSunday.getDay());
lastSunday.setHours(0, 0, 0, 0);

if (!isLoading) {
const thisWeekData = data.filter((repo) => repo.created_at && new Date(repo.created_at) > lastSunday);
const thisWeekData = data.filter(repo => repo.created_at && new Date(repo.created_at) > lastSunday);

thisWeekData.sort((a, b) => (new Date(a.created_at!) > new Date(b.created_at!) ? 1 : -1));
setThisWeek(thisWeekData);

const lastWeekData = data.filter(
(repo) =>
repo =>
repo.created_at &&
new Date(repo.created_at) < lastSunday &&
new Date(repo.created_at) > new Date(lastSunday.getTime() - 7 * 24 * 60 * 60 * 1000)
new Date(repo.created_at) > new Date(lastSunday.getTime() - 7 * 24 * 60 * 60 * 1000),
);

lastWeekData.sort((a, b) => (new Date(a.created_at!) > new Date(b.created_at!) ? 1 : -1));
lastWeekData.sort((a, b) => (a.votesCount! > b.votesCount! ? -1 : 1));
setLastWeek(lastWeekData);

const olderData = data.filter(
(repo) =>
repo.created_at && new Date(repo.created_at) < new Date(lastSunday.getTime() - 7 * 24 * 60 * 60 * 1000)
repo =>
repo.created_at && new Date(repo.created_at) < new Date(lastSunday.getTime() - 7 * 24 * 60 * 60 * 1000),
);

olderData.sort((a, b) => (new Date(a.created_at!) > new Date(b.created_at!) ? 1 : -1));
Expand All @@ -80,49 +80,57 @@ const RecentRepoListWrap = (): JSX.Element => {

return (
<>
{isLoading ? (
<div className="mx-auto max-w-7xl px-4 mt-10">
<div className="flex flex-col gap-y-5 overflow-hidden mb-12">
{Array.from(Array(25).keys()).map((item) => (
<div key={item} className="p-4 border rounded-2xl bg-white w-full space-y-1 relative">
<Skeleton enableAnimation count={4} />
</div>
))}
{isLoading
? (
<div className="mx-auto max-w-7xl px-4 mt-10">
<div className="flex flex-col gap-y-5 overflow-hidden mb-12">
{Array.from(Array(25).keys()).map(item => (
<div
key={item}
className="p-4 border rounded-2xl bg-white w-full space-y-1 relative"
>
<Skeleton
enableAnimation
count={4}
/>
</div>
))}
</div>
</div>
</div>
) : (
<>
{thisWeek && thisWeek.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={thisWeek}
handleLoadingMore={handleLoadingMore}
hasNextPage={meta.hasNextPage}
title="This Week"
/>
)}

{lastWeek && lastWeek.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={lastWeek}
handleLoadingMore={handleLoadingMore}
hasNextPage={meta.hasNextPage}
title="Last Week"
/>
)}

{older && older.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={older}
handleLoadingMore={handleLoadingMore}
hasNextPage={meta.hasNextPage}
title="Older"
/>
)}
</>
)}
)
: (
<>
{thisWeek && thisWeek.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={thisWeek}
handleLoadingMore={handleLoadingMore}
hasNextPage={meta.hasNextPage}
title="This Week"
/>
)}

{lastWeek && lastWeek.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={lastWeek}
handleLoadingMore={handleLoadingMore}
hasNextPage={meta.hasNextPage}
title="Last Week"
/>
)}

{older && older.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={older}
handleLoadingMore={handleLoadingMore}
hasNextPage={meta.hasNextPage}
title="Older"
/>
)}
</>
)}
</>
);
};
Expand Down
2 changes: 0 additions & 2 deletions src/components/RepoList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { emojify } from "node-emoji";
import { useEffect } from "react";
import { FaDotCircle, FaStar } from "react-icons/fa";
import humanizeNumber from "../lib/humanizeNumber";
import { getAvatarLink, getRepoLink } from "../lib/github";
import StackedAvatar from "./StackedAvatar";
import useVotedRepos from "../hooks/useVotedRepos";
import useContributions from "../hooks/useContributions";

export declare interface RepoListProps {
Expand Down
1 change: 0 additions & 1 deletion src/components/SecondaryNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Link, useLocation } from "react-router-dom";
import useSupabaseAuth from "../hooks/useSupabaseAuth";
import locationsHash from "../lib/locationsHash";
import { RepoOrderByEnum } from "./RepoListWrap";

Expand Down
1 change: 0 additions & 1 deletion src/e2e-tests/loggedOutUser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ test("logged out user should see all categories", async ({ page }) => {

await expect(popular).toHaveAttribute("href", "/popular");
await expect(popular).toBeVisible();

});

0 comments on commit 426c355

Please sign in to comment.