-
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주차 기본/심화] 가계부 💸 #7
Conversation
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.
넘 고생많았어 코드가 넘 깔끔하고 !!! 선생각 후코딩 했다는게 완전 잘 느껴져!!! 나도 진짜 담부터는 선생각 후코딩 해야지 ,,
@@ -0,0 +1,30 @@ | |||
export const HISTORY_LIST_DATA = [ |
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.
엇 코드 깔끔하려면 더미데이터 분리해야하는거..!! 난 아무생각없이 그냥 한 파일에 다 넣어부럿다 역시 연서는 꼼꼼 & 실력자 ,,
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.
나도 한 파일에...ㅎㅎㅎㅎ
@@ -0,0 +1,229 @@ | |||
import { HISTORY_LIST_DATA } from "./data/HISTORY_LIST.js"; |
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.
나도 이렇게할걸 ,, , ,,
@@ -0,0 +1,229 @@ | |||
import { HISTORY_LIST_DATA } from "./data/HISTORY_LIST.js"; | |||
|
|||
const $ = (selector) => document.querySelector(selector); |
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.
그리고 나 이거 연서 덕에 처음알았어 !! 템플릿 스트링이자 document.getElementById() 함수의 바로가기 기능을 한다는 ,, 난 이거 모르고 그냥 하나하나 다 코딩했다 키키 배워갑니당
const historyBox = document.createElement("li"); | ||
historyBox.classList.add(`history__list__box`); | ||
historyBox.id = id; | ||
historyBox.innerHTML = ` |
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.
와 미쳤다 리터럴처리 미쳤다 ..
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.
이렇게 해도 되는구나....
}; | ||
|
||
// 총 자산, 수입, 지출 렌더링 함수 | ||
const renderTotalBalance = () => { |
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.
오 렌더링 새로해야할때마다 얘를 호출하는거구나!! 히히 나도 나름 비슷하게 생각한거같아서 다행스 ㅎ.ㅎ
}, 0); | ||
|
||
const totalAmount = $(".asset__box__total-amount"); | ||
totalAmount.innerHTML = ( |
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.
구조가 넘 깔끔해요 ..
|
||
incomeCheckbox.checked | ||
? incomeLists.forEach((list) => (list.parentNode.style.display = "flex")) | ||
: incomeLists.forEach((list) => (list.parentNode.style.display = "none")); |
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.
와 여기 미쳤다 난 아예 filter용 리스트를 하나 만들어서 checkbox 수정될때마다 해당 조건에 따른 필터링 요소들을 넣었는데 이렇게하면 굳이 여러번 작업 안해도되니까 훨~~씬 효율적일거같다!!
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.
아예 style을 바꿔주니까 내역리스트를 건드릴 필요가 없네!!
$( | ||
".add-category__select" | ||
).innerHTML = `<option class="add-category__option">알바비</option> | ||
<option class="add-category__option">용돈</option>`; |
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.
내가 짤때는 element 새로 만들고 그안에 innerText 설정하느라 세네줄 코딩했던거같은데 이거 진짜 경험치에서 나오는 센스 미쳤어
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.
속성이 많은 애들은 innerHTML로 해주는게 더 편하규만,,,
const handleEnterAmount = () => { | ||
const newAmount = $(".add-amounts__input"); | ||
|
||
newAmount.addEventListener("keyup", checkNumber); |
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.
오 keyup으로 이벤트 줬구나!! 나는 그냥 change로 줬는데 keyup으로 주는것도 알아봐야겠다
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.
함수에 한 기능만 있도록 신경쓴게 보인다! 그리고 전체적으로 너무 깔끔하고 센스있는 코드야✨ 넘넘 수고했어!!!
@@ -0,0 +1,30 @@ | |||
export const HISTORY_LIST_DATA = [ |
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.
나도 한 파일에...ㅎㅎㅎㅎ
const historyBox = document.createElement("li"); | ||
historyBox.classList.add(`history__list__box`); | ||
historyBox.id = id; | ||
historyBox.innerHTML = ` |
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.
이렇게 해도 되는구나....
// 총 자산, 수입, 지출 렌더링 함수 | ||
const renderTotalBalance = () => { | ||
const incomeAmounts = [...$$(".history-amount.income")].map((history) => { | ||
return Number(history.innerHTML.replaceAll(",", "")); |
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.
history-amount와 income을 동시에 가진 모든 HTML 요소를 찾아서 그 요소들의 내용(innerHTML)을 숫자로 변환해서 배열을 생성한 거구나!! 이런방법도 있군...
근데 궁금한점!! ...이 스프레드 연산자가 여기서 무슨역할 하는건지 궁금해!
|
||
incomeCheckbox.checked | ||
? incomeLists.forEach((list) => (list.parentNode.style.display = "flex")) | ||
: incomeLists.forEach((list) => (list.parentNode.style.display = "none")); |
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.
아예 style을 바꿔주니까 내역리스트를 건드릴 필요가 없네!!
$( | ||
".add-category__select" | ||
).innerHTML = `<option class="add-category__option">알바비</option> | ||
<option class="add-category__option">용돈</option>`; |
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.
속성이 많은 애들은 innerHTML로 해주는게 더 편하규만,,,
handleOpenListAddModal(); | ||
handleChangeType(); | ||
handleAddList(); | ||
handleCloseListAddModal(); |
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.
이함수는 modal나타나게하는 함수랑 별개로 이렇게 전역으로 호출해줘도 event발생할 때마다 알아서 해주는건가...?
전역으로 호출해주는거랑 함수안에서 또 함수 호출해주는게 좀 헷갈려!!
✨ 구현 기능 명세
⭐️기본 과제
1. 최초 데이터
상수로
INIT_BALANCE
,HISTORY_LIST
데이터를 가집니다. (상수명은 자유)INIT_BALANCE
= 0HISTORY_LIST
: 입출금 내역 리스트 (4개
)최초 실행시 위 상수 데이터들 이용해 렌더링합니다. (즉, html에 직접 박아놓는 하드코딩 ❌)
→ 나의 자산은
INIT_BALANCE
로부터 4개의 입출금 내역 리스트를 반영하여 보여줍니다.2. 총수입 / 총지출
HISTORY_LIST
에 있는 수입 내역과 지출 내역을 계산해서 총수입, 총지출을 보여줍니다.3. 수입/지출 필터링
4. 리스트 삭제
X
버튼을 누르면 해당 리스트가 삭제됩니다.5. 리스트 추가
수입
지출
버튼카테고리
를 선택수입
을 선택하면 수입 관련된 항목들이,지출
을 선택하면 종류에 지출 관련된 항목들이 나옵니다.금액
과내용
입력 input저장하기
버튼닫기
버튼⭐️ 심화 과제
1. 리스트 삭제 모달
x
버튼 클릭시 삭제 모달이 나타납니다.→
예
클릭시 삭제를 진행합니다.→
취소
클릭시 모달이 사라집니다.2. 리스트 추가
alert
를 띄워 막습니다.alert
를 띄워 막습니다.3. 모달 백그라운드 & 애니메이션 (삭제, 추가)
+
클릭시 추가 모달이 아래에서 위로 올라옵니다.4. 카테고리 추가
Enter
키를 누르면 카테고리가 추가됩니다.5. 금액
,
로 표시됩니다. (나의 자산, 총수입/지출, 내역 리스트, 리스트 추가 input)💎 PR Point
1️⃣ 상수 데이터로 나의 자산, 총 수입, 총 지출, 내역 리스트 초기 값 렌더링 (기본)
INIT_BALANCE
,SUM_EXPENSE
,SUM_INCOME
,HISTORY_LIST_DATA
2️⃣ 수입 지출 필터링 (기본)
3️⃣ 리스트 삭제 (기본)
renderTotalBalance()
함수 재사용하여 실행4️⃣ 리스트 추가 (기본 + 심화)
5️⃣ 금액 3개 단위로 , 표시
🥺 소요 시간, 어려웠던 점
4h ~ 5h
🌈 구현 결과물
배포 링크