-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add review item component #37
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,34 @@ | ||
.review-item { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 10px; | ||
padding: 41px 51px 31px; | ||
background-color: #efefef; | ||
max-width: 568px; | ||
} | ||
.review-img-text-container { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.review-img { | ||
width: 104px; | ||
height: 104px; | ||
flex-shrink: 0; | ||
margin-right: 31px; | ||
} | ||
.review-img img { | ||
width: 100%; | ||
height: 100%; | ||
padding-top: 7px; | ||
border-radius: 50%; | ||
background-color: #ffffff; | ||
} | ||
.review-text { | ||
font-size: 14px; | ||
} | ||
.review-name { | ||
width: 100%; | ||
margin-top: 14px; | ||
text-align: right; | ||
} |
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,46 @@ | ||
class ReviewItem extends HTMLElement { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
// initial render in here to ensure the element is fully connected to the DOM. | ||
connectedCallback() { | ||
this.attachShadow({ mode: "open" }); | ||
this.render(); | ||
} | ||
|
||
// getter to make it clean to access the attribute value and ensure a default empty string if the attribute is missing. | ||
get text() { | ||
return this.getAttribute("text") || ""; | ||
} | ||
|
||
get name() { | ||
return this.getAttribute("name") || ""; | ||
} | ||
|
||
get img() { | ||
return this.getAttribute("img") || ""; | ||
} | ||
|
||
render() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inspired from React? 😆 |
||
try { | ||
this.shadowRoot.innerHTML = ` | ||
<link rel="stylesheet" href="components/review-item/review-item.css"> | ||
<div class="review-item"> | ||
<div class="review-img-text-container"> | ||
<div class="review-img"> | ||
<img src="${this.img}" alt="Reviewer"> | ||
</div> | ||
<div class="review-text">${this.text}</div> | ||
</div> | ||
<div class="review-name">${this.name}</div> | ||
</div> | ||
Comment on lines
+29
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분 HTML 마크업을 다음과 같이 좀 더 sementic하게 하면 좀 더 좋지 않을까 생각이 들었습니다. (머지된 된 PR에 이렇게 의견을 드려서 죄송합니다 ㅠㅠ) <figure>
<blockquote>
당신이 언젠가 죽을 것이라는 사실을 기억하는 것이야말로 무언가 잃을지도
모른다는 두려움에 갖히는 것을 피할 수 있는, 제가 아는 가장 최고의
방법입니다.
</blockquote>
<figcaption>
<cite>스티브 잡스</cite>
</figcaption>
</figure> |
||
`; | ||
} catch (error) { | ||
// log any rendering errors. | ||
console.error("Error during render:", error); | ||
} | ||
} | ||
} | ||
|
||
customElements.define("review-item", ReviewItem); |
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
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
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.
connectedCallback을 사용하면 더 안전하게 render할 수 있겠군요! 참고하겠습니다!