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
Binary file modified .DS_Store
Binary file not shown.
43 changes: 24 additions & 19 deletions css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,28 @@ body {
line-height: 1.4;
}

.iogin_title {
.login_title {
margin: 0 0 16px;
}

.login_input_field::placeholder {
.input_field::placeholder {
font-family: Pretendard, sans-serif;
font-size: 1rem;
font-weight: 400;
line-height: 1.6;
}

.login_input_field {
.input_field {
width: 100%;
background: var(--gray100);
font: 400 1rem;
color: var(--Secondary800);
padding: 16px 24px;
border: 0;
border-radius: 12px;
}

.login_input_field:focus {
.input_field:focus {
outline: none;
}

Expand All @@ -82,17 +84,22 @@ body {
transform: translateY(-50%);
}

.ic_eyes {
.password_toggle {
display: inline-block;
width: 100%;
height: 100%;
background-image: url(../icon/ic_passwrod_hide.svg);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
background-color: transparent;
border: none;
}

.error_msg {
margin: 8px 0 0 16px;
font-size: 0.875rem;
font-weight: 600;
line-height: 1.5;
color: var(--errorMsg);
}

.connection_info {
text-align: center;
}
Expand All @@ -105,10 +112,15 @@ body {
font-weight: 600;
color: var(--gray100);
line-height: 2;
background: var(--Secondary400);
background: var(--blue);
border: none;
border-radius: 40px;
}

.connection_button:disabled {
background: var(--Secondary400);
}

.simple_login {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -153,13 +165,6 @@ body {
color: var(--blue);
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1200px) {
.connection_button {
background: var(--Secondary400);
}
}

/* Mobile */
@media (min-width: 375px) and (max-width: 767px) {
.container {
Expand Down Expand Up @@ -189,11 +194,11 @@ body {
font-size: 0.875rem;
}

.iogin_title {
.login_title {
margin: 0 0 8px;
}

.login_input_field {
.input_field {
width: 100%;
background: var(--gray100);
padding: 16px 24px;
Expand Down
4 changes: 3 additions & 1 deletion css/palette.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:root {
--blue: #3692ff;
--Secondary400: #9ca3af;
--Secondary800: #1f2937;
--gray900: #111827;
Comment on lines +3 to 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

(제안) 컬러 팔레트 변수명도 일관성있는 컨벤션으로 작성하는게 어떨까요 ? 😉

Suggested change
--Secondary400: #9ca3af;
--Secondary800: #1f2937;
--gray900: #111827;
--secondary400: #9ca3af;
--secondary800: #1f2937;
--gray900: #111827;

--gray800: #1f2937;
--gray700: #374151;
Expand All @@ -14,6 +16,6 @@
:root {
--white: #ffffff;
--black: #111111;
--Secondary400: #9ca3af;
--skyblue: #e6f2ff;
--errorMsg: #f74747;
}
6 changes: 6 additions & 0 deletions css/reset.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ acronym {
a {
text-decoration: none;
}

button {
cursor: pointer;
border: none;
background-color: transparent;
}
45 changes: 18 additions & 27 deletions css/signup.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ body {
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
height: 100%;
background: var(--white);
}

Expand Down Expand Up @@ -50,22 +50,24 @@ body {
margin: 0 0 16px;
}

.sign_input_field::placeholder {
.input_field::placeholder {
font-family: Pretendard, sans-serif;
font-size: 1rem;
font-weight: 400;
line-height: 1.6;
}

.sign_input_field {
.input_field {
width: 100%;
background: var(--gray100);
font: 400 1rem;
color: var(--Secondary800);
padding: 16px 24px;
border: 0;
border-radius: 12px;
}

.sign_input_field:focus {
.input_field:focus {
outline: none;
}

Expand All @@ -82,25 +84,18 @@ body {
transform: translateY(-50%);
}

.ic_eyes {
.password_toggle {
display: inline-block;
width: 100%;
height: 100%;
border: none;
}

.hide {
background-image: url(../icon/ic_passwrod_hide.svg);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}

.open {
background-image: url(../icon/ic_passwrod_open.svg);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
.error_msg {
margin: 8px 0 0 16px;
font-size: 0.875rem;
font-weight: 600;
line-height: 1.5;
color: var(--errorMsg);
}

.connection {
Expand All @@ -115,10 +110,14 @@ body {
font-weight: 600;
color: var(--gray100);
line-height: 2;
background: var(--Secondary400);
background: var(--blue);
border-radius: 40px;
}

.connection_button:disabled {
background: var(--Secondary400);
}

.simple_login {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -199,12 +198,4 @@ body {
.sign_title {
margin: 0 0 8px;
}

/* open 이미지 hide로 변겨 */
.open {
background-image: url(../icon/ic_passwrod_hide.svg);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
}
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
<title>판다마켓</title>
<meta property="og:title" content="판다마켓" />
<meta property="og:description" content="일상의 모든 물건을 거래해보세요" />
<meta property="og:image" content="./image/Landing_Page_img" />
<meta property="og:url" content="pandamakert.netlify.app" />
<meta property="og:image" content="/image/Landing_Page_img.png" />
<meta property="og:url" content="http://pandamakert.netlify.app" />
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.

굿굿 ! 메타 태그를 적절하게 수정하셨군요 ! 👍

Suggested change
<meta property="og:image" content="/image/Landing_Page_img.png" />
<meta property="og:url" content="http://pandamakert.netlify.app" />
<meta property="og:image" content="/image/Landing_Page_img.png" />
<meta property="og:url" content="https://pandamakert.netlify.app" />

그런데 프로토콜에 s가 빠진 것 같아요 !
물론 http로 접근해도 리다이렉트(https로) 되긴 하겠으나 정확한 URL이 더 낫겠죠 ?😊

<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/reset.css" />
<link
rel="stylesheet"
type="text/css"
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css"
/>
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
</head>
<body>
<!-- Header -->
Expand Down
88 changes: 88 additions & 0 deletions js/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {
form,
userEmail,
userPassword,
submitButton,
emailErrorMsg,
pwErrorMsg,
pwToggle,
errMsg,
changeImg,
} from "./shared_variable.js";

form.addEventListener("submit", (e) => {
e.preventDefault();
window.location.href = "/item";
});
Comment on lines +13 to +16
Copy link
Collaborator

Choose a reason for hiding this comment

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

크으 ~ 제출 이벤트 리스너를 추가하셨군요 ! 👍

이벤트 객체를 활용한 e.preventDefault();도 너무 좋습니다 !

제출에 이벤트 리스너를 추가하면 접근성은 물론이고 브라우저의 기본 사용자 경험인 엔터나 제출 버튼 클릭 모두 유효하겠어요 👍


// error messsage show
function showError(inputEle, errorEle, message) {
inputEle.style.border = "1px solid #f74747";
errorEle.innerHTML = message;
errorEle.style.display = "block";
}

// error message hide
function hideError(inputEle, errorEle) {
inputEle.style.border = "none";
errorEle.style.display = "none";
}

// 이메일 focusout
userEmail.addEventListener("focusout", () => {
if (userEmail.value === "") {
showError(userEmail, emailErrorMsg, errMsg.id.voidOut.trim());
} else if (!emailCheck(userEmail.value)) {
showError(userEmail, emailErrorMsg, errMsg.id.fail.trim());
} else {
hideError(userEmail, emailErrorMsg);
}
activeButton();
});

// 이메일 정규 표현식 체크
function emailCheck(value) {
const emailRegex =
/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;

return emailRegex.test(value);
}
Comment on lines +44 to +49
Copy link
Collaborator

Choose a reason for hiding this comment

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

함수 이름은 동사로 짓는게 어떨까요?

Suggested change
function emailCheck(value) {
const emailRegex =
/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
return emailRegex.test(value);
}
function checkEmail(value) { // 혹은 validateEmail
const emailRegex =
/^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
return emailRegex.test(value);
}

일반적으로 변수는 명사, 함수는 동사로 지어요.
boolean의 경우 isValidEmail와 같이 is, are, has로 시작하기도 합니다. =)

함수의 경우 다음과 같은 단어들이 접두사가 될 수 있어요:

  • get
  • fetch
  • push
  • update
  • create
  • calculate
  • set
  • 등등 ...

일반적인 네이밍 컨벤션 보기

Comment on lines +44 to +49
Copy link
Collaborator

Choose a reason for hiding this comment

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

크으 ~ 순수 함수를 구현하시다니 👍

해당 함수는 입력값(email)이 같으면 언제나 같은 결과(true/false)를 반환하고 외부 상태에 영향을 주거나 의존하지도 않아요.
이런 함수를 “순수 함수(Pure Function)” 라고 부릅니다.

이러한 구조는 테스트하기도 쉽고, 예측 가능한 코드 작성에 도움이 되는 좋은 패턴입니다.
지금처럼 유틸리티 함수를 순수하게 분리해 작성하는 습관, 정말 잘 하고 계세요! 🔥


// 비밀번호 focusout
userPassword.addEventListener("focusout", () => {
if (userPassword.value.length === 0) {
showError(userPassword, pwErrorMsg, errMsg.pw.voidOut.trim());
} else if (userPassword.value.length < 8) {
showError(userPassword, pwErrorMsg, errMsg.pw.fail.trim());
} else {
hideError(userPassword, pwErrorMsg);
}
activeButton();
});

// 버튼 활성화
function activeButton() {
if (emailCheck(userEmail.value) && userPassword.value.length >= 8) {
submitButton.disabled = false;
} else {
submitButton.disabled = true;
}
}
Comment on lines +64 to +70
Copy link
Collaborator

Choose a reason for hiding this comment

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

다음과 같이 작성해볼 수 있을 것 같아요 !

Suggested change
function activeButton() {
if (emailCheck(userEmail.value) && userPassword.value.length >= 8) {
submitButton.disabled = false;
} else {
submitButton.disabled = true;
}
}
function activeButton() {
const isValidEmail = emailCheck(userEmail.value) && userPassword.value.length >= 8;
submitButton.disabled = isValidEmail;
}

이렇게 하면 별칭(isValidEmail)으로 인해 가독성도 좋아지고, 조건 분기를 사용하지 않고 조건 자체를 값으로 대입해 볼 수 있어요 !


// 비밀번호 보기
pwToggle.forEach((button) => {
button.addEventListener("click", (target) => {
const clickBtn = target.currentTarget;
const parentEle = clickBtn.closest(".flex_item");
const targetInput = parentEle.querySelector(".input_field");
const img = clickBtn.querySelector(".pw-icon");

if (targetInput.type === "password") {
targetInput.type = "text";
img.src = changeImg.show;
} else {
targetInput.type = "password";
img.src = changeImg.hide;
}
});
});
27 changes: 27 additions & 0 deletions js/shared_variable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const form = document.querySelector(".form_contorl");
export const userEmail = document.querySelector("#user_email");
export const userPassword = document.querySelector("#user_password");
export const submitButton = document.querySelector(".connection_button");
export const emailErrorMsg = document.querySelector(".info_email .error_msg");
export const pwErrorMsg = document.querySelector(".info_password .error_msg");
export const pwToggle = document.querySelectorAll(".password_toggle");

export const errMsg = {
id: {
voidOut: "이메일을 입력해주세요.",
fail: "잘못된 이메일 형식입니다.",
},
name: {
fail: "닉네임을 입력해주세요.",
},
pw: {
voidOut: "비밀번호를 입력해주세요.",
fail: "비밀번호를 8자 이상 입력해주세요.",
},
rePw: "비밀번호가 일치하지 않습니다.",
};
Comment on lines +9 to +22
Copy link
Collaborator

Choose a reason for hiding this comment

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

(심화) 오오...... 에러 메시지를 구조적인 설계로 접근하셨네요 ..? 🫢

좀 더 응용하면 스키마로 만들 수도 있겠는데요?

스키마: 어떤 구조로 데이터가 저장되는가를 나타내는 구조
예를 들어서 다음과 같이:

Suggested change
export const errMsg = {
id: {
voidOut: "이메일을 입력해주세요.",
fail: "잘못된 이메일 형식입니다.",
},
name: {
fail: "닉네임을 입력해주세요.",
},
pw: {
voidOut: "비밀번호를 입력해주세요.",
fail: "비밀번호를 8자 이상 입력해주세요.",
},
rePw: "비밀번호가 일치하지 않습니다.",
};
export const validationSchema = {
id: {
validate: (value) => !!value && /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/.test(value),
message: {
voidOut: "이메일을 입력해주세요.",
fail: "잘못된 이메일 형식입니다.",
},
},
name: {
validate: (value) => !!value,
message: {
fail: "닉네임을 입력해주세요.",
},
},
pw: {
validate: (value) => !!value && value.length >= 8,
message: {
voidOut: "비밀번호를 입력해주세요.",
fail: "비밀번호를 8자 이상 입력해주세요.",
},
},
rePw: {
validate: (value, originalPw) => value === originalPw,
message: "비밀번호가 일치하지 않습니다.",
},
};

이렇게 확장해서 구성해볼 수도 있겠어요 !
접근 방법이 좋으셔서 심화 인사이트도 드려봅니다 ! 😉


export const changeImg = {
hide: "./icon/ic_passwrod_hide.svg",
show: "./icon/ic_passwrod_open.svg",
};
Loading
Loading