First commit
This commit is contained in:
98
frontend/app/components/GameCard.vue
Normal file
98
frontend/app/components/GameCard.vue
Normal file
@@ -0,0 +1,98 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
oracleId: string
|
||||
name: string
|
||||
tapped?: boolean
|
||||
}>()
|
||||
|
||||
const { public: { apiBase } } = useRuntimeConfig()
|
||||
|
||||
const failed = ref(false)
|
||||
const src = computed(() => `${apiBase}/cards/${encodeURIComponent(props.oracleId)}/image`)
|
||||
const token = computed(() => props.oracleId.startsWith('token:'))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="game-card" :class="{ tapped, token }">
|
||||
<div class="card-face">
|
||||
<img
|
||||
v-if="!failed && !token"
|
||||
:src="src"
|
||||
:alt="name"
|
||||
loading="lazy"
|
||||
draggable="false"
|
||||
@error="failed = true"
|
||||
>
|
||||
<div v-else class="card-fallback">
|
||||
<span class="fallback-name">{{ name }}</span>
|
||||
<span v-if="token" class="fallback-kind">Token</span>
|
||||
</div>
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.game-card {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 488 / 680;
|
||||
}
|
||||
|
||||
.game-card.tapped {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.card-face {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform-origin: center;
|
||||
transition: transform 150ms ease;
|
||||
}
|
||||
|
||||
.game-card.tapped .card-face {
|
||||
transform: rotate(90deg) scale(0.7);
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
background: #0b0d12;
|
||||
box-shadow: 0 3px 10px rgb(0 0 0 / 45%);
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
|
||||
.card-fallback {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.35rem;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0.6rem;
|
||||
border: 1px solid #5b563f;
|
||||
border-radius: 6px;
|
||||
background:
|
||||
radial-gradient(circle at 50% 30%, rgb(232 192 125 / 14%), transparent 70%),
|
||||
#1d211b;
|
||||
box-shadow: 0 3px 10px rgb(0 0 0 / 45%);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fallback-name {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.fallback-kind {
|
||||
font-size: 0.6rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--muted);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user