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-13 05:37:30 +00:00
|
|
|
:class="[
|
|
|
|
colorClasses,
|
|
|
|
{
|
|
|
|
disabled,
|
|
|
|
[`text-${$store.getters.activeTab.darkColor}`]: disabled,
|
|
|
|
'cursor-pointer': clickable,
|
|
|
|
'cursor-default': !clickable,
|
|
|
|
},
|
|
|
|
]"
|
2022-01-08 03:46:33 +00:00
|
|
|
: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"
|
2022-01-13 05:37:30 +00:00
|
|
|
:class="{ hidden: disabled }"
|
2022-01-08 03:46:33 +00:00
|
|
|
:max="max"
|
2022-01-10 10:15:49 +00:00
|
|
|
:value="cappedValue"
|
2022-01-08 03:46:33 +00:00
|
|
|
/>
|
|
|
|
|
2022-01-13 05:37:30 +00:00
|
|
|
<span
|
|
|
|
class="absolute top-3 right-3 font-semibold text-sm"
|
|
|
|
:class="{ hidden: disabled }"
|
|
|
|
>
|
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-15 18:03:14 +00:00
|
|
|
<span v-if="unit === 'mana'" class="fas fa-star" />
|
2022-01-08 03:46:33 +00:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<span
|
2022-01-15 07:24:33 +00:00
|
|
|
class="w-full text-left 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-13 05:37:30 +00:00
|
|
|
current: { type: [Number, String], default: null },
|
|
|
|
next: { type: [Number, String], default: null },
|
|
|
|
disabled: { type: Boolean, default: false },
|
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
|
2022-01-14 01:28:19 +00:00
|
|
|
: this.$store.getters.suffixedDecimalText(this.cappedValue)
|
2022-01-11 02:09:32 +00:00
|
|
|
},
|
|
|
|
maxText() {
|
2022-01-14 01:28:19 +00:00
|
|
|
return this.unit === 'maxAge'
|
|
|
|
? this.$store.getters.ageMaxText
|
|
|
|
: this.$store.getters.suffixedDecimalText(this.max)
|
2022-01-11 02:09:32 +00:00
|
|
|
},
|
2022-01-08 03:46:33 +00:00
|
|
|
clickable() {
|
2022-01-13 05:37:30 +00:00
|
|
|
return !this.disabled && this.value >= this.max
|
2022-01-08 03:46:33 +00:00
|
|
|
},
|
|
|
|
colorClasses() {
|
|
|
|
const { lightColor, darkColor } = this.$store.getters.activeTab
|
|
|
|
|
|
|
|
return this.clickable
|
|
|
|
? `bg-${darkColor} text-${lightColor}`
|
|
|
|
: `bg-${lightColor} text-${darkColor}`
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2022-01-13 05:37:30 +00:00
|
|
|
.disabled {
|
|
|
|
background-color: rgba(0, 0, 0, 0.1);
|
|
|
|
}
|
|
|
|
.clickable {
|
|
|
|
box-shadow: 0px 4px 8px -3px var(--dark-color);
|
|
|
|
}
|
2022-01-08 03:46:33 +00:00
|
|
|
/* 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>
|