2022-01-07 19:46:33 -08:00
< template >
< button
2022-01-10 02:15:49 -08:00
class = "relative flex flex-col pt-2 pb-3 px-3 border rounded-lg overflow-hidden border-current"
2022-01-07 19:46:33 -08:00
: class = "[colorClasses, clickable ? 'cursor-pointer' : 'cursor-default']"
: disable = "!clickable"
2022-01-10 02:15:49 -08:00
@ click = "$emit('click')"
2022-01-07 19:46:33 -08:00
>
< progress
v - if = "!clickable"
class = "absolute top-0 left-0 right-0 h-1 w-full"
: max = "max"
2022-01-10 02:15:49 -08:00
: value = "cappedValue"
2022-01-07 19:46:33 -08:00
/ >
< span class = "absolute top-3 right-3 font-semibold text-sm" >
2022-01-10 02:15:49 -08:00
{ { cappedValue } } / { { max } }
2022-01-07 19:46:33 -08:00
< span class = "fas fa-hourglass-half" / >
< / span >
< span
2022-01-10 02:15:49 -08:00
class = "w-full text-left lg:text-center text-lg lg:text-xl font-semibold"
2022-01-07 19:46:33 -08:00
v - text = "label"
/ >
< p class = "w-full text-left" v-text = "description" / >
2022-01-10 02:15:49 -08:00
< div v-if = "current && next" class="text-sm m-auto" >
< span > Current : { { current } } < / span >
< span class = "fas fa-arrow-right mx-2" / >
< span > Next : { { next } } < / span >
< / div >
2022-01-07 19:46:33 -08:00
< / button >
< / template >
< script >
2022-01-09 23:12:41 -08:00
import Decimal from 'break_infinity.js'
2022-01-07 19:46:33 -08:00
export default {
props : {
label : { type : String , required : true } ,
description : { type : String , default : null } ,
max : { type : Number , required : true } ,
2022-01-09 23:12:41 -08:00
value : { type : [ Number , Decimal ] , required : true } ,
2022-01-07 19:46:33 -08:00
unit : { type : String , default : null } ,
2022-01-10 02:15:49 -08:00
current : { type : String , default : null } ,
next : { type : String , default : null } ,
2022-01-07 19:46:33 -08:00
} ,
computed : {
2022-01-10 02:15:49 -08:00
cappedValue ( ) {
return this . value > this . max ? this . max : this . value
} ,
2022-01-07 19:46:33 -08:00
clickable ( ) {
return this . value >= this . max
} ,
colorClasses ( ) {
const { lightColor , darkColor } = this . $store . getters . activeTab
return this . clickable
? ` bg- ${ darkColor } text- ${ lightColor } `
: ` bg- ${ lightColor } text- ${ darkColor } `
} ,
} ,
}
< / script >
< style scoped >
/* progress background for all browsers */
progress : : - webkit - progress - bar {
background - color : rgba ( 0 , 0 , 0 , 0.1 ) ;
width : 100 % ;
}
progress {
background - color : rgba ( 0 , 0 , 0 , 0.1 ) ;
}
/* progress value for all browsers */
progress : : - webkit - progress - value {
background - color : currentColor ;
}
progress : : - moz - progress - bar {
background - color : currentColor ;
}
progress {
color : currentColor ;
}
< / style >