-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
am I gonna regret not making this a new PR
- Loading branch information
1 parent
68297ba
commit 56a94a3
Showing
18 changed files
with
1,123 additions
and
760 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,94 @@ | ||
import { Validator } from '@dydxprotocol/v4-client-js/build/node_modules/@dydxprotocol/v4-proto/src/codegen/cosmos/staking/v1beta1/staking'; | ||
import styled from 'styled-components'; | ||
|
||
import { ValidatorFaviconIcon } from './ValidatorFaviconIcon'; | ||
import { WithTooltip } from './WithTooltip'; | ||
|
||
type ElementProps = { | ||
numToShow?: number; | ||
validators: Validator[]; | ||
}; | ||
|
||
type StyleProps = { | ||
className?: string; | ||
}; | ||
|
||
export const ValidatorIcons = ({ | ||
numToShow = 3, | ||
validators, | ||
className, | ||
}: ElementProps & StyleProps) => { | ||
const validatorNames = validators.map((validator) => validator.description?.moniker).join(', '); | ||
return ( | ||
<$ValidatorIcons className={className}> | ||
{validators?.length <= numToShow | ||
? validators.map((validator) => ( | ||
<$ValidatorIcon | ||
key={validator.description?.moniker} | ||
url={validator.description?.website} | ||
fallbackText={validator.description?.moniker} | ||
/> | ||
)) | ||
: validators | ||
.slice(0, numToShow - 1) | ||
.map((validator) => ( | ||
<$ValidatorIcon | ||
key={validator.description?.moniker} | ||
url={validator.description?.website} | ||
fallbackText={validator.description?.moniker} | ||
/> | ||
)) | ||
.concat( | ||
<WithTooltip tooltipString={validatorNames}> | ||
<$OverflowIcon key="overflow"> | ||
{`+${validators.length - (numToShow - 1)}`} | ||
</$OverflowIcon> | ||
</WithTooltip> | ||
)} | ||
</$ValidatorIcons> | ||
); | ||
}; | ||
|
||
const $ValidatorIcons = styled.div` | ||
--border-color: var(--color-border); | ||
--icon-size: 2.25rem; | ||
display: flex; | ||
> * { | ||
&:nth-child(1) { | ||
z-index: 2; | ||
} | ||
&:nth-child(2) { | ||
z-index: 1; | ||
} | ||
&:not(:first-child) { | ||
margin-left: -0.66em; | ||
} | ||
} | ||
`; | ||
|
||
const $ValidatorIcon = styled(ValidatorFaviconIcon)` | ||
height: var(--icon-size); | ||
width: var(--icon-size); | ||
margin: 0; | ||
border: 2px solid var(--border-color); | ||
`; | ||
|
||
const $OverflowIcon = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 50%; | ||
margin: 0; | ||
border: 2px solid var(--border-color); | ||
height: var(--icon-size); | ||
width: var(--icon-size); | ||
background-color: var(--color-layer-6); | ||
color: var(--color-text-1); | ||
`; |
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
Oops, something went wrong.