-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validators list filter search (#4404)
* add types for Validator * add ValidatorItem component for validator table * fix tokenValue * add validatorLists and filter component * complete ValidatorLists and filter * add mocking data * fix useValidator hook to check the state of validator * add entries method to array for api mocking * add waiting validators to mocking data * remove duplicate accounts from mocking data * mock verification state randomly in hook for test * add filter and search tests * fix storybook test * add social media to validator info * Revert "remove route, sidebar item, tab, dashboard, modal" This reverts commit 480cd09. * fix the case of zero totalstaking * Revert "Revert "remove route, sidebar item, tab, dashboard, modal"" This reverts commit 02594e1. * fix optionVariables type mocking qn * fix type Validator, ValidatorInfo component * mocking validator membership in hook (temp) * fix components according to the review * fix storybook test, add the expectations more * fix interaction-test * Fix the search test * make the process calculating apr more readable * fix storybook interaction test according to the review * remove startedOn * lint fix * fix useValidatorsList when totalStaking is zero --------- Co-authored-by: Theophile Sandoz <[email protected]>
- Loading branch information
1 parent
3691ce7
commit 3d2099e
Showing
13 changed files
with
666 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
137 changes: 137 additions & 0 deletions
137
packages/ui/src/validators/components/ValidatorInfo.tsx
This file contains 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,137 @@ | ||
import { Identicon } from '@polkadot/react-identicon' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { CopyComponent } from '@/common/components/CopyComponent' | ||
import { DiscordIcon, TelegramIcon, TwitterIcon } from '@/common/components/icons/socials' | ||
import { DefaultTooltip, Tooltip } from '@/common/components/Tooltip' | ||
import { BorderRad, Colors, Transitions } from '@/common/constants' | ||
import { shortenAddress } from '@/common/model/formatters' | ||
import { Address } from '@/common/types' | ||
import { MemberIcons } from '@/memberships/components' | ||
import { Avatar } from '@/memberships/components/Avatar' | ||
import { MemberWithDetails } from '@/memberships/types' | ||
|
||
interface ValidatorInfoProps { | ||
address: Address | ||
member?: MemberWithDetails | ||
isOnDark?: boolean | ||
} | ||
|
||
export const ValidatorInfo = React.memo(({ address, member }: ValidatorInfoProps) => { | ||
const twitter = member?.externalResources?.find(({ source }) => source === 'TWITTER') | ||
const telegram = member?.externalResources?.find(({ source }) => source === 'TELEGRAM') | ||
const discord = member?.externalResources?.find(({ source }) => source === 'DISCORD') | ||
|
||
return ( | ||
<ValidatorInfoWrap> | ||
<PhotoWrapper> | ||
<AccountPhoto> | ||
{member ? <Avatar avatarUri={member.avatar} /> : <Identicon size={40} theme={'beachball'} value={address} />} | ||
</AccountPhoto> | ||
</PhotoWrapper> | ||
<ValidatorHandle className="accountName"> | ||
{member?.handle ?? 'Unknown'} | ||
{(twitter || telegram || discord) && ( | ||
<MemberIcons> | ||
{twitter && ( | ||
<Tooltip tooltipText={twitter.value}> | ||
<SocialTooltip> | ||
<TwitterIcon /> | ||
</SocialTooltip> | ||
</Tooltip> | ||
)} | ||
{telegram && ( | ||
<Tooltip tooltipText={telegram.value}> | ||
<SocialTooltip> | ||
<TelegramIcon /> | ||
</SocialTooltip> | ||
</Tooltip> | ||
)} | ||
{discord && ( | ||
<Tooltip tooltipText={discord.value}> | ||
<SocialTooltip> | ||
<DiscordIcon /> | ||
</SocialTooltip> | ||
</Tooltip> | ||
)} | ||
</MemberIcons> | ||
)} | ||
</ValidatorHandle> | ||
<AccountCopyAddress altText={shortenAddress(address)} copyText={address} /> | ||
</ValidatorInfoWrap> | ||
) | ||
}) | ||
|
||
const ValidatorInfoWrap = styled.div` | ||
display: grid; | ||
grid-template-columns: 40px 1fr; | ||
grid-template-rows: min-content 24px 18px; | ||
grid-column-gap: 12px; | ||
grid-template-areas: | ||
'accountphoto accounttype' | ||
'accountphoto accountname' | ||
'accountphoto accountaddress'; | ||
align-items: center; | ||
width: 100%; | ||
justify-self: start; | ||
` | ||
|
||
const AccountPhoto = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
align-content: center; | ||
align-self: center; | ||
height: 40px; | ||
width: 40px; | ||
border-radius: ${BorderRad.full}; | ||
overflow: hidden; | ||
` | ||
|
||
const PhotoWrapper = styled.div` | ||
grid-area: accountphoto; | ||
position: relative; | ||
` | ||
|
||
const ValidatorHandle = styled.h5` | ||
grid-area: accountname; | ||
max-width: 100%; | ||
margin: 0; | ||
padding: 0; | ||
font-size: 16px; | ||
line-height: 24px; | ||
font-weight: 700; | ||
color: ${Colors.Black[900]}; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
text-align: left; | ||
transition: ${Transitions.all}; | ||
display: grid; | ||
grid-auto-flow: column; | ||
grid-column-gap: 4px; | ||
align-items: center; | ||
width: fit-content; | ||
` | ||
|
||
const AccountCopyAddress = styled(CopyComponent)` | ||
grid-area: accountaddress; | ||
` | ||
const SocialTooltip = styled(DefaultTooltip)` | ||
> svg { | ||
width: 8px; | ||
height; 8px; | ||
cursor: pointer; | ||
path { | ||
fill: ${Colors.Black[900]}; | ||
} | ||
} | ||
&:hover { | ||
border-color: ${Colors.Blue[300]} !important; | ||
background: transparent !important; | ||
path { | ||
fill: ${Colors.Blue[500]}; | ||
} | ||
} | ||
` |
Oops, something went wrong.
3d2099e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pioneer-2-storybook – ./
pioneer-2-storybook.vercel.app
pioneer-2-storybook-git-dev-joystream.vercel.app
pioneer-2-storybook-joystream.vercel.app
3d2099e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pioneer-2 – ./
pioneer-2.vercel.app
pioneer-2-joystream.vercel.app
pioneer-2-git-dev-joystream.vercel.app