self destroying notifications, working on validating login form

This commit is contained in:
Sockenklaus
2021-10-24 21:43:10 +02:00
parent 08b31860b3
commit bc56f65abd
3 changed files with 28 additions and 6 deletions

View File

@@ -1,5 +1,4 @@
<template> <template>
<transition-group name="toasts" tag="div" class="toast-container position-absolute top-0 start-50 mt-3 translate-middle-x"> <transition-group name="toasts" tag="div" class="toast-container position-absolute top-0 start-50 mt-3 translate-middle-x">
<div v-for="(note) in notifications" :key="note[0]" class="show toast border-0 text-white" :class="`bg-${note[1].type}`" role="alert" aria-live="assertive" aria-atomic="true"> <div v-for="(note) in notifications" :key="note[0]" class="show toast border-0 text-white" :class="`bg-${note[1].type}`" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex"> <div class="d-flex">

View File

@@ -15,13 +15,15 @@ export const useNotifications = defineStore('notifications', {
}, },
add(type : string, text: string) : void { add(type : string, text: string) : void {
const id = uuidv4()
this.notifications.set( this.notifications.set(
uuidv4(), id,
{ {
type:type, type:type,
text:text, text:text,
} }
) )
setTimeout(() => this.remove(id), 1500)
} }
} }
}) })

View File

@@ -1,17 +1,38 @@
<template> <template>
<img src="/src/assets/logo.png"> <img src="/src/assets/logo.png">
<form class="m-auto"> <form class="m-auto needs-validation" novalidate>
<h1 class="h3 mb-4">Bitte einloggen</h1> <h1 class="h3 mb-4">Bitte einloggen</h1>
<div class="form-floating"> <div class="form-floating">
<input type="text" class="form-control" id="usernameInput" v-model="input.username" placeholder="Benutzername"> <input
type="text"
class="form-control"
id="usernameInput"
v-model="input.username"
placeholder="Benutzername"
required
>
<label for="usernameInput">Benutzername</label> <label for="usernameInput">Benutzername</label>
</div> </div>
<div class="form-floating mb-4"> <div class="form-floating mb-4">
<input type="password" class="form-control" id="passwordInput" v-model="input.password" placeholder="Passwort"> <input
type="password"
class="form-control"
id="passwordInput"
v-model="input.password"
placeholder="Passwort"
required
>
<label for="passwordInput">Passwort</label> <label for="passwordInput">Passwort</label>
</div> </div>
<button class="btn btn-lg btn-success w-100 mb-5" @click.prevent="onClick">Einloggen</button> <button
type="submit"
class="btn btn-lg btn-success w-100 mb-5"
@click.prevent="onClick"
>
Einloggen
</button>
</form> </form>
</template> </template>