-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): rewards column in ValidatorTable is sortable (#249)
* feat(ui): rewards column in ValidatorTable is sortable * fix(ui): remove unused argument from sortRewardsFn * feat(ui): update TrafficLight indicator UI * feat(ui): warning level for validator health * feat(ui): calculate avg APY only using pools with non-zero balance Closes TXN-1742 * test(ui): add unit tests for calculateValidatorPoolMetrics Also moves the function to `src/utils/contracts.ts` and the PoolData type to `src/interfaces/validator.ts`
- Loading branch information
Showing
13 changed files
with
460 additions
and
99 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 was deleted.
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,58 @@ | ||
import { Tooltip } from '@/components/Tooltip' | ||
import { Indicator } from '@/constants/indicator' | ||
import { cn } from '@/utils/ui' | ||
|
||
interface TrafficLightProps { | ||
indicator: Indicator | ||
tooltipContent?: string | Partial<Record<Indicator, string>> | ||
className?: string | ||
showGreen?: boolean | ||
} | ||
|
||
export function TrafficLight({ | ||
indicator, | ||
tooltipContent = '', | ||
className = '', | ||
showGreen = false, | ||
}: TrafficLightProps) { | ||
const getClassName = () => { | ||
switch (indicator) { | ||
case Indicator.Error: | ||
return 'bg-red-500' | ||
case Indicator.Normal: | ||
return 'bg-green-500' | ||
case Indicator.Watch: | ||
return 'bg-yellow-500' | ||
case Indicator.Warning: | ||
return 'bg-orange-500' | ||
case Indicator.Max: | ||
return 'bg-red-500' | ||
} | ||
} | ||
|
||
const getTooltipContent = () => { | ||
if (typeof tooltipContent === 'string') { | ||
return tooltipContent | ||
} | ||
|
||
return tooltipContent[indicator] | ||
} | ||
|
||
const renderIndicator = () => { | ||
return <div className={cn('w-2.5 h-2.5 rounded-full', getClassName(), className)} /> | ||
} | ||
|
||
if (indicator === Indicator.Normal && !showGreen) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className="inline-flex items-center justify-center"> | ||
{tooltipContent ? ( | ||
<Tooltip content={getTooltipContent()}>{renderIndicator()}</Tooltip> | ||
) : ( | ||
renderIndicator() | ||
)} | ||
</div> | ||
) | ||
} |
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.