Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function MainLayout({
<SidebarInset className="flex flex-col min-w-0 h-screen">
<SiteHeader isFullWidth={isFullWidth} onToggleFullWidth={setIsFullWidth} />
<div className="flex flex-1 flex-col bg-background overflow-y-auto overflow-x-hidden min-w-0 hide-scrollbar">
<div className={`w-full mx-auto px-12 min-w-0 transition-all duration-300 ease-in-out ${!isFullWidth ? "max-w-[1320px]" : "max-w-full"}`}>
<div className={`w-full mx-auto px-4 sm:px-6 md:px-8 lg:px-12 min-w-0 transition-all duration-300 ease-in-out ${!isFullWidth ? "max-w-[1320px]" : "max-w-full"}`}>
<motion.div
key={pathname}
initial={{ opacity: 0 }}
Expand Down
16 changes: 13 additions & 3 deletions frontend/components/common/leaderboard/leaderboard-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,26 @@ export const LeaderboardTable = React.memo(function LeaderboardTable({
return Math.max(...items.map(item => parseFloat(item.available_balance))) || 1
}, [items])

const computePercentage = React.useCallback(
(balance: number) => {
const denominator = Math.log(maxBalance + 1)
if (denominator <= 0) return 0
const safeBalance = Math.max(balance, 0)
return (Math.log(safeBalance + 1) / denominator) * 100
},
[maxBalance]
)

const rankedItems = React.useMemo(
() =>
items
.map((entry, index) => ({
entry,
rank: startRank + index,
percentage: (parseFloat(entry.available_balance) / maxBalance) * 100,
percentage: computePercentage(parseFloat(entry.available_balance)),
}))
.filter(({ entry }) => entry.user_id !== currentUserEntry?.user_id),
[items, startRank, currentUserEntry?.user_id, maxBalance]
[items, startRank, currentUserEntry?.user_id, computePercentage]
)

const virtualizer = useVirtualizer({
Expand All @@ -69,7 +79,7 @@ export const LeaderboardTable = React.memo(function LeaderboardTable({
}, [virtualItems, rankedItems.length, hasMore, loading, onLoadMore])

const currentUserPercentage = currentUserEntry
? (parseFloat(currentUserEntry.available_balance) / maxBalance) * 100
? computePercentage(parseFloat(currentUserEntry.available_balance))
: 0

if (loading && items.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function SiteHeader({ isFullWidth = false, onToggleFullWidth }: { isFullW
</div>
</div>

<div className={`hidden md:flex w-full items-center gap-4 transition-all duration-300 ease-in-out ${!isFullWidth ? "max-w-[1320px]" : "max-w-full"} mx-auto px-12`}>
<div className={`hidden md:flex w-full items-center gap-4 transition-all duration-300 ease-in-out ${!isFullWidth ? "max-w-[1320px]" : "max-w-full"} mx-auto md:px-8 lg:px-12`}>
<div className="relative w-64 cursor-pointer" onClick={() => setSearchOpen(true)}>
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
<div className="flex h-8 items-center rounded-md border border-border/60 bg-muted/70 pl-10 pr-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted">
Expand Down
Loading