Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2주차 기본/심화 과제] 웨비들의 냠냠 🍰 창업🏠 손님을 모셔오자!🌈 #4

Merged
merged 32 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d680b98
docs : week2 1번과제 초기 세팅
simeunseo Apr 14, 2023
118ad51
refactor : 1주차 과제 코드리뷰 반영
simeunseo Apr 14, 2023
dd3201e
refactor : js파일 연결, 디렉토리 구조 변경
simeunseo Apr 16, 2023
e3bd44d
refactor : ul 태그 삭제
simeunseo Apr 16, 2023
bef3c52
feat : template 태그 사용 샘플 테스트
simeunseo Apr 16, 2023
c66cce2
feat : 상수값으로 저장된 데이터로 card 동적 생성
simeunseo Apr 16, 2023
00da546
docs : 상수값으로 저장된 데이터 사용 관련 주석 작성
simeunseo Apr 17, 2023
db96001
feat : 체크박스 필터링 - 항목 추가
simeunseo Apr 17, 2023
b58b25a
feat : 체크박스 필터링 - 항목 제거
simeunseo Apr 17, 2023
7614451
refactor : 체크박스 필터링 모듈화
simeunseo Apr 17, 2023
7e25f3f
feat: 체크박스 필터링 - 전체 체크(체크 해제 기능 제외)
simeunseo Apr 17, 2023
04e79e2
feat,refactor : 체크박스 필터링 완료
simeunseo Apr 17, 2023
dc34286
docs : 카테고리 태그 템플릿 제작
simeunseo Apr 17, 2023
9c68e7b
feat : 카테고리 태그 생성 및 삭제 기능
simeunseo Apr 17, 2023
d62dcf9
refactor : listToCard()에서 map을 forEach로
simeunseo Apr 17, 2023
8723c14
style : cursor관련 css 수정
simeunseo Apr 17, 2023
4a36bd8
style : nav 카테고리 메뉴 css 수정
simeunseo Apr 17, 2023
f83bd69
docs, style : tag modal 추가
simeunseo Apr 17, 2023
6141332
feat : 브라우저 처음 실행시 전체 카테고리가 디폴트 선택
simeunseo Apr 17, 2023
b25f4cb
refactor : '전체' 카테고리 객체를 변수에 할당하여 사용
simeunseo Apr 17, 2023
d4ff5ed
style : header z-index 수정, 우측 nav 그림자 추가
simeunseo Apr 17, 2023
b6f0204
style : tag modal css
simeunseo Apr 17, 2023
0ad4d7a
feat : modal 완료
simeunseo Apr 17, 2023
cd3af87
feat : modal overlay 클릭시 모달 close
simeunseo Apr 17, 2023
3d38655
docs : addCard 페이지 기본 세팅
simeunseo Apr 17, 2023
d643760
feat : form 생성 및 입력값 저장(이미지 제외)
simeunseo Apr 17, 2023
4de1ad9
style : 이미지 미리보기 및 form css 완료
simeunseo Apr 17, 2023
35e2c8c
feat : 아이템 추가 기능 완료
simeunseo Apr 17, 2023
2517278
style : 아이템 추가 페이지 썸네일 크기, 마진 수정
simeunseo Apr 17, 2023
a016b37
style : 카드 애니메이션
simeunseo Apr 18, 2023
2aa2362
rename : 폴더 구조 정리
simeunseo Apr 18, 2023
2c17434
fix : addCard 후 redirect url 수정
simeunseo Apr 18, 2023
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
89 changes: 89 additions & 0 deletions week2/assign1/addCard/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>✠ 마라명가 ✠ : 새 상품 추가</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<header>
<a href="../home"><h1>✠ 마라명가 ✠</h1></a>
<button type="button" id="header__button">
<i class="fa-solid fa-bars"></i>
</button>
<nav id="header__menu">
<h1>메뉴</h1>
<div id="header__menu__list">
<a href="../home">홈</a>
<a href="./">새 상품 추가</a>
<a href="#">찜 목록</a>
</div>
</nav>
</header>
<main>
<section class="heading">
<h1>당신이 원하는 그 어떤 재료도</h1>
<h1>마라명가에서는 가능합니다.</h1>
</section>
<section class="form-container">
<form id="add-card-form" method="post" enctype="multipart/form-data">
<span>
<label for="name"><h4>재료 이름</h4></label>
<input required type="text" name="name" id="name" />
</span>
<hr />
<span>
<label for="hashtag"><h4>해시태그</h4></label>
<input
required
placeholder="쉼표(,)로 구분"
type="text"
name="hashtag"
id="hashtag"
/>
</span>
<hr />
<span>
<div class="button">
<label for="image"><h4>이미지 선택</h4></label>
</div>
<input
required
type="file"
id="image"
name="image"
accept="image/*"
/>
</span>
<hr />
<span>
<label><h4>이미지 미리보기</h4></label>
<img
src="https://skg1891.cafe24.com/wp-content/uploads/2013/11/dummy-image-portrait.jpg"
id="image-thumbnail"
/>
</span>
<hr />
<span>
<label for="cateogry"><h4>카테고리</h4></label>
<select required name="category">
<option value="">=== 선택 ===</option>
<option value="veg">채소</option>
<option value="mush">버섯</option>
<option value="tofu">두부</option>
<option value="etc">기타</option>
</select>
Comment on lines +70 to +77
Copy link

Choose a reason for hiding this comment

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

시맨틱 태그 넘 좋다 !

</span>
<button type="submit"><h2>재료 추가</h2></button>
</form>
</section>
</main>
<script
src="https://kit.fontawesome.com/6fbcf91afd.js"
crossorigin="anonymous"
></script>
<script defer type="module" src="./script.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions week2/assign1/addCard/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//select option의 vlaue를 카테고리명으로 변환하기 위한 객체
const CATEGORY_NAME = {
veg: "채소",
mush: "버섯",
tofu: "두부",
etc: "기타",
};

const imageInput = document.getElementById("image");
const imageThumbNail = document.getElementById("image-thumbnail");
imageInput.addEventListener("input", () => {
const reader = new FileReader();
reader.addEventListener("load", () => {
imageThumbNail.src = reader.result;
});
reader.readAsDataURL(imageInput.files[0]);
});

const form = document.getElementById("add-card-form");
form.addEventListener("submit", (e) => {
e.preventDefault();
Copy link

Choose a reason for hiding this comment

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

꼼꼼하다!
나도 넣어줘야겠어 ㅎㅎ

const name = e.target.name.value;
const hashTags = e.target.hashtag.value.replace(/ /g, "").split(",");
const category = CATEGORY_NAME[e.target.category.value];

let localStorageData = JSON.parse(localStorage.getItem("item_data"));
localStorageData.push({
category: category,
name: name,
tags: hashTags,
img: imageThumbNail.src,
});

localStorage.setItem("item_data", JSON.stringify(localStorageData));

location.replace("../home");
});
231 changes: 231 additions & 0 deletions week2/assign1/addCard/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
@import url("../common/reset.css");

/* CSS 전역 변수 선언 */
:root {
--main-color: rgb(141, 19, 19);
--shadow-color: rgba(0, 0, 0, 0.3);
}

/* animation */
@keyframes fadeInUp {
0% {
opacity: 0.2;
transform: translateY(20%);
}
to {
opacity: 1;
transform: translateY(0%);
}
}

@keyframes fadeInRight {
0% {
opacity: 0.2;
transform: translateX(20%);
}
to {
opacity: 1;
transform: translateX(0%);
}
}

/* font setting */
@font-face {
font-family: "Pretendard-Regular";
src: url("https://cdn.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Regular.woff")
format("woff");
font-weight: 400;
font-style: normal;
}

@font-face {
font-family: "EBSHunminjeongeumSBA";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_one@1.0/EBSHunminjeongeum.woff")
format("woff");
font-weight: normal;
font-style: normal;
}

body {
font-family: "Pretendard-Regular", sans-serif;
}

h1 {
font-family: EBSHunminjeongeumSBA;
font-size: 2rem;
}
h2 {
font-family: EBSHunminjeongeumSBA;
font-size: 1.8rem;
}
h3,
nav > a {
font-size: 1.3rem;
}
small {
font-size: 0.8rem;
}

/* header */
header > a {
color: white;
}
header {
padding: 2rem;
width: -webkit-fill-available;

display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
z-index: 2;

background-color: var(--main-color);
color: white;
}

#header__menu {
display: none;
box-shadow: -1rem 0 1rem var(--shadow-color);
animation: fadeInRight 0.7s;
}

#header__button {
width: 2rem;
height: 2rem;
}

#header__button i {
color: white;
font-size: 1.2rem;
}

#header__button:hover + #header__menu,
#header__menu:hover {
display: block;
}

#header__menu {
background-color: white;
color: black;
height: 100vh;
position: absolute;
right: 0;
top: 0;
padding: 2rem;
width: 10rem;
}

#header__menu > h1 {
padding-bottom: 2rem;
font-weight: bold;
}

#header__menu__list {
display: flex;
flex-direction: column;
}

#header__menu a {
color: black;
padding-bottom: 1.5rem;
cursor: pointer;
}

#header__menu a:hover {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: var(--main-color);
text-underline-offset: 0.3rem;
}

/* main */

main {
padding-top: 8rem;
text-align: center;

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.heading {
padding: 1rem 0;
}

/* form */

.form-container {
background-color: white;
color: black;

display: flex;
flex-direction: column;
align-items: center;

padding: 3rem;
margin: 2rem 6rem;

border-radius: 1rem;

animation: fadeInUp 1s;
}

form {
width: 35vw;
}

form > span {
display: flex;
justify-content: space-between;
align-items: center;

width: 100%;
}

span > label {
margin-right: 1rem;
}

form input[type="file"] {
width: 10rem;
}

form > button {
background-color: var(--main-color);
color: white;

border-radius: 1rem;

padding: 1rem 0;
margin-top: 2rem;

width: 100%;
}

form > button > h2 {
font-size: 1.3rem;
}

form > button:hover {
background-color: black;
transition-duration: 0.3s;
}

form > hr {
margin: 1rem 0;
border: 0.01rem solid var(--shadow-color);
}

#image-thumbnail {
width: 14rem;
}

input,
select {
padding: 0.5rem;
border-radius: 0.5rem;
border: 0.1rem solid var(--shadow-color);
}
Loading