-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from boostcampwm-2024/Feature/#130_로그인_회원가입_U_구현
Feature/#130 로그인 회원가입 ui 구현
- Loading branch information
Showing
12 changed files
with
242 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { css } from "@styled-system/css"; | ||
|
||
export const formGroup = css({ | ||
position: "relative", | ||
}); | ||
|
||
export const inputContainer = css({ | ||
position: "relative", | ||
borderRadius: "md", | ||
padding: "1", | ||
background: "white/30", | ||
}); | ||
|
||
export const inputBox = css({ | ||
width: "100%", | ||
padding: "2", | ||
paddingLeft: "4", | ||
paddingRight: "12", | ||
color: "gray.700", | ||
"&:focus": { | ||
outline: "none", | ||
}, | ||
"&:placeholder": { | ||
color: "gray.500", | ||
}, | ||
}); | ||
|
||
export const iconBox = css({ | ||
position: "absolute", | ||
top: "50%", | ||
right: "4", | ||
transform: "translateY(-50%)", | ||
width: "6", | ||
height: "6", | ||
color: "white", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { formGroup, iconBox, inputBox, inputContainer } from "./InputField.style"; | ||
|
||
interface InputFieldProps { | ||
type?: string; | ||
name: string; | ||
value: string; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
placeholder?: string; | ||
Icon?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>; | ||
} | ||
|
||
export const InputField = ({ type, name, value, onChange, placeholder, Icon }: InputFieldProps) => ( | ||
<div className={formGroup}> | ||
<div className={inputContainer}> | ||
<input | ||
type={type} | ||
name={name} | ||
value={value} | ||
onChange={onChange} | ||
className={inputBox} | ||
placeholder={placeholder} | ||
required | ||
/> | ||
</div> | ||
{Icon && <Icon className={iconBox} />} | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { useModal } from "@components/modal/useModal"; | ||
import { AuthModal } from "@src/features/auth/AuthModal"; | ||
import { menuItemWrapper, imageBox, textBox } from "./MenuButton.style"; | ||
|
||
export const MenuButton = () => { | ||
const { isOpen, openModal, closeModal } = useModal(); | ||
|
||
return ( | ||
<div className={menuItemWrapper}> | ||
<div className={imageBox}></div> | ||
<p className={textBox}>Noctturn</p> | ||
</div> | ||
<> | ||
<button className={menuItemWrapper} onClick={openModal}> | ||
<div className={imageBox}></div> | ||
<p className={textBox}>Noctturn</p> | ||
</button> | ||
<AuthModal isOpen={isOpen} onClose={closeModal} /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { css, cva } from "@styled-system/css"; | ||
|
||
export const container = cva({ | ||
base: { | ||
display: "flex", | ||
gap: "lg", | ||
flexDirection: "column", | ||
justifyContent: "space-between", | ||
width: "100%", | ||
}, | ||
variants: { | ||
mode: { | ||
login: { | ||
height: "300px", | ||
}, | ||
register: { | ||
height: "360px", | ||
}, | ||
}, | ||
}, | ||
defaultVariants: { | ||
mode: "login", | ||
}, | ||
}); | ||
|
||
export const title = css({ | ||
textStyle: "display-medium32", | ||
color: "white", | ||
textAlign: "center", | ||
textShadow: "0 2px 4px rgba(0,0,0,0.1)", | ||
}); | ||
|
||
export const toggleButton = css({ | ||
marginBottom: "md", | ||
color: "white", | ||
cursor: "pointer", | ||
"&:hover": { | ||
textDecoration: "underline", | ||
}, | ||
}); | ||
|
||
export const formContainer = css({ | ||
display: "flex", | ||
gap: "md", | ||
flexDirection: "column", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { useState } from "react"; | ||
import Lock from "@assets/icons/lock.svg?react"; | ||
import Mail from "@assets/icons/mail.svg?react"; | ||
import User from "@assets/icons/user.svg?react"; | ||
import { Modal } from "@components/modal/modal"; | ||
import { InputField } from "@src/components/inputField/InputField"; | ||
import { container, formContainer, title, toggleButton } from "./AuthModal.style"; | ||
|
||
interface AuthModalProps { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
export const AuthModal = ({ isOpen, onClose }: AuthModalProps) => { | ||
const [mode, setMode] = useState<"login" | "register">("login"); | ||
const [formData, setFormData] = useState({ | ||
name: "", | ||
email: "", | ||
password: "", | ||
}); | ||
|
||
const toggleMode = () => { | ||
setMode(mode === "login" ? "register" : "login"); | ||
setFormData({ email: "", password: "", name: "" }); | ||
}; | ||
|
||
const closeModal = () => { | ||
setMode("login"); | ||
setFormData({ email: "", password: "", name: "" }); | ||
onClose(); | ||
}; | ||
|
||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const { name, value } = e.target; | ||
setFormData((prev) => ({ ...prev, [name]: value })); | ||
}; | ||
|
||
const handleSubmitButtonClick = () => { | ||
// TODO API 연결 | ||
closeModal(); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
primaryButtonLabel={mode === "login" ? "로그인" : "회원가입"} | ||
primaryButtonOnClick={handleSubmitButtonClick} | ||
secondaryButtonLabel="취소" | ||
secondaryButtonOnClick={closeModal} | ||
> | ||
<div className={container({ mode })}> | ||
<h1 className={title}>{mode === "login" ? "Login" : "Sign Up"}</h1> | ||
<div className={formContainer}> | ||
{mode === "register" && ( | ||
<InputField | ||
type="text" | ||
name="name" | ||
value={formData.name} | ||
onChange={handleInputChange} | ||
placeholder="이름" | ||
Icon={User} | ||
/> | ||
)} | ||
<InputField | ||
type="email" | ||
name="email" | ||
value={formData.email} | ||
onChange={handleInputChange} | ||
placeholder="이메일" | ||
Icon={Mail} | ||
/> | ||
<InputField | ||
type="password" | ||
name="password" | ||
value={formData.password} | ||
onChange={handleInputChange} | ||
placeholder="비밀번호" | ||
Icon={Lock} | ||
/> | ||
</div> | ||
|
||
<button onClick={toggleMode} className={toggleButton}> | ||
{mode === "login" | ||
? "계정이 없으신가요? 회원가입하기" | ||
: "이미 계정이 있으신가요? 로그인하기"} | ||
</button> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters