File size: 4,233 Bytes
beb4764
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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);