Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
319b06e
Refactor: Sprint Mission3 feedback except for the mobile size repons…
Seon-K Mar 12, 2025
8c93366
Refactor: add padding-left and padding-right 16px of body tag in auth…
Seon-K Mar 12, 2025
0d5df26
refactor: fix banner size to prevent unwanted width expansion and add…
Seon-K Mar 15, 2025
e6e7176
fix: add reponsive design to keep content-title text in a single line…
Seon-K Mar 15, 2025
c5d46b5
fix: meta image tag content url
Seon-K Mar 15, 2025
6c0f76a
fix: change meta tag url
Seon-K Mar 15, 2025
501ce82
test meta tag image
Seon-K Mar 15, 2025
ec103c5
change: meta tag image url
Seon-K Mar 15, 2025
28b23b0
fix: delete margin 16px in auth.css for body tag because the main has…
Seon-K Mar 15, 2025
daedc5e
refactor: 폴더 구조 변경 (auth, home 구분 및 reset.css파일 추가) + change .button…
Seon-K Mar 18, 2025
c0e862b
add: 로그인 페이지 오류 메세지 적용 (비밀번호 적용 X)
Seon-K Mar 18, 2025
986689c
add: 회원가입 페이지 오류 메세지 완료 적용 (비밀번호 구현 X)
Seon-K Mar 18, 2025
db325b9
add: 눈 아이콘 기능 추가
Seon-K Mar 19, 2025
30a262e
meta image
Seon-K Mar 19, 2025
3acfcbf
add: meta image
Seon-K Mar 19, 2025
61d304d
add: login페이지에서 버튼 활성화시 items로 이동
Seon-K Mar 19, 2025
ad54a71
refactor: 비밀번호 확인 눈 아이콘 기능 수정
Seon-K Mar 19, 2025
b352740
refactor: 회원가입 버튼 활성시 로그인 페이지로 이동하는 경로 수정
Seon-K Mar 19, 2025
56014dc
PR을 잘못 올려서 다시 올리기위한 커밋...
Seon-K Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 48 additions & 37 deletions css/auth.css → auth/auth.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
html {
font-size: 10px;
display: flex;
flex-direction: column;
align-items: center;
Expand Down Expand Up @@ -31,7 +30,7 @@ html {
overflow: auto;
}

header {
.banner {
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -42,7 +41,7 @@ header {
margin: 0 12.2rem 4rem 12.2rem;
}

header a {
.banner a {
display: flex;
align-items: center;
justify-content: space-around;
Expand All @@ -62,7 +61,11 @@ label {
font-weight: 700;
}

input{
.error {
border: 2px solid var(--error);
}

input {
width: 64rem;
height: 5.6rem;

Expand All @@ -76,26 +79,58 @@ input{
padding: 1.6rem 2.4rem;
}

.email-error, .pw-error, .pwconfirm-error, .nickname-error {
display: none;
font-size: 1.4rem;
font-weight: 600;
color: var(--error);

margin-left: 1.6rem;
}

.input-box {
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 1.6rem;
}

.pw-content {
position: relative;
display: flex;
align-items: center;
}

.button-eye {
position: absolute;
right: 1.6rem;
border: none;

cursor: pointer;
}

.button-submit {
width: 64rem;
height: 5.6rem;

background-color: var(--gray400);
background-color: var(--blue);
color: var(--white);

font-size: 2rem;
font-weight: 60rem;

border: 2px solid var(--gray400);
border: none;
border-radius: 4rem;

cursor: pointer;
}

.button-submit:hover {
background-color: var(--blue);
border: 2px solid var(--blue);
.button-submit:disabled {
background-color: var(--gray400);
}

footer{
footer {
display: flex;
flex-direction: column;
align-items: center;
Expand All @@ -104,25 +139,6 @@ footer{
padding-bottom: 10rem;
}

.input-box {
position: relative;
display: flex;
flex-direction: column;
gap: 1.6rem;
}

.pw-content {
position:relative;
display: flex;
align-items: center;
}

.button-eye {
position: absolute;
right: 1.6rem;
border: none;
}

.social-login {
display: flex;
align-items: center;
Expand All @@ -134,7 +150,6 @@ footer{
width: 64rem;
height: 7.4rem;

border: 2px solid var(--skyblue);
border-radius: 0.8rem;
}

Expand All @@ -157,16 +172,12 @@ footer{
color: var(--blue);
}

@media (max-width: 76.7rem) {
/* body {
margin-top: 20rem;
} */

header {
@media (max-width: 767px) {
.banner {
margin: 0;
}

header a {
.banner a {
width: 19.8rem;
height: 6.6rem;
}
Expand Down
33 changes: 33 additions & 0 deletions auth/common.js
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";
Comment on lines +9 to +10
Copy link
Collaborator

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로 처리하시는 것이 더 좋을 것 같아요~

Suggested change
button.disabled = true;
button.style.cursor = "not-allowed";
// common 이나 button 관련 css 파일
button:disabled { 
  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};
42 changes: 34 additions & 8 deletions html/login.html → auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
module js의 경우 자동으로 defer 되기 때문에 defer 속성을 빼셔도 됩니다~

Suggested change
<script defer type="module" src="/auth/common.js"></script>
<script type="module" src="/auth/common.js"></script>

mdn script

<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"
Expand All @@ -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>

Expand All @@ -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>
Expand Down
61 changes: 61 additions & 0 deletions auth/login.js
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
해당 정규식이 로그인과 회원가입 관려 JS에서 모두 사용되니 따로 분리하셔서 같이 써도 될 것 같아요~


// 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
early return 을 하고 계시기 때문에 else if문으로 사용하지 않고 아래처럼 작성하시는 것이 동일동작하며 가독성측면에서도 더 유리합니다~

Suggested change
return false;
} else if (!pattern.test(emailValue)) { // 정규식으로 이메일 형식 검사하기
showError(inputEmail, emailError, "잘못된 이메일 형식입니다.");
return false;
} else {
hiddenError(inputEmail, emailError);
return true;
}
return false;
}
if (!pattern.test(emailValue)) {
showError(inputEmail, emailError, "잘못된 이메일 형식입니다.");
return false;
}
hiddenError(inputEmail, emailError);
return true;

}

// 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";
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
버튼의 disabled 속성만 js로 조작하시고 css cursor 속성은 css를 통해 조작하시는 것을 추천드려요~
위에서 말씀드린 것처럼 disabled시 js에서 cursor속성을 not-allowed 로 바꾸는 코드를 제거하면 해당 코드도 불필요해집니다!

Suggested change
button.style.cursor = "pointer";

} 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);
32 changes: 32 additions & 0 deletions auth/password-visibility.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
비밀번호 토글하는 함수 isPwVisibility와 비밀번호 확인 토글하는 함수 isPwConfirmVisibility가 겹치는 부분이 많아 보여요~
최대한 서연님의 코드를 유지하면서 중복을 줄이는 예시입니다~ 아래처럼 중복을 줄일 수 있게 작성하시는 것을 추천드려요!
(다른 부분도 중복을 줄이는 방법을 고민해보시면 더 좋습니다! )

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);
Loading
Loading