-
Notifications
You must be signed in to change notification settings - Fork 31
[나예진] Sprint 4 #55
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-\uB098\uC608\uC9C4-sprint4"
[나예진] Sprint 4 #55
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* common */ | ||
| @media (min-width:375px)and (max-width:1199px){ | ||
| footer-div{ | ||
| flex-flow:wrap; | ||
| } | ||
| .main-left, .main-right { | ||
| width: 100%; | ||
| background-color: #ffffff; | ||
| flex-wrap: wrap; | ||
| } | ||
| .main-div, .main-div-right { | ||
| padding: 0 20px; | ||
| } | ||
| .main-img{ | ||
| width: 100%; | ||
| } | ||
| .top-section { | ||
| height: auto; | ||
| } | ||
| .top-div{ | ||
| flex-direction: column; | ||
| align-items: center; | ||
| } | ||
| .top-content{ | ||
| width: 100%; | ||
| } | ||
| .content { | ||
| width: 100%; | ||
| height: 300px; | ||
| text-align: center; | ||
| } | ||
| .img-home{ | ||
| width: 100%; | ||
| } | ||
| .footer-div { | ||
| flex-flow:wrap; | ||
| } | ||
| .br-none{ | ||
| display: none; | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| export const pwd = document.getElementById('login-pwd'); | ||
| export const email = document.getElementById('login-email'); | ||
| export const nick = document.getElementById('login-nickname'); | ||
| export const confirmPwd = document.getElementById('login-pwd-confirm'); | ||
| export const loginBtn = document.getElementById('login-btn'); | ||
| export const signBtn= document.getElementById('sign-btn'); | ||
| export const visibilityIcon = document.querySelectorAll(".visibility-off"); | ||
|
|
||
| // 에러 메세지 추가 | ||
| export function addErrorMessage(target,message) { | ||
| removeErrorMessage(target); | ||
| const error = document.createElement("div"); | ||
| error.textContent= message; | ||
| error.classList.add("alert-empty"); | ||
| target.classList.add("empty"); | ||
| target.after(error); | ||
| } | ||
|
|
||
| // 에러 메세지 삭제 | ||
| export function removeErrorMessage(target){ | ||
| const error = target.nextElementSibling; | ||
| if(error && error.classList.contains("alert-empty")){ | ||
| error.remove(); | ||
| } | ||
| target.classList.remove("empty"); | ||
| } | ||
|
|
||
| // 비밀번호 체크 | ||
| export function checkedPwd(){ | ||
| if(pwd.value==''){ | ||
| addErrorMessage(pwd,'비밀번호를 입력해주세요'); | ||
| }else if (pwd.value.length < 8) { | ||
| addErrorMessage(pwd, "비밀번호를 8자 이상 입력해주세요"); | ||
| } | ||
| } | ||
|
|
||
| // 이메일 체크 | ||
| export function checkedEmail(){ | ||
| if(email.value===''){ | ||
| addErrorMessage(email,'이메일을 입력해주세요'); | ||
| }else if(!email.value.includes('@')||email.value.split("@")[1] === ""||email.value.split("@")[0] === ""){ | ||
|
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. 정규표현식을 써보시는 것도 좋습니다 :) |
||
| addErrorMessage(email,'잘못된 이메일 형식입니다.') | ||
| } | ||
| } | ||
|
|
||
| // 비밀번호 확인 | ||
| export function confirmPassword() { | ||
|
|
||
| if (confirmPwd.value === "") { | ||
| addErrorMessage(confirmPwd, "비밀번호를 입력해주세요"); | ||
| } else if (pwd.value !== confirmPwd.value) { | ||
| addErrorMessage(confirmPwd, "비밀번호가 일치하지 않습니다."); | ||
| } | ||
| } | ||
|
|
||
| // 닉네임 체크 | ||
| export function checkedNickname(){ | ||
| if(nick.value===''){ | ||
| addErrorMessage(nick,'닉네임을 입력해주세요'); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // 비밀번호 보이기 아이콘 변화 | ||
| export function visibileIcon(event,icon,input) { | ||
| event.preventDefault(); | ||
| icon.classList.toggle("on"); | ||
|
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. on 클래스에 따로 스타일은 없는 거 같은데, 단순히 상태 구분 목적이라면 icon.type === 'text' 등을 활용할 수 있습니다! |
||
| if (icon.classList.contains("on")) { | ||
| icon.setAttribute("src", "image/visibility_on.png"); | ||
| input.setAttribute("type", "text"); | ||
| } else { | ||
| icon.setAttribute("src", "image/visibility_off.png"); | ||
| input.setAttribute("type", "password"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* Mobile */ | ||
| @media (min-width:375px) and (max-width:767px){ | ||
| .main-header-div { | ||
| margin: 0 16px; | ||
| } | ||
| .img-home{ | ||
| width: 100%; | ||
| } | ||
|
|
||
| } | ||
| /* Tablet */ | ||
| @media (min-width:768px) and (max-width:1199px){ | ||
| .main-header-div { | ||
| margin: 0 24px; | ||
| } | ||
| .main-left, .main-right { | ||
| max-width: 900px; | ||
| } | ||
| .br-none-title { | ||
| display: none; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,8 @@ | |
| <meta property="og:description" content="일상의 모든 물건을 거래해보세요"> | ||
|
|
||
| <link rel="stylesheet" href="style.css"> | ||
| <link rel="stylesheet" href="responsive.css"> | ||
| <link rel="stylesheet" href="common-responsive.css"> | ||
| <link rel="stylesheet" href="index-responsive.css"> | ||
| <link rel="stylesheet" href="root.css"> | ||
| <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css" /> | ||
| </head> | ||
|
|
@@ -23,7 +24,7 @@ | |
| <section class="top-section"> | ||
| <div class="top-div"> | ||
| <div class="content"> | ||
| <div class="top-content">일상의 모든 물건을<br>거래해 보세요</div> | ||
| <div class="top-content">일상의 모든 물건을<br class="br-none-title">거래해 보세요</div> | ||
| <a href="/items.html" class="top-btn">구경하러 가기</a> | ||
| </div> | ||
| <img src="image/img_home.png" class="img-home" alt="배너이미지"> | ||
|
|
@@ -34,15 +35,15 @@ | |
| <img src="image/main_01.png" class="main-img" alt="첫 번째 본문 이미지"> | ||
| <div class="main-div"> | ||
| <div class="title">Hot Item</div> | ||
| <div class="main-content-bold">인기 상품을<br> 확인해 보세요</div> | ||
| <div class="main-content-bold">인기 상품을<br class="br-none"> 확인해 보세요</div> | ||
| <div class="main-content">가장 HOT한 중고거래 물품을<br> 판다 마켓에서 확인해 보세요</div> | ||
| </div> | ||
| </div> | ||
| <div class="main-right"> | ||
| <img src="image/main_02.png" class="main-img" alt="두 번째 본문 이미지"> | ||
| <div class="main-div-right"> | ||
| <div class="title">Search</div> | ||
| <div class="main-content-bold">구매를 원하는<br>상품을 검색하세요</div> | ||
| <div class="main-content-bold">구매를 원하는<br class="br-none">상품을 검색하세요</div> | ||
| <div class="main-content">구매하고 싶은 물품은 검색해서<br> 쉽게 찾아보세요</div> | ||
| </div> | ||
|
|
||
|
|
@@ -51,7 +52,7 @@ | |
| <img src="image/main_03.png" class="main-img" alt="세 번째 본문 이미지"> | ||
| <div class="main-div"> | ||
| <div class="title">Register</div> | ||
| <div class="main-content-bold">판매를 원하는<br> 상품을 등록하세요</div> | ||
| <div class="main-content-bold">판매를 원하는<br class="br-none"> 상품을 등록하세요</div> | ||
| <div class="main-content">어떤 물건이든 판매하고 싶은 상품을<br> 쉽게 등록하세요</div> | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,12 @@ | |
| <head> | ||
| <meta charset="utf-8"> | ||
| <link rel="stylesheet" href="sign.css"> | ||
| <link rel="stylesheet" href="responsive.css"> | ||
| <link rel="stylesheet" href="common-responsive.css"> | ||
| <link rel="stylesheet" href="sign-responsive.css"> | ||
| <link rel="stylesheet" href="root.css"> | ||
| <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css" /> | ||
| <title>로그인</title> | ||
|
|
||
| </head> | ||
| <body class="sign-body"> | ||
| <a href="/"><img src="image/logo_large.png" alt="로그인 로고" class="sign-logo"></a> | ||
|
|
@@ -25,7 +27,7 @@ | |
| placeholder="비밀번호를 입력해주세요" class="sign-form-input" required/> | ||
| <img src="image/visibility_off.png" class="visibility-off" alt="비밀번호 숨기기"> | ||
| </div> | ||
| <button class="sign-btn">로그인</button> | ||
| <a class="sign-btn" id="login-btn">로그인</a> | ||
|
|
||
| </form> | ||
| <div class="simple-login-div"> | ||
|
|
@@ -38,5 +40,7 @@ | |
| <div class="footer">판다마켓이 처음이신가요? | ||
| <a href="/signup.html" class="footer-signup-link">회원가입</a> | ||
| </div> | ||
| <script type="module" src="login.js"></script> | ||
| </body> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import {pwd,email,loginBtn,visibilityIcon} from './common.js' | ||
| import {removeErrorMessage,visibileIcon,checkedPwd,checkedEmail} from './common.js' | ||
|
|
||
| // 비밀번호 체크 | ||
| pwd.addEventListener('focusout',checkedPwd); | ||
| pwd.addEventListener("focusin", () => removeErrorMessage(pwd)); | ||
|
|
||
| // 이메일 체크 | ||
| email.addEventListener("focusout",checkedEmail); | ||
| email.addEventListener('focusin',()=>removeErrorMessage(email)); | ||
|
|
||
| // 비밀번호 보이기 아이콘 변화 | ||
| visibilityIcon.forEach((icon,i) => { | ||
| icon.addEventListener("mousedown", ()=>visibileIcon(event, | ||
|
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. icon.addEventListener("mousedown", (event)=>visibileIcon(event,
visibilityIcon[i]
,visibilityIcon[i].parentElement.firstElementChild));event객체를 명시적으로 넘겨주세요! 현재는 콜백 함수로 전달되는 이벤트 객체가 아니라 전역에 존재하는 window.event에 접근하는 거 같네요..! 전역에서 관리되는 요소들은 다른 로직과 충돌 될 수 있습니다. |
||
| visibilityIcon[i] | ||
| ,visibilityIcon[i].parentElement.firstElementChild)); | ||
| }); | ||
|
|
||
| // 로그인 버튼 체크 | ||
| function blockLoginBtn(){ | ||
| if(document.querySelector('.alert-empty')||email.value==='' | ||
| || !email.value.includes('@')||email.value.split("@")[1] === ""||email.value.split("@")[0] === "" | ||
| ||pwd.value==''||pwd.value.length < 8){ | ||
| loginBtn.classList.remove('ok-btn') | ||
| loginBtn.removeAttribute('href'); | ||
|
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. 지금은 a tag로 되어 있는데, 로그인을 하면 단순히 페이지 이동을 시키는 것이 아니라 서버에 로그인 요청을 보내게 될 거에요! 해당 로직을 처리하는 태그로는 button이 적절합니다 :) |
||
| }else{ | ||
| loginBtn.classList.add('ok-btn') | ||
| loginBtn.setAttribute('href','items.html') | ||
| } | ||
| } | ||
|
|
||
| loginBtn.addEventListener('click',()=>{ | ||
| checkedEmail(); | ||
| checkedPwd(); | ||
| blockLoginBtn(); | ||
| }); | ||
|
|
||
| loginBtn.addEventListener('mouseover',blockLoginBtn); | ||
|
|
||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,7 @@ | |
| --gray50 : #f9fafb; | ||
| --blue:#3692ff; | ||
| --white:#ffffff; | ||
| } | ||
| --red :#F74747; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* Mobile */ | ||
| @media (min-width:375px) and (max-width:767px) { | ||
| .sign-body { | ||
| width: 100%; | ||
| padding-left: 16px; | ||
| padding-right: 16px; | ||
| } | ||
| .sign-logo{ | ||
| width: 55%; | ||
| height: 20%; | ||
| } | ||
|
|
||
| .sign-form * , .sign-logo { | ||
| max-width: 400px; | ||
| display: block; | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| } | ||
|
|
||
| .simple-login-div{ | ||
| max-width: 400px; | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| } | ||
|
|
||
| } |
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.
checked로 이름 붙이신 이유가 있으실까요!? 함수명 자체가 명사나 과거형 처럼 보입니다 🤔
별거 아닌거 같지만, 함수가 어떤 일을 하는지 명확하게 이름 지어주는 것은 너무너무 중요합니다!
개발자 커뮤니티에서는 변수, 함수 이름 짓는 게 가장 어렵다는 밈이 돌기도 합니다 🤣