LeagueStats/client/src/components/Match/MatchItems.vue

124 lines
2.8 KiB
Vue
Raw Normal View History

<template>
2020-11-14 17:28:39 +00:00
<div
:class="oneRow ? 'ml-2 items-center' : 'items-2-rows flex-wrap'"
class="flex"
>
<Tooltip v-for="(item, index) in items" :key="index">
<template v-slot:trigger>
<div
2020-11-14 17:28:39 +00:00
:style="{ backgroundImage: itemLink(item) }"
:class="[
oneRow ? 'ml-2px w-6 h-6' : 'ml-1 w-8 h-8',
{ 'cursor-pointer': item !== null },
]"
class="bg-center bg-cover rounded-md bg-blue-1000"
></div>
</template>
<template v-if="item !== null" v-slot:default>
<div class="flex max-w-md p-2 text-xs text-left text-white select-none">
<div
2020-11-14 17:28:39 +00:00
:style="{ backgroundImage: itemLink(item) }"
class="flex-shrink-0 w-12 h-12 ml-1 bg-center bg-cover rounded-md bg-blue-1000"
></div>
<div class="ml-2 leading-none">
<div class="text-base">{{ itemName(item.name) }}</div>
<div class="mt-1">
<span class="text-blue-200">Price:</span>
2020-11-14 17:28:39 +00:00
<span class="ml-1 text-sm font-semibold text-yellow-500">{{
item.price
}}</span>
</div>
2020-11-14 17:28:39 +00:00
<div
v-html="item.description"
class="mt-1 font-light text-blue-200 item-description"
></div>
</div>
</div>
</template>
</Tooltip>
</div>
</template>
<script>
import Tooltip from '@/components/Common/Tooltip.vue'
export default {
components: {
Tooltip
},
props: {
oneRow: {
type: Boolean,
default: false
},
items: {
type: Array,
required: true
}
2020-11-14 17:28:39 +00:00
},
methods: {
itemLink(item) {
if (!item) {
return null
}
// Fix to still make work the old items links (before season 11)
const originalUrl = item.image
const newUrl = originalUrl.includes('/global/default/assets/items/') ? originalUrl : originalUrl.replace('latest', '10.22')
return `url('${newUrl}')`
},
itemName(name) {
// Remove placeholders in item names (e.g.: for Ornn items)
return name.replace(/%[^%]*%/, '')
2020-11-14 17:28:39 +00:00
}
}
}
</script>
<style scoped>
.items-2-rows {
width: 7rem;
height: 4.5rem;
}
.item-description >>> stats {
@apply text-white leading-tight;
}
.item-description >>> br + br {
@apply hidden;
}
.item-description >>> stats br {
@apply block;
}
.item-description >>> li {
@apply block mt-2;
}
.item-description >>> passive {
@apply text-white font-normal;
}
.item-description >>> active {
@apply inline-block text-white font-bold mt-2;
}
.item-description >>> unique,
.item-description >>> li > passive:first-child,
.item-description >>> rarityMythic {
@apply text-white font-bold block mt-2;
}
.item-description >>> font {
@apply text-blue-400;
}
.item-description >>> rules {
@apply block mt-2 text-blue-400 italic;
}
</style>