-
Notifications
You must be signed in to change notification settings - Fork 37
[이민서] Sprint4 #152
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
Merged
kich555
merged 3 commits into
codeit-bootcamp-frontend:Basic-이민서
from
LMS10:Basic-이민서-sprint4
Nov 17, 2024
The head ref may contain hidden characters: "Basic-\uC774\uBBFC\uC11C-sprint4"
Merged
[이민서] Sprint4 #152
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -6,13 +6,13 @@ document.addEventListener("DOMContentLoaded", () => { | |
|
|
||
| const emailRegex = /^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/; | ||
|
|
||
| const loginForm = document.querySelector('.login-form'); | ||
| const signupForm = document.querySelector('.signup-form'); | ||
| const emailInput = document.querySelector('#email'); | ||
| const nicknameInput = document.querySelector('#nickname'); | ||
| const passwordInput = document.querySelector('#password'); | ||
| const passwordConfirmationInput = document.querySelector('#passwordConfirmation'); | ||
| const submitButton = document.querySelector('button[type="submit"]'); | ||
| const loginForm = document.querySelector(".login-form"); | ||
| const signupForm = document.querySelector(".signup-form"); | ||
| const emailInput = document.querySelector("#email"); | ||
| const nicknameInput = document.querySelector("#nickname"); | ||
| const passwordInput = document.querySelector("#password"); | ||
| const passwordConfirmationInput = document.querySelector("#passwordConfirmation"); | ||
| const submitButton = document.querySelector("button[type='submit']"); | ||
|
|
||
| // 오류 메세지 노출 함수 | ||
| function showError(input, errorClass) { | ||
|
|
@@ -127,6 +127,25 @@ document.addEventListener("DOMContentLoaded", () => { | |
| submitButton.disabled = !isFormValid; | ||
| } | ||
|
|
||
| // 비밀번호 토글 버튼 동작 | ||
| function togglePasswordVisibility(event) { | ||
| const button = event.currentTarget; | ||
| const inputField = button.parentElement.querySelector("input"); | ||
| const toggleIcon = button.querySelector(".password-toggle-icon"); | ||
|
|
||
| // 비밀번호가 표시된 상태인지 확인 | ||
| const isPasswordVisible = inputField.type === "text"; | ||
|
|
||
| inputField.type = isPasswordVisible ? "password" : "text"; | ||
| toggleIcon.src = isPasswordVisible ? "/images/icons/eye-invisible.svg" : "/images/icons/eye-visible.svg" | ||
| toggleIcon.alt = isPasswordVisible ? "비밀번호 숨김 상태 아이콘" : "비밀번호 표시 상태 아이콘"; | ||
|
Comment on lines
+140
to
+141
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. HTML에서 이렇게 <button class="password-toggle-button"
data-visible-icon="/images/icons/eye-visible.svg"
data-invisible-icon="/images/icons/eye-invisible.svg"
data-visible-alt="비밀번호 표시 상태 아이콘"
data-invisible-alt="비밀번호 숨김 상태 아이콘">
<img class="password-toggle-icon" src="/images/icons/eye-invisible.svg" alt="비밀번호 숨김 상태 아이콘">
</button>JS // 데이터 속성에서 아이콘 및 대체 텍스트 가져오기
const visibleIcon = button.dataset.visibleIcon;
const invisibleIcon = button.dataset.invisibleIcon;
const visibleAlt = button.dataset.visibleAlt;
const invisibleAlt = button.dataset.invisibleAlt; |
||
| } | ||
|
|
||
| // 비밀번호 토글 버튼에 이벤트 리스너 추가 | ||
| const toggleButtons = document.querySelectorAll(".password-toggle-button"); | ||
| toggleButtons.forEach((button) => | ||
| button.addEventListener("click", togglePasswordVisibility) | ||
| ); | ||
|
|
||
| // 입력 필드에 이벤트 리스너 추가 | ||
| if (emailInput) { | ||
|
|
@@ -160,6 +179,11 @@ document.addEventListener("DOMContentLoaded", () => { | |
| passwordConfirmationInput.removeEventListener("focusout", checkPasswordConfirmationValidity); | ||
| passwordConfirmationInput.removeEventListener("input", checkPasswordConfirmationValidity); | ||
| } | ||
|
|
||
| // 비밀번호 토글 버튼의 이벤트 리스너 제거 | ||
| toggleButtons.forEach((button) => | ||
| button.removeEventListener("click", togglePasswordVisibility) | ||
| ); | ||
| } | ||
|
|
||
| // 이후 기능 추가 후 수정 (현재는 단순히 특정 페이지로 이동) | ||
|
|
||
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
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
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.
이런 부분은 커밋 이름인
feat(auth): 비밀번호 표시/숨기기 아이콘 토글 기능 추가과 연관성이 없고 사전에 self-review를 진행했다면 나오지 않을 불필요한 변경점 인 것 같아요 ㅎ뭐 크리티컬하게 문제가 있는 부분은 아니긴한데 커밋을 잘 통제할 수 있도록 git 다루는 연습을 미리 해두시면 좋을것 같아요!