2022-01-08 03:46:33 +00:00
|
|
|
<template>
|
|
|
|
<button
|
2022-01-10 10:15:49 +00:00
|
|
|
class="relative flex flex-col pt-2 pb-3 px-3 border rounded-lg overflow-hidden border-current"
|
2022-01-08 03:46:33 +00:00
|
|
|
:class="[colorClasses, clickable ? 'cursor-pointer' : 'cursor-default']"
|
|
|
|
:disable="!clickable"
|
2022-01-11 05:46:55 +00:00
|
|
|
@click="clickable && $emit('click')"
|
2022-01-08 03:46:33 +00:00
|
|
|
>
|
|
|
|
<progress
|
|
|
|
v-if="!clickable"
|
|
|
|
class="absolute top-0 left-0 right-0 h-1 w-full"
|
|
|
|
:max="max"
|
2022-01-10 10:15:49 +00:00
|
|
|
:value="cappedValue"
|
2022-01-08 03:46:33 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<span class="absolute top-3 right-3 font-semibold text-sm">
|
2022-01-11 05:46:55 +00:00
|
|
|
<span v-if="unit === 'apprenticeLevels'">L</span>{{ cappedValueText }}
|
|
|
|
/
|
|
|
|
<span v-if="unit === 'apprenticeLevels'">L</span>{{ maxText }}
|
2022-01-11 02:09:32 +00:00
|
|
|
<span v-if="unit === 'spareTime'" class="fas fa-hourglass-half" />
|
2022-01-12 06:23:41 +00:00
|
|
|
<span v-if="unit === 'energy'" class="fas fa-bolt" />
|
2022-01-08 03:46:33 +00:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<span
|
2022-01-10 10:15:49 +00:00
|
|
|
class="w-full text-left lg:text-center text-lg lg:text-xl font-semibold"
|
2022-01-08 03:46:33 +00:00
|
|
|
v-text="label"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<p class="w-full text-left" v-text="description" />
|
2022-01-10 10:15:49 +00: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-08 03:46:33 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-01-10 07:12:41 +00:00
|
|
|
import Decimal from 'break_infinity.js'
|
|
|
|
|
2022-01-08 03:46:33 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
label: { type: String, required: true },
|
|
|
|
description: { type: String, default: null },
|
|
|
|
max: { type: Number, required: true },
|
2022-01-10 07:12:41 +00:00
|
|
|
value: { type: [Number, Decimal], required: true },
|
2022-01-11 02:09:32 +00:00
|
|
|
unit: { type: String, default: 'spareTime' },
|
2022-01-10 10:15:49 +00:00
|
|
|
current: { type: String, default: null },
|
|
|
|
next: { type: String, default: null },
|
2022-01-08 03:46:33 +00:00
|
|
|
},
|
|
|
|
computed: {
|
2022-01-10 10:15:49 +00:00
|
|
|
cappedValue() {
|
|
|
|
return this.value > this.max ? this.max : this.value
|
|
|
|
},
|
2022-01-11 02:09:32 +00:00
|
|
|
cappedValueText() {
|
2022-01-11 05:46:55 +00:00
|
|
|
return this.unit === 'maxAge'
|
|
|
|
? this.$store.getters.ageText
|
|
|
|
: this.cappedValue
|
2022-01-11 02:09:32 +00:00
|
|
|
},
|
|
|
|
maxText() {
|
2022-01-11 05:46:55 +00:00
|
|
|
return this.unit === 'maxAge' ? this.$store.getters.ageMaxText : this.max
|
2022-01-11 02:09:32 +00:00
|
|
|
},
|
2022-01-08 03:46:33 +00: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>
|