Skip to content

Commit

Permalink
Sticky footer's bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
westernal committed Jul 10, 2023
1 parent 528880f commit 5e8307f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 73 deletions.
31 changes: 2 additions & 29 deletions src/components/ListRepositories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,17 @@ const ListRepositories = ({
fetchedData,
title,
}: ListRepositoriesProps): JSX.Element => {

Check failure on line 19 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`

Check failure on line 19 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`

Check failure on line 19 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
if (!fetchedData.length) {
return (
<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(10).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>
);
}

return (
<div className="mx-auto max-w-7xl px-4 pb-1 mt-10">
<div className="flex flex-col gap-y-5 mb-12">
<div className="flex items-center gap-x-2.5">
<BsFillCalendar2Fill className="w-8 h-8 text-white" />

{activeLink && (
<h1 className="text-2xl text-white font-semibold">
{title}
</h1>
)}
{activeLink && <h1 className="text-2xl text-white font-semibold">{title}</h1>}

Check failure on line 26 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

`{title}` must be placed on a new line

Check failure on line 26 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

`{title}` must be placed on a new line

Check failure on line 26 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

`{title}` must be placed on a new line
</div>

{fetchedData.map((item, i) => (
<RepoList
key={`${item.full_name}_${i}`}
data={item}
/>
<RepoList key={`${item.full_name}_${i}`} data={item} />

Check failure on line 30 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Prop `data` must be placed on a new line

Check failure on line 30 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Prop `data` must be placed on a new line

Check failure on line 30 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Prop `data` must be placed on a new line
))}
</div>

Expand Down
109 changes: 65 additions & 44 deletions src/components/RecentRepoListWrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import locationsHash from "../lib/locationsHash";
import ListRepositories from "./ListRepositories";
import { useEffect, useState } from "react";
import { useRepositoriesList } from "../hooks/useRepositoriesList";
import Skeleton from "react-loading-skeleton";

export enum RepoOrderByEnum {
popular = "stars",
recent = "created_at",
upvoted = "votesCount",
discussed = "issues",
myVotes = "myVotes"
myVotes = "myVotes",
}

const parseLimitValue = (limit: string | null): number => {
Expand Down Expand Up @@ -39,29 +40,37 @@ const RecentRepoListWrap = (): JSX.Element => {
const [lastWeek, setLastWeek] = useState<DbRepo[] | null>(null);
const [older, setOlder] = useState<DbRepo[] | null>(null);

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

Check failure on line 44 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unnecessary '()' invoking a constructor with no arguments

Check failure on line 44 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unnecessary '()' invoking a constructor with no arguments

Check failure on line 44 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unnecessary '()' invoking a constructor with no arguments

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);

Check failure on line 50 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

Check failure on line 50 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

Check failure on line 50 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

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

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

Check failure on line 57 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

Check failure on line 57 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

Check failure on line 57 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument
repo.created_at &&
new Date(repo.created_at) < lastSunday &&
new Date(repo.created_at) > new Date(lastSunday.getTime() - 7 * 24 * 60 * 60 * 1000)

Check failure on line 60 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Missing trailing comma

Check failure on line 60 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Missing trailing comma

Check failure on line 60 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Missing trailing comma
);

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));
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));
const olderData = data.filter(
(repo) =>

Check failure on line 68 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

Check failure on line 68 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument

Check failure on line 68 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Unexpected parentheses around single function argument
repo.created_at && new Date(repo.created_at) < new Date(lastSunday.getTime() - 7 * 24 * 60 * 60 * 1000)

Check failure on line 69 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Missing trailing comma

Check failure on line 69 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Missing trailing comma

Check failure on line 69 in src/components/RecentRepoListWrap.tsx

View workflow job for this annotation

GitHub Actions / Code standards

Missing trailing comma
);

olderData.sort( (a, b) => (new Date(a.created_at!) > new Date(b.created_at!) ? 1 : -1));
olderData.sort( (a, b) => (a.votesCount! > b.votesCount! ? -1 : 1));
olderData.sort((a, b) => (new Date(a.created_at!) > new Date(b.created_at!) ? 1 : -1));
olderData.sort((a, b) => (a.votesCount! > b.votesCount! ? -1 : 1));
setOlder(olderData);
}
}, [data]);
Expand All @@ -72,40 +81,52 @@ const RecentRepoListWrap = (): JSX.Element => {

return (
<>
{!isLoading &&
(
<>
{/* limit set to 101, a temporary fix to hide "Load More" from "This Week" & "Last Week".
{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(10).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>
) : (
<>
{/* limit set to 101, a temporary fix to hide "Load More" from "This Week" & "Last Week".
TODO: Make a real solution for this. */}

{thisWeek && thisWeek.length > 0 &&
<ListRepositories
activeLink={activeLink}
fetchedData={thisWeek}
handleLoadingMore={handleLoadingMore}
limit={101}
title="This Week"
/>}

{lastWeek && lastWeek.length > 0 &&
<ListRepositories
activeLink={activeLink}
fetchedData={lastWeek}
handleLoadingMore={handleLoadingMore}
limit={101}
title="Last Week"
/>}

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

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

{older && older.length > 0 && (
<ListRepositories
activeLink={activeLink}
fetchedData={older}
handleLoadingMore={handleLoadingMore}
limit={limit}
title="Older"
/>
)}
</>
)}
</>
);
};
Expand Down

0 comments on commit 5e8307f

Please sign in to comment.