changes to login

modified:   src/pages/login.rs
	modified:   src/pages/signup.rs
	modified:   style/login.scss
	modified:   style/signup.scss
This commit is contained in:
Danny Zou 2024-02-23 21:03:10 -05:00
parent f4bea8aa33
commit 2b76340608
4 changed files with 55 additions and 22 deletions

View File

@ -2,6 +2,7 @@ use crate::auth::login;
use leptos::leptos_dom::*; use leptos::leptos_dom::*;
use leptos::*; use leptos::*;
use leptos_icons::IoIcon::*; use leptos_icons::IoIcon::*;
use leptos_icons::AiIcon::*;
use leptos_icons::*; use leptos_icons::*;
#[component] #[component]
@ -9,6 +10,13 @@ pub fn Login() -> impl IntoView {
let (username_or_email, set_username_or_email) = create_signal("".to_string()); let (username_or_email, set_username_or_email) = create_signal("".to_string());
let (password, set_password) = create_signal("".to_string()); let (password, set_password) = create_signal("".to_string());
let (show_password, set_show_password) = create_signal(false);
let toggle_password = move |_| {
set_show_password.update(|show_password| *show_password = !*show_password);
log!("showing password");
};
let on_submit = move |ev: leptos::ev::SubmitEvent| { let on_submit = move |ev: leptos::ev::SubmitEvent| {
ev.prevent_default(); ev.prevent_default();
@ -49,7 +57,7 @@ pub fn Login() -> impl IntoView {
<i></i> <i></i>
</div> </div>
<div class="input-box"> <div class="input-box">
<input class="login-password" type="text" required <input class="login-password" type={move || if show_password() { "text" } else { "password"} } required
on:input = move |ev| { on:input = move |ev| {
set_password(event_target_value(&ev)); set_password(event_target_value(&ev));
log!("password changed to: {}", password.get()); log!("password changed to: {}", password.get());
@ -57,6 +65,17 @@ pub fn Login() -> impl IntoView {
/> />
<span>Password</span> <span>Password</span>
<i></i> <i></i>
<Show
when=move || {show_password() == false}
fallback=move || view!{ <button on:click=toggle_password class="login-password-visibility">
<Icon icon=Icon::from(AiEyeInvisibleFilled) />
</button> /> }
>
<button on:click=toggle_password class="login-password-visibility">
<Icon icon=Icon::from(AiEyeFilled) />
</button>
</Show>
</div> </div>
<a href="" class="forgot-pw">Forgot Password?</a> <a href="" class="forgot-pw">Forgot Password?</a>
<input type="submit" value="Login" /> <input type="submit" value="Login" />

View File

@ -92,6 +92,7 @@ pub fn Signup() -> impl IntoView {
</Show> </Show>
</div> </div>
<input type="submit" value="Sign Up" /> <input type="submit" value="Sign Up" />
<span class="go-to-login"> <span class="go-to-login">
Already Have an Account? <a href="/login">Go to Login</a> Already Have an Account? <a href="/login">Go to Login</a>

View File

@ -1,4 +1,4 @@
@import 'theme.scss'; @import "theme.scss";
.login-container { .login-container {
display: flex; display: flex;
@ -25,7 +25,7 @@
width: 75%; width: 75%;
} }
.login-form .input-box:first-child { .login-form .input-box:first-child {
margin-top: .5rem; margin-top: 1rem;
} }
.login-form .input-box { .login-form .input-box {
position: relative; position: relative;
@ -87,7 +87,7 @@
.login-form .forgot-pw { .login-form .forgot-pw {
display: inline-flex; display: inline-flex;
margin-top: 3px; margin-top: 3px;
font-size: .9rem; font-size: 0.9rem;
cursor: pointer; cursor: pointer;
color: #8f8f8f; color: #8f8f8f;
text-decoration: underline; text-decoration: underline;
@ -110,7 +110,7 @@
} }
.login-form .go-to-signup { .login-form .go-to-signup {
color: #8f8f8f; color: #8f8f8f;
font-size: .9rem; font-size: 0.9rem;
} }
.login-form .go-to-signup a { .login-form .go-to-signup a {
cursor: pointer; cursor: pointer;
@ -133,8 +133,19 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: .3rem; padding: 0.3rem;
} }
.login-container .return:hover { .login-container .return:hover {
background-color: rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.4);
} }
.login-password-visibility {
position: absolute;
font-size: 1.7rem;
top: 28%;
right: 5px;
z-index: 5;
cursor: pointer;
border: none;
background-color: transparent;
color: white;
}

View File

@ -28,7 +28,7 @@
margin-top: 3rem; margin-top: 3rem;
} }
.signup-form .input-box:first-child { .signup-form .input-box:first-child {
margin-top: 1rem; margin-top: 0.7rem;
} }
.signup-form .input-box input { .signup-form .input-box input {
position: relative; position: relative;
@ -126,7 +126,6 @@
.signup-container .return:hover { .signup-container .return:hover {
background-color: rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.4);
} }
.password-visibility { .password-visibility {
position: absolute; position: absolute;
font-size: 1.7rem; font-size: 1.7rem;
@ -138,3 +137,6 @@
background-color: transparent; background-color: transparent;
color: white; color: white;
} }
.pw-requirements {
font-size: 0.7rem;
}