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

feat: add review item component #37

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions components/review-item/review-item.css
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;
}
46 changes: 46 additions & 0 deletions components/review-item/review-item.js
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() {
Copy link
Contributor

Choose a reason for hiding this comment

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

connectedCallback을 사용하면 더 안전하게 render할 수 있겠군요! 참고하겠습니다!

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
123 changes: 34 additions & 89 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@
}

.review-card-list {
margin-top: 4rem;
display: flex;
flex-wrap: wrap;
gap: 0.9rem;
display: grid;
grid-template-columns: repeat(2, 568px);
gap: 10px 9px;
padding-top: 40px;
}

.review-card {
Expand Down Expand Up @@ -279,91 +279,36 @@
<div id="member-review-container">
<span>참가자 후기</span>
<div class="review-card-list">
<div class="review-card">
<div class="picture-placeholder">
<img src="images/human.png" />
</div>
<div class="review">
<p>
해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은
선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를
풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며
실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수
있었습니다.
</p>
<div class="name">
<span>Sam</span>
</div>
</div>
</div>
<div class="review-card">
<div class="picture-placeholder">
<img src="images/human.png" />
</div>
<div class="review">
<p>
해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은
선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를
풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며
실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수
있었습니다.
</p>
<div class="name">
<span>Sam</span>
</div>
</div>
</div>
<div class="review-card">
<div class="picture-placeholder">
<img src="images/human.png" />
</div>
<div class="review">
<p>
해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은
선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를
풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며
실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수
있었습니다.
</p>
<div class="name">
<span>Sam</span>
</div>
</div>
</div>
<div class="review-card">
<div class="picture-placeholder">
<img src="images/human.png" />
</div>
<div class="review">
<p>
해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은
선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를
풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며
실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수
있었습니다.
</p>
<div class="name">
<span>Sam</span>
</div>
</div>
</div>
<div class="review-card">
<div class="picture-placeholder">
<img src="images/human.png" />
</div>
<div class="review">
<p>
해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은
선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를
풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며
실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수
있었습니다.
</p>
<div class="name">
<span>Sam</span>
</div>
</div>
</div>
<review-item
img="images/human.png"
text="해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은 선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를 풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며 실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수 있었습니다."
name="John Doe"
>
</review-item>
<review-item
img="images/human.png"
text="해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은 선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를 풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며 실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수 있었습니다."
name="John Doe"
>
</review-item>
<review-item
img="images/human.png"
text="해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은 선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를 풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며 실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수 있었습니다."
name="John Doe"
>
</review-item>
<review-item
img="images/human.png"
text="해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은 선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를 풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며 실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수 있었습니다."
name="John Doe"
>
</review-item>
<review-item
img="images/human.png"
text="해외취업을 목표로 리트코드 스터디 모임에 참여한 것은 좋은 선택이었습니다. 특히 혼자 공부하는 것보다 멤버들과 함께 문제를 풀며 시너지를 낼 수 있었습니다. 모임 중에 다양한 질문을 주고받으며 실력을 쌓을 수 있었고, 해외 취업 준비에 실질적인 도움을 받을 수 있었습니다."
name="John Doe"
>
</review-item>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import "./components/divider/divider.js";
import "./components/footer-link/footer-link.js";
import "./components/hero/hero.js";
import "./components/link-button/link-button.js";
import "./components/review-item/review-item.js";
import "./components/seo-meta-tag/seo-meta-tag.js";