Skip to content

Commit

Permalink
[김수영] Sprint4 (#59)
Browse files Browse the repository at this point in the history
* feat: 랜딩페이지

* fixed untracked files

* style: 불필요한 font 스타일 코드 수정

* refactor: 클래스 네이밍

* feat:header고정

* feat: 로그인

* feat:회원가입

* fix:페이지 루트 수정

* refactor: 랜딩페이지 section ,footer

* feat : tablet display

* feat: landing page mobile display

* feat: auth page mobile display

* feat:줄바꿈 수정

* feat: meta tag

* feat:meta tag

* chore: github action

* feat : login, signup meta tag

* feat : login email,password validation

* feat: signup email, password, nickname validation

* feat : login, signup password visibility

* docs : 주석 수정
  • Loading branch information
swim-kim authored Sep 2, 2024
1 parent 3d6feb9 commit 4038f2e
Show file tree
Hide file tree
Showing 12 changed files with 403 additions and 185 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/delete-merged-branch-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ jobs:
delete-branch:
runs-on: ubuntu-latest
steps:
- name: delete branch
- name: Checkout repository
uses: actions/checkout@v3

- name: Check if branch exists
id: check_branch
run: |
if git show-ref --verify --quiet refs/heads/${{ github.head_ref }}; then
echo "branch_exists=true" >> $GITHUB_ENV
else
echo "branch_exists=false" >> $GITHUB_ENV
fi
- name: Delete branch
if: env.branch_exists == 'true'
uses: SvanBoxel/delete-merged-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Binary file added img/btn_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.
2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
>
<link rel="stylesheet" href="style/index.css">
<link rel="stylesheet" href="style/global.css">
<link rel="stylesheet" href="style/index_tablet.css">
<link rel="stylesheet" href="style/index_mobile.css">
</head>
<body>
<header>
Expand Down
19 changes: 15 additions & 4 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta property="og:type" content="website">
<meta property="og:title" content="판다마켓">
<meta property="og:description" content="일상의 모든 물건을 거래해보세요">
<meta property="og:image" content="./img/logo/logo.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>로그인</title>
<link rel="stylesheet" href="style/global.css">
<link rel="stylesheet" href="style/auth.css">
<link rel="stylesheet" href="style/auth_mobile.css">
</head>
<body>
<div class="auth-container">
Expand All @@ -16,7 +19,7 @@
<img class="panda-logo" src="./img/logo/logo.png" alt="판다마켓 홈 버튼">
</a>
</div>
<form method="post">
<form id="login-form" method="post">
<div class="input-box">
<label for="email">이메일</label>
<input
Expand All @@ -26,6 +29,10 @@
placeholder="이메일을 입력해주세요"
required
/>
<span id="email-empty" class="error-message">
이메일을 입력해 주세요</span>
<span id="email-invalidate" class="error-message">
잘못된 이메일 형식입니다</span>
</div>
<div class="input-box">
<label for="password">비밀번호</label>
Expand All @@ -37,8 +44,12 @@
required
/>
<img class="visibility-btn" src="img/btn_visibility_off.png" alt="비밀번호 숨김">
<span id="password-empty" class="error-message">
비밀번호를 입력해주세요</span>
<span id="password-invalidate" class="error-message">
비밀번호를 8자 이상 입력해주세요</span>
</div>
<button class="login-button" type="submit" >로그인</button>
<button id="login-button" class="login-button" type="submit" >로그인</button>
</form>
<div class="simple-login-box">
<p class="simple-login-text">간편 로그인하기</p>
Expand All @@ -64,6 +75,6 @@
</div>
</div>


<script src="script/auth.js"></script>
</body>
</html>
165 changes: 165 additions & 0 deletions script/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
const loginForm = document.getElementById('login-form');
const signupForm = document.getElementById('signup-form');
const emailInput = document.getElementById('email');
const passwordInput = document.getElementById('password');
const passwordConfirmInput = document.getElementById('password-confirm');
const nameInput = document.getElementById('name');
const loginButton = document.getElementById('login-button');
const signupButton = document.getElementById('signup-button');

// 재할당 가능하도록 - let
let isEmailValidate = false;
let isPasswordValidate = false;
let isPasswordConfirmValidate = false;
let isNameValidate = false;

// 오류 메시지
function showError(input, errorId) {
const errorElement = document.getElementById(errorId);
if (errorElement) {
errorElement.style.display = "block";
input.style.border = "1px solid #f74747";
}
}

// 상태 초기화
function hideError(input, errorId) {
const errorElement = document.getElementById(errorId);
if (errorElement) {
errorElement.style.display = "none";
input.style.border = "none";
}
}

// 이메일 형식 검증
function validateEmail(email) {
const emailRegex = /^[A-Za-z0-9_\.\-]+@[A-Za-z0-9\-]+\.[A-za-z0-9\-]+/;
return emailRegex.test(email);
}

// 이메일 검사
function checkEmail() {
const emailValue = emailInput.value;

if (!emailValue) {
showError(emailInput, "email-empty");
} else if (!validateEmail(emailValue)) {
isEmailValidate = false;
hideError(emailInput, "email-empty"); // 두 가지 오류 메세지가 동시에 나타나지 않도록 함
showError(emailInput, "email-invalidate");
} else {
isEmailValidate = true;
hideError(emailInput, "email-empty");
hideError(emailInput, "email-invalidate");
}
submitButtonInvalidate();
}

if (emailInput) {
emailInput.addEventListener("focusout", checkEmail);
}

// 비밀번호 검사
function checkPassword() {
const passwordValue = passwordInput.value;

if (!passwordValue) {
showError(passwordInput, "password-empty");
} else if (passwordValue.length < 8) {
hideError(passwordInput, "password-empty");
showError(passwordInput, "password-invalidate");
} else {
isPasswordValidate = true;
hideError(passwordInput, "password-empty");
hideError(passwordInput, "password-invalidate");
}
submitButtonInvalidate();
}

if (passwordInput) {
passwordInput.addEventListener("focusout", checkPassword);
}

// 닉네임 검사
function checkName() {
const nameValue = nameInput.value;
if (!nameValue) {
showError(nameInput, "name-empty");
isNameValidate = false;
} else {
isNameValidate = true;
hideError(nameInput, "name-empty");
}
submitButtonInvalidate();
}

if (nameInput) {
nameInput.addEventListener("focusout", checkName);
}

// 비밀번호 확인
function checkPasswordConfirm() {
const passwordValue = passwordInput.value;
const passwordConfirmValue = passwordConfirmInput.value;

if (!passwordConfirmValue) {
showError(passwordConfirmInput, "password-confirm-empty");
isPasswordConfirmValidate = false;
} else if (passwordValue !== passwordConfirmValue) {
hideError(passwordConfirmInput, "password-confirm-empty");
showError(passwordConfirmInput, "password-confirm-invalidate");
isPasswordConfirmValidate = false;
} else {
isPasswordConfirmValidate = true;
hideError(passwordConfirmInput, "password-confirm-empty");
hideError(passwordConfirmInput, "password-confirm-invalidate");
}
submitButtonInvalidate();
}

if (passwordConfirmInput) {
passwordConfirmInput.addEventListener("focusout", checkPasswordConfirm);
}

// 조건 모두 충족 시 로그인, 회원가입 버튼 활성화
function submitButtonInvalidate() {
if (signupForm) {
if (isEmailValidate && isPasswordValidate && isPasswordConfirmValidate && isNameValidate) {
signupButton.disabled = false;
window.location.href="/login.html";
} else {
signupButton.disabled = true;
}
} else if (loginForm) {
if (isEmailValidate && isPasswordValidate) {
loginButton.disabled = false;
window.location.href="/items.html";
} else {
loginButton.disabled = true;
}
}
}

// 처음에 비활성화 되도록
submitButtonInvalidate();

// 비밀번호 표시/숨김 함수
function passwordVisibility(event) {
const button = event.currentTarget;
const passwordInput = button.previousElementSibling;
const visibilityIcon = button;
const isPasswordVisible = passwordInput.type;

if (isPasswordVisible === "text") {
passwordInput.type = "password";
visibilityIcon.src = "../img/btn_visibility_off.png";
} else {
passwordInput.type = "text";
visibilityIcon.src = "../img/btn_visibility_on.png";
}
}

const visibilityButtons = document.querySelectorAll('.visibility-btn');
visibilityButtons.forEach((button) =>
button.addEventListener("click", passwordVisibility)
);
32 changes: 25 additions & 7 deletions signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:type" content="website">
<meta property="og:title" content="판다마켓">
<meta property="og:description" content="일상의 모든 물건을 거래해보세요">
<meta property="og:image" content="./img/logo/logo.png">
<title>회원가입</title>
<link rel="stylesheet" href="style/global.css">
<link rel="stylesheet" href="style/auth.css">
<link rel="stylesheet" href="style/auth_mobile.css">
</head>
<body>
<div class="auth-container">
Expand All @@ -16,7 +19,7 @@
<img class="panda-logo" src="./img/logo/logo.png" alt="판다마켓 홈 버튼">
</a>
</div>
<form method="input-box">
<form id="signup-form" method="input-box">
<div class="input-box">
<label for="email">이메일</label>
<input
Expand All @@ -26,6 +29,10 @@
placeholder="이메일을 입력해주세요"
required
/>
<span id="email-empty" class="error-message">
이메일을 입력해 주세요</span>
<span id="email-invalidate" class="error-message">
잘못된 이메일 형식입니다</span>
</div>
<div class="input-box">
<label for="name">닉네임</label>
Expand All @@ -36,6 +43,8 @@
placeholder="닉네임을 입력해주세요"
required
/>
<span id="name-empty" class="error-message">
닉네임을 입력해 주세요</span>
</div>
<div class="input-box">
<label for="password">비밀번호</label>
Expand All @@ -47,19 +56,27 @@
required
/>
<img class="visibility-btn" src="img/btn_visibility_off.png" alt="비밀번호 숨김">
<span id="password-empty" class="error-message">
비밀번호를 입력해 주세요</span>
<span id="password-invalidate" class="error-message">
비밀번호를 8자 이상 입력해주세요</span>
</div>
<div class="input-box">
<label for="passwordConfirmation">비밀번호 확인</label>
<div class="input-box">
<label for="password-confirm">비밀번호 확인</label>
<input
name="passwordConfirmation"
id="passwordConfirmation"
name="password-confirm"
id="password-confirm"
type="password"
placeholder="비밀번호를 입력해주세요"
required
/>
<img class="visibility-btn" src="img/btn_visibility_off.png" alt="비밀번호 숨김">
<span id="password-confirm-empty" class="error-message">
비밀번호를 입력해 주세요</span>
<span id="password-confirm-invalidate" class="error-message">
비밀번호가 일치하지 않습니다</span>
</div>
<button class="signup-button" type="submit" >회원가입</button>
<button id="signup-button" class="signup-button" type="submit" >회원가입</button>
</form>
<div class="simple-login-box">
<p class="simple-login-text">간편 로그인하기</p>
Expand All @@ -84,5 +101,6 @@
</div>
</div>
</div>
<script src="script/auth.js"></script>
</body>
</html>
28 changes: 26 additions & 2 deletions style/auth.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ input::placeholder {
font-size: 16px;
line-height: 24px;
}

input:focus {
outline-color: #3692FF;;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ input:focus {
color: #F3F4F6;
font-size: 20px;
font-weight: 600;

cursor: pointer;
}

Expand Down Expand Up @@ -164,4 +164,28 @@ button:disabled {
font-weight: 500;
line-height: normal;
text-decoration-line: underline;
}
.error-message {
color: #f74747;
font-weight: 600;
font-size: 15px;
line-height: 18px;
margin-top: 8px;
display: none;
padding-left: 16px;
}

/* mobile */
@media (max-width:767px){
.auth-container {
padding: 0 16px;
display:inline-flex;
}
.panda-logo {
width:198px;
}
.auth-wrap {
max-width: 400px;
margin:24px 0;
}
}
Loading

0 comments on commit 4038f2e

Please sign in to comment.