Conversation
taggon
reviewed
Nov 30, 2024
| /* 자판기 스타일 */ | ||
| .vending-machine { | ||
| border: 1px solid #000; | ||
| padding: 20px !important; |
Contributor
There was a problem hiding this comment.
꼭 필요한 !important 였을까요? CSS에서 !important는 너무 높은 우선순위를 가지고 있어서 최대한 자제하는 게 좋습니다.
Contributor
There was a problem hiding this comment.
이건 vite에서 기본으로 만들어 준 파일이 남은 거죠?
| <input class="input-amount" type="number" id="inputAmount" placeholder="금액 입력" min="1"> | ||
| </div> | ||
| <div class="col s2 input-button"> | ||
| <button class="btn action-button" onclick="insertAmount()">투입</button> |
Contributor
There was a problem hiding this comment.
onclick 이벤트 핸들러를 js에서 추가하도록 해보시겠어요?
전역 함수에 의존하지 않고도 기능이 동작하도록 만들기 위해서입니다.
| let totalAmount = 0; | ||
|
|
||
|
|
||
| function init() { |
Contributor
There was a problem hiding this comment.
이 부분은 async 함수로 만들어보세요. await과 함께 사용되면 로직이 훨씬 단순해질 수 있습니다.
| button.classList.add('btn', 'product'); | ||
| button.setAttribute('data-price', product.price); | ||
| button.innerHTML = `${product.name}<br><span>${product.price.toLocaleString()}원</span>`; | ||
| button.onclick = () => purchaseProduct(button); |
Contributor
There was a problem hiding this comment.
"이벤트 위임을 사용해보세요"라고 말씀드렸던 것 기억하시죠? :)
taggon
reviewed
Nov 30, 2024
|
|
||
| const button = document.createElement('button'); | ||
| button.classList.add('btn', 'product'); | ||
| button.setAttribute('data-price', product.price); |
Contributor
There was a problem hiding this comment.
button.dataset을 사용하지 않은 이유가 있을까요? :)
taggon
reviewed
Nov 30, 2024
Comment on lines
+16
to
+20
| const buttonWrapper = document.createElement('div'); | ||
| buttonWrapper.classList.add('col', 's4'); | ||
|
|
||
| const button = document.createElement('button'); | ||
| button.classList.add('btn', 'product'); |
Contributor
There was a problem hiding this comment.
이렇게 한땀한땀 HTML 구조를 정의하는 것보다는 template 태그를 사용해보시면 어떨까요?
added 16 commits
November 30, 2024 14:32
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
IC2_FE 온보딩 프로젝트 - 자판기