feat/FRO-15 Added Join Game Component #6
79
src/components/MainMenuBoxes.vue
Normal file
79
src/components/MainMenuBoxes.vue
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const menuItems = [
|
||||||
|
{
|
||||||
|
title: 'Create game',
|
||||||
|
description: 'Create a new game and invite your friends to play with you.',
|
||||||
|
icon: 'add_circle_outline',
|
||||||
|
routeName: 'create-Game',
|
||||||
|
color: 'green-9'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Spiel beitreten',
|
||||||
|
description: 'Join a game by typing in the game identifier.',
|
||||||
|
icon: 'login',
|
||||||
|
routeName: 'join-Game',
|
||||||
|
color: 'blue-9'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Settings',
|
||||||
|
description: 'This area is currently under construction.',
|
||||||
|
icon: 'settings',
|
||||||
|
routeName: 'settings',
|
||||||
|
color: 'grey-8'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const navigateTo = (routeName: string) => {
|
||||||
|
router.push({ name: routeName });
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="row q-col-gutter-md justify-center" style="width: 100%; max-width: 1000px;">
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in menuItems"
|
||||||
|
:key="index"
|
||||||
|
class="col-12 col-sm-6 col-md-4"
|
||||||
|
>
|
||||||
|
<q-card
|
||||||
|
class="menu-card bg-dark text-white q-pa-sm cursor-pointer"
|
||||||
|
v-ripple
|
||||||
|
@click="navigateTo(item.routeName)"
|
||||||
|
>
|
||||||
|
<q-card-section class="row items-center no-wrap">
|
||||||
|
<q-avatar
|
||||||
|
:icon="item.icon"
|
||||||
|
:color="item.color"
|
||||||
|
text-color="white"
|
||||||
|
size="lg"
|
||||||
|
class="q-mr-md shadow-2"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<div class="text-h6">{{ item.title }}</div>
|
||||||
|
<div class="text-caption text-grey-5">
|
||||||
|
{{ item.description }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.menu-card {
|
||||||
|
transition: transform 0.2s, background-color 0.2s;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hover-Effekt für die Karten */
|
||||||
|
.menu-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
background-color: #2c3e50 !important;
|
||||||
|
border-color: var(--q-primary);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,6 +3,7 @@ import HomeView from '../views/HomeView.vue'
|
|||||||
import LoginView from '../views/LoginView.vue'
|
import LoginView from '../views/LoginView.vue'
|
||||||
import MainMenuView from '../views/MainMenuView.vue'
|
import MainMenuView from '../views/MainMenuView.vue'
|
||||||
import createGameView from '../views/CreateGame.vue'
|
import createGameView from '../views/CreateGame.vue'
|
||||||
|
import joinGameView from "@/views/JoinGameView.vue";
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
@@ -35,6 +36,12 @@ const router = createRouter({
|
|||||||
name: 'create-Game',
|
name: 'create-Game',
|
||||||
component: createGameView
|
component: createGameView
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/join',
|
||||||
|
name: 'join-Game',
|
||||||
|
component: joinGameView
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
93
src/views/JoinGameView.vue
Normal file
93
src/views/JoinGameView.vue
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {ref} from "vue";
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import {useQuasar} from "quasar";
|
||||||
|
const router = useRouter();
|
||||||
|
const lobbyCode = ref('');
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const $q = useQuasar();
|
||||||
|
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
const startGameQuasar = async() => {
|
||||||
|
if (!lobbyCode.value) {
|
||||||
|
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isLoading.value = true;
|
||||||
|
//TODO: Implement Logic to Start the Game and Redirect to Ingame
|
||||||
|
await delay(3000)
|
||||||
|
isLoading.value = false;
|
||||||
|
$q.notify({
|
||||||
|
message: `Lobby "${lobbyCode.value}" erfolgreich gefunden`,
|
||||||
|
color: 'green-6',
|
||||||
|
icon: 'check_circle',
|
||||||
|
position: 'top'
|
||||||
|
});
|
||||||
|
router.push({ name: 'mainmenu'});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-layout>
|
||||||
|
<q-page-container>
|
||||||
|
<q-page class="flex justify-start items-center column ">
|
||||||
|
<header class="text-center q-mb-xl">
|
||||||
|
<h1 class="game-title text-white q-my-none">
|
||||||
|
KnockOutWhist
|
||||||
|
</h1>
|
||||||
|
<p
|
||||||
|
class="text-h5 text-grey-4 q-mt-md"
|
||||||
|
style="max-width: 900px; margin-left: auto; margin-right: auto;"
|
||||||
|
>
|
||||||
|
Enter the Lobbycode below to join your friend's game and you are ready to go!
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="q-pa-md" style="width: 100%; max-width: 400px;">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<q-input
|
||||||
|
v-model="lobbyCode"
|
||||||
|
label="Lobbycode"
|
||||||
|
placeholder="123abc"
|
||||||
|
filled
|
||||||
|
dark
|
||||||
|
label-color="white"
|
||||||
|
color="white"
|
||||||
|
:rules="[val => !!val || 'Lobbycode is missing']"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center q-mt-lg">
|
||||||
|
<q-btn
|
||||||
|
:loading="isLoading"
|
||||||
|
label="Join Game"
|
||||||
|
color="positive"
|
||||||
|
rounded
|
||||||
|
@click="startGameQuasar"
|
||||||
|
size="lg"
|
||||||
|
class="full-width"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</q-page>
|
||||||
|
</q-page-container>
|
||||||
|
</q-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.game-title {
|
||||||
|
font-family: serif;
|
||||||
|
|
||||||
|
|
||||||
|
font-size: 5rem;
|
||||||
|
font-weight: 900;
|
||||||
|
letter-spacing: 3px;
|
||||||
|
color: #FFD700;
|
||||||
|
|
||||||
|
text-shadow:
|
||||||
|
2px 2px 0px #000000,
|
||||||
|
4px 4px 0px #8B4513,
|
||||||
|
6px 6px 12px rgba(0, 0, 0, 0.9);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
50
src/views/MainMenuView.vue
Normal file
50
src/views/MainMenuView.vue
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import MainMenuBoxes from "@/components/MainMenuBoxes.vue";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-layout view="hHh lpR fFf" class="font-roboto">
|
||||||
|
<q-page-container>
|
||||||
|
<q-page class="flex justify-start items-center column">
|
||||||
|
|
||||||
|
<header class="text-center q-mb-xl">
|
||||||
|
<h1 class="game-title text-white q-my-none">
|
||||||
|
KnockOutWhist
|
||||||
|
</h1>
|
||||||
|
<p
|
||||||
|
class="text-h5 text-grey-4 q-mt-md"
|
||||||
|
style="max-width: 900px; margin-left: auto; margin-right: auto;"
|
||||||
|
>
|
||||||
|
Welcome to KnockOutWhist! In this game you have to "knock-out" your opponents until you are the last player standing.
|
||||||
|
Do you have what it takes to be crowned the champion?
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<MainMenuBoxes />
|
||||||
|
|
||||||
|
</q-page>
|
||||||
|
</q-page-container>
|
||||||
|
</q-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.game-title {
|
||||||
|
font-family: serif;
|
||||||
|
|
||||||
|
|
||||||
|
font-size: 5rem;
|
||||||
|
font-weight: 900;
|
||||||
|
letter-spacing: 3px;
|
||||||
|
color: #FFD700;
|
||||||
|
|
||||||
|
text-shadow:
|
||||||
|
2px 2px 0px #000000,
|
||||||
|
4px 4px 0px #8B4513,
|
||||||
|
6px 6px 12px rgba(0, 0, 0, 0.9);
|
||||||
|
}
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.game-title {
|
||||||
|
font-size: 3rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user