-
Notifications
You must be signed in to change notification settings - Fork 1
[Campaign Launcher UI] Leaderboard #835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KirillKirill
merged 10 commits into
kb/785-redesign-campaign-details
from
kb/586-leaderboard
Apr 8, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
923a611
feat: add leaderboard query and related types
KirillKirill 394d874
feat: implement leaderboard UI; cover responsive and business logic
KirillKirill 6be8414
chore: change the order of rendering components
KirillKirill 163b481
fix: address the feedback from copilot
KirillKirill f1773e7
fix: show leaderboard if there's some data exist
KirillKirill 7a97950
feat: display score field
KirillKirill 2223860
chore: display updatedAt
KirillKirill 0d848bc
fix: change imports order
KirillKirill 4b06d1b
fix: remove optional chaining, as leaderboard is always define
KirillKirill 7d9e3e9
fix: specify leaderboard type with rank; make activeAddress required;…
KirillKirill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
87 changes: 87 additions & 0 deletions
87
campaign-launcher/client/src/components/Leaderboard/List.tsx
This file contains hidden or 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,87 @@ | ||
| import { memo } from 'react'; | ||
|
|
||
| import { Box, Stack, Typography } from '@mui/material'; | ||
|
|
||
| import FormattedNumber from '@/components/FormattedNumber'; | ||
| import { type EvmAddress, type LeaderboardEntry } from '@/types'; | ||
| import { formatAddress, getCompactNumberParts } from '@/utils'; | ||
|
|
||
| import MyEntryLabel from './MyEntryLabel'; | ||
|
|
||
| type Props = { | ||
| data: LeaderboardEntry[]; | ||
| activeAddress: EvmAddress | undefined; | ||
| }; | ||
|
|
||
| const LeaderboardList = memo(({ data, activeAddress }: Props) => ( | ||
| <Stack flex={1} minHeight={0} overflow="auto"> | ||
| {data.map((entry) => { | ||
| const { address, rank, result, score } = entry; | ||
| const { | ||
| value: resultValue, | ||
| suffix: resultSuffix, | ||
| decimals: resultDecimals, | ||
| } = getCompactNumberParts(result); | ||
| const { | ||
| value: scoreValue, | ||
| suffix: scoreSuffix, | ||
| decimals: scoreDecimals, | ||
| } = getCompactNumberParts(score); | ||
| const isMyEntry = address.toLowerCase() === activeAddress?.toLowerCase(); | ||
| return ( | ||
| <Box | ||
| key={address} | ||
| display="flex" | ||
| alignItems="center" | ||
| justifyContent="space-between" | ||
| height="60px" | ||
| gap={1} | ||
| px={{ xs: 2, md: 4 }} | ||
| py={1.5} | ||
| bgcolor={isMyEntry ? '#3a2e6f' : 'transparent'} | ||
| borderBottom="1px solid #3a2e6f" | ||
| sx={{ | ||
| '&:last-of-type': { | ||
| borderBottom: 'none', | ||
| }, | ||
| }} | ||
| > | ||
| <Box display="flex" alignItems="center" gap={1} color="white"> | ||
| <Typography variant="body1" fontWeight={500} mr={1}> | ||
| #{rank} | ||
| </Typography> | ||
| <Typography variant="body2" fontWeight={500}> | ||
| {formatAddress(address)} | ||
| </Typography> | ||
| {isMyEntry && <MyEntryLabel />} | ||
| </Box> | ||
| <Box display="flex" alignItems="center" gap={3}> | ||
| <Stack alignItems="center"> | ||
| <Typography variant="body2" color="white" fontWeight={500}> | ||
| <FormattedNumber | ||
| value={scoreValue} | ||
| decimals={scoreDecimals} | ||
| suffix={scoreSuffix} | ||
| /> | ||
| </Typography> | ||
| <Typography variant="caption">Score</Typography> | ||
| </Stack> | ||
| <Stack alignItems="center"> | ||
| <Typography variant="body2" color="white" fontWeight={500}> | ||
| <FormattedNumber | ||
| value={resultValue} | ||
| prefix="$" | ||
| decimals={resultDecimals} | ||
| suffix={resultSuffix} | ||
| /> | ||
| </Typography> | ||
| <Typography variant="caption">Volume</Typography> | ||
| </Stack> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| })} | ||
| </Stack> | ||
| )); | ||
|
|
||
| export default LeaderboardList; |
27 changes: 27 additions & 0 deletions
27
campaign-launcher/client/src/components/Leaderboard/MyEntryLabel.tsx
This file contains hidden or 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,27 @@ | ||
| import { Box, Typography } from '@mui/material'; | ||
|
|
||
| const MyEntryLabel = () => ( | ||
| <Box | ||
| display="flex" | ||
| alignItems="center" | ||
| justifyContent="center" | ||
| py={0.5} | ||
| px={1} | ||
| borderRadius="9px" | ||
| sx={{ | ||
| background: 'linear-gradient(98deg, #FFF -10.24%, #FEC0D6 106.59%)', | ||
| }} | ||
| > | ||
| <Typography | ||
| variant="caption" | ||
| color="#e65d8e" | ||
| fontWeight={600} | ||
| letterSpacing={0} | ||
| lineHeight={1} | ||
| > | ||
| You | ||
| </Typography> | ||
| </Box> | ||
| ); | ||
|
|
||
| export default MyEntryLabel; |
135 changes: 135 additions & 0 deletions
135
campaign-launcher/client/src/components/Leaderboard/Overlay.tsx
This file contains hidden or 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,135 @@ | ||
| import { | ||
| type ChangeEvent, | ||
| type FC, | ||
| useDeferredValue, | ||
| useMemo, | ||
| useState, | ||
| } from 'react'; | ||
|
|
||
| import SearchIcon from '@mui/icons-material/Search'; | ||
| import { | ||
| Box, | ||
| InputAdornment, | ||
| Stack, | ||
| TextField, | ||
| Typography, | ||
| } from '@mui/material'; | ||
|
|
||
| import ResponsiveOverlay from '@/components/ResponsiveOverlay'; | ||
| import { useIsMobile } from '@/hooks/useBreakpoints'; | ||
| import { useActiveAccount } from '@/providers/ActiveAccountProvider'; | ||
| import { type LeaderboardEntry } from '@/types'; | ||
|
|
||
| import LeaderboardList from './List'; | ||
|
|
||
| import { formatActualOnDate } from '.'; | ||
|
|
||
| type Props = { | ||
| open: boolean; | ||
| onClose: () => void; | ||
| data: LeaderboardEntry[]; | ||
| updatedAt: string; | ||
| symbol: string; | ||
| }; | ||
|
|
||
| const LeaderboardOverlay: FC<Props> = ({ | ||
| open, | ||
| onClose, | ||
| data, | ||
| updatedAt, | ||
| symbol, | ||
| }) => { | ||
| const [search, setSearch] = useState(''); | ||
| const deferredSearch = useDeferredValue(search); | ||
| const isMobile = useIsMobile(); | ||
| const { activeAddress } = useActiveAccount(); | ||
|
|
||
| const filteredData = useMemo(() => { | ||
| const normalizedSearch = deferredSearch.trim().toLowerCase(); | ||
| if (!normalizedSearch) return data; | ||
|
|
||
| return data.filter(({ address }) => | ||
| address.toLowerCase().includes(normalizedSearch) | ||
| ); | ||
| }, [data, deferredSearch]); | ||
|
|
||
| const handleSearchChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
| setSearch(event.target.value); | ||
| }; | ||
|
|
||
| const handleClose = () => { | ||
| setSearch(''); | ||
| onClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <ResponsiveOverlay | ||
| open={open} | ||
| onClose={handleClose} | ||
| desktopSx={{ p: 0, height: 650 }} | ||
| mobileSx={{ p: 0 }} | ||
| closeButtonSx={{ | ||
| top: { xs: 20, md: 32 }, | ||
| right: { xs: 16, md: 32 }, | ||
| }} | ||
| > | ||
| <Stack height="100%" minHeight={0}> | ||
| <Box | ||
| px={{ xs: 2, md: 4 }} | ||
| pt={{ xs: 2, md: 4 }} | ||
| pb={{ xs: 2, md: 3 }} | ||
| bgcolor="background.default" | ||
| overflow="hidden" | ||
| > | ||
| <Typography | ||
| component="h6" | ||
| variant={isMobile ? 'h6' : 'h5'} | ||
| color="white" | ||
| fontWeight={700} | ||
| > | ||
| {`Leaderboard (${symbol})`} | ||
| </Typography> | ||
| <Typography fontSize="12px" fontWeight={500} lineHeight={1} mt={0.5}> | ||
| Actual on: {formatActualOnDate(updatedAt)} | ||
| </Typography> | ||
| <TextField | ||
| fullWidth | ||
| size="small" | ||
| placeholder="Search Wallet" | ||
| value={search} | ||
| onChange={handleSearchChange} | ||
| slotProps={{ | ||
| input: { | ||
| 'aria-label': 'Search Wallet', | ||
| endAdornment: ( | ||
| <InputAdornment position="end"> | ||
| <SearchIcon sx={{ color: 'white', fontSize: 24 }} /> | ||
| </InputAdornment> | ||
| ), | ||
| }, | ||
| }} | ||
| sx={{ | ||
| mt: 2, | ||
| '& .MuiOutlinedInput-root': { | ||
| color: 'white', | ||
| bgcolor: '#382c6b', | ||
| borderRadius: '28px', | ||
| border: 'none', | ||
| '& fieldset': { | ||
| border: 'none', | ||
| }, | ||
| }, | ||
| '& .MuiInputBase-input::placeholder': { | ||
| color: 'white', | ||
| opacity: 1, | ||
| }, | ||
| }} | ||
| /> | ||
| </Box> | ||
| <LeaderboardList data={filteredData} activeAddress={activeAddress} /> | ||
| </Stack> | ||
| </ResponsiveOverlay> | ||
| ); | ||
| }; | ||
|
|
||
| export default LeaderboardOverlay; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.