From 1501ad821dc8b1eda56df228c54f20af0bfffd52 Mon Sep 17 00:00:00 2001 From: encryptedDegen Date: Thu, 5 Dec 2024 01:53:11 +0100 Subject: [PATCH] =?UTF-8?q?=C3=B6eaderboard=20stats=20adjustments=20&=20fi?= =?UTF-8?q?lter=20dropdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/leaderboard/components/filters.tsx | 62 ++++++++++++++++++---- src/app/leaderboard/components/table.tsx | 50 ++++++++--------- 2 files changed, 77 insertions(+), 35 deletions(-) diff --git a/src/app/leaderboard/components/filters.tsx b/src/app/leaderboard/components/filters.tsx index f7d0f711..0123fcb7 100644 --- a/src/app/leaderboard/components/filters.tsx +++ b/src/app/leaderboard/components/filters.tsx @@ -1,7 +1,10 @@ -import React from 'react' import Image from 'next/image' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' +import { IoIosArrowDown } from 'react-icons/io' +import { useClickAway } from '@uidotdev/usehooks' +import { cn } from '#/lib/utilities' import type { LeaderboardFilter } from '#/types/common' import { leaderboardFiltersEmojies, leaderboardFilters } from '#/lib/constants' @@ -11,22 +14,59 @@ interface FiltersProps { } const Filters: React.FC = ({ filter, onSelectFilter }) => { + const [isDropdownOpen, setIsDropdownOpen] = useState(false) + const clickAwayRef = useClickAway(() => setIsDropdownOpen(false)) + const { t } = useTranslation() return ( -
- {leaderboardFilters.map((item, i) => ( +
+
setIsDropdownOpen(prev => !prev)} + className='flex w-full cursor-pointer flex-wrap h-[50px] z-30 justify-between px-3 glass-card border-grey hover:border-text/80 transition-colors rounded-xl border-[3px] bg-neutral items-center gap-4' + >
onSelectFilter(item)} + key={filter} + className={`font-bold flex gap-1 justify-center capitalize cursor-pointer transition-all rounded-full`} + onClick={() => onSelectFilter(filter)} > -

{t(item)}

- {item} +

{t(filter)}

+ {filter} +
+ +
+
+
+ {leaderboardFilters.map(item => ( +
{ + onSelectFilter(item) + setIsDropdownOpen(false) + }} + className='flex items-center gap-2 p-4 w-full rounded-lg hover:bg-text/10' + > +

{t(item)}

+ {item} +
+ ))}
- ))} +
) } diff --git a/src/app/leaderboard/components/table.tsx b/src/app/leaderboard/components/table.tsx index 501a5824..fdf70313 100644 --- a/src/app/leaderboard/components/table.tsx +++ b/src/app/leaderboard/components/table.tsx @@ -70,11 +70,11 @@ const LeaderboardTable = () => { return (

{t('leaderboard')}

-
+
{LeaderboardStatNames.map((name, i) => (
{isLeaderboardStatsLoading || !leaderboardStats ? ( @@ -87,17 +87,17 @@ const LeaderboardTable = () => {
))}
-
+
{t('last updated')} {isLeaderboardLoading ? : timeStamp}
-
-
+
+
-
+
{ />
-
- +
+
+ +
+ { + setChunk(1) + fetchNextLeaderboard() + }} + fetchPrevious={() => { + setChunk(1) + fetchPreviousLeaderboard() + }} + />
- { - setChunk(1) - fetchNextLeaderboard() - }} - fetchPrevious={() => { - setChunk(1) - fetchPreviousLeaderboard() - }} - />
-
+
{leaderboard ?.slice(0, chunk * LEADERBOARD_CHUNK_SIZE) .map((entry: LeaderboardItem, index) => (