Skip to content
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

[박나겸] Spritn4 #179

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@
<div class="foot_con">
<div class="foot_sen name">@codeit-2024</div>
<div class="foot_sen pf">
<div class="pri" onclick="location.href='/pages/privacy.html'">Privacy Policy</div>
<div class="faq" onclick="location.href='/pages/faq.html'"> FAQ</div>
<a href="/pages/privacy.html">
Privacy Policy
</a>
<a href="/pages/faq.html">
FAQ
</a>
</div>
<div class="foot_icons">
<a href="https://www.facebook.com/?locale=ko_KR" target="_blank"><img src="images/Group.svg"></a>
Expand Down
14 changes: 0 additions & 14 deletions js/javascript.js

This file was deleted.

64 changes: 64 additions & 0 deletions js/login_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const passwordInput= document.getElementById('password');

function onEyecliked(){
if(passwordInput.type === 'password'){
passwordInput.type='text';
}else{
passwordInput.type='password';
}
}

function emailChange(){
const emailInput = document.getElementById('email');
const emailError = document.getElementById('emailError');
const submitBtn=document.querySelector('.button');
const email=emailInput.value;

if(email.includes("@")&&email.includes(".")){
Copy link
Collaborator

Choose a reason for hiding this comment

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

이부분을 조금 개선하면 좋을것같아요!

일단 이메일인지 아닌지 구분하기 위해서 @. 이 포함되긴 해야겠지만 다른 조건들도 여러가지가 있을꺼에요...ㅠ

그걸 하나하나 if문으로 거르는건 어렵고, 이런 문제를 해결하기 위해서 실무에서 정규표현식 이라는걸 많이 사용해요!

문자열의 패턴을 검사하는건데, 다음과 같이 사용해요

function isValidEmail(email) {
  // 이메일 정규표현식
  const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
  return emailRegex.test(email);
}

// 테스트
console.log(isValidEmail("[email protected]")); // true
console.log(isValidEmail("invalid-email"));      // false
console.log(isValidEmail("[email protected]"));  // true
console.log(isValidEmail("[email protected]"));          // false

형태는 조금 어려울 수있는데, 우선 이런게 있다 정도만 알고 넘어가도 좋아요ㅎㅎ

emailInput.classList.remove('error');
emailError.innerText = ''; // 에러 메시지 제거
emailError.classList.remove('error_msg');
submitBtn.disabled = false;
submitBtn.style.backgroundColor = 'var(--blue100)'; // 원

}else if(!email){
emailError.innerText='이메일을 입력해주세요'
emailInput.classList.add('error');
emailError.classList.add('error_msg');
submitBtn.disabled=true;
}else{
emailError.innerText='유효한 이메일 형식이 아닙니다.'
emailInput.classList.add('error');
submitBtn.disabled=true;
}

}


function passwordChange(){
const pwInput = document.getElementById('password');
const pwError = document.getElementById('passwordError');
const submitBtn=document.querySelector('.button');
const password=pwInput.value;

if(!password){
pwError.innerText='비밀번호를 입력해주세요'
pwInput.classList.add('error');
pwError.classList.add('error_msg');
submitBtn.disabled=true;
}
else if(password.length<=8){
pwError.innerText='비밀번호를 8자 이상 입력해주세요';
pwInput.classList.add('error');
pwError.classList.add('error_msg');
submitBtn.disabled=true;
}
else{
pwInput.classList.remove('error');
pwError.innerText = ''; // 에러 메시지 제거
pwError.classList.remove('error_msg');
submitBtn.disabled = false;
submitBtn.style.backgroundColor = 'var(--blue100)'; // 원

}
Comment on lines +44 to +63
Copy link
Collaborator

Choose a reason for hiding this comment

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

꼼꼼하게 예외처리 잘 처리하신것같아요ㅎㅎ!
코드도 깔끔해서 읽기도 편하구요

}
37 changes: 37 additions & 0 deletions js/signup_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function nicknameChange(){
const nickname=document.getElementById('nickname');
const nameError=document.getElementById('nicknameError');
const name=nickname.value;

if(!name){
nickname.classList.add('error');
nameError.innerText='닉네임을 입력해주세요.';
submitBtn.disabled=true;
}else{
nickname.classList.remove('error');
nameError.innerText='';
submitBtn.disabled = false;
submitBtn.style.backgroundColor = 'var(--blue100)'; // 원

}

}

function passwordConfirm(){
const password=document.getElementById('password').value;
const confirmPw=document.getElementById('confirm_password');
const confirmPassword=confirmPw.value;
const confirmPasswordError=document.getElementById('confirm_password_Error');

if(password !== confirmPassword){
confirmPasswordError.innerText='비밀번호가 일치하지 않습니다'
confirmPw.classList.add('error');
submitBtn.disabled=true;
} else{
confirmPw.classList.remove('error');
confirmPasswordError.innerText='';
submitBtn.disabled = false;
submitBtn.style.backgroundColor = 'var(--blue100)'; // 원

}
}
25 changes: 14 additions & 11 deletions pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<link href="../styles/auth_style.css" rel="stylesheet" type="text/css">
<title>판다마켓</title>
</head>
<body class="body_divider">
<div class="divider"></div>
<body>
<div class="auth_box">
<div class="auth_logo">
<a href="/index.html">
Expand All @@ -20,20 +19,25 @@
<form class="auth_contents">
<div class="auth_content">
<label>이메일</label>
Copy link
Collaborator

Choose a reason for hiding this comment

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

                <label for="email">이메일</label>

이렇게 바꾸면 로그인을 클릭하더라도 email input에 포커스가 갈꺼에요ㅎㅎ!

<input class="info" type="text" name="name" placeholder="이메일을 입력해주세요">
<input id="email" class="info" type="text" name="name" placeholder="이메일을 입력해주세요" onblur="emailChange()">
<div id="emailError"></div>
</div>
<div class="auth_content pw">
<label>비밀번호</label>
<div class="auth_content">
<label for="password">비밀번호</label>
Copy link
Collaborator

Choose a reason for hiding this comment

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

아아 알고계신데 위에 이메일은 누락되신거군요ㅎㅎ

이미 알고계시다면 그냥 넘어가도 괜찮아요~!!

<div class="info_pw">
<input class="info" type="password" name="password" placeholder="비밀번호를 입력해주세요">
<div class="eye">
<img src="/images/btn_visibility_on_24px.svg">
<input id="password" class="info" type="password" name="password" placeholder="비밀번호를 입력해주세요" onblur="passwordChange()">
<div class="eye" onclick="onEyecliked()">
<img id="eye_img" onclick="onImgcliked()" src="/images/btn_visibility_on_24px.svg">
</div>
<div id="passwordError"></div>
<span></span>
</div>
</div>
<div>
<input class="button" type="submit" value="로그인">
<input class="button" type="button" value="로그인" onclick="location.href='/pages/items.html';">
Comment on lines -35 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

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

아직 form을 안배워서 submit 버튼이 되면 action이 발생되어서 원하는대로 동작이 안되시긴 할꺼에요...!

원래대로 submit이 맞고, form 태그로 감싸주는게 원래는맞아요ㅎㅎ;;

일단 이부분은 배우기 전이니 넘어가도 괜찮습니다!

</div>
<!-- 여기서 type을 submit에서 button으로 바꾸면 나중에 서버와 연동 할때 안되지 않나요,..
그러면 ,, -->
</form>

<div class="at_easy">
Expand All @@ -53,8 +57,7 @@
</a>
</div>
</div>
<div class="divider"></div>

<script src="/js/login_js.js"></script>
</body>
<script src="/js/javascript.js"></script>
</html>
26 changes: 15 additions & 11 deletions pages/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,36 @@
<form class="auth_contents">
<div class="auth_content">
<label>이메일</label>
<input class="info" type="text" name="name" placeholder="이메일을 입력해주세요">
<input id="email" class="info" type="text" name="name" placeholder="이메일을 입력해주세요" onblur="emailChange()">
<div id="emailError"></div>
</div>
<div class="auth_content">
<label>닉네임</label>
<input class="info" type="text" name="name" placeholder="닉네임을 입력해주세요">
<input id='nickname' class="info" type="text" name="name" placeholder="닉네임을 입력해주세요" onblur="nicknameChange()">
</div>
<div class="auth_content">
<label>비밀번호</label>
<label for="password">비밀번호</label>
<div class="info_pw">
<input class="info" type="password" name="password" placeholder="비밀번호를 입력해주세요">
<div class="eye">
<img src="/images/btn_visibility_on_24px.svg">
<input id="password" class="info" type="password" name="password" placeholder="비밀번호를 입력해주세요" onblur="passwordChange()">
<div class="eye" onclick="onEyecliked()">
<img id="eye_img" onclick="onImgcliked()" src="/images/btn_visibility_on_24px.svg">
Comment on lines +34 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

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

클릭했을때 onImgcliked 도 있고 onEyecliked 가 있는데 어떤게 맞는걸까요?

</div>
<div id="passwordError"></div>
</div>
</div>
<div class="auth_content">
<label>비밀번호 확인</label>
<div class="info_pw">
<input class="info" type="password" name="password" placeholder="비밀번호를 다시 한 번 입력해주세요">
<div class="eye">
<input id="confirm_password" class="info" type="password" name="confirm_password" placeholder="비밀번호를 다시 한 번 입력해주세요" onblur="passwordConfirm()">
<div class="eye" onclick="onEyecliked()">
<img src="/images/btn_visibility_on_24px.svg">
</div>
Comment on lines +44 to 46
Copy link
Collaborator

Choose a reason for hiding this comment

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

아래쪽꺼 눈 아이콘을 클릭해도 위에있는 비밀번호 input의 type이 바뀌는것같아요ㅠ

image

이 버그를 해겨결하기 위해선 비밀번호 확인에도 별도의 함수를 만들어주어야 겠네요...!ㅠ

근데 그렇게 하자니 너무 코드가 길어지고 중복되는 코드가 많아져서 보기 싫으실 수 있어요...ㅠㅠㅠ
저희가 그래서 part1에서 중복되는 코드를 줄이고자 모듈화 했던거 기억 나실꺼에요!

js도 모듈화를 할 수 있는데, 그건 멘토링때 같이 해보구요, 일단 회원가입 페이지에서 비밀번호확인쪽도 정상적으로 동작하도록 수정해보면 좋을것같아요!

제일 쉽게는 그냥 passwordConfirm을 위한 함수를 따로 만들어주면 되겠죠ㅎㅎ!

<div id="confirm_password_Error"></div>
</div>
<span></span>
</div>
<div>
<input class="button" type="submit" value="회원가입">
<input class="button" type="button" value="회원가입" onclick="location.href='/pages/login.html';">
</div>
</form>

Expand All @@ -66,7 +70,7 @@
</div>

</div>

<script src="/js/login_js.js"></script>
<script src="/js/signup_js.js"></script>
</body>
<script src="/js/javascript.js"></script>
</html>
60 changes: 41 additions & 19 deletions styles/auth_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@

.auth_logo{
padding-bottom: 40px;

}

.auth_contents{
display: flex;
flex-direction: column;
justify-content: left;
width:640px;
width:100%;
}

.auth_content > a{
Expand All @@ -47,9 +46,10 @@
gap:16px;
padding-top:12px;
padding-bottom:12px;
width: 640px;
width: 100%;
}


input:focus{
border-color:var(--blue100) ;
}
Expand All @@ -66,7 +66,7 @@ input:focus{
line-height: 26px;
text-align: left;

width:640px;
width:100%;
box-sizing: border-box;


Expand All @@ -92,7 +92,7 @@ input:focus{
cursor: pointer;
}
.button{
width: 640px;
width: 100%;
height: 56px;
border-radius: 40px;
border-style: none;
Expand All @@ -109,12 +109,12 @@ input:focus{
cursor:pointer;
}

.button:hover{
/* .button:hover{
background-color: var(--blue100);
}
} */

.at_easy{
width:640px;
width:100%;
background-color: #E6F2FF;
height: 74px;
border-radius: 8px;
Expand Down Expand Up @@ -154,22 +154,44 @@ input:focus{
cursor: pointer;
}

/*Mobile 미디어 쿼리*/


/* js에서 필요한 css */
.error{
border: 1px, solid, red;
display: block;
}

#emailError{
color:red;
}

#passwordError {
color: red;
margin-top: 15px; /* 입력란과 메시지 간의 간격 */
}

#nicknameError{
color:red;
}

#confirm_password_Error{
color: red;
margin-top: 15px;
}



/*Mobile 미디어 쿼리*/

@media(max-width:767px){
*{
.auth_box {
max-width: 400px;
}
}

.auth_logo > img{
.auth_logo > a > img{
width:198px;
height:66px;
}

}


/* 태블릿 미디어 쿼리는 불필요한 것 같아서 등록 안함,, 맞을까요,,?
@media (max-width: 1199px) and (min-width: 768px){

} */
}
7 changes: 6 additions & 1 deletion styles/index_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ header{
line-height: 19.09px;
}

.pf>a{
text-decoration: none;
color:var(--gray300);
}

.name{
color:#9CA3AF;
}
Expand Down Expand Up @@ -353,7 +358,7 @@ header{

.banner{
position: relative;
height: 771px;
padding-bottom:160px;
}

.banner_content{
Expand Down
Loading