Skip to content

Commit

Permalink
Remove max count from token rarity display
Browse files Browse the repository at this point in the history
  • Loading branch information
Isti01 committed Oct 2, 2024
1 parent 2f95f40 commit e3ec86a
Showing 1 changed file with 37 additions and 62 deletions.
99 changes: 37 additions & 62 deletions frontend/src/common-components/TokenRarityDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
import { Box, Flex, Text } from '@chakra-ui/react'
import { useConfigContext } from '../api/contexts/config/ConfigContext.tsx'

const rarities = [
{
rarity: 'COMMON',
color: '#b7bfc5',
background: '#40464d'
},
{
rarity: 'UNCOMMON',
color: '#61bf00',
background: '#024f03'
},
{
rarity: 'RARE',
color: '#00afff',
background: '#00458a'
},
{
rarity: 'EPIC',
color: '#ce59ff',
background: '#4c197b'
},
{
rarity: 'LEGENDARY',
color: '#ffe8cf',
background: '#de6e0e'
},
{
rarity: 'RAINBOW',
color: '#000',
background:
'linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080)'
}
]

type TokenRarityChipProps = {
count: number
Expand All @@ -10,8 +43,7 @@ type TokenRarityChipProps = {
}

// based on https://fortnite.fandom.com/wiki/Rarity
const TokenRarityChip = ({ count, max, color, background, showMax }: TokenRarityChipProps) => {
const unique = max == 1
const TokenRarityChip = ({ count, color, background }: TokenRarityChipProps) => {
return (
<Box
display="inline-block"
Expand All @@ -26,13 +58,8 @@ const TokenRarityChip = ({ count, max, color, background, showMax }: TokenRarity
fontSize="1.1em"
>
<Text as="span" fontWeight="900">
{unique ? 'LGBTQ' : count}
{count}
</Text>
{showMax && max && !unique && (
<Text fontSize=".7em" as="sub">
/{max}
</Text>
)}
</Box>
)
}
Expand All @@ -42,64 +69,12 @@ interface TokenRarityDisplayProps {
}

export const TokenRarityDisplay = ({ collected }: TokenRarityDisplayProps) => {
const showMaxCount = useConfigContext().components.leaderboard.showTokenMaxCountByRarity

// TODO: get count by rarity from config
const maxByRarity: { [key: string]: number } = {
COMMON: 1500,
UNCOMMON: 500,
RARE: 250,
EPIC: 125,
LEGENDARY: 62,
RAINBOW: 1
}

const rarities = [
{
rarity: 'COMMON',
color: '#b7bfc5',
background: '#40464d'
},
{
rarity: 'UNCOMMON',
color: '#61bf00',
background: '#024f03'
},
{
rarity: 'RARE',
color: '#00afff',
background: '#00458a'
},
{
rarity: 'EPIC',
color: '#ce59ff',
background: '#4c197b'
},
{
rarity: 'LEGENDARY',
color: '#ffe8cf',
background: '#de6e0e'
},
{
rarity: 'RAINBOW',
color: '#000',
background: 'linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080)'
}
]

return (
<Flex gap={1} wrap="wrap">
{rarities
.filter((rarity) => collected[rarity.rarity] > 0)
.map((rarity) => (
<TokenRarityChip
key={rarity.rarity}
count={collected[rarity.rarity]}
max={maxByRarity[rarity.rarity]}
color={rarity.color}
background={rarity.background}
showMax={showMaxCount}
/>
<TokenRarityChip key={rarity.rarity} count={collected[rarity.rarity]} color={rarity.color} background={rarity.background} />
))}
</Flex>
)
Expand Down

0 comments on commit e3ec86a

Please sign in to comment.