@@ -5,15 +5,19 @@ interface StakingCapBarProps {
5
5
height ?: number
6
6
fillPercentage : number
7
7
secondFillPercentage : number
8
- labelText ?: string
8
+ firstFillLabel ?: string
9
+ secondFillLabel ?: string
10
+ totalLabel ?: string
9
11
}
10
12
11
13
export default function StakingCapBar ( {
12
14
totalLength = 300 ,
13
15
height = 80 ,
14
16
fillPercentage,
15
17
secondFillPercentage,
16
- labelText
18
+ firstFillLabel,
19
+ secondFillLabel,
20
+ totalLabel
17
21
} : StakingCapBarProps ) {
18
22
// Ensure fillPercentages are between 0 and 100
19
23
const clampedFillPercentage = Math . min ( 100 , Math . max ( 0 , fillPercentage ) )
@@ -23,7 +27,7 @@ export default function StakingCapBar({
23
27
return (
24
28
< div className = "flex flex-col items-start" >
25
29
< div
26
- className = "rounded overflow-hidden"
30
+ className = "rounded overflow-hidden relative "
27
31
style = { {
28
32
width : `${ totalLength } px` ,
29
33
height : `${ height } px` ,
@@ -37,24 +41,46 @@ export default function StakingCapBar({
37
41
>
38
42
< div className = "flex h-full" >
39
43
< div
40
- className = "h-full transition-all duration-300 ease-in-out"
44
+ className = "h-full transition-all duration-300 ease-in-out relative "
41
45
style = { {
42
46
width : `${ clampedFillPercentage } %` ,
43
47
backgroundColor : '#7142CF'
44
48
} }
45
- > </ div >
49
+ >
50
+ { firstFillLabel && (
51
+ < div
52
+ className = "absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-full mt-1 text-xs font-medium text-gray-700 whitespace-nowrap"
53
+ style = { {
54
+ transition : 'left 300ms ease-in-out'
55
+ } }
56
+ >
57
+ { firstFillLabel } : { clampedFillPercentage } %
58
+ </ div >
59
+ ) }
60
+ </ div >
46
61
< div
47
- className = "h-full transition-all duration-300 ease-in-out"
62
+ className = "h-full transition-all duration-300 ease-in-out relative "
48
63
style = { {
49
64
width : `${ clampedSecondFillPercentage } %` ,
50
- backgroundColor : '#E6DAFE '
65
+ backgroundColor : '#7142CF '
51
66
} }
52
- > </ div >
67
+ >
68
+ { secondFillLabel && (
69
+ < div
70
+ className = "absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-full mt-1 text-xs font-medium text-gray-700 whitespace-nowrap"
71
+ style = { {
72
+ transition : 'left 300ms ease-in-out'
73
+ } }
74
+ >
75
+ { secondFillLabel } : { clampedSecondFillPercentage } %
76
+ </ div >
77
+ ) }
78
+ </ div >
53
79
</ div >
54
80
</ div >
55
- { labelText && (
56
- < div className = "mt-2 text-sm font-medium text-gray-700" >
57
- { labelText } : { totalFillPercentage } %
81
+ { totalLabel && (
82
+ < div className = "mt-6 text-sm font-medium text-gray-700" >
83
+ { totalLabel } : { totalFillPercentage } %
58
84
</ div >
59
85
) }
60
86
</ div >
0 commit comments