-
Notifications
You must be signed in to change notification settings - Fork 1
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주차 기본/심화 과제] 가계부 💸 #5
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
59c9173
docs: add constant datas
simeunseo 45a41a9
feat: render list from localStorage
simeunseo 67b1caf
feat: count and render overall balance
simeunseo 8b8dc13
feat: count and render income and spending balance
simeunseo 4c18f82
feat: income and spending button filtering
simeunseo d5a96e8
feat: delete item
simeunseo 9c22715
feat: change balance after item deletion
simeunseo 3f74f92
feat: delete modal
simeunseo 79ef728
design: add modal radio
simeunseo c1a823b
docs: add form skeleton
simeunseo fa89914
design: add form styling
simeunseo 8c13791
feat: add modal open and close
simeunseo c7f0419
feat: add form select option dynamically
simeunseo c62f142
feat: add form input validation
simeunseo 7e64b27
feat: localeString on cost Input
simeunseo c263762
feat: alert when input text on cost input
simeunseo 773d847
fix: seperate modalhandler and modalworkhandler
simeunseo 6cbace9
design: add item modal animation
simeunseo b87a7e1
docs, design: create category page
simeunseo 6d4120d
feat: render category list from localStorage
simeunseo 6b2be78
feat: add new category with enter key
simeunseo 0f1d783
chore: delete console log
simeunseo 164433f
refactor: change list overflow scroll section
simeunseo 411f53b
fix : intialize select option when close modal
simeunseo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>💸시믄서의 가계부💸</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
<link rel="icon" href="assign4-favicon.png" /> | ||
</head> | ||
<body> | ||
<section class="summary"> | ||
<header>✍️ 카테고리 관리 ✍️</header> | ||
<article class="income-category"> | ||
<h2>수입 카테고리</h2> | ||
<div class="category-list" id="income-category-list"> | ||
<ol id="income-category-list-wrapper"> | ||
</ol> | ||
<div>🖊️ <input id="income-category-input" type="text"></div> | ||
</div> | ||
</article> | ||
<article class="spending-category"> | ||
<h2>지출 카테고리</h2> | ||
<div class="category-list" id="spending-category-list"> | ||
<ol id="spending-category-list-wrapper"> | ||
</ol> | ||
<div>🖊️ <input id="spending-category-input" type="text"></div> | ||
</div> | ||
</article> | ||
|
||
<a href="/"> | ||
<button type="button" id="home-btn">🏠</button> | ||
</a> | ||
<script type="module" src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { INCOME_CATEGORY } from "../data.js"; | ||
import { SPENDING_CATEGORY } from "../data.js"; | ||
|
||
let incomeCategoryData = []; //localStorage에 저장된 수입 카테고리 목록을 가져와 저장하는 배열 | ||
let spendingCategoryData = []; //localStorage에 저장된 지출 카테고리 목록을 가져와 저장하는 배열 | ||
|
||
window.onload = () => { | ||
//localStorage 초기화 | ||
localStorage.getItem("income_category_data") === null && | ||
localStorage.setItem( | ||
"income_category_data", | ||
JSON.stringify(INCOME_CATEGORY) | ||
); | ||
localStorage.getItem("spending_category_data") === null && | ||
localStorage.setItem( | ||
"spending_category_data", | ||
JSON.stringify(SPENDING_CATEGORY) | ||
); | ||
|
||
//localStorage에 저장된 목록을 가져옴 | ||
incomeCategoryData = JSON.parse(localStorage.getItem("income_category_data")); | ||
spendingCategoryData = JSON.parse( | ||
localStorage.getItem("spending_category_data") | ||
); | ||
|
||
renderCategoryList(); | ||
handleAddIncome(); | ||
handleAddSpending(); | ||
}; | ||
|
||
function renderCategoryList() { | ||
const IncomeCategoryWrapper = document.getElementById( | ||
"income-category-list-wrapper" | ||
); | ||
const SpendingCategoryWrapper = document.getElementById( | ||
"spending-category-list-wrapper" | ||
); | ||
|
||
IncomeCategoryWrapper.replaceChildren(); | ||
incomeCategoryData.forEach((category) => { | ||
const li = document.createElement("li"); | ||
li.innerText = category; | ||
IncomeCategoryWrapper.appendChild(li); | ||
}); | ||
|
||
SpendingCategoryWrapper.replaceChildren(); | ||
spendingCategoryData.forEach((category) => { | ||
const li = document.createElement("li"); | ||
li.innerText = category; | ||
SpendingCategoryWrapper.appendChild(li); | ||
}); | ||
} | ||
|
||
function handleAddIncome() { | ||
const incomeCategoryInput = document.getElementById("income-category-input"); | ||
incomeCategoryInput.addEventListener("keyup", (e) => { | ||
if (incomeCategoryInput.value !== "" && e.key === "Enter") { | ||
e.target.blur(); | ||
|
||
incomeCategoryData.push(incomeCategoryInput.value); | ||
localStorage.setItem( | ||
"income_category_data", | ||
JSON.stringify(incomeCategoryData) | ||
); | ||
renderCategoryList(incomeCategoryData); | ||
incomeCategoryInput.value = ""; | ||
} | ||
}); | ||
} | ||
|
||
function handleAddSpending() { | ||
const spendingCategoryInput = document.getElementById( | ||
"spending-category-input" | ||
); | ||
spendingCategoryInput.addEventListener("keyup", (e) => { | ||
if (spendingCategoryInput.value !== "" && e.key === "Enter") { | ||
e.target.blur(); | ||
|
||
spendingCategoryData.push(spendingCategoryInput.value); | ||
localStorage.setItem( | ||
"spending_category_data", | ||
JSON.stringify(spendingCategoryData) | ||
); | ||
renderCategoryList(spendingCategoryData); | ||
spendingCategoryInput.value = ""; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
@import url("../reset.css"); | ||
|
||
@import url("https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css"); | ||
|
||
:root { | ||
--yellow-color: #f9e44c; | ||
--dark-yellow-color: #f1db49; | ||
--red-color: #d06661; | ||
--blue-color: #618dd0; | ||
--white-color: #ffffff; | ||
--weak-white-color: #ffffff5a; | ||
--weak-gray-color: rgb(231, 231, 231); | ||
--dark-gray-color: #464646; | ||
--gray-color: #898989; | ||
} | ||
|
||
html, | ||
body { | ||
font-size: 62.5%; | ||
line-height: 1.285; | ||
} | ||
|
||
body { | ||
font-family: "Pretendard"; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
font-size: 1rem; | ||
color: var(--dark-gray-color-color); | ||
|
||
height: 100%; | ||
} | ||
|
||
/* summary section */ | ||
.summary { | ||
background-color: var(--yellow-color); | ||
|
||
width: 100%; | ||
height: 100%; | ||
padding-bottom: 5rem; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
font-size: 1.6rem; | ||
} | ||
|
||
header { | ||
font-size: 2.4rem; | ||
font-weight: 700; | ||
|
||
margin: 2.5rem 0; | ||
padding-bottom: 2rem; | ||
margin-bottom: 4rem; | ||
width: 100%; | ||
|
||
text-align: center; | ||
|
||
border-bottom: 0.1rem solid var(--weak-white-color); | ||
} | ||
|
||
article > h2 { | ||
width: 100%; | ||
|
||
margin-bottom: 1rem; | ||
} | ||
|
||
.category-list { | ||
width: 31rem; | ||
|
||
background-color: var(--white-color); | ||
|
||
margin-bottom: 3rem; | ||
padding: 2rem; | ||
|
||
border-radius: 1rem; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
gap: 5rem; | ||
} | ||
|
||
.category-list > ol { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 1rem; | ||
} | ||
|
||
#income-category-list > ol > li { | ||
padding: 1rem 1.5rem; | ||
border-radius: 1rem; | ||
|
||
background-color: var(--red-color); | ||
color: var(--white-color); | ||
} | ||
|
||
#spending-category-list > ol > li { | ||
padding: 1rem 1.5rem; | ||
border-radius: 1rem; | ||
|
||
background-color: var(--blue-color); | ||
color: var(--white-color); | ||
} | ||
|
||
input { | ||
width: 90%; | ||
|
||
border-bottom: 0.1rem solid var(--dark-gray-color); | ||
} | ||
|
||
#home-btn { | ||
background-color: var(--white-color); | ||
padding: 1rem; | ||
border-radius: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export const INIT_BALANCE = 0; | ||
export const LIST_DATA = [ | ||
{ | ||
customId: 1, | ||
category: "식비", | ||
name: "크라이치즈버거 역곡점", | ||
cost: -10800, | ||
}, | ||
{ | ||
customId: 2, | ||
category: "취미", | ||
name: "포토그레이 부천점", | ||
cost: -4000, | ||
}, | ||
{ | ||
customId: 3, | ||
category: "월급", | ||
name: "근로장학", | ||
cost: 300000, | ||
}, | ||
{ | ||
customId: 4, | ||
category: "쇼핑", | ||
name: "풋락커 커먼그라운드점", | ||
cost: -99000, | ||
}, | ||
]; | ||
|
||
export const INCOME_CATEGORY = ["월급", "용돈"]; | ||
|
||
export const SPENDING_CATEGORY = ["식비", "쇼핑", "취미"]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 식으로 데이터 분리하는 거 너무 좋은 거 같습니다!!