learncode's picture
Create a professional, high-end website for “CHESS TITANS,” a premier chess coaching brand.
beb4764 verified
Raw History Blame Contribute Delete
4.23 kB
class CustomTestimonial extends HTMLElement {
static get observedAttributes() {
return ['name', 'title', 'text', 'photo'];
}
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this.render();
}
}
render() {
const name = this.getAttribute('name') || '';
const title = this.getAttribute('title') || '';
const text = this.getAttribute('text') || '';
const photo = this.getAttribute('photo') || 'http://static.photos/people/200x200/10';
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
}
.testimonial-card {
background-color: rgba(255, 255, 255, 0.1);
border-radius: 0.5rem;
padding: 2rem;
height: 100%;
transition: all 0.3s ease;
}
.testimonial-card:hover {
transform: translateY(-5px);
background-color: rgba(255, 255, 255, 0.15);
}
.testimonial-content {
margin-bottom: 1.5rem;
font-style: italic;
position: relative;
}
.testimonial-content::before,
.testimonial-content::after {
content: '"';
font-size: 3rem;
color: #D4AF37;
opacity: 0.3;
position: absolute;
}
.testimonial-content::before {
top: -1rem;
left: -1rem;
}
.testimonial-content::after {
bottom: -2rem;
right: -1rem;
}
.testimonial-author {
display: flex;
align-items: center;
}
.testimonial-photo {
width: 50px;
height: 50px;
border-radius: 50%;
object-fit: cover;
margin-right: 1rem;
border: 2px solid #D4AF37;
}
.author-info {
display: flex;
flex-direction: column;
}
.author-name {
font-weight: 600;
}
.author-title {
font-size: 0.875rem;
opacity: 0.8;
}
.rating {
color: #D4AF37;
margin-top: 0.5rem;
display: flex;
}
</style>
<div class="testimonial-card">
<div class="testimonial-content">
${text}
</div>
<div class="testimonial-author">
<img src="${photo}" alt="${name}" class="testimonial-photo">
<div class="author-info">
<span class="author-name">${name}</span>
<span class="author-title">${title}</span>
<div class="rating">
<i data-feather="star" fill="currentColor"></i>
<i data-feather="star" fill="currentColor"></i>
<i data-feather="star" fill="currentColor"></i>
<i data-feather="star" fill="currentColor"></i>
<i data-feather="star" fill="currentColor"></i>
</div>
</div>
</div>
</div>
`;
}
}
customElements.define('custom-testimonial', CustomTestimonial);