69 lines
3.2 KiB
Vue
69 lines
3.2 KiB
Vue
<script setup lang="ts">
|
|
import { clamp } from '#shared/general.util';
|
|
import { MAIN_STATS, mainStatTexts, type CharacterConfig } from '~/types/character';
|
|
|
|
const { config, progress = false } = defineProps<{
|
|
config: CharacterConfig,
|
|
progress?: boolean,
|
|
}>();
|
|
|
|
const dragger = useTemplateRef<HTMLElement | null>('dragger');
|
|
const position = ref(0), id = ref<number>(0);
|
|
const dragging = ref(false), offset = ref(0);
|
|
|
|
const dragend = () => {
|
|
window.removeEventListener('mousemove', dragmove);
|
|
window.removeEventListener('mouseup', dragend);
|
|
|
|
dragging.value = false;
|
|
};
|
|
const dragmove = (e: MouseEvent) => {
|
|
const box = dragger.value!.getBoundingClientRect();
|
|
offset.value = clamp(offset.value - e.movementY, 0, 100);
|
|
if(dragger.value) dragger.value.scrollTop = offset.value;
|
|
};
|
|
const dragstart = () => {
|
|
window.addEventListener('mousemove', dragmove);
|
|
window.addEventListener('mouseup', dragend);
|
|
|
|
dragging.value = true;
|
|
};
|
|
onMounted(() => {
|
|
dragger.value?.addEventListener('mousedown', dragstart);
|
|
});
|
|
onUnmounted(() => {
|
|
dragger.value?.removeEventListener('mousedown', dragstart);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex flex-col relative max-w-full">
|
|
<div class="sticky top-8 w-full bg-light-0 dark:bg-dark-0 z-20 flex pt-2 pb-6">
|
|
<div class="flex flex-row gap-3 items-center relative w-48">
|
|
<span v-for="(stat, i) of MAIN_STATS" :value="stat" class="block w-2.5 h-2.5 m-px outline outline-1 outline-transparent
|
|
hover:outline-light-70 dark:hover:outline-dark-70 rounded-full bg-light-40 dark:bg-dark-40 cursor-pointer" @click="position = i"></span>
|
|
<span :style="{ 'left': position * 1.5 + 'em' }" :data-text="mainStatTexts[MAIN_STATS[position]]" class="rounded-full w-3 h-3 bg-accent-blue absolute transition-[left]
|
|
after:content-[attr(data-text)] after:absolute after:-translate-x-1/2 after:top-4 after:p-px after:bg-light-0 dark:after:bg-dark-0 after:text-center"></span>
|
|
</div>
|
|
<div>
|
|
<slot name="addin" :stat="MAIN_STATS[position]"></slot>
|
|
</div>
|
|
</div>
|
|
<div ref="dragger" class="flex flex-1 px-8 overflow-hidden max-w-full">
|
|
<div class="relative cursor-grab active:cursor-grabbing select-none transition-[left] flex flex-1 flex-row max-w-full" >
|
|
<div class="flex flex-shrink-0 flex-col gap-4 relative w-full" v-for="(stat, name) in config.training" ><!-- v-for="(stat, name) in config.training" -->
|
|
<div class="flex flex-row gap-2 justify-center relative" v-for="(options, level) in stat">
|
|
<template v-if="progress">
|
|
<div class="absolute -left-8 -right-8 -top-2 h-px border-t border-light-30 dark:border-dark-30 border-dashed">
|
|
<span class="absolute right-0 p-1 text-end">{{ level }}</span>
|
|
</div>
|
|
</template>
|
|
<template v-for="(option, i) in options">
|
|
<slot :stat="name" :level="level" :index="i" :option="option"></slot>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template> |