рефактор логина. анимация onmount. рефактор ошибок логина и пароль. ошибки в placeholder

This commit is contained in:
UNIKNOW 2024-04-05 21:25:48 +04:00
parent 2cb5598b85
commit 5327139049
3 changed files with 237 additions and 160 deletions

View file

@ -135,7 +135,7 @@ export async function VerificationEmail(Code){
}
else if(response.status === 401)
{
return "Неправильный логин или парль"
return "Неправильный логин или пароль"
}
else{
console.log(response.status)

View file

@ -1,128 +1,210 @@
<script>
import { dictionary } from './../../../.svelte-kit/generated/client/app.js';
import Header from '../Header.svelte';
import {handleLogin} from '$lib/userFunction'
import { handleLogin } from '$lib/userFunction';
import { onMount } from 'svelte';
import { fly } from 'svelte/transition';
import { fly, blur } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
import { backInOut } from 'svelte/easing';
let username = ""; let usernameError = "";
let password = ""; let passwordError = "";
async function listener(event){
if(enterError.length !== 0){
enterError = ""
}
}
let username = '';
let password = '';
let enterError = '';
let passwordError = "длжо";
async function login() {
switch (true) {
case username.length === 0 && password.length !== 0:
document.getElementById('username').placeholder = 'ничего не забыл?';
document.getElementById('password').placeholder = '';
console.log(usernameError.length,passwordError.length)
console.log(usernameError,passwordError)
if((username.length == 0) && (password.length != 0)){
usernameError = ""
usernameError = "ничего не забыл?"
passwordError = ""
console.log("ЖОПА1")
}
console.log('ЖОПА1');
break;
else if((username.length != 0)&& (password.length == 0)){
usernameError = ""
passwordError = ""
passwordError = "ничего не забыл?"
console.log("ЖОПА2")
}
case username.length !== 0 && password.length === 0:
document.getElementById('username').placeholder = '';
document.getElementById('password').placeholder = 'ничего не забыл?';
console.log('ЖОПА2');
break;
else if((username == "") && (password == "")){
usernameError = "ничего не забыл?"
passwordError = "ничего не забыл?"
console.log("ЖОПА3")
}
else if((username != "") && (password != ""))
{
usernameError = await handleLogin(username,password)
case username.length === 0 && password.length === 0:
document.getElementById('password').placeholder = 'ничего не забыл?';
document.getElementById('username').placeholder = 'ничего не забыл?';
console.log('ЖОПА3');
break;
default:
document.getElementById('password').placeholder = '';
document.getElementById('username').placeholder = '';
enterError = await handleLogin(username, password);
break;
}
}
let greeting
//список приветствований. TODO: пополнить пул
let greetings = ["опять ты? ну давай, заходи",];
let hi = ' ';
let greeting = ' ';
let greetings = [
'Опять ты? Ну давай, заходи',
'Рад видеть тебя снова',
'Как прошел день?',
'Как настроение?',
'Come in'
];
greeting = greetings[Math.floor(Math.random() * greetings.length)];
let His = ['Привет!', 'Дарова!', 'Хай!', 'Приветствую!'];
hi = His[Math.floor(Math.random() * (His.length - 0))];
let loadingPage = false;
onMount(() => {
greeting = greetings[Math.floor(Math.random() * greetings.length)]
})
loadingPage = !loadingPage;
});
</script>
{#if loadingPage === true}
<body>
<div class="loginField">
<div class="loginMainDiv">
<div class="loginDiv">
<div class="loginDiv" transition:fly={{ y: -1920, duration: 1000, backInOut }}>
<div class="jopa1">
<div class="marginDiv">
<h1>Дарова</h1>
<h2>{greeting}</h2>
<div>
<div class="greetingsDiv">
<h1 id="hi" transition:blur={{
y: -30, duration: 1900, easing: cubicOut }}>{hi}</h1>
<h2 id="greetings" transition:blur={{
y: -30, duration: 2000, easing: cubicOut }}>
{greeting}</h2>
</div>
<div class="bigGroup">
<div class="group">
<h3>никнейм или почта</h3>
{#if usernameError && usernameError !== ''}
<h3 id="usernameError" transition:fly={{ y: -30, duration: 300, easing: cubicOut }}
>{usernameError}</h3>
{/if}
<input placeholder=" " type="text" id="username" on:input={listener} bind:value={username} />
</div>
<input type="text" id="username" bind:value={username} />
<div class="group">
<h3>пароль</h3>
{#if usernameError && usernameError !== ''}
<h3 id="passwordError" transition:fly={{ y: -30, duration: 300, easing: cubicOut }}
>{passwordError}</h3>
<input placeholder=" " type="password" id="password" on:input={listener} bind:value={password} />
</div>
</div>
<div class="enterDiv">
<button class="enterButt" on:click={login}>Войти</button>
{#if enterError !== ''}
<h3 class="enterError"
transition:fly={{ y: 200, duration: 300, backInOut }}>{enterError}</h3>
{/if}
</div>
<input type="password" id="password" bind:value={password} />
</div>
<button on:click={login}>Войти</button>
</div>
</div>
</div>
<div class="regDiv">
<div class="regDiv" transition:fly={{ y: -1920, duration: 800, backInOut }}>
<div class="jopa1">
<div class="regregDiv">
<h2>Нет аккаунта? Лох!</h2>
<button on:click={() => window.location.href = '/register'}>Перестать был лохом</button>
<h2 class="reg1">Нет аккаунта? Лох!</h2>
<button class="reg2" on:click={() => (window.location.href = '/register')}
>Перестать был лохом</button>
</div>
</div>
</div>
</div>
</div>
<div class="previewField">
<h3>не жопа</h3>
</div>
</body>
{/if}
<style lang="scss">
// .passwordError{
// z-index: 1;
// position: absolute;
// color: var(--disable);
// border: 1px solid white;
// bottom: 29.5%;
// }
// не рабоая хуйня. переделать как нибудь <h3 class="passwordError">{passwordError}</h3>
.greetingsDiv{
height: 30%;
display: flex;
flex-direction: column;
gap: 35px;
justify-content: center;
}
.enterDiv{
display: flex;
flex-direction: column;
height: 20%;
}
.enterButt{
height: 60%;
display: flex;
justify-content: center;
align-items: center;
}
.enterError{
margin-bottom: 1%;
display: flex;
justify-content: center;
align-items: center;
}
.reg1,
.reg2{
height: 40%;
display: flex;
justify-content: center;
align-items: center;
}
input::placeholder {
color: var(--disable);
transition: opacity 1s ease;
opacity: 1;
}
#greetings,
#hi {
transition: opacity 1s ease;
}
.group > * {
margin-top: 1%;
margin-bottom: 1%;
}
.group {
display: flex;
flex-direction: row;
justify-content: space-between;
flex-direction: column;
}
.bigGroup{
height: 40%;
}
.regregDiv {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-around;
justify-content: center;
align-items: center;
}
.loginMainDiv {
@ -132,17 +214,14 @@ onMount(() => {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.regDiv {
width: 100%;
height: 32%;
}
.loginDiv {
width: 100%;
height: 66%;
}
.loginDiv,
@ -171,20 +250,25 @@ onMount(() => {
align-items: center;
}
#usernameError,
#passwordError {
.enterError {
color: var(--disable);
font-weight: 700;
}
.marginDiv {
position: relative;
display: flex;
flex-direction: column;
justify-content: space-around;
justify-content: space-between;
width: 90%;
height: 100%;
padding-left: 5%;
padding-right: 5%;
}
.marginDiv > * {
//border: 1px solid white;
}
.jopa1 {
@ -198,7 +282,7 @@ onMount(() => {
}
.jopa1::after {
content: "";
content: '';
background-image: url(../noise.gif);
opacity: 0.011;
position: absolute;
@ -208,7 +292,6 @@ onMount(() => {
height: 100%;
pointer-events: none;
border-radius: 15px;
}
input {
@ -255,7 +338,6 @@ onMount(() => {
h2,
h3,
input,
select,
button {
color: var(--fontColor);
}
@ -282,6 +364,7 @@ onMount(() => {
}
body {
overflow: hidden;
display: flex;
flex-direction: row;
}
@ -290,5 +373,4 @@ onMount(() => {
font-family: Comfortaa;
margin: 0;
}
</style>

View file

@ -1,7 +1,5 @@
<script>
import Header from './../Header.svelte';
import { handleRegister, checkName, checkMail, VerificationEmail } from '$lib/userFunction.js';
import { onMount } from 'svelte';
import { fly } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
@ -22,7 +20,6 @@
let code = ''; let codeError = '';
async function SendData() {
console.log(`name=${nameError} mail=${mailError} password=${passwordError} password2=${password2Error}`)
if ((name === '' )|| (name === undefined))
nameError = 'пустой ник';
@ -45,7 +42,6 @@ console.log(`name=${nameError} mail=${mailError} password=${passwordError} passw
let date = `${dateYear}-${dateMonth}-${dateDay}`;
let reg = await handleRegister(name, password, mail, date);
console.log(reg);
rotate();
console.log("отправлено")
}
@ -116,14 +112,13 @@ console.log(`name=${nameError} mail=${mailError} password=${passwordError} passw
<div class="mainDivFront">
<div class="jopa1">
<div class="marginDiv">
<form on:submit|preventDefault={SendData}>
<h1>Регистрация</h1>
<div class="group">
<div class="groupname">
<h3>имя</h3>
{#if nameError && nameError !== ''}
{#if nameError !== ''}
<h3 id="name" transition:fly={{ y: -30, duration: 300, easing: cubicOut }}>
{nameError}
</h3>
@ -135,7 +130,7 @@ console.log(`name=${nameError} mail=${mailError} password=${passwordError} passw
<div class="group">
<div class="groupname">
<h3>эл почта</h3>
{#if mailError && mailError !== ''}
{#if mailError !== ''}
<h3 id="mail" transition:fly={{ y: -30, duration: 300, easing: cubicOut }}>
{mailError}
</h3>