-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sliit-foss/feature/leaderboard
Feat: added leaderboard components without filtering and sorting
- Loading branch information
Showing
8 changed files
with
132 additions
and
7 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
export * from "./score-card"; |
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,44 @@ | ||
import { GraduationCap } from "lucide-react"; | ||
import { Body, Body2, Footnote, Title } from "@sliit-foss/bashaway-ui/typography"; | ||
|
||
const topThreeGradient = (position) => { | ||
if (position === 0) return "bg-gradient-to-r from-[#FF107B]/[.12] to-[#F99A2A]/[.12] border-[#ff0000]/10"; | ||
else if (position === 1) return "bg-gradient-to-r from-[#FF107B]/[.08] to-[#F99A2A]/[.08] border-[#ff0000]/10"; | ||
else if (position === 2) return "bg-gradient-to-r from-[#FF107B]/[.04] to-[#F99A2A]/[.04] border-[#ff0000]/10"; | ||
return ""; | ||
}; | ||
|
||
export { default as ScoreCardSkeleton } from "./skeleton"; | ||
|
||
export const ScoreCard = ({ item, index, ...props }) => { | ||
return ( | ||
<div | ||
className={`flex gap-6 px-6 py-5 rounded-2xl border border-black/10 justify-between items-center ${topThreeGradient( | ||
index | ||
)}`} | ||
{...props} | ||
> | ||
<div className="flex gap-6 items-center"> | ||
<div | ||
className={`w-16 h-16 rounded-2xl border border-black/10 flex justify-center items-center ${ | ||
index === 0 || index === 1 || index === 2 ? "bg-gradient-to-tr from-[#f90000] to-[#FF881A] text-white" : "" | ||
}`} | ||
> | ||
<Title className="font-medium">{index + 1}</Title> | ||
</div> | ||
<div className="flex flex-col gap-1"> | ||
<Body className="font-inter font-semibold leading-none">{item.name}</Body> | ||
<div className="flex gap-[6px] items-center opacity-40"> | ||
<GraduationCap strokeWidth={1.5} /> | ||
<Footnote>{item.university}</Footnote> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="px-5 py-3 rounded-full border border-black/10 min-w-[116px] bg-white flex justify-center items-center"> | ||
<Body2>{item.score.toFixed(2)}</Body2> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ScoreCard; |
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 { Skeleton } from "@sliit-foss/bashaway-ui/components"; | ||
|
||
const ScoreCardSkeleton = () => { | ||
return Array.from({ length: 3 }).map((_, i) => ( | ||
<Skeleton key={i} className="px-6 py-5 rounded-2xl flex w-full justify-between items-center" inline> | ||
<div className="flex gap-6 items-center"> | ||
<Skeleton shade="dark" className="w-[60px] h-[60px] rounded-2xl" inline /> | ||
<div className="flex flex-col gap-1"> | ||
<Skeleton shade="dark" className="h-[28px] w-24" inline /> | ||
<Skeleton shade="dark" className="h-[18px] w-[72px] rounded-2xl" inline /> | ||
</div> | ||
</div> | ||
<Skeleton shade="dark" className="px-5 py-3 rounded-full min-w-[116px] h-12" inline /> | ||
</Skeleton> | ||
)); | ||
}; | ||
|
||
export default ScoreCardSkeleton; |
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,2 @@ | ||
export * from "./layout"; | ||
export * from "./home"; |
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 |
---|---|---|
@@ -1,9 +1,62 @@ | ||
/* eslint-disable no-unused-vars */ | ||
import { useState } from "react"; | ||
import { ScoreCardSkeleton } from "@/components"; | ||
import { ScoreCard } from "@/components/home"; | ||
import { filters as filterData, sorts as sortData } from "@/filters"; | ||
import { useTitle } from "@/hooks"; | ||
import { useFetchLeaderboardQuery } from "@/store/api"; | ||
import { AnimatedSwitcher, Filters, NoRecords, Pagination, Sorts } from "@sliit-foss/bashaway-ui/components"; | ||
import { Footnote, Title } from "@sliit-foss/bashaway-ui/typography"; | ||
import { computeFilterQuery, computeSortQuery } from "@sliit-foss/bashaway-ui/utils"; | ||
|
||
const Home = () => { | ||
useTitle("Leaderboard | Bashaway"); | ||
const [_filters, setFilters] = useState(computeFilterQuery(filterData)); | ||
const [_sorts, setSorts] = useState(computeSortQuery(sortData)); | ||
|
||
return <>Placeholder</>; | ||
const { data: scores, isFetching } = useFetchLeaderboardQuery(); | ||
|
||
return ( | ||
<> | ||
<div className="w-full flex flex-col justify-center items-center gap-6 mb-8 max-w-4xl"> | ||
<div className="flex flex-col items-center gap-2 md:gap-1 mb-6 pointer-events-none"> | ||
<Title className="tracking-normal">The Leaderboard</Title> | ||
<Footnote className="text-black/40 max-w-[500px] text-xl lg:text-center leading-6"> | ||
A place where your true colors showed off despite all the differences | ||
</Footnote> | ||
</div> | ||
<div className="w-full flex justify-center items-center gap-6 mb-8"> | ||
<Filters filters={filterData} setFilterQuery={setFilters} /> | ||
<Sorts styles={{ root: "justify-end" }} sorts={sortData} setSortQuery={setSorts} /> | ||
</div> | ||
<AnimatedSwitcher | ||
show={isFetching} | ||
className={`w-full flex flex-col gap-5`} | ||
component={<ScoreCardSkeleton />} | ||
alternateComponent={ | ||
scores && scores.data.length ? ( | ||
<> | ||
{scores.data.map((item, index) => ( | ||
<ScoreCard item={item} index={index} key={`score-card-${index}`} /> | ||
))} | ||
</> | ||
) : ( | ||
<div className="h-full flex flex-1 items-center"> | ||
<NoRecords text="No leaders at the moment" /> | ||
</div> | ||
) | ||
} | ||
/> | ||
<div className="w-full flex justify-center items-center mt-6 mb-2"> | ||
<Pagination | ||
currentPage={1} | ||
// onPageChange={(newPage) => setPage(newPage)} | ||
totalPages={1} | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Home; |