diff --git a/panda-market/login.html b/panda-market/login.html index adb8d585..663b290d 100644 --- a/panda-market/login.html +++ b/panda-market/login.html @@ -15,7 +15,7 @@
-
+ +
-
+
눈 감은 아이콘
+
- @@ -58,5 +65,6 @@
+ diff --git a/panda-market/scripts/login.js b/panda-market/scripts/login.js new file mode 100644 index 00000000..dcb4ec7e --- /dev/null +++ b/panda-market/scripts/login.js @@ -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; + + if (isEmailValid && isPasswordValid) { + 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(); +}; + +emailInput.addEventListener("blur", emailValid); +passwordInput.addEventListener("blur", passwordValid); diff --git a/panda-market/scripts/sign-up.js b/panda-market/scripts/sign-up.js new file mode 100644 index 00000000..326b8371 --- /dev/null +++ b/panda-market/scripts/sign-up.js @@ -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); diff --git a/panda-market/sign-in.html b/panda-market/sign-in.html new file mode 100644 index 00000000..3dee291a --- /dev/null +++ b/panda-market/sign-in.html @@ -0,0 +1,11 @@ + + + + + + 판다마켓 + + + sign-in + + diff --git a/panda-market/sign-up.html b/panda-market/sign-up.html index 7e595c66..d2747bcd 100644 --- a/panda-market/sign-up.html +++ b/panda-market/sign-up.html @@ -15,7 +15,7 @@
-
+ +
-
+
+
-
+
눈 감은 아이콘
+
-
+
눈 감은 아이콘
+
- @@ -83,5 +92,6 @@
+ diff --git a/panda-market/styles/login.css b/panda-market/styles/login.css index acc917bc..3f71c68c 100644 --- a/panda-market/styles/login.css +++ b/panda-market/styles/login.css @@ -9,6 +9,11 @@ gap: 40px; } +.login-logo-image { + width: 103px; + height: 103px; +} + .login-logo { display: flex; align-items: center; @@ -68,12 +73,22 @@ input::placeholder { border: 3px solid #3692ff; } +.error { + font-family: Pretendard; + font-size: 14px; + font-weight: 600; + line-height: 24px; + color: #f74747; + margin-left: 16px; +} + button { width: 640px; border: none; - background-color: #9ca3af; + background-color: #3692ff; border-radius: 40px; padding: 12px 0; + cursor: pointer; } .btn-text { display: inline-block; @@ -83,10 +98,11 @@ button { text-align: center; color: #f3f4f6; } -form:has(#email:valid):has(#password:valid) button { - background-color: #3692ff; - cursor: pointer; +button.disabled { + background-color: #9ca3af; + pointer-events: none; } + .sns-login-box { display: flex; width: 640px; @@ -129,3 +145,24 @@ form:has(#email:valid):has(#password:valid) button { line-height: 16.71px; text-align: left; } + +@media screen and (min-width: 375px) and (max-width: 768px) { + .container { + max-width: 400px; + } + .login-logo-image { + width: 52px; + height: 52px; + } + .home-anchor { + font-size: 33px; + line-height: 45px; + } + .login-form, + .input-wrapper, + .input-box, + button, + .sns-login-box { + width: 100%; + } +} diff --git a/panda-market/styles/sign-up.css b/panda-market/styles/sign-up.css index 07289dcb..145fd297 100644 --- a/panda-market/styles/sign-up.css +++ b/panda-market/styles/sign-up.css @@ -9,6 +9,11 @@ gap: 40px; } +.sign-up-logo-image { + width: 103px; + height: 103px; +} + .sign-up-logo { display: flex; align-items: center; @@ -68,12 +73,22 @@ input::placeholder { border: 3px solid #3692ff; } +.error { + font-family: Pretendard; + font-size: 14px; + font-weight: 600; + line-height: 24px; + color: #f74747; + margin-left: 16px; +} + button { width: 640px; border: none; - background-color: #9ca3af; + background-color: #3692ff; border-radius: 40px; padding: 12px 0; + cursor: pointer; } .btn-text { display: inline-block; @@ -83,12 +98,9 @@ button { text-align: center; color: #f3f4f6; } -form:has(#email:valid):has(#nickname:valid):has(#password:valid):has( - #checkPassword:valid - ) - button { - background-color: #3692ff; - cursor: pointer; +.disabled { + background-color: #9ca3af; + pointer-events: none; } .sns-login-box { display: flex; @@ -132,3 +144,24 @@ form:has(#email:valid):has(#nickname:valid):has(#password:valid):has( line-height: 16.71px; text-align: left; } + +@media screen and (min-width: 375px) and (max-width: 768px) { + .container { + max-width: 400px; + } + .sign-up-logo-image { + width: 52px; + height: 52px; + } + .home-anchor { + font-size: 33px; + line-height: 45px; + } + .sign-up-form, + .input-wrapper, + .input-box, + button, + .sns-login-box { + width: 100%; + } +}