Skip to content

Commit

Permalink
Builder gems 7 contribution viz on card (#4898)
Browse files Browse the repository at this point in the history
* Update builder card activity script

* Gems activity viz

* Fixed gems viz circle

* Fixed issue with mobile screen

* Added script to prefixx builder card activities

* Added points map tooltip

* Show builder activity map tooltip and dialog

* Resolved reviews

* Fixed update builder card activity script

* Update circiles to fit on mobile screen

* Fixed heading for mobile

* Prefilled builder card activities
  • Loading branch information
Devorein authored Oct 26, 2024
1 parent a92166c commit dabc2c9
Show file tree
Hide file tree
Showing 19 changed files with 429 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export function BuilderCard({
username={builder.username}
showHotIcon={showHotIcon}
size={size}
hideDetails={hideDetails}
>
{builder.builderStatus === 'banned' ? (
<Typography textAlign='center'>SUSPENDED</Typography>
) : hideDetails ? null : (
<BuilderCardStats {...builder} />
<BuilderCardStats {...builder} size={size} />
)}
</BuilderCardNftDisplay>
{typeof builder.price !== 'undefined' && showPurchaseButton && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
'use client';

import type { Theme } from '@mui/material';
import { Stack, Tooltip, useMediaQuery } from '@mui/material';
import { useState } from 'react';

import { Dialog } from 'components/common/Dialog';

import { BuilderCardActivityTooltip } from './BuilderCardActivityTooltip';

export function BuilderCardActivity({
size,
last7DaysGems
}: {
size: 'x-small' | 'small' | 'medium' | 'large';
last7DaysGems: number[];
}) {
const [isDialogOpen, setIsDialogOpen] = useState(false);
const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'), { noSsr: true });
let gemHeight = size === 'x-small' ? 12 : size === 'small' ? 13.5 : size === 'medium' ? 14.5 : 16;
if (isMobile) {
gemHeight *= 0.75;
}
return (
<>
<Tooltip title={<BuilderCardActivityTooltip />}>
<Stack
flexDirection='row'
gap={{
xs: 0.75,
md: 1.25
}}
width='100%'
height={gemHeight}
px={1}
mt={0.5}
alignItems='center'
onClick={(e) => {
if (isMobile) {
e.preventDefault();
setIsDialogOpen(true);
}
}}
>
{last7DaysGems?.map((gem, index) => {
const height = gem === 0 ? gemHeight * 0.35 : gem <= 29 ? gemHeight * 0.65 : gemHeight;

return (
<Stack
key={`${index.toString()}-${gem}`}
sx={{
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: '100%'
}}
>
<Stack
sx={{
borderRadius: '50%',
width: height,
height,
backgroundColor: 'text.secondary'
}}
/>
</Stack>
);
})}
</Stack>
</Tooltip>
<Dialog
open={isDialogOpen}
onClick={(e) => {
e.preventDefault();
}}
onClose={() => setIsDialogOpen(false)}
title='Builder Activity Map'
>
<BuilderCardActivityTooltip />
</Dialog>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Stack, Typography } from '@mui/material';

import { GemsIcon } from 'components/common/Icons';

export function BuilderCardActivityTooltip() {
return (
<Stack flexDirection='column' gap={0.5} py={1} width='fit-content'>
<Stack flexDirection='row' gap={2} justifyContent='space-between' alignItems='center'>
<Stack width={50} alignItems='center'>
<Stack
sx={{
width: 20,
height: 20,
borderRadius: '50%',
backgroundColor: 'text.secondary'
}}
/>
</Stack>
<Stack flexDirection='row' gap={0.5} flex={1} alignItems='center'>
<Typography>= Scored 30+ </Typography>
<GemsIcon size={16} />
</Stack>
</Stack>
<Stack flexDirection='row' gap={2} justifyContent='space-between' alignItems='center'>
<Stack width={50} alignItems='center'>
<Stack
sx={{
width: 10,
height: 10,
borderRadius: '50%',
backgroundColor: 'text.secondary'
}}
/>
</Stack>
<Stack flexDirection='row' gap={0.5} flex={1} alignItems='center'>
<Typography>= Scored 1 to 29 </Typography>
<GemsIcon size={16} />
</Stack>
</Stack>
<Stack flexDirection='row' gap={2} justifyContent='space-between' alignItems='center'>
<Stack width={50} alignItems='center'>
<Stack
sx={{
width: 5,
height: 5,
borderRadius: '50%',
backgroundColor: 'text.secondary'
}}
/>
</Stack>
<Stack flexDirection='row' gap={0.5} flex={1} alignItems='center'>
<Typography>= No activity </Typography>
</Stack>
</Stack>
<Stack flexDirection='row' gap={2} justifyContent='space-between' alignItems='center'>
<Stack width={50} alignItems='center'>
<Typography color='text.secondary'>Empty</Typography>
</Stack>
<Stack flexDirection='row' gap={0.5} flex={1} alignItems='center'>
<Typography>= No data </Typography>
</Stack>
</Stack>
</Stack>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export function BuilderCardNftDisplay({
children,
username,
showHotIcon = false,
size = 'medium'
size = 'medium',
hideDetails = false
}: {
username: string;
nftImageUrl?: string | null;
showHotIcon?: boolean;
children?: React.ReactNode;
size?: 'x-small' | 'small' | 'medium' | 'large';
hideDetails?: boolean;
}) {
const width = nftDisplaySize[size].width;
const height = nftDisplaySize[size].height;
Expand Down Expand Up @@ -80,25 +82,13 @@ export function BuilderCardNftDisplay({
</Box>
<Box
sx={{
px:
size === 'small'
? 0.5
: {
xs: 0.5,
md: 1
},
height: 'fit-content',
height: hideDetails ? 'fit-content' : '33.33%',
position: 'absolute',
width: 'calc(100% - 10px)',
left: '50%',
backgroundColor: hideDetails ? 'transparent' : '#000',
transform: 'translateX(-50%)',
bottom:
size === 'small'
? 7.5
: {
xs: 7.5,
md: 10
}
bottom: 7.5
}}
>
{nftImageUrl ? null : (
Expand Down
135 changes: 104 additions & 31 deletions apps/scoutgame/components/common/Card/BuilderCard/BuilderCardStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,119 @@ import Image from 'next/image';

import { PointsIcon } from 'components/common/Icons';

import { BuilderCardActivity } from './BuilderCardActivity/BuilderCardActivity';

export function BuilderCardStats({
username,
builderPoints,
nftsSold,
rank
rank,
last7DaysGems,
size
}: {
username: string;
builderPoints?: number;
nftsSold?: number;
rank?: number;
last7DaysGems?: number[];
size: 'x-small' | 'small' | 'medium' | 'large';
}) {
return (
<Stack flexDirection='row' alignItems='center' justifyContent='space-between' gap={1}>
{typeof builderPoints === 'number' && (
<Tooltip title='Total # of Scout Points earned this season to date'>
<Stack flexDirection='row' gap={0.2} alignItems='center'>
<Typography variant='body2' component='span' color='green.main'>
{builderPoints}
</Typography>
<PointsIcon size={15} color='green' />
</Stack>
</Tooltip>
)}
{typeof rank === 'number' && (
<Tooltip title='Current week’s rank'>
<Stack flexDirection='row' gap={0.2} alignItems='center'>
<Typography variant='body2' component='span' color='text.secondary'>
#{rank}
</Typography>
</Stack>
</Tooltip>
)}
{typeof nftsSold === 'number' && (
<Tooltip title='Total # of cards sold this season to date'>
<Stack flexDirection='row' gap={0.2} alignItems='center'>
<Typography variant='body2' component='span' color='orange.main'>
{nftsSold}
</Typography>
<Image width={12} height={12} src='/images/profile/icons/nft-orange-icon.svg' alt='Nfts' />
</Stack>
</Tooltip>
)}
<Stack
alignItems='center'
pt={0.25}
gap={{
xs: 0,
md: size === 'medium' || size === 'large' ? 0.25 : 0.1
}}
width='100%'
height='100%'
>
<Typography
component='span'
sx={{
fontSize: {
xs: '11.5px',
md: '14px'
}
}}
>
@{username}
</Typography>
<Stack flexDirection='row' width='100%' px={1} alignItems='center' justifyContent='space-between' gap={1}>
{typeof builderPoints === 'number' && (
<Tooltip title='Total # of Scout Points earned this season to date'>
<Stack flexDirection='row' gap={0.25} alignItems='center'>
<Typography
sx={{
fontSize: {
xs: '12px',
md: '14px'
}
}}
component='span'
color='green.main'
>
{builderPoints}
</Typography>
<PointsIcon size={16} color='green' />
</Stack>
</Tooltip>
)}
{typeof rank === 'number' && (
<Tooltip title='Current week’s rank'>
<Stack flexDirection='row' gap={0.2} alignItems='center'>
<Typography
sx={{
fontSize: {
xs: '12px',
md: '14px'
}
}}
component='span'
color='text.secondary'
>
#{rank}
</Typography>
</Stack>
</Tooltip>
)}
{typeof nftsSold === 'number' && (
<Tooltip title='Total # of cards sold this season to date'>
<Stack flexDirection='row' gap={0.25} alignItems='center'>
<Typography
sx={{
fontSize: {
xs: '12px',
md: '14px'
}
}}
component='span'
color='orange.main'
>
{nftsSold}
</Typography>
<Image width={14} height={14} src='/images/profile/icons/nft-orange-icon.svg' alt='Nfts' />
</Stack>
</Tooltip>
)}
</Stack>
<Stack flexDirection='row' gap={1} width='100%' px={1} alignItems='center'>
<Stack sx={{ backgroundColor: 'text.secondary', height: '1px', flex: 1 }} />
<Typography
sx={{
color: 'text.secondary',
fontSize: {
xs: '7.5px',
md: '10px'
}
}}
>
7 DAY ACTIVITY
</Typography>
<Stack sx={{ backgroundColor: 'text.secondary', height: '1px', flex: 1 }} />
</Stack>
<BuilderCardActivity size={size} last7DaysGems={last7DaysGems ?? []} />
</Stack>
);
}
Loading

0 comments on commit dabc2c9

Please sign in to comment.