create-account.tsx
import { useState } from "react";
import { styled } from "styled-components";
const Wrapper = styled.div`
height: 100vh; /* 화면 전체 높이를 기준으로 중앙 정렬 */
display: flex;
justify-content: center; /* 수평 중앙 */
align-items: center; /* 수직 중앙 */
flex-direction: column;
width: 420px;
margin: 0 auto; /* 화면 가운데로 */
padding: 50px 0px;
`;
const Title = styled.h1`
font-size: 42px;
`;
const Form = styled.form`
margin-top: 50px;
display: flex;
flex-direction: column;
gap: 10px;
width: 100%;
`;
const Input = styled.input`
padding: 10px 20px;
border-radius: 50px;
border: none;
width: 100%;
font-size: 16px;
&[type="submit"] {
cursor: pointer;
&:hover {
opacity: 0.8;
}
}
`;
const Error = styled.span`
font-weight: 600;
color: tomato;
`;
export default function CreateAccount() {
const [isLoading, setLoading] = useState(false);
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const {
target: { name, value },
} = e;
if (name === "name") {
setName(value);
} else if (name === "email") {
setEmail(value);
} else if (name === "password") {
setPassword(value);
}
};
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
try {
// create an account
// set the name of the user.
// redirect to the home page
} catch (e) {
// setError
} finally {
setLoading(false);
}
};
return (
<Wrapper>
<Title>Log into 𝕏</Title>
<Form onSubmit={onSubmit}>
<Input
onChange={onChange}
name="name"
value={name}
placeholder="Name"
type="text"
required
/>
<Input
onChange={onChange}
name="email"
value={email}
placeholder="Email"
type="email"
required
/>
<Input
onChange={onChange}
value={password}
name="password"
placeholder="Password"
type="password"
required
/>
<Input
type="submit"
value={isLoading ? "Loading..." : "Create Account"}
/>
</Form>
{error !== "" ? <Error>{error}</Error> : null}
</Wrapper>
);
}
nwitter-reloaded.z01
19.53MB
nwitter-reloaded.z02
19.53MB
nwitter-reloaded.z03
19.53MB
nwitter-reloaded.z04
19.53MB
nwitter-reloaded.z05
19.53MB
nwitter-reloaded.zip
14.58MB
'트위터(React, TypeScript, Firebase, Vite)' 카테고리의 다른 글
09. Authentication - Protected Routes (0) | 2025.04.15 |
---|---|
08. Authentication - Create Account (0) | 2025.04.14 |
06. Authentication - Setup (0) | 2025.04.11 |
04. Firebase Project (0) | 2025.04.11 |
03. LoadingScreen (0) | 2025.04.11 |