-
Notifications
You must be signed in to change notification settings - Fork 1
구현 과제 - 로그인/회원가입 모달 - 의진 #30
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
Open
timetam24
wants to merge
9
commits into
main
Choose a base branch
from
11-yooUiJin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f296ecc
[#11] 로그인 모달 및 기능 구현
timetam24 eb8e71e
[#11] 로그인 모달닫기 키보드 포커싱 문제해결
timetam24 dad61df
[#11] 웹 접근성 위한 label 추가 & 가상요소 적용 태그 변경
timetam24 ed77a95
[#11] 중첩 if문 수정
timetam24 8f1446a
[#11] Fix: "아이디와 비밀번호 불일치 안내 메세지 오류 수정"
timetam24 cb9d856
[#11] Fix: "아이디 미입력 안내 메세지 오류 수정"
timetam24 9ad5f26
[#11] 로그인 성공 시 비밀번호 focus 삭제
timetam24 a730cc5
[#11] Fix: "비밀번호 focus 오류 수정"
timetam24 ac5db27
[#11] Refactor: "중복 코드 함수로 추출"
timetam24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,69 @@ | ||
| const loginBtn = document.querySelector(".login-btn"); | ||
|
|
||
| const userId = document.querySelector(".user-id"); | ||
| const userPwd = document.querySelector(".user-pwd"); | ||
| const firstErrorMsg = document.createElement("p"); | ||
| const secondErrorMsg = document.createElement("p"); | ||
|
|
||
| const loginBtnHandler = (event) => { | ||
| event.preventDefault(); | ||
|
|
||
| const createErrorMsg = (element, className, text, nodeBehindErrorMsg) => { | ||
| element.classList.add(className); | ||
| element.innerText = text; | ||
| userPwd.parentNode.insertBefore(element, nodeBehindErrorMsg); | ||
| }; | ||
|
|
||
| const removeErrorMsg = (errorMsg) => { | ||
| if (errorMsg.parentNode) { | ||
| errorMsg.parentNode.removeChild(errorMsg); | ||
| } else { | ||
| return; | ||
| } | ||
| }; | ||
|
|
||
| const checkFocusAndErrorMsg = (input, errorMsg) => { | ||
| input.classList.remove("focus"); | ||
| removeErrorMsg(errorMsg); | ||
| }; | ||
|
|
||
| if (userId.value === "weniv07" && userPwd.value === "frontend07!") { | ||
| alert("로그인 성공!"); | ||
| checkFocusAndErrorMsg(userId, firstErrorMsg); | ||
| checkFocusAndErrorMsg(userPwd, secondErrorMsg); | ||
| } else if (!userId.value.trim()) { | ||
| // 아이디 미입력 시 | ||
| userId.classList.add("focus"); | ||
| createErrorMsg( | ||
| firstErrorMsg, | ||
| "first-error-msg", | ||
| "아이디를 입력해주세요.", | ||
| userPwd | ||
| ); | ||
| secondErrorMsg ? checkFocusAndErrorMsg(userPwd, secondErrorMsg) : null; | ||
| return; | ||
| } else if (userId.value.trim() && !userPwd.value.trim()) { | ||
| // 비밀번호 미입력 시 | ||
| checkFocusAndErrorMsg(userId, firstErrorMsg); | ||
| userPwd.classList.add("focus"); | ||
| createErrorMsg( | ||
| secondErrorMsg, | ||
| "second-error-msg", | ||
| "비밀번호를 입력해주세요.", | ||
| userPwd.nextSibling | ||
| ); | ||
| return; | ||
| } else if (userId.value !== "weniv07" || userPwd.value !== "frontend07!") { | ||
| // 아이디 또는 비밀번호 불일치 시 | ||
| userPwd.classList.remove("focus"); | ||
| createErrorMsg( | ||
| secondErrorMsg, | ||
| "second-error-msg", | ||
| "아이디 혹은 비밀번호가 일치하지 않습니다.", | ||
| userPwd.nextSibling | ||
| ); | ||
| firstErrorMsg ? checkFocusAndErrorMsg(userId, firstErrorMsg) : null; | ||
| } | ||
| }; | ||
|
|
||
| loginBtn.addEventListener("click", loginBtnHandler); | ||
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.
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 hidden or 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,74 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="ko"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>로그인 | 위니브</title> | ||
| <link rel="shortcut icon" href="#" /> | ||
| <link rel="stylesheet" href="./style.css" /> | ||
| </head> | ||
| <body> | ||
| <div id="modal-login"> | ||
| <header> | ||
| <h1>로그인 또는 회원가입</h1> | ||
| </header> | ||
| <main> | ||
| <section class="weniv-login"> | ||
| <h2>위니브에서 여러분의 궁금증을 해결하세요! :)</h2> | ||
| <form action="#" class="login-form"> | ||
| <label class="a11y-hidden" for="id">아이디</label> | ||
| <input type="text" id="id" class="user-id" placeholder="아이디" /> | ||
| <label class="a11y-hidden" for="pwd">비밀번호</label> | ||
| <input | ||
| type="password" | ||
| id="pwd" | ||
| class="user-pwd" | ||
| placeholder="비밀번호" | ||
| autocomplete="off" | ||
| /> | ||
| <input type="checkbox" id="inpHold" class="inp-hold txt-hide" /> | ||
| <label for="inpHold" class="labl-hold">로그인 상태 유지</label> | ||
| <button type="submit" class="login-btn">로그인</button> | ||
| </form> | ||
| <ul class="login-service"> | ||
| <li> | ||
| <a href="#" class="join-member">회원가입</a> | ||
| </li> | ||
| <li><a href="#">아이디/비밀번호 찾기</a></li> | ||
| </ul> | ||
| </section> | ||
| <div class="or">또는</div> | ||
| <section class="social-login"> | ||
| <h3 class="txt-hide">소셜서비스로 로그인</h3> | ||
| <ul> | ||
| <li> | ||
| <a href="#" class="icon-google" | ||
| ><span>구글 계정으로 로그인</span></a | ||
| > | ||
| </li> | ||
| <li> | ||
| <a href="#" class="icon-facebook" | ||
| ><span>페이스북 계정으로 로그인</span></a | ||
| > | ||
| </li> | ||
| <li> | ||
| <a href="#" class="icon-naver" | ||
| ><span>네이버 계정으로 로그인</span></a | ||
| > | ||
| </li> | ||
| <li> | ||
| <a href="#" class="icon-kakaotalk" | ||
| ><span>카카오톡 계정으로 로그인</span></a | ||
| > | ||
| </li> | ||
| </ul> | ||
| </section> | ||
| </main> | ||
| <a href="https://litt.ly/weniv" class="link-go-to-weniv"> | ||
| <img src="./images/modal-close.png" alt="로그인 모달 닫기" | ||
| /></a> | ||
| </div> | ||
| <script src="./app.js"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
키야 내부함수를 바로 만드시다니 증말 최고애요👍
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.
ㅎㅎㅎ 감사합니다❤️