104 lines
3.5 KiB
Vue
104 lines
3.5 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, computed } from "vue";
|
|
import { useRouter } from "vue-router";
|
|
import { useI18n } from "vue-i18n";
|
|
import { useTitle } from "@vueuse/core";
|
|
import { gamesApiListEventGames } from "./api";
|
|
import type { GamesApiListEventGamesResponse } from "./api/types.gen";
|
|
|
|
interface Props {
|
|
eventPath: string;
|
|
}
|
|
|
|
const props = defineProps<Props>();
|
|
|
|
const router = useRouter();
|
|
const { t } = useI18n();
|
|
useTitle(computed(() => t("home.title")));
|
|
|
|
const games = ref<GamesApiListEventGamesResponse | undefined>();
|
|
const loading = ref(true);
|
|
const imageErrors = ref<Set<number>>(new Set());
|
|
|
|
const getHeaderImage = (game: GamesApiListEventGamesResponse[number]) => {
|
|
if (game.image) {
|
|
return game.image;
|
|
}
|
|
if (game.steam_app_id) {
|
|
return `https://cdn.akamai.steamstatic.com/steam/apps/${game.steam_app_id}/header.jpg`;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
const onImageError = (gameId: number) => {
|
|
imageErrors.value.add(gameId);
|
|
};
|
|
|
|
const goToGame = (game: GamesApiListEventGamesResponse[number]) => {
|
|
const path = game.custom_path ? `/${game.path}` : `/submissions/${game.path}`;
|
|
router.push(`/${props.eventPath}${path}`);
|
|
};
|
|
|
|
onMounted(async () => {
|
|
const gamesResponse = await gamesApiListEventGames({
|
|
path: { event_path: props.eventPath },
|
|
});
|
|
if (gamesResponse.data) {
|
|
games.value = gamesResponse.data;
|
|
}
|
|
loading.value = false;
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex-1 bg-base-300 flex items-center justify-center px-4">
|
|
<div class="w-full max-w-6xl">
|
|
<!-- Header -->
|
|
<div class="text-center mb-12">
|
|
<h1 class="text-5xl font-bold mb-4">{{ t("home.title") }}</h1>
|
|
<p class="text-xl text-base-content/70">
|
|
{{ t("home.subtitle") }}
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Loading -->
|
|
<div v-if="loading" class="flex justify-center py-20">
|
|
<span class="loading loading-spinner loading-lg"></span>
|
|
</div>
|
|
|
|
<!-- Cards Grid -->
|
|
<div v-else class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
|
<!-- Game Cards -->
|
|
<div v-for="game in games" :key="game.id"
|
|
@click="goToGame(game)"
|
|
class="card card-xl bg-base-200 shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 hover:scale-[1.05] hover:bg-base-100 overflow-hidden">
|
|
<figure class="relative h-60 bg-base-300 overflow-hidden">
|
|
<img v-if="getHeaderImage(game) && !imageErrors.has(game.id)" :src="getHeaderImage(game)!" :alt="game.name"
|
|
@error="onImageError(game.id)" class="w-full h-full object-cover" />
|
|
<div v-else
|
|
class="w-full h-full bg-gradient-to-br from-blue-600 to-blue-400 flex items-center justify-center text-white">
|
|
<i class="mdi mdi-gamepad-variant text-5xl"></i>
|
|
</div>
|
|
<div class="absolute inset-0 bg-black/30 group-hover:bg-black/20 transition-colors"></div>
|
|
</figure>
|
|
<div class="card-body">
|
|
<h2 class="card-title text-2xl">{{ game.name }}</h2>
|
|
<p v-if="game.description" class="text-base-content/70">{{ game.description }}</p>
|
|
<div class="card-actions justify-end mt-4">
|
|
<button class="btn btn-primary">
|
|
<i class="mdi mdi-arrow-right mr-2"></i>
|
|
{{ t("home.submitResults") }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div class="text-center mt-12 text-base-content/50">
|
|
<p>{{ t("home.footer") }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|