-
Notifications
You must be signed in to change notification settings - Fork 20
[한동형] Sprint 4 #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "Basic-\uD55C\uB3D9\uD615-sprint4"
[한동형] Sprint 4 #43
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const emailInput = document.querySelector("#email"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const passwordInput = document.querySelector("#password"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const emailError = document.querySelector(".email.error"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const passwordError = document.querySelector(".password.error"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const loginBtn = document.querySelector(".login-btn"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const emailInputWrapper = document.querySelector(".input-wrapper.email"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const passwordInputWrapper = document.querySelector(".input-wrapper.password"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ENTER_EMAIL = "이메일을 입력해주세요."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ENTER_PASSWORD = "비밀번호를 입력해주세요."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const WRONG_EMAIL = "잘못된 이메일 형식입니다"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const PASSWORD_NEED_EIGHT_WORDS = "비밀번호를 8자 이상 입력해주세요."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const NO_ERROR_MESSAGE = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const toggleLoginButton = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isEmailValid = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailInput.value && emailError.innerHTML === NO_ERROR_MESSAGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isPasswordValid = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordInput.value && passwordError.innerHTML === NO_ERROR_MESSAGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+18
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굿굿 ! 복잡한 조건문은 변수로 정의하셨네요 !이렇게 하신다면 조건문에 별칭을 붙일 수 있고 가독성은 향상될거예요 ! 좋은 패턴입니다 ! 👍👍👍 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isEmailValid && isPasswordValid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loginBtn.classList.remove("disabled"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loginBtn.disabled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loginBtn.classList.add("disabled"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loginBtn.disabled = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+26
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (팁) 다음과 같이 정의해둔 조건을 그대로 사용하실 수도 있습니다. 😊
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const emailValid = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수는 동사로 시작하는게 일반적입니다 !
Suggested change
일반적으로 변수는 명사, 함수는 동사로 지어요. 함수의 경우 다음과 같은 단어들이 접두사가 될 수 있어요:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!emailInput.value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailError.innerHTML = ENTER_EMAIL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailInputWrapper.style.border = "3px solid #F74747"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (emailInput.value && !emailInput.value.includes("@")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailError.innerHTML = WRONG_EMAIL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailInputWrapper.style.border = "3px solid #F74747"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (emailInput.value && emailInput.value.includes("@")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailError.innerHTML = NO_ERROR_MESSAGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| emailInputWrapper.style.border = "none"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toggleLoginButton(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const passwordValid = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!passwordInput.value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordError.innerHTML = ENTER_PASSWORD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordInputWrapper.style.border = "3px solid #F74747"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (passwordInput.value && passwordInput.value.length < 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordError.innerHTML = PASSWORD_NEED_EIGHT_WORDS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordInputWrapper.style.border = "3px solid #F74747"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (passwordInput.value && passwordInput.value.length >= 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordError.innerHTML = NO_ERROR_MESSAGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| passwordInputWrapper.style.border = "none"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+56
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (제안)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!emailInput.value) { | |
| emailError.innerHTML = ENTER_EMAIL; | |
| emailInputWrapper.style.border = "3px solid #F74747"; | |
| } | |
| if (emailInput.value && !emailInput.value.includes("@")) { | |
| emailError.innerHTML = WRONG_EMAIL; | |
| emailInputWrapper.style.border = "3px solid #F74747"; | |
| } | |
| if (emailInput.value && emailInput.value.includes("@")) { | |
| emailError.innerHTML = NO_ERROR_MESSAGE; | |
| emailInputWrapper.style.border = "none"; | |
| } | |
| toggleLoginButton(); | |
| }; | |
| const passwordValid = () => { | |
| if (!passwordInput.value) { | |
| passwordError.innerHTML = ENTER_PASSWORD; | |
| passwordInputWrapper.style.border = "3px solid #F74747"; | |
| } | |
| if (passwordInput.value && passwordInput.value.length < 8) { | |
| passwordError.innerHTML = PASSWORD_NEED_EIGHT_WORDS; | |
| passwordInputWrapper.style.border = "3px solid #F74747"; | |
| } | |
| if (passwordInput.value && passwordInput.value.length >= 8) { | |
| passwordError.innerHTML = NO_ERROR_MESSAGE; | |
| passwordInputWrapper.style.border = "none"; | |
| } | |
| if (!emailInput.value) { | |
| emailError.innerHTML = ENTER_EMAIL; | |
| emailInputWrapper.classList.add("input-error"); | |
| } | |
| if (emailInput.value && !emailInput.value.includes("@")) { | |
| emailError.innerHTML = WRONG_EMAIL; | |
| emailInputWrapper.classList.add("input-error"); | |
| } | |
| if (emailInput.value && emailInput.value.includes("@")) { | |
| emailError.innerHTML = NO_ERROR_MESSAGE; | |
| emailInputWrapper.classList.remove("input-error"); | |
| } | |
| toggleLoginButton(); | |
| }; | |
| const passwordValid = () => { | |
| if (!passwordInput.value) { | |
| passwordError.innerHTML = ENTER_PASSWORD; | |
| passwordInputWrapper.classList.add("input-error"); | |
| } | |
| if (passwordInput.value && passwordInput.value.length < 8) { | |
| passwordError.innerHTML = PASSWORD_NEED_EIGHT_WORDS; | |
| passwordInputWrapper.classList.add("input-error"); | |
| } | |
| if (passwordInput.value && passwordInput.value.length >= 8) { | |
| passwordError.innerHTML = NO_ERROR_MESSAGE; | |
| passwordInputWrapper.classList.remove("input-error"); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| const emailInput = document.querySelector("#email"); | ||
| const passwordInput = document.querySelector("#password"); | ||
| const nicknameInput = document.querySelector("#nickname"); | ||
| const checkPasswordInput = document.querySelector("#checkPassword"); | ||
| const emailError = document.querySelector(".email.error"); | ||
| const passwordError = document.querySelector(".password.error"); | ||
| const checkPasswordError = document.querySelector(".checkPassword.error"); | ||
| const nicknameError = document.querySelector(".nickname.error"); | ||
| const loginBtn = document.querySelector(".login-btn"); | ||
| const emailInputWrapper = document.querySelector(".input-wrapper.email"); | ||
| const passwordInputWrapper = document.querySelector(".input-wrapper.password"); | ||
| const nicknameInputWrapper = document.querySelector(".input-wrapper.nickname"); | ||
| const checkPasswordInputWrapper = document.querySelector( | ||
| ".input-wrapper.checkPassword" | ||
| ); | ||
| const ENTER_EMAIL = "이메일을 입력해주세요."; | ||
| const ENTER_NICKNAME = "닉네임을 입력해주세요."; | ||
| const ENTER_PASSWORD = "비밀번호를 입력해주세요."; | ||
| const WRONG_CHECK_PASSWORD = "비밀번호가 일치하지 않습니다."; | ||
| const WRONG_EMAIL = "잘못된 이메일 형식입니다"; | ||
| const PASSWORD_NEED_EIGHT_WORDS = "비밀번호를 8자 이상 입력해주세요."; | ||
| const NO_ERROR_MESSAGE = ""; | ||
|
|
||
| const toggleLoginButton = () => { | ||
| const isEmailValid = | ||
| emailInput.value && emailError.innerHTML === NO_ERROR_MESSAGE; | ||
| const isPasswordValid = | ||
| passwordInput.value && passwordError.innerHTML === NO_ERROR_MESSAGE; | ||
| const isNicknameValid = | ||
| nicknameInput.value && nicknameError.innerHTML === NO_ERROR_MESSAGE; | ||
| const isCheckPasswordValid = | ||
| checkPasswordInput.value && | ||
| checkPasswordError.innerHTML === NO_ERROR_MESSAGE; | ||
|
|
||
| if ( | ||
| isEmailValid && | ||
| isPasswordValid && | ||
| isNicknameValid && | ||
| isCheckPasswordValid | ||
| ) { | ||
| loginBtn.classList.remove("disabled"); | ||
| loginBtn.disabled = false; | ||
| } else { | ||
| loginBtn.classList.add("disabled"); | ||
| loginBtn.disabled = true; | ||
| } | ||
| }; | ||
| const emailValid = () => { | ||
| if (!emailInput.value) { | ||
| emailError.innerHTML = ENTER_EMAIL; | ||
| emailInputWrapper.style.border = "3px solid #F74747"; | ||
| } | ||
| if (emailInput.value && !emailInput.value.includes("@")) { | ||
| emailError.innerHTML = WRONG_EMAIL; | ||
| emailInputWrapper.style.border = "3px solid #F74747"; | ||
| } | ||
| if (emailInput.value && emailInput.value.includes("@")) { | ||
| emailError.innerHTML = NO_ERROR_MESSAGE; | ||
| emailInputWrapper.style.border = "none"; | ||
| } | ||
| toggleLoginButton(); | ||
| }; | ||
| const passwordValid = () => { | ||
| if (!passwordInput.value) { | ||
| passwordError.innerHTML = ENTER_PASSWORD; | ||
| passwordInputWrapper.style.border = "3px solid #F74747"; | ||
| } | ||
| if (passwordInput.value && passwordInput.value.length < 8) { | ||
| passwordError.innerHTML = PASSWORD_NEED_EIGHT_WORDS; | ||
| passwordInputWrapper.style.border = "3px solid #F74747"; | ||
| } | ||
| if (passwordInput.value && passwordInput.value.length >= 8) { | ||
| passwordError.innerHTML = NO_ERROR_MESSAGE; | ||
| passwordInputWrapper.style.border = "none"; | ||
| } | ||
| toggleLoginButton(); | ||
| }; | ||
| const nicknameValid = () => { | ||
| if (!nicknameInput.value) { | ||
| nicknameError.innerHTML = ENTER_NICKNAME; | ||
| nicknameInputWrapper.style.border = "3px solid #F74747"; | ||
| } else { | ||
| nicknameError.innerHTML = NO_ERROR_MESSAGE; | ||
| nicknameInputWrapper.style.border = "none"; | ||
| } | ||
|
|
||
| toggleLoginButton(); | ||
| }; | ||
|
|
||
| const checkPasswordValid = () => { | ||
| if (passwordInput.value !== checkPasswordInput.value) { | ||
| checkPasswordError.innerHTML = WRONG_CHECK_PASSWORD; | ||
| checkPasswordInputWrapper.style.border = "3px solid #F74747"; | ||
| } else { | ||
| checkPasswordError.innerHTML = NO_ERROR_MESSAGE; | ||
| checkPasswordInputWrapper.style.border = "none"; | ||
| } | ||
|
|
||
| toggleLoginButton(); | ||
| }; | ||
|
|
||
| emailInput.addEventListener("blur", emailValid); | ||
| passwordInput.addEventListener("blur", passwordValid); | ||
| nicknameInput.addEventListener("blur", nicknameValid); | ||
| checkPasswordInput.addEventListener("blur", checkPasswordValid); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>판다마켓</title> | ||
| </head> | ||
| <body> | ||
| sign-in | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(제안) 에러 메시지를 정의하셨군요? 😊
현재 전역 상수로 정의하셨는데 객체로 만들어서 같은 관심사끼리 묶을 수도 있습니다 !