feat: change login page styles
This commit is contained in:
parent
c8d56fe0b2
commit
b2ad6f1a5e
@ -1,48 +1,82 @@
|
|||||||
#login {
|
.login-view {
|
||||||
background: #fff;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
height: 100%;
|
||||||
|
|
||||||
#login img {
|
|
||||||
width: 4em;
|
|
||||||
height: 4em;
|
|
||||||
margin: 0 auto;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#login h1 {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 2.5em;
|
|
||||||
margin: .4em 0 .67em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#login form {
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
background-color: #ffffff;
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
max-width: 16em;
|
|
||||||
width: 90%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#login.recaptcha form {
|
.login-view--with-captcha .login-form {
|
||||||
min-width: 304px;
|
min-width: 304px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#login #recaptcha {
|
.login-form {
|
||||||
margin: .5em 0 0;
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 90%;
|
||||||
|
position: fixed;
|
||||||
|
max-width: 20rem;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
#login .wrong {
|
.login-form__logo {
|
||||||
background: var(--red);
|
margin: 0 auto;
|
||||||
color: #fff;
|
}
|
||||||
padding: .5em;
|
|
||||||
|
.login-form__title {
|
||||||
|
font-size: 1.5em;
|
||||||
|
margin-top: 1rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
animation: .2s opac forwards;
|
}
|
||||||
|
|
||||||
|
.login-form__description {
|
||||||
|
display: block;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form__inputs {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form__input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form__input:not(:first-child) {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form__submit {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-view #recaptcha {
|
||||||
|
margin: 0.5em 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form__change-mode {
|
||||||
|
border: 0;
|
||||||
|
outline: 0;
|
||||||
|
width: 100%;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: right;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
color: var(--blue);
|
||||||
|
font-size: 0.875rem; /* 14px */
|
||||||
|
background-color: unset;
|
||||||
|
text-transform: lowercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-form__error {
|
||||||
|
padding: 0.5em;
|
||||||
|
display: block;
|
||||||
|
margin-top: 1rem;
|
||||||
|
color: var(--red);
|
||||||
|
text-align: center;
|
||||||
|
animation: 0.2s opac forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes opac {
|
@keyframes opac {
|
||||||
@ -54,12 +88,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#login p {
|
/* New */
|
||||||
cursor: pointer;
|
.logo {
|
||||||
text-align: right;
|
width: 4rem;
|
||||||
color: var(--blue);
|
height: 4rem;
|
||||||
text-transform: lowercase;
|
position: relative;
|
||||||
font-weight: 500;
|
}
|
||||||
font-size: 0.9rem;
|
|
||||||
margin: .5rem 0;
|
.logo__image {
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
@import "./listing-icons.css";
|
@import "./listing-icons.css";
|
||||||
@import "./upload-files.css";
|
@import "./upload-files.css";
|
||||||
@import "./dashboard.css";
|
@import "./dashboard.css";
|
||||||
@import "./login.css";
|
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
color: var(--blue);
|
color: var(--blue);
|
||||||
|
|||||||
@ -1,44 +1,57 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="login" :class="{ recaptcha: recaptcha }">
|
<div :class="['login-view', { 'login-view--with-captcha': recaptcha }]">
|
||||||
<form @submit="submit">
|
<form @submit.prevent="submit" class="login-form">
|
||||||
<img :src="logoURL" alt="File Browser" />
|
<div class="logo login-form__logo">
|
||||||
<h1>{{ name }}</h1>
|
<img :src="logoURL" :alt="name" class="logo__image" />
|
||||||
<div v-if="error !== ''" class="wrong">{{ error }}</div>
|
</div>
|
||||||
|
|
||||||
<input
|
<h1 class="login-form__title">{{ title }}</h1>
|
||||||
autofocus
|
|
||||||
class="input input--block"
|
<span class="login-form__description">
|
||||||
type="text"
|
To use all the <b>{{ name }}</b> features you need to
|
||||||
autocapitalize="off"
|
{{ title.toLowerCase() }} first.
|
||||||
v-model="username"
|
</span>
|
||||||
:placeholder="$t('login.username')"
|
|
||||||
/>
|
<div class="login-form__inputs">
|
||||||
<input
|
<Input
|
||||||
class="input input--block"
|
v-model="username"
|
||||||
type="password"
|
autocapitalize="off"
|
||||||
v-model="password"
|
class="login-form__input"
|
||||||
:placeholder="$t('login.password')"
|
:placeholder="$t('login.username')"
|
||||||
/>
|
autofocus
|
||||||
<input
|
/>
|
||||||
class="input input--block"
|
|
||||||
v-if="createMode"
|
<Input
|
||||||
type="password"
|
type="password"
|
||||||
v-model="passwordConfirm"
|
v-model="password"
|
||||||
:placeholder="$t('login.passwordConfirm')"
|
class="login-form__input"
|
||||||
/>
|
:placeholder="$t('login.password')"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
v-if="createMode"
|
||||||
|
type="password"
|
||||||
|
v-model="passwordConfirm"
|
||||||
|
class="login-form__input"
|
||||||
|
:placeholder="$t('login.passwordConfirm')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button class="login-form__submit" fullWidth>
|
||||||
|
{{ title }}
|
||||||
|
</Button>
|
||||||
|
|
||||||
<div v-if="recaptcha" id="recaptcha"></div>
|
<div v-if="recaptcha" id="recaptcha"></div>
|
||||||
<input
|
|
||||||
class="button button--block"
|
|
||||||
type="submit"
|
|
||||||
:value="createMode ? $t('login.signup') : $t('login.submit')"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<p @click="toggleMode" v-if="signup">
|
<p v-if="!signup" class="login-form__change-mode" @click="toggleMode">
|
||||||
{{
|
{{
|
||||||
createMode ? $t("login.loginInstead") : $t("login.createAnAccount")
|
createMode ? $t("login.loginInstead") : $t("login.createAnAccount")
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<span v-if="error" class="login-form__error">
|
||||||
|
{{ error }}
|
||||||
|
</span>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -53,45 +66,67 @@ import {
|
|||||||
signup,
|
signup,
|
||||||
} from "@/utils/constants";
|
} from "@/utils/constants";
|
||||||
|
|
||||||
|
import Input from "@/components/Input.vue";
|
||||||
|
import Button from "@/components/Button.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "login",
|
name: "LoginView",
|
||||||
computed: {
|
|
||||||
signup: () => signup,
|
components: {
|
||||||
name: () => name,
|
Input,
|
||||||
logoURL: () => logoURL,
|
Button,
|
||||||
},
|
},
|
||||||
data: function () {
|
|
||||||
|
data() {
|
||||||
return {
|
return {
|
||||||
|
name,
|
||||||
|
signup,
|
||||||
|
logoURL,
|
||||||
|
recaptcha,
|
||||||
createMode: false,
|
createMode: false,
|
||||||
error: "",
|
error: "",
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
recaptcha: recaptcha,
|
|
||||||
passwordConfirm: "",
|
passwordConfirm: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
if (!recaptcha) return;
|
|
||||||
|
|
||||||
window.grecaptcha.ready(function () {
|
computed: {
|
||||||
window.grecaptcha.render("recaptcha", {
|
title() {
|
||||||
sitekey: recaptchaKey,
|
return this.createMode
|
||||||
});
|
? this.$t("login.signup")
|
||||||
});
|
: this.$t("login.submit");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
error(value) {
|
||||||
|
if (value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.error = "";
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.renderRecaptcha();
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
renderRecaptcha() {
|
||||||
|
if (!this.recaptcha) return;
|
||||||
|
|
||||||
|
window.grecaptcha.ready(() => {
|
||||||
|
window.grecaptcha.render("recaptcha", { sitekey: recaptchaKey });
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
toggleMode() {
|
toggleMode() {
|
||||||
this.createMode = !this.createMode;
|
this.createMode = !this.createMode;
|
||||||
},
|
},
|
||||||
async submit(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
let redirect = this.$route.query.redirect;
|
|
||||||
if (redirect === "" || redirect === undefined || redirect === null) {
|
|
||||||
redirect = "/files/";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
async submit() {
|
||||||
let captcha = "";
|
let captcha = "";
|
||||||
if (recaptcha) {
|
if (recaptcha) {
|
||||||
captcha = window.grecaptcha.getResponse();
|
captcha = window.grecaptcha.getResponse();
|
||||||
@ -102,11 +137,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.createMode) {
|
if (this.createMode && this.password !== this.passwordConfirm) {
|
||||||
if (this.password !== this.passwordConfirm) {
|
this.error = this.$t("login.passwordsDontMatch");
|
||||||
this.error = this.$t("login.passwordsDontMatch");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -115,15 +148,18 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await auth.login(this.username, this.password, captcha);
|
await auth.login(this.username, this.password, captcha);
|
||||||
|
|
||||||
|
const redirect = this.$route.query.redirect || "/files/";
|
||||||
this.$router.push({ path: redirect });
|
this.$router.push({ path: redirect });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.message == 409) {
|
this.error =
|
||||||
this.error = this.$t("login.usernameTaken");
|
e.message == 409
|
||||||
} else {
|
? this.$t("login.usernameTaken")
|
||||||
this.error = this.$t("login.wrongCredentials");
|
: this.$t("login.wrongCredentials");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style src="@/css/login.css" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user