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
23 changes: 23 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"arrowParens": "always",
"bracketSameLine": false,
"objectWrap": "preserve",
"bracketSpacing": true,
"semi": true,
"experimentalOperatorPosition": "end",
"experimentalTernaries": false,
"singleQuote": true,
"jsxSingleQuote": false,
"quoteProps": "as-needed",
"trailingComma": "all",
"singleAttributePerLine": false,
"htmlWhitespaceSensitivity": "css",
"vueIndentScriptAndStyle": false,
"proseWrap": "preserve",
"insertPragma": false,
"printWidth": 80,
"requirePragma": false,
"tabWidth": 2,
"useTabs": false,
"embeddedLanguageFormatting": "auto"
}
55 changes: 39 additions & 16 deletions css/login.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
body {
margin: 0;
font-family: 'Pretendard' ;
font-family: 'Pretendard';
}

.login-wrapper {
Expand All @@ -11,7 +11,7 @@ body {

.login-box {
width: 640px;
padding: 48px;
padding: 56px;
box-sizing: border-box;
}

Expand All @@ -20,12 +20,13 @@ body {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 40px;
}

.logo-img {
width: 396px;
height: 132px;
display: block;
display: block;
}

/*입력창*/
Expand All @@ -38,18 +39,18 @@ label {
font-size: 18px;
font-weight: 700;
margin-bottom: 16px;
color: #1F2937;
color: #1f2937;
}

input[type="email"],
input[type="password"] {
input[type='email'],
input[type='password'] {
Comment on lines +45 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.

(제안) 만약 스타일 선택자 목적이라면 태그보다는 class를 선택자로 사용하는게 어떨까요?

Suggested change
input[type='email'],
input[type='password'] {
.input[type='email'],
.input[type='password'] {

클래스는 재사용이 가능하며, 자유롭게 태그에 스타일을 붙일 수 있어서 유지보수에 용이하므로 단순히 스타일을 위해서라면 class를 추천드려요 !

좀 더 자세히 🤔

유지보수가 어려워질 수 있어요.

특정 p 태그에만 다른 스타일을 적용하려면 추가적인 선택자를 작성하거나 기존 스타일을 덮어써야 하므로 유지보수가 어려워집니다.

태그 의미를 명확히 부여하기 어려워요.

스타일링을 태그에 직접 적용하면, 태그가 어떤 의미를 가지는지 어렵기에 가독성이 보다 좋지 못할 수 있어요.

만약 다음 코드의 스타일을 태그 선택자로만 지정한다면 ?

<p class="error-message">오류가 발생했습니다.</p>

물론 전역적인 것을 의미한다면 일정 허용될 수 있어요.

예를 들어서 p의 기본 마진을 없애고 싶다면 다음과 같이 작성할 수 있을거예요:

p {
    margin: 0;
}

그렇지만 특정 스타일을 지정하고 싶다면 다음과 같이 작성해볼 수 있어요:

.paragraph {
    font-size: 16px;
    color: #333;
}

.highlight {
    background-color: yellow;
}

width: 100%;
height: 48px;
height: 56px;
font-size: 15px;
padding: 16px;
padding: 16px;
border-radius: 12px;
border: none;
background-color: #F3F4F6;
background-color: #f3f4f6;
box-sizing: border-box;
}

Expand All @@ -65,9 +66,10 @@ input[type="password"] {
margin: 16 48 48 48px;
border-radius: 12px;
box-sizing: border-box;
background-color: #F3F4F6;
background-color: #f3f4f6;
border: none;
font-size: 16px;
margin: 0;
}

.password-input .btn {
Expand All @@ -88,12 +90,11 @@ input[type="password"] {
height: 100%;
}


/*로그인 버튼*/
.login-btn {
width: 100%;
height: 56px;
background-color: #9CA3AF;
background-color: #9ca3af;
color: #ffffff;
font-weight: 600;
font-size: 20px;
Expand All @@ -103,7 +104,7 @@ input[type="password"] {

/*간편 로그인*/
.social-login {
background-color: #E6F2FF;
background-color: #e6f2ff;
height: 74px;
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -134,11 +135,11 @@ input[type="password"] {
font-size: 14px;
font-weight: 500;
text-align: center;
color: #1F2937;
color: #1f2937;
}

.signup-callout a {
color: #3182F6;
color: #3182f6;
font-size: 14px;
font-weight: 500;
}
Expand All @@ -151,4 +152,26 @@ input[type="password"] {
width: 100%;
height: auto;
}
}
}

/*에러 메세지*/
.error-input {
border: 1px solid #f74747 !important;
}

.error-message {
color: #f74747;
font-size: 14px;
font-weight: 600;
margin-top: 10px;
display: block;
}

/*로그인 버튼 활성화*/
.login-btn.enabled {
background-color: #3692ff;
}

.login-btn:disabled {
cursor: not-allowed;
}
54 changes: 39 additions & 15 deletions css/signup.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
body {
margin: 0;
font-family: 'Pretendard' ;
font-family: 'Pretendard';
}

.login-wrapper {
Expand All @@ -20,12 +20,13 @@ body {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 40px;
}

.logo-img {
width: 396px;
height: 132px;
display: block;
display: block;
}

/*입력창*/
Expand All @@ -38,19 +39,19 @@ label {
font-size: 18px;
font-weight: 700;
margin-bottom: 16px;
color: #1F2937;
color: #1f2937;
}

input[type="email"],
input[type="password"],
input[type="text"]{
input[type='email'],
input[type='password'],
input[type='text'] {
width: 100%;
height: 48px;
height: 56px;
font-size: 15px;
padding: 16px;
padding: 16px;
border-radius: 12px;
border: none;
background-color: #F3F4F6;
background-color: #f3f4f6;
box-sizing: border-box;
}

Expand All @@ -67,7 +68,7 @@ input[type="text"]{
margin: 16 48 48 48px;
border-radius: 12px;
box-sizing: border-box;
background-color: #F3F4F6;
background-color: #f3f4f6;
border: none;
font-size: 16px;
}
Expand All @@ -90,12 +91,11 @@ input[type="text"]{
height: 100%;
}


/*로그인 버튼*/
.login-btn {
width: 100%;
height: 56px;
background-color: #9CA3AF;
background-color: #9ca3af;
color: #ffffff;
font-weight: 600;
font-size: 20px;
Expand All @@ -105,7 +105,7 @@ input[type="text"]{

/*간편 로그인*/
.social-login {
background-color: #E6F2FF;
background-color: #e6f2ff;
height: 74px;
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -136,11 +136,11 @@ input[type="text"]{
font-size: 14px;
font-weight: 500;
text-align: center;
color: #1F2937;
color: #1f2937;
}

.signup-callout a {
color: #3182F6;
color: #3182f6;
Copy link
Collaborator

Choose a reason for hiding this comment

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

컬러 팔레트를 사용해보시는건 어떨까요? 🎨

컬러는 따로 선언해두시고 재사용 해보시는건 어떨까요?
컬러 팔레트는 color.css 혹은 global.css에서 정의하는게 일반적입니다 !
컬러 팔레트는 다음과 같이 정의할 수 있습니다:

:root {
  --primary: #6D6AFE;
  --red: #FF5B56;
  --black: #111322;
  --white: #FFFFFF;
  --gray-100: #3E3E43;
  --gray-200: #9FA6B2;
  --gray-300: #CCD5E3;
  --gray-400: #E7EFFB;
  --gray-500: #F0F6FF;
}

font-size: 14px;
font-weight: 500;
}
Expand All @@ -155,4 +155,28 @@ input[type="text"]{
}
}

/*에러 메세지*/
.error-input {
border: 1px solid #f74747 !important;
}

.correct-input {
border: 1px solid #3692ff !important;
}

.error-message {
color: #f74747;
font-size: 14px;
font-weight: 600;
margin-top: 10px;
display: block;
}

/*로그인 버튼 활성화*/
.login-btn.enabled {
background-color: #3692ff;
}

.login-btn:disabled {
cursor: not-allowed;
}
Binary file removed images/eye-off.png
Binary file not shown.
3 changes: 3 additions & 0 deletions images/eye-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/eye-on.png
Binary file not shown.
3 changes: 3 additions & 0 deletions images/eye-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>판다마켓</title>
<link rel="icon" href="images/favicon-panda.png" type="image/x-icon" />
<link rel="icon" href="images/favicon-panda.png"/>
<meta property="og:title" content="판다마켓" />
<meta property="og:description" content="일상의 모든 물건을 거래해보세요" />
<meta property="og:image" content="https://file2.nocutnews.co.kr/newsroom/image/2019/01/18/20190118151430114340_0_800_451.jpg" />
Expand Down
93 changes: 82 additions & 11 deletions js/login.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,83 @@
function inputPassword(inputId, eyeId) {
const passwordInput = document.getElementById(inputId);
const eyeIcon = document.getElementById(eyeId);

if (passwordInput.type === "password") {
passwordInput.type = "text";
eyeIcon.src = "images/eye-on.png";
} else {
passwordInput.type = "password";
eyeIcon.src = "images/eye-off.png";
}
}
const passwordInput = document.getElementById(inputId);
const eyeIcon = document.getElementById(eyeId);

if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.src = 'images/eye-on.svg';
} else {
passwordInput.type = 'password';
eyeIcon.src = 'images/eye-off.svg';
}
}

document.addEventListener('DOMContentLoaded', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

굿굿 ! 적절한 이벤트 리스너네요 👍

이렇게 되면 DOM이 로드가 된 후 순서를 보장할 수 있으며, 글로벌 스코프를 방지할 수 있겠어요

const emailInput = document.getElementById('email');
const emailError = document.getElementById('email-error');
const passwordInput = document.getElementById('password');
const passwordError = document.getElementById('password-error');
const loginButton = document.getElementById('login-button');

function validateEmail(email) {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return emailRegex.test(email);
}
Comment on lines +21 to +24
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)” 라고 부릅니다.

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


function updateButtonState() {
const emailValue = emailInput.value.trim();
const passwordValue = passwordInput.value.trim();
const emailValid = emailValue !== '' && validateEmail(emailValue);
const passwordValid = passwordValue !== '' && passwordValue.length >= 8;
if (emailValid && passwordValid) {
Comment on lines +27 to +31
Copy link
Collaborator

Choose a reason for hiding this comment

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

별칭을 작성해서 가독성을 높이셨군요 ! 깔끔합니다!

emailValid, passwordValid 등. 조건문을 인라인으로 바로 사용하지 않고 별칭을 사용해서 가독성이 훨씬 좋아졌네요 👍

다만 보통 booleanis~로 시작하는게 일반적입니다

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

loginButton.disabled = false;
loginButton.classList.add('enabled');
} else {
loginButton.disabled = true;
loginButton.classList.remove('enabled');
}
}

emailInput.addEventListener('input', function () {
const value = emailInput.value.trim();
if (value === '') {
emailInput.classList.add('error-input');
emailError.textContent = '이메일을 입력해주세요.';
emailError.style.display = 'block';
} else if (!validateEmail(value)) {
emailInput.classList.add('error-input');
emailError.textContent = '잘못된 이메일 형식입니다.';
emailError.style.display = 'block';
} else {
emailInput.classList.remove('error-input');
emailError.textContent = '';
emailError.style.display = 'none';
}
updateButtonState();
});

passwordInput.addEventListener('input', function () {
const value = passwordInput.value.trim();
if (value === '') {
passwordInput.classList.add('error-input');
passwordError.textContent = '비밀번호를 입력해주세요.';
passwordError.style.display = 'block';
} else if (value.length < 8) {
passwordInput.classList.add('error-input');
passwordError.textContent = '비밀번호를 8자 이상 입력해주세요.';
passwordError.style.display = 'block';
} else {
passwordInput.classList.remove('error-input');
passwordError.textContent = '';
passwordError.style.display = 'none';
}
updateButtonState();
});

loginButton.addEventListener('click', function () {
if (!this.disabled) {
window.location.href = '/items';
}
});

updateButtonState();
});
Loading
Loading