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
28 changes: 16 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
<meta property="og:title" content="판다마켓">
<meta property="og:description" content="일상의 모든 물건을 거래해보세요">
<meta property="og:url" content="/">
Copy link
Collaborator

Choose a reason for hiding this comment

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

혹시나 싶어 남겨드립니다!
절대 경로 말씀드렸던 것은 og:url 부분이었습니다 🤣
해당 부분은 유저가 공유 카드를 클릭했을 때 이동할 url 입니다. 배포를 아직 안 하셨다면 안 넣으셔도 돼요! 참고만 해주세요 :)

<meta property="og:image" content="images/preview_panda.jpg">
<script src="/main.js"></script>
<meta property="og:image" content="/images/preview_panda.jpg">
</head>
<body>
<header class="flex-center" role="navigation">
<div class="container flex flex-between">
<a href="/" class="logo"></a>
<a href="/" class="logo">
<picture>
<source srcset="/images/logo.svg" media="(min-width:768px)"">
<img src="/images/logo_typo_only.svg" alt="판다마켓 로고">
</picture>
</a>
<a href="/login.html" class="button button--small-48">로그인</a>
</div>
</header>
Expand All @@ -27,11 +31,11 @@
<h1>일상의 모든 물건을 <br>거래해 보세요</h1>
<a href="/items" class="button button--large">구경하러 가기</a>
</div>
<img src="images/landing_top.svg" alt="판다마켓 랜딩 이미지">
<img src="/images/landing_top.svg" alt="판다마켓 랜딩 이미지">
</div>
</section>
<section class="section section--normal flex flex-left gap-64">
<img src="images/landing_01.svg" alt="판다마켓 랜딩 이미지">
<img src="/images/landing_01.svg" alt="판다마켓 랜딩 이미지">
<div class="text-left">
<h3 class="section__tag">Hot item</h3>
<h2>인기 상품을 <br>확인해 보세요</h2>
Expand All @@ -44,10 +48,10 @@ <h3 class="section__tag">Search</h3>
<h2>구매를 원하는 <br>상품을 검색하세요</h2>
<p class="description">구매하고 싶은 물품은 검색해서<br>쉽게 찾아보세요</p>
</div>
<img src="images/landing_02.svg" alt="판다마켓 랜딩 이미지">
<img src="/images/landing_02.svg" alt="판다마켓 랜딩 이미지">
</section>
<section class="section section--normal flex flex-left gap-64">
<img src="images/landing_03.svg" alt="판다마켓 랜딩 이미지">
<img src="/images/landing_03.svg" alt="판다마켓 랜딩 이미지">
<div class="text-left">
<h3 class="section__tag">Register</h3>
<h2>판매를 원하는 <br>상품을 등록하세요</h2>
Expand All @@ -59,7 +63,7 @@ <h2>판매를 원하는 <br>상품을 등록하세요</h2>
<div class="text-left">
<h2>믿을 수 있는<br>판다마켓 중고 거래</h2>
</div>
<img src="images/landing_bottom.svg" alt="판다마켓 랜딩 이미지">
<img src="/images/landing_bottom.svg" alt="판다마켓 랜딩 이미지">
</div>
</section>
</main>
Expand All @@ -70,10 +74,10 @@ <h2>믿을 수 있는<br>판다마켓 중고 거래</h2>
<a href="/faq">FAQ</a>
</div>
<div class="flex gap-12">
<a class="icon icon--18" href="https://www.facebook.com" target="_blank" style="background-image: url(images/ico_facebook.svg);"></a>
<a class="icon icon--18" href="https://www.twitter.com" target="_blank" style="background-image: url(images/ico_twitter.svg);"></a>
<a class="icon icon--18" href="https://www.youtube.com" target="_blank" style="background-image: url(images/ico_youtube.svg);"></a>
<a class="icon icon--18" href="https://www.instagram.com" target="_blank" style="background-image: url(images/ico_instagram.svg);"></a>
<a class="icon icon--18" aria-label="페이스북 계정 방문하기" href="https://www.facebook.com" target="_blank" style="background-image: url(/images/ico_facebook.svg);"></a>
<a class="icon icon--18" aria-label="트위터 계정 방문하기" href="https://www.twitter.com" target="_blank" style="background-image: url(/images/ico_twitter.svg);"></a>
<a class="icon icon--18" aria-label="유튜브 채널 방문하기" href="https://www.youtube.com" target="_blank" style="background-image: url(/images/ico_youtube.svg);"></a>
<a class="icon icon--18" aria-label="인스타그램 계정 방문하기" href="https://www.instagram.com" target="_blank" style="background-image: url(/images/ico_instagram.svg);"></a>
</div>
</footer>
</body>
Expand Down
11 changes: 7 additions & 4 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
</head>
<body class="sign">
<div class="sign-container">
<a href="/" class="logo"></a>
<a href="/" class="logo"><img src="/images/logo.svg"></a>
<form class="sign-form" action="">
<label for="email">이메일</label>
<input class="sign-form__input" placeholder="이메일을 입력해주세요" type="text" name="email" id="email">
<span class="sign-form__input__msg hide" id="msg-email">이메일을 입력해주세요</span>
<label for="password">비밀번호</label>
<div class="password-container">
<input class="sign-form__input" placeholder="비밀번호를 입력해주세요" type="password" name="password" id="password">
<button id="password__toggle" class="icon icon--24" type="button" style="background-image: url(images/ico_eye-close.svg);"></button>
<button id="show-password" class="icon icon--24 show-password password-hide" type="button"></button>
</div>
<input class="button button--wide" type="submit" value="로그인">
<span class="sign-form__input__msg hide" id="msg-password">비밀번호를 입력해주세요</span>
<input disabled class="button button--wide" type="submit" id="submit" value="로그인">
</form>
<div class="social-log-wrap">
<p class="social-log-wrap__title">간편 로그인하기</p>
Expand All @@ -30,4 +32,5 @@
</footer>
</div>
</body>
</html>
</html>
<script src="/login.js" type="module"></script>
44 changes: 44 additions & 0 deletions login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { showInputError, hideInputError, regEmail } from "/sign.js";

const email = document.querySelector('#email');
const password = document.querySelector('#password');
const showPassword = document.querySelector('.show-password');

email.addEventListener('focusout', (e) => {
const value = e.target.value;

if (!value) { showInputError('email', '이메일을 입력해주세요'); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

이왕 분리하신 거 공통으로 사용되는 유효성 검사, 메세지 등도 따로 관리해 보시는 것도 좋겠네요 🤣 (참고만 해주세요!)

else if (!regEmail.test(value)){ showInputError('email', '잘못된 이메일 형식입니다'); }
else { hideInputError('email'); };
});

password.addEventListener('focusout', (e) => {
const value = e.target.value;

if (!value) { showInputError('password', '비밀번호를 입력해주세요'); }
else if (value.length < 8){ showInputError('password', '비밀번호를 8자 이상 입력해주세요'); }
else { hideInputError('password'); };
});

showPassword.addEventListener('mousedown', (e) => {
const sibling = e.target.previousElementSibling;
e.target.classList.remove('password-hide');
sibling.type = 'text';
});

showPassword.addEventListener('mouseup', (e) => {
const sibling = e.target.previousElementSibling;
e.target.classList.add('password-hide');
sibling.type = 'password';
});

showPassword.addEventListener('mouseleave', (e) => {
const sibling = e.target.previousElementSibling;
e.target.classList.add('password-hide');
sibling.type = 'password';
});

document.querySelector('.sign-form').addEventListener('submit', (e) => {
e.preventDefault();
window.location.href = '/items';
});
14 changes: 0 additions & 14 deletions main.js

This file was deleted.

32 changes: 32 additions & 0 deletions sign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const errorClass = 'sign-form__input--error';
Copy link
Collaborator

Choose a reason for hiding this comment

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

상수는 보통 대문자를 사용합니다!

const ERROR_CLASS = 'sign-form__input--error';

export const regEmail = /^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
Copy link
Collaborator

Choose a reason for hiding this comment

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

정규표현식을 쓰셨군요! 👍


export function showInputError(id, text) {
const input = document.querySelector(`#${id}`);
const inputMsg = document.querySelector(`#msg-${id}`);

input.classList.add(errorClass);
inputMsg.classList.remove('hide');
inputMsg.innerHTML = text;

checkValidity();
Copy link
Collaborator

Choose a reason for hiding this comment

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

언제나 그럴 수는 없지만 함수는 단일 책임을 가지는 것이 좋습니다~! 또한 이름을 명확하게 지어주는 것이 좋아요.
이름만 봤을 때 showInputError 의 역할은 input의 error ui를 보여주는 거 같은데, 실제로는 form 전체 에러 상태와 버튼 상태까지 관리하고 있습니다. 로직이 숨겨지게 되는 거죠!

지금은 충분히 잘하셨고 간단한 코드라 괜찮습니다 :) 참고만 해주세요~!

}

export function hideInputError(id) {
const input = document.querySelector(`#${id}`);
const inputMsg = document.querySelector(`#msg-${id}`);

input.classList.remove(errorClass);
inputMsg.classList.add('hide');

checkValidity();
}

function checkValidity() {
const confirm = document.querySelector('#submit');
let empty = false;
document.querySelectorAll(`.sign-form__input`).forEach((input) => {
if (!input.value) { empty = true; };
});
confirm.disabled = empty || (document.querySelectorAll(`.${errorClass}`).length > 0);
}
27 changes: 16 additions & 11 deletions signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@
</head>
<body class="sign">
<div class="sign-container">
<a href="/" class="logo"></a>
<a href="/" class="logo"><img src="/images/logo.svg"></a>
<form class="sign-form" action="">

<label for="email">이메일</label>
<input class="sign-form__input" placeholder="이메일을 입력해주세요" type="text" name="email" id="email">
<input class="sign-form__input" autocomplete="email" placeholder="이메일을 입력해주세요" type="text" name="email" id="email">
<span class="sign-form__input__msg hide" id="msg-email">이메일을 입력해주세요</span>

<label for="name">닉네임</label>
<input class="sign-form__input" placeholder="닉네임을 입력해주세요" type="text" name="name" id="name">
<label for="nickname">닉네임</label>
<input class="sign-form__input" autocomplete="username" placeholder="닉네임을 입력해주세요" type="text" name="name" id="nickname">
<span class="sign-form__input__msg hide" id="msg-nickname">닉네임을 입력해주세요</span>

<label for="password">비밀번호</label>
<div class="password-container">
<input class="sign-form__input" placeholder="비밀번호를 입력해주세요" type="password" name="password" id="password">
<button id="password__toggle" class="icon icon--24" type="button" style="background-image: url(images/ico_eye-close.svg);"></button>
<input class="sign-form__input" autocomplete="new-password" placeholder="비밀번호를 입력해주세요" type="password" name="password" id="password">
<button class="icon icon--24 show-password password-hide" type="button"></button>
</div>
<span class="sign-form__input__msg hide" id="msg-password">비밀번호를 입력해주세요</span>

<label for="password--check">비밀번호 확인</label>
<label for="confirm-password">비밀번호 확인</label>
<div class="password-container">
<input class="sign-form__input" placeholder="비밀번호를 다시 한 번 입력해주세요" type="password" name="password--check" id="password--check">
<button id="password__toggle" class="icon icon--24" style="background-image: url(images/ico_eye-close.svg);"></button>
<input class="sign-form__input" autocomplete="new-password" placeholder="비밀번호를 다시 한 번 입력해주세요" type="password" name="confirm-password" id="confirm-password">
<button class="icon icon--24 show-password password-hide" type="button"></button>
</div>
<span class="sign-form__input__msg hide" id="msg-confirm-password">비밀번호가 일치하지 않습니다</span>

<input class="button button--wide" type="submit" value="회원가입">
<input disabled class="button button--wide" type="submit" id="submit" value="회원가입">
</form>
<div class="social-log-wrap">
<p class="social-log-wrap__title">간편 로그인하기</p>
Expand All @@ -41,4 +45,5 @@
</footer>
</div>
</body>
</html>
</html>
<script src="/signup.js" type="module"></script>
69 changes: 69 additions & 0 deletions signup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { showInputError, hideInputError, regEmail } from "/sign.js";

const email = document.querySelector('#email');
const password = document.querySelector('#password');
const confirmPassword = document.querySelector('#confirm-password');
const showPasswords = document.querySelectorAll('.show-password');
const nickname = document.querySelector('#nickname');

email.addEventListener('focusout', (e) => {
const value = e.target.value;

if (!value) { showInputError('email', '이메일을 입력해주세요'); }
else if (!regEmail.test(value)){ showInputError('email', '잘못된 이메일 형식입니다'); }
else { hideInputError('email'); };
});

nickname.addEventListener('focusout', (e) => {
const value = e.target.value;

if (!value) { showInputError('nickname', '닉네임을 입력해주세요'); }
else { hideInputError('nickname'); };
});

password.addEventListener('focusout', (e) => {
const value = e.target.value;

if (!value) { showInputError('password', '비밀번호를 입력해주세요'); }
else if (value.length < 8){ showInputError('password', '비밀번호를 8자 이상 입력해주세요'); }
else { hideInputError('password'); };

//Check confirm password again
if ((value != confirmPassword.value) && (document.querySelector('.activated'))) { showInputError('confirm-password', '비밀번호가 일치하지 않습니다'); }
else { hideInputError('confirm-password'); };
});

showPasswords.forEach((showPassword) => {
showPassword.addEventListener('mousedown', (e) => {
const sibling = e.target.previousElementSibling;
e.target.classList.remove('password-hide');
sibling.type = 'text';
});

showPassword.addEventListener('mouseup', (e) => {
const sibling = e.target.previousElementSibling;
e.target.classList.add('password-hide');
sibling.type = 'password';
});

showPassword.addEventListener('mouseleave', (e) => {
const sibling = e.target.previousElementSibling;
e.target.classList.add('password-hide');
sibling.type = 'password';
});
});

confirmPassword.addEventListener('focusout', (e) => {
const value = e.target.value;
e.target.classList.add('activated');
Copy link
Collaborator

Choose a reason for hiding this comment

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

잘못 들어간 걸까요? 🤔


if (value != password.value) { showInputError('confirm-password', '비밀번호가 일치하지 않습니다'); }
else { hideInputError('confirm-password'); };
});

document.querySelector('.sign-form').addEventListener('submit', (e) => {
e.preventDefault();

//회원가입을 끝냈는데 다시 회원가입으로 가는 게 이상해서 로그인으로 변경했습니다.
window.location.href = '/login.html';
});
17 changes: 12 additions & 5 deletions styles/global.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading