-
Notifications
You must be signed in to change notification settings - Fork 39
[김서연] sprint4 #114
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-\uAE40\uC11C\uC5F0-sprint4"
[김서연] sprint4 #114
Changes from all commits
319b06e
8c93366
0d5df26
e6e7176
c5d46b5
6c0f76a
501ce82
ec103c5
28b23b0
daedc5e
c0e862b
986689c
db325b9
30a262e
3acfcbf
61d304d
ad54a71
b352740
56014dc
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,33 @@ | ||
| // 필요한 태그 변수로 선언 | ||
| const button = document.querySelector(".button-submit"); | ||
| const inputEmail = document.querySelector("#email"); | ||
| const inputPassword = document.querySelector("#password"); | ||
| const inputNickName = document.querySelector("#nickname"); | ||
| const inputPasswordConfirm = document.querySelector("#password-confirm"); | ||
|
|
||
| // 초기 버튼 비활성화 | ||
| button.disabled = true; | ||
| button.style.cursor = "not-allowed"; | ||
|
|
||
| // input 타입별 error메세지 변수 | ||
| // const errorMessage = document.querySelector(".error-message"); | ||
| const emailError = document.querySelector(".email-error"); | ||
| const pwError = document.querySelector(".pw-error"); | ||
| const nicknameError = document.querySelector(".nickname-error"); | ||
| const pwConfirmError = document.querySelector(".pwconfirm-error"); | ||
|
|
||
| // 공통된 에러 메시지 표시 함수 | ||
| const showError = (input, errorElement, message) => { | ||
| errorElement.textContent = message; | ||
| errorElement.style.display = "block"; | ||
| input.classList.add("error"); | ||
| }; | ||
|
|
||
| // 공통된 에러 메시지 숨기기 함수 | ||
| const hiddenError = (input, errorElement) => { | ||
| errorElement.textContent = ""; | ||
| errorElement.style.display = "none"; | ||
| input.classList.remove("error"); | ||
| }; | ||
|
|
||
| export {button, inputEmail, inputPassword, inputNickName, inputPasswordConfirm ,emailError, pwError, nicknameError, pwConfirmError, showError, hiddenError}; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,40 +4,65 @@ | |||||
| <meta charset="UTF-8" /> | ||||||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||||||
| <title>로그인</title> | ||||||
|
|
||||||
| <!-- favicon 불러오기 --> | ||||||
| <link rel="icon" type="image/svg" href="/image/logo.svg" /> | ||||||
|
|
||||||
| <!-- Pretendard 폰트 불러오기 --> | ||||||
| <link | ||||||
| rel="stylesheet" | ||||||
| as="style" | ||||||
| crossorigin | ||||||
| href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css" | ||||||
| /> | ||||||
| <!-- normalize css 불러오기 --> | ||||||
| <link | ||||||
| rel="stylesheet" | ||||||
| href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" | ||||||
| /> | ||||||
| <link rel="stylesheet" href="/css/common.css"> | ||||||
| <link rel="stylesheet" href="/css/auth.css" /> | ||||||
|
|
||||||
| <!-- css 불러오기 --> | ||||||
| <link rel="stylesheet" href="/css/reset.css" /> | ||||||
| <link rel="stylesheet" href="/css/common.css" /> | ||||||
| <link rel="stylesheet" href="/auth/auth.css" /> | ||||||
|
|
||||||
| <!-- script 불러오기 --> | ||||||
| <script defer type="module" src="/auth/common.js"></script> | ||||||
|
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
|
||||||
| <script defer type="module" src="/auth/login.js"></script> | ||||||
| <script defer type="module" src="/auth/password-visibility.js"></script> | ||||||
| </head> | ||||||
|
|
||||||
| <body class="body-login"> | ||||||
| <header> | ||||||
| <header class="banner"> | ||||||
| <a href="/"> | ||||||
| <img class="logo" src="/image/logo.svg" alt="판다마켓 로고" /> | ||||||
| <img class="logo-title" src="/image/logo_title.svg" alt="판다마켓 로고 글씨" /> | ||||||
| <img class="logo-title" src="/image/logo_title.svg" alt="판다마켓" /> | ||||||
| </a> | ||||||
| </header> | ||||||
|
|
||||||
| <main> | ||||||
| <form class="auth-form"> | ||||||
| <div class="input-box"> | ||||||
| <label for="email">이메일</label> | ||||||
| <input name="email" id="email" type="email" placeholder="이메일을 입력해주세요"/> | ||||||
| <input | ||||||
| name="email" | ||||||
| id="email" | ||||||
| type="email" | ||||||
| placeholder="이메일을 입력해주세요" | ||||||
| /> | ||||||
| <div class="email-error"></div> | ||||||
| </div> | ||||||
|
|
||||||
| <div class="input-box"> | ||||||
| <label for="password">비밀번호</label> | ||||||
| <div class="pw-content"> | ||||||
| <input name="password" id="password" type="password" placeholder="비밀번호를 입력해주세요" /> | ||||||
| <input | ||||||
| class="pw-visibility" | ||||||
| name="password" | ||||||
| id="password" | ||||||
| type="password" | ||||||
| placeholder="비밀번호를 입력해주세요" | ||||||
| /> | ||||||
| <button type="button" class="button-eye"> | ||||||
| <img | ||||||
| class="eye_icon" | ||||||
|
|
@@ -46,9 +71,10 @@ | |||||
| /> | ||||||
| </button> | ||||||
| </div> | ||||||
| <div class="pw-error"></div> | ||||||
| </div> | ||||||
|
|
||||||
| <button type="submit" class="button-submit">로그인</button> | ||||||
| <button id="button-login" type="button" class="button-submit" disabled>로그인</button> | ||||||
| </form> | ||||||
| </main> | ||||||
|
|
||||||
|
|
@@ -74,7 +100,7 @@ | |||||
|
|
||||||
| <section class="sign_up"> | ||||||
| <span>판다마켓이 처음이신가요?</span> | ||||||
| <a href="/html/signup.html">회원가입</a> | ||||||
| <a href="/auth/signup.html">회원가입</a> | ||||||
| </section> | ||||||
| </footer> | ||||||
| </body> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||||||||||||
| import { button, inputEmail, inputPassword, emailError, pwError, showError, hiddenError} from "./common.js"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // email 유효성 검사 패턴 | ||||||||||||||||||||||||||||||||||||||
| const pattern = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+4
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. 💊 제안 |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // email 유효성 검사 및 에러 메세지 | ||||||||||||||||||||||||||||||||||||||
| const isValidEmail = () => { | ||||||||||||||||||||||||||||||||||||||
| const emailValue = inputEmail.value.trim(); // 이메일 입력값을 공백 제거 후 가져오기 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (emailValue === "") { | ||||||||||||||||||||||||||||||||||||||
| showError(inputEmail, emailError, "이메일을 입력해주세요.") | ||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||
| } else if (!pattern.test(emailValue)) { // 정규식으로 이메일 형식 검사하기 | ||||||||||||||||||||||||||||||||||||||
| showError(inputEmail, emailError, "잘못된 이메일 형식입니다."); | ||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| hiddenError(inputEmail, emailError); | ||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+19
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
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // password 유효성 검사 및 에러 메세지 | ||||||||||||||||||||||||||||||||||||||
| const isValidPassword = () => { | ||||||||||||||||||||||||||||||||||||||
| const passwordValue = inputPassword.value.trim(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (!passwordValue) { | ||||||||||||||||||||||||||||||||||||||
| showError(inputPassword, pwError, "비밀번호를 입력해주세요."); | ||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||
| } else if (passwordValue.length < 8) { | ||||||||||||||||||||||||||||||||||||||
| showError(inputPassword, pwError, "비밀번호 8자 이상 입력해주세요."); | ||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| hiddenError(inputPassword, pwError); | ||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // 버튼 활성화 함수 | ||||||||||||||||||||||||||||||||||||||
| const validateButton = () => { | ||||||||||||||||||||||||||||||||||||||
| if (isValidEmail() && isValidPassword()) { | ||||||||||||||||||||||||||||||||||||||
| button.disabled = false; | ||||||||||||||||||||||||||||||||||||||
| button.style.cursor = "pointer"; | ||||||||||||||||||||||||||||||||||||||
|
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
|
||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| button.disabled = true; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // 로그인 버튼 활성화시 item 페이지로 이동 | ||||||||||||||||||||||||||||||||||||||
| const loginButton = document.querySelector("#button-login"); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| loginButton.onclick = () => { | ||||||||||||||||||||||||||||||||||||||
| if (!button.disabled) { | ||||||||||||||||||||||||||||||||||||||
| location.href = "/html/items.html"; // items 페이지로 이동 | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // 이벤트 리스너 추가 | ||||||||||||||||||||||||||||||||||||||
| inputEmail.addEventListener("input", validateButton); | ||||||||||||||||||||||||||||||||||||||
| inputPassword.addEventListener("input", validateButton); | ||||||||||||||||||||||||||||||||||||||
| inputEmail.addEventListener("focusout", isValidEmail); | ||||||||||||||||||||||||||||||||||||||
| inputPassword.addEventListener("focusout", isValidPassword); | ||||||||||||||||||||||||||||||||||||||
|
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. 💊 제안 const pwVisibility = document.querySelector(".pw-visibility");
const eyeImage = document.querySelector(".eye_icon");
const pwConfirmVisibility = document.querySelector("#password-confirm");
const pwConfirmEyeImage = document.querySelector("#password-confirm-eye");
const togglePassword = () => {
if (input.type === "password") {
// password면 text로
img.src = "/image/password_show_icon.svg";
input.type = "text";
} else {
// text면 password로
img.src = "/image/password_toggle_icon.svg";
input.type = "password";
}
};
const isPwVisibility = () => togglePassword(pwVisibility, eyeImage);
const isPwConfirmVisibility = () =>
togglePassword(pwConfirmVisibility, pwConfirmEyeImage);
eyeImage.addEventListener("click", isPwVisibility);
pwConfirmEyeImage.addEventListener("click", isPwConfirmVisibility); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // 비밀번호 눈 | ||
| const pwVisibility = document.querySelector(".pw-visibility"); | ||
| const eyeImage = document.querySelector(".eye_icon"); | ||
|
|
||
| const isPwVisibility = () => { | ||
| if (pwVisibility.type === "password") { // password면 text로 | ||
| eyeImage.src = "/image/password_show_icon.svg"; | ||
| pwVisibility.type = "text"; | ||
| } else { // text면 password로 | ||
| eyeImage.src = "/image/password_toggle_icon.svg"; | ||
| pwVisibility.type = "password"; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| eyeImage.addEventListener("click", isPwVisibility); | ||
|
|
||
| // 비밀번호 확인 눈 | ||
| const pwConfirmVisibility = document.querySelector("#password-confirm"); | ||
| const pwConfirmEyeImage = document.querySelector("#password-confirm-eye"); | ||
|
|
||
| const isPwConfirmVisibility = () => { | ||
| if (pwConfirmVisibility.type === "password") { // password면 text로 | ||
| pwConfirmEyeImage.src = "/image/password_show_icon.svg"; | ||
| pwConfirmVisibility.type = "text"; | ||
| } else { // text면 password로 | ||
| pwConfirmEyeImage.src = "/image/password_toggle_icon.svg"; | ||
| pwConfirmVisibility.type = "password"; | ||
| } | ||
| } | ||
|
|
||
| pwConfirmEyeImage.addEventListener("click", isPwConfirmVisibility); |
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.
💊 제안
로그인, 회원가입 페이지에서 기본적으로 disabled 속성을 가지고 있기 때문에 해당 부분이 없어도 될 것 같아요!
버튼이 비활성화 되었을 때 cursor를 not-allowed로 해주신 것은 좋지만 이는 css로도 가능한 부분이라 css로 처리하시는 것이 더 좋을 것 같아요~