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

refactor: modify review item component #54

Merged
merged 10 commits into from
Jun 26, 2024
91 changes: 91 additions & 0 deletions components/review-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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() {
try {
this.shadowRoot.innerHTML = `
<style>
.review-item {
display: flex;
flex-direction: column;
align-items: center;
border-radius: 10px;
padding: 41px 51px 31px;
background-color: #efefef;
max-width: 568px;
}
.review-item blockquote,
figure {
margin: 0;
}
.review-content {
display: flex;
align-items: center;
}
.review-content figure {
width: 104px;
height: 104px;
flex-shrink: 0;
object-fit: cover;
margin-right: 31px;
}
.review-content figure > img {
width: 100%;
height: 100%;
padding-top: 7px;
border-radius: 48%;
background-color: #ffffff;
}
.review-content blockquote {
font-size: 14px;
}
.review-footer {
width: 100%;
margin-top: 14px;
}
.review-footer figcaption {
font-size: 16px;
text-align: right;
}
</style>
<article class="review-item">
<section class="review-content">
<figure>
<img src="${this.img}" alt="Reviewer">
</figure>
<blockquote>${this.text}</blockquote>
</section>
<footer class="review-footer">
<figcaption>${this.name}</figcaption>
</footer>
Comment on lines +79 to +81
Copy link
Member

@sounmind sounmind Jun 26, 2024

Choose a reason for hiding this comment

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

한 페이지 안에 footer가 두 개 이상 있으면 안 될 것 같아요. 어색해보이네요.
하지만 또, 찾아보면 꼭 footer가 하나만 있어야 한다는 것도 아니네요. SEO에도 큰 영향은 없어보입니다.

@DaleSeo @nhistory 분들은 어떻게 생각하시나요?

</article>
`;
} catch (error) {
// log any rendering errors.
console.error("Error during render:", error);
}
}
}

customElements.define("review-item", ReviewItem);
34 changes: 0 additions & 34 deletions components/review-item/review-item.css

This file was deleted.

46 changes: 0 additions & 46 deletions components/review-item/review-item.js

This file was deleted.

2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import "./components/footer-link/footer-link.js";
import "./components/header.js";
import "./components/hero/hero.js";
import "./components/link-button/link-button.js";
import "./components/review-item.js";
import "./components/button-link.js";
import "./components/review-item/review-item.js";
import "./components/seo-meta-tag/seo-meta-tag.js";