-
-
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): stake saturation indicator in ValidatorTable (#243)
* chore: rename saturationThreshold to amtConsideredSaturated * feat(ui): stake saturation indicator in ValidatorTable
- Loading branch information
Showing
8 changed files
with
285 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Tooltip } from '@/components/Tooltip' | ||
import { SaturationLevel } from '@/constants/saturation' | ||
import { Constraints, Validator } from '@/interfaces/validator' | ||
import { calculateSaturationPercentage, calculateStakeSaturation } from '@/utils/contracts' | ||
import { cn } from '@/utils/ui' | ||
|
||
interface SaturationIndicatorProps { | ||
validator: Validator | ||
constraints: Constraints | ||
} | ||
|
||
export function SaturationIndicator({ validator, constraints }: SaturationIndicatorProps) { | ||
const saturationLevel = calculateStakeSaturation(validator, constraints) | ||
|
||
const getClassName = () => { | ||
switch (saturationLevel) { | ||
case SaturationLevel.Error: | ||
return 'bg-red-500' | ||
case SaturationLevel.Normal: | ||
return 'bg-green-500' | ||
case SaturationLevel.Watch: | ||
return 'bg-yellow-500' | ||
case SaturationLevel.Warning: | ||
return 'bg-orange-500' | ||
case SaturationLevel.Max: | ||
return 'bg-red-500' | ||
} | ||
} | ||
|
||
const saturationPercent = calculateSaturationPercentage(validator, constraints) | ||
|
||
return ( | ||
<div className="inline-flex items-center justify-center"> | ||
<Tooltip content={`${saturationPercent}%`}> | ||
<div className={cn('w-2.5 h-2.5 rounded-full ml-2', getClassName())} /> | ||
</Tooltip> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const SATURATION_ERROR = 0 | ||
export const SATURATION_NORMAL = 1 | ||
export const SATURATION_WATCH = 2 | ||
export const SATURATION_WARNING = 3 | ||
export const SATURATION_MAX = 4 | ||
|
||
export enum SaturationLevel { | ||
Error = SATURATION_ERROR, | ||
Normal = SATURATION_NORMAL, | ||
Watch = SATURATION_WATCH, | ||
Warning = SATURATION_WARNING, | ||
Max = SATURATION_MAX, | ||
} |
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