Skip to content
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
45 changes: 45 additions & 0 deletions common-responsive.css
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;
}

}



77 changes: 77 additions & 0 deletions common.js
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(){
Copy link
Collaborator

Choose a reason for hiding this comment

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

checked로 이름 붙이신 이유가 있으실까요!? 함수명 자체가 명사나 과거형 처럼 보입니다 🤔
별거 아닌거 같지만, 함수가 어떤 일을 하는지 명확하게 이름 지어주는 것은 너무너무 중요합니다!
개발자 커뮤니티에서는 변수, 함수 이름 짓는 게 가장 어렵다는 밈이 돌기도 합니다 🤣

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] === ""){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

The 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");
}
}


Binary file added image/visibility_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions index-responsive.css
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;
}
}
11 changes: 6 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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="배너이미지">
Expand All @@ -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>

Expand All @@ -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>
Expand Down
8 changes: 6 additions & 2 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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">
Expand All @@ -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>
40 changes: 40 additions & 0 deletions login.js
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The 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');
Copy link
Collaborator

Choose a reason for hiding this comment

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


84 changes: 0 additions & 84 deletions responsive.css

This file was deleted.

5 changes: 4 additions & 1 deletion root.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
--gray50 : #f9fafb;
--blue:#3692ff;
--white:#ffffff;
}
--red :#F74747;
}


26 changes: 26 additions & 0 deletions sign-responsive.css
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;
}

}
Loading
Loading