Files
buildpath/frontend/components/ChampionTitle.vue
Valentin Haudiquet 271c2b26d8 Multiple changes
- backend: add summoner spells
- backend: add build variants
- backend: builds are now storing full tree with runes (keystones)
- backend: build trees are split on starter items and merged on runes
- frontend: computing core tree now
- frontend: variant selectors
2026-03-06 23:33:02 +01:00

131 lines
2.8 KiB
Vue

<script setup lang="ts">
const props = defineProps<{
championId: number
winrate: number
pickrate: number
gameCount: number
}>()
const winrate = ref((props.winrate * 100).toFixed(2))
watch(
() => props.winrate,
() => {
winrate.value = (props.winrate * 100).toFixed(2)
}
)
const pickrate = ref((props.pickrate * 100).toFixed(2))
watch(
() => props.pickrate,
() => {
pickrate.value = (props.pickrate * 100).toFixed(2)
}
)
const { data: championData } = useFetch<{ name: string; title: string }>(
CDRAGON_BASE +
'plugins/rcp-be-lol-game-data/global/default/v1/champions/' +
props.championId +
'.json',
{
lazy: true, // Don't block rendering
server: false // Client-side only
}
)
// Handle loading and error states
const championName = computed(() => championData.value?.name || 'Loading...')
const championDescription = computed(() => championData.value?.title || '')
</script>
<template>
<div style="display: flex; width: fit-content">
<div class="champion-title-img-container">
<NuxtImg
width="100"
height="100"
class="champion-title-img"
:src="
CDRAGON_BASE +
'plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/' +
championId +
'.png'
"
/>
</div>
<div id="ct-info-container">
<h1 style="font-size: 1.5rem">{{ championName }}</h1>
<h3 id="ct-desc" style="font-size: 1rem">{{ championDescription }}</h3>
<div id="ct-basic-stat-container">
<h2 style="font-size: 1.2rem" class="ct-basic-stat">{{ winrate }}% win.</h2>
<h2 style="font-size: 1.2rem" class="ct-basic-stat ct-basic-stat-margin">
{{ pickrate }}% pick.
</h2>
<h2 style="font-size: 1.2rem" class="ct-basic-stat">{{ gameCount }} games</h2>
</div>
</div>
</div>
</template>
<style>
.champion-title-img-container {
width: 100px;
height: 100px;
overflow: hidden;
border: 1px solid var(--color-on-surface);
}
.champion-title-img {
width: 100px;
height: 100px;
transform: translate(4px, 4px) scale(1.2, 1.2);
user-select: none;
}
#ct-info-container {
margin-left: 15px;
margin-top: 5px;
}
.ct-basic-stat-margin {
margin-left: 20px;
margin-right: 20px;
}
#ct-desc {
margin-top: 5px;
}
#ct-basic-stat-container {
margin-top: 16px;
display: flex;
}
@media only screen and (max-width: 650px) {
.champion-title-img-container {
width: 86px;
height: 86px;
}
.champion-title-img {
width: 86px;
height: 86px;
}
#ct-desc {
display: none;
}
.ct-basic-stat {
text-align: center;
}
.ct-basic-stat-margin {
margin-left: 2px;
margin-right: 2px;
}
#ct-basic-stat-container {
margin-top: 10px;
}
#ct-info-container {
margin-left: 10px;
margin-top: 0px;
max-width: 220px;
}
}
</style>