mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-22 02:12:38 +01:00
work on implementing login form
This commit is contained in:
parent
6dc3c61317
commit
b3ea83a561
@ -1,3 +1,4 @@
|
|||||||
|
import { useForm } from "react-hook-form";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import Container from "../components/Container";
|
import Container from "../components/Container";
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ const SubHeader = styled.h2`
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FormContainer = styled.div`
|
const FormContainer = styled.form`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -70,8 +71,7 @@ const InputWrapper = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Input = styled.input`
|
const Input = styled.input<{invalid?: boolean}>`
|
||||||
border: none;
|
|
||||||
outline: none;
|
outline: none;
|
||||||
background: var(--secondary);
|
background: var(--secondary);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@ -80,6 +80,8 @@ const Input = styled.input`
|
|||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
border: ${(props) => props.invalid ? "1px solid red" : "none"};
|
||||||
|
aria-invalid: ${(props) => props.invalid ? "true" : "false"};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PasswordResetLink = styled.a`
|
const PasswordResetLink = styled.a`
|
||||||
@ -122,6 +124,11 @@ const RegisterLink = styled.a`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function LoginPage() {
|
function LoginPage() {
|
||||||
|
const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
||||||
|
const onSubmit = (data: any) => console.log(data);
|
||||||
|
|
||||||
|
console.log(errors)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<LoginBox>
|
<LoginBox>
|
||||||
@ -130,23 +137,23 @@ function LoginPage() {
|
|||||||
<SubHeader>We're so excited to see you again!</SubHeader>
|
<SubHeader>We're so excited to see you again!</SubHeader>
|
||||||
</HeaderContainer>
|
</HeaderContainer>
|
||||||
|
|
||||||
<FormContainer>
|
<FormContainer onSubmit={handleSubmit(onSubmit)}>
|
||||||
<InputContainer marginBottom={true} style={{ marginTop: 0 }}>
|
<InputContainer marginBottom={true} style={{ marginTop: 0 }}>
|
||||||
<InputLabel>Email</InputLabel>
|
<InputLabel>Email</InputLabel>
|
||||||
<InputWrapper>
|
<InputWrapper>
|
||||||
<Input />
|
<Input type="email" autoFocus {...register("email", {required: true})} invalid={!!errors.email} />
|
||||||
</InputWrapper>
|
</InputWrapper>
|
||||||
</InputContainer>
|
</InputContainer>
|
||||||
|
|
||||||
<InputContainer marginBottom={false}>
|
<InputContainer marginBottom={false}>
|
||||||
<InputLabel>Password</InputLabel>
|
<InputLabel>Password</InputLabel>
|
||||||
<InputWrapper>
|
<InputWrapper>
|
||||||
<Input />
|
<Input type="password" {...register("password", {required: true})} invalid={!!errors.password} />
|
||||||
</InputWrapper>
|
</InputWrapper>
|
||||||
</InputContainer>
|
</InputContainer>
|
||||||
|
|
||||||
<PasswordResetLink href="#">Forgot your password?</PasswordResetLink>
|
<PasswordResetLink href="#">Forgot your password?</PasswordResetLink>
|
||||||
<Button>Log In</Button>
|
<Button type="submit">Log In</Button>
|
||||||
|
|
||||||
<RegisterContainer>
|
<RegisterContainer>
|
||||||
<RegisterLabel>Don't have an account? </RegisterLabel>
|
<RegisterLabel>Don't have an account? </RegisterLabel>
|
||||||
|
Loading…
Reference in New Issue
Block a user