-
Notifications
You must be signed in to change notification settings - Fork 39
[문주영] Sprint4 #162
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-\uBB38\uC8FC\uC601-sprint4"
[문주영] Sprint4 #162
Changes from all commits
d2e31a8
60cfa02
136a046
d16f09f
2281f66
3622c2a
33e089a
8b65fca
33d8db8
8e7c06d
2bae4e6
5f0d23c
79d0911
f38cb1b
aaf9909
ff3b51e
d38a869
a1ade8c
a462964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
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. 💊 제안 |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,106 @@ | ||||||||||||||
| const form = document.querySelector("form"); | ||||||||||||||
| const inputs = document.querySelectorAll("form input"); | ||||||||||||||
| const button = document.querySelector("button.complete-btn"); | ||||||||||||||
|
|
||||||||||||||
| const email = document.querySelector("input#email"); | ||||||||||||||
|
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 nickname = document.querySelector("input#nickname"); | ||||||||||||||
| const password = document.querySelector("input#password"); | ||||||||||||||
| const passwordCheck = document.querySelector("input#password-check"); | ||||||||||||||
|
|
||||||||||||||
| const passwordContainers = document.querySelectorAll(".password-container"); | ||||||||||||||
|
|
||||||||||||||
| function wrongInput(node, text){ | ||||||||||||||
|
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. 💊 제안 |
||||||||||||||
| node.classList.add("wrong"); | ||||||||||||||
| node.classList.remove("correct"); | ||||||||||||||
|
|
||||||||||||||
| let wrongMessage; | ||||||||||||||
| if (node.nextElementSibling?.tagName === 'DIV'){ | ||||||||||||||
| wrongMessage = node.nextElementSibling; | ||||||||||||||
|
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. 💊 제안 |
||||||||||||||
| } else { | ||||||||||||||
| wrongMessage = document.createElement('div'); | ||||||||||||||
| wrongMessage.setAttribute("class","wrong-message"); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+16
to
+22
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. 💊 제안 function getErrorMessageTag(node) {
if (node.nextElementSibling?.tagName === 'DIV') return node.nextElementSibling;
const errorMessage = document.createElement('div');
errorMessage.setAttribute("class", "wrong-message");
return errorMessage;
}
function wrongInput(node, text) {
node.classList.add("wrong");
node.classList.remove("correct");
const errorMessage = getErrorMessageTag(node);
errorMessage.textContent = text;
if (!node.nextElementSibling?.isSameNode(errorMessage)) {
node.after(errorMessage);
}
} |
||||||||||||||
| wrongMessage.textContent = text; | ||||||||||||||
| node.after(wrongMessage); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| function correctInput(node) { | ||||||||||||||
| node.classList.add("correct"); | ||||||||||||||
| node.classList.remove("wrong"); | ||||||||||||||
|
|
||||||||||||||
| if (node.nextElementSibling?.tagName === 'DIV'){ | ||||||||||||||
| node.nextElementSibling.remove(); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| function passwordMatch() { | ||||||||||||||
| if (password.value !== passwordCheck.value) { | ||||||||||||||
| wrongInput(passwordCheck, "비밀번호가 일치하지 않습니다."); | ||||||||||||||
| } else { | ||||||||||||||
| correctInput(passwordCheck); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| email.addEventListener("focusout", (e) => { | ||||||||||||||
| if (!e.target.value) { | ||||||||||||||
| wrongInput(e.target, "이메일을 입력해주세요."); | ||||||||||||||
| } else if (!e.target.validity.valid) { | ||||||||||||||
| wrongInput(e.target, "잘못된 이메일 형식입니다."); | ||||||||||||||
| } else { | ||||||||||||||
| correctInput(e.target); | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| nickname?.addEventListener("focusout", (e) => { | ||||||||||||||
| if (!e.target.value) { | ||||||||||||||
| wrongInput(e.target, "닉네임을 입력해주세요."); | ||||||||||||||
| } else { | ||||||||||||||
| correctInput(e.target); | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| password.addEventListener("focusout", (e) => { | ||||||||||||||
| if (!e.target.value) { | ||||||||||||||
| wrongInput(e.target, "비밀번호를 입력해주세요."); | ||||||||||||||
| } else if (e.target.value.length < 8) { | ||||||||||||||
| wrongInput(e.target, "비밀번호를 8자 이상 입력해주세요."); | ||||||||||||||
| } else { | ||||||||||||||
| correctInput(e.target); | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| if (passwordCheck) { | ||||||||||||||
| password.addEventListener("change", () => { | ||||||||||||||
| if (passwordCheck.value) { | ||||||||||||||
| passwordMatch(); | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
| passwordCheck.addEventListener("input", () => { | ||||||||||||||
| if (password.value) { | ||||||||||||||
| passwordMatch(); | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| form.addEventListener("focusout", () => { | ||||||||||||||
| for (let input of inputs) { | ||||||||||||||
|
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 (!input.classList.contains("correct")){ | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| button.removeAttribute("disabled"); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| passwordContainers.forEach( (node) => { | ||||||||||||||
|
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
|
||||||||||||||
| node.addEventListener("click", (e) => { | ||||||||||||||
| if (e.target.tagName === "IMG") { | ||||||||||||||
| if (e.currentTarget.firstElementChild.getAttribute("type") === "password"){ | ||||||||||||||
|
Comment on lines
+95
to
+97
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
|
||||||||||||||
| e.currentTarget.firstElementChild.setAttribute("type", "text"); | ||||||||||||||
| e.target.setAttribute("src", "images/ic_eye_visible.svg"); | ||||||||||||||
| } else { | ||||||||||||||
| e.currentTarget.firstElementChild.setAttribute("type", "password"); | ||||||||||||||
| e.target.setAttribute("src", "images/ic_eye_invisible.svg"); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
| } ) | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| :root { | ||
| --blue: #3692FF; | ||
| --gray900: #111827 ; | ||
| --gray800: #1F2937 ; | ||
| --gray700: #374151 ; | ||
| --gray600: #4B5563 ; | ||
| --gray500: #6B7280 ; | ||
| --gray400: #9CA3AF ; | ||
| --gray200: #E5E7EB ; | ||
| --gray100: #F3F4F6 ; | ||
| --gray50: #F9FAFB ; | ||
| --red: #F74747; | ||
| --gray900: #111827; | ||
| --gray800: #1F2937; | ||
| --gray700: #374151; | ||
| --gray600: #4B5563; | ||
| --gray500: #6B7280; | ||
| --gray400: #9CA3AF; | ||
| --gray200: #E5E7EB; | ||
| --gray100: #F3F4F6; | ||
| --gray50: #F9FAFB; | ||
| } |
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.
💊 제안
아마 script 태그를 HTML의 하단에 배치하신 이유가 script가 문서의 렌더링을 막지 않도록 하기 위해서이실 것 같아요.
하지만, script 태그에 defer나 async 속성을 사용하면 이런 문제를 해결할 수 있기 때문에 반드시 하단에 배치할 필요는 없습니다!
또한 script 태그는 상단에 있는게 구조 파악에서도 유리하기 때문에 상단 head 태그에 두시는 것을 추천드려요~
script async
script defer
지금과 같은 경우 DOM을 조작하는 JS 이니 defer 속성을 추가하시면 되겠습니다~