79 lines
1.7 KiB
Vue
79 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
|
|
export interface Props {
|
|
data?: string
|
|
}
|
|
|
|
const props = defineProps<Props>()
|
|
|
|
const cards = useState<{ [key: string]: any }>('cards')
|
|
|
|
const buttonsElement = ref<HTMLElement | null>(null)
|
|
const rightClicked = ref(false)
|
|
|
|
function cardClick() {
|
|
if (!props.data) return
|
|
console.log(JSON.parse(JSON.stringify(cards.value[props.data].effects)))
|
|
}
|
|
|
|
function contextmenu(e: MouseEvent) {
|
|
if (buttonsElement.value?.childElementCount === 0) { return }
|
|
buttonsElement.value?.setAttribute("style", `top:${e.clientY + 10}px;left:${e.clientX + 10}px`)
|
|
rightClicked.value = true
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div :class="`card ${Number(buttonsElement?.childElementCount) > 0 ? 'active' : ''}`" @contextmenu.prevent="false"
|
|
@click.left="cardClick" @click.right="contextmenu">
|
|
|
|
<img :class="`card_image ${rightClicked ? 'outlined' : ''}`" v-if="props.data"
|
|
:src="'/cards/' + cards[props.data].card_id.toString().padStart(3, '0') + '.jpg'">
|
|
<span v-if="props.data === null">
|
|
HIDDEN
|
|
</span>
|
|
</div>
|
|
|
|
<div :class="rightClicked ? '' : 'hidden'" id="contextMenu" @click.self.prevent="rightClicked = false">
|
|
<div id="contextMenuButtons" ref="buttonsElement">
|
|
<slot></slot>
|
|
</div>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<style scoped>
|
|
.card.active {
|
|
cursor: pointer
|
|
}
|
|
|
|
.card_image.outlined {
|
|
outline: 2px solid red;
|
|
outline-offset: -2px;
|
|
}
|
|
|
|
.card_image {
|
|
max-height: 150px;
|
|
}
|
|
|
|
.hidden {
|
|
display: none;
|
|
}
|
|
|
|
#contextMenu {
|
|
position: fixed;
|
|
height: 100%;
|
|
width: 100%;
|
|
top: 0;
|
|
left: 0;
|
|
/* background: rgba(0, 0, 0, .5); */
|
|
}
|
|
|
|
#contextMenuButtons {
|
|
position: absolute;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
</style>
|