Skip to content

Conversation

@dkozowlk
Copy link
Collaborator

요구사항

기본

로그인

  • 이메일 input에서 focus out 할 때, 값이 없을 경우 input에 빨강색 테두리와 아래에 "이메일을 입력해주세요." 빨강색 에러 메세지를 보입니다.
  • 이메일 input에서 focus out 할 때, 이메일 형식에 맞지 않는 경우 input에 빨강색 테두리와 아래에 "잘못된 이메일 형식입니다" 빨강색 에러 메세지를 보입니다.
  • 비밀번호 input에서 focus out 할 때, 값이 없을 경우 아래에 "비밀번호를 입력해주세요." 에러 메세지를 보입니다
  • 비밀번호 input에서 focus out 할 때, 값이 8자 미만일 경우 아래에 "비밀번호를 8자 이상 입력해주세요." 에러 메세지를 보입니다.
  • input 에 빈 값이 있거나 에러 메세지가 있으면 '로그인' 버튼은 비활성화 됩니다.
  • input 에 유효한 값을 입력하면 '로그인' 버튼이 활성화 됩니다.
  • 활성화된 '로그인' 버튼을 누르면 "/items" 로 이동합니다

회원가입

  • 이메일 input에서 focus out 할 때, 값이 없을 경우 input에 빨강색 테두리와 아래에 "이메일을 입력해주세요." 빨강색 에러 메세지를 보입니다.
  • 이메일 input에서 focus out 할 때, 이메일 형식에 맞지 않는 경우 input에 빨강색 테두리와 아래에 "잘못된 이메일 형식입니다" 빨강색 에러 메세지를 보입니다.
  • 닉네임 input에서 focus out 할 때, 값이 없을 경우 input에 빨강색 테두리와 아래에 "닉네임을 입력해주세요." 빨강색 에러 메세지를 보입니다.
  • 비밀번호 input에서 focus out 할 때, 값이 없을 경우 아래에 "비밀번호를 입력해주세요." 에러 메세지를 보입니다
  • 비밀번호 input에서 focus out 할 때, 값이 8자 미만일 경우 아래에 "비밀번호를 8자 이상 입력해주세요." 에러 메세지를 보입니다.
  • 비밀번호 input과 비밀번호 확인 input의 값이 다른 경우, 비밀번호 확인 input 아래에 "비밀번호가 일치하지 않습니다.." 에러 메세지를 보입니다.
  • input 에 빈 값이 있거나 에러 메세지가 있으면 '회원가입' 버튼은 비활성화 됩니다.
  • input 에 유효한 값을 입력하면 '회원가입' 버튼이 활성화 됩니다.
  • 활성화된 '회원가입' 버튼을 누르면 로그인 페이지로 이동합니다

심화

  • 눈 모양 아이콘 클릭시 비밀번호의 문자열이 보이기도 하고, 가려지기도 합니다.
  • 비밀번호의 문자열이 가려질 때는 눈 모양 아이콘에는 사선이 그어져있고, 비밀번호의 문자열이 보일 때는 사선이 없는 눈 모양 아이콘이 보이도록 합니다.

주요 변경사항

  • 로그인 페이지 인풋에 placeholder를 추가했습니다.
  • 버튼에 비활성화 상태를 추가했습니다
  • 인풋에 에러메시지를 추가했습니다
  • 눈모양 아이콘 토글버튼을 구현했습니다

스크린샷

캡처
캡처2
로그인 페이지입니다.

캡처3
캡처4
회원가입 페이지입니다.

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@dkozowlk dkozowlk changed the title [김태욱] [김태욱] sprint4 May 16, 2025
@dkozowlk dkozowlk added the 순한맛🐑 마음이 많이 여립니다.. label May 16, 2025
@dongqui dongqui changed the base branch from main to Basic-김태욱 May 19, 2025 05:36
Copy link
Collaborator

@dongqui dongqui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

태욱님 이번 미션도 고생 많으셨습니다~!

군더더기 없이 깔끔하게 잘 진행해 주셨네요 :)
재사용과 가독성을 위해 함수를 좀 더 활용해 주시면 더욱 좋을 거 같습니다~!

const togglePassword = document.getElementById("togglePassword");

/* 이미지 파일 경로 설정 */
const eyeOpenSrc = "./images/anyicons/passwardeye.svg";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대체로 변수, 함수명이 직관적이고 명확합니다 👍 👍

let isPasswordVisible = false;

/* 이메일 정규표현식 */
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정규식을 써주셨군요~! 💯

const value = emailInput.value.trim();

if (!value) {
emailInput.classList.add("error");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에러를 추가하고 제거하는 로직이 반복되고 있네요! 이런 경우 함수로 정의해 주시면 재사용도 쉽고 가독성도 높일 수 있습니다 :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function addError(id, message) {
  const $emailInput = document.getElementById(`${id}Input`);
  const $emailError = document.getElementById(`${id}Error`);
  //..
}


/* 📌 유효성 검사 후 버튼 활성화 체크 */
const updateButtonState = () => {
if (isEmailValid && isNicknameValid && isPasswordValid && isPasswordMatch) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

크게 상관 없지만.. 이렇게 나타낼 수도 있겠네요!

signupButton.disabled = !(isEmailValid && isNicknameValid && isPasswordValid && isPasswordMatch);

}

.logininput.error {
border: 1px solid #f74747 !important;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

important는 관리하기가 힘들어, 지양하시는 것이 좋습니다 :)

그리고 지금 이미 .error 클래스로 특이성이 올라간 상태라 important를 안 써도 잘 적용될 거 같네요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

important 를 사용 안하니깐 적용이 안되더라구요...그래서 임시방편으로 사용한거긴 합니다..ㅠㅠ

src="./images/anyicons/passwardcancel.svg"
alt="비밀번호 보기 토글"
id="toggle-Password"
alt="passwardtoggle"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기능을 가진 아이콘이라면 버튼을 감싸주시거나 aria-label등을 활용해 주시는 것이 접근성에 좋습니다 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 확인했습니다!

let isPasswordConfirmVisible = false;

/* 이메일 정규표현식 */
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

login 과 겹치는 부분이 많은데 이런 경우 공통 부분을 따로 정의하고 import 해서 쓰셔도 좋습니다 :)

https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html

@dongqui dongqui merged commit 867cfc8 into codeit-bootcamp-frontend:Basic-김태욱 May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

순한맛🐑 마음이 많이 여립니다..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants