|
| 1 | +<!-- Feedback Widget --> |
1 | 2 | <div class="rating-widget" style=" |
2 | | - background: #fff; |
3 | | - border: 1px solid #ddd; |
| 3 | + background: var(--md-default-bg-color); |
| 4 | + border: 0.05rem solid var(--md-default-fg-color--lightest); |
4 | 5 | padding: 10px 15px; |
5 | 6 | border-radius: 0.2rem; |
6 | 7 | margin-bottom: 16px; |
7 | 8 | font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
8 | | - font-size: 15px; |
9 | | - color: #000; |
| 9 | + font-size: 16px; |
10 | 10 | text-align: center; |
| 11 | + transition: all 0.2s ease-out; |
11 | 12 | "> |
12 | | - <div style=" |
| 13 | + |
| 14 | + <div class="rating-title" style=" |
13 | 15 | margin-bottom: 4px; |
14 | | - font-weight: bold; |
15 | | - color: #0E5FB5; |
16 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
17 | 16 | font-size: 15px; |
| 17 | + font-weight: bold; |
| 18 | + /* Removed inline color to use CSS */ |
18 | 19 | "> |
19 | | - Do you like Percona docs? |
| 20 | + Rate this page |
20 | 21 | </div> |
21 | 22 |
|
22 | 23 | <div class="rating-stars" style="display: inline-block;"> |
|
25 | 26 | font-size: 24px; |
26 | 27 | cursor: pointer; |
27 | 28 | margin: 0 2px; |
28 | | - color: #000; |
29 | 29 | display: inline-block; |
30 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
31 | 30 | ">☆</span> |
32 | 31 | {% endfor %} |
33 | 32 | </div> |
34 | 33 |
|
35 | | - <!-- Notification container --> |
36 | 34 | <div id="feedback-notification" style=" |
37 | 35 | display: none; |
38 | 36 | margin-top: 10px; |
39 | | - color: green; |
| 37 | + color: var(--md-typeset-a-color); |
40 | 38 | font-weight: 500; |
41 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
42 | 39 | font-size: 14px; |
43 | | - ">Thank you for your feedback</div> |
| 40 | + ">Thanks for your feedback</div> |
44 | 41 |
|
45 | 42 | <div id="feedback-form" style=" |
46 | 43 | display: none; |
47 | 44 | margin-top: 12px; |
48 | 45 | text-align: left; |
49 | 46 | position: relative; |
50 | | - border: 1px solid #ccc; |
| 47 | + border: 0.05rem solid var(--md-default-fg-color--lightest); |
51 | 48 | padding: 12px; |
52 | 49 | border-radius: 6px; |
53 | | - background: #f9f9f9; |
| 50 | + background: var(--md-default-bg-color); |
54 | 51 | width: 100%; |
55 | 52 | box-sizing: border-box; |
56 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
| 53 | + transition: all 0.2s ease-out; |
57 | 54 | "> |
58 | | - <button id="close-feedback" aria-label="Close feedback form" title="Close" style=" |
| 55 | + <button id="close-feedback" title="Close" style=" |
59 | 56 | position: absolute; |
60 | 57 | top: 8px; |
61 | 58 | right: 8px; |
|
64 | 61 | font-size: 20px; |
65 | 62 | font-weight: bold; |
66 | 63 | cursor: pointer; |
67 | | - color: #999; |
| 64 | + color: var(--md-default-fg-color--light); |
68 | 65 | line-height: 1; |
69 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
70 | 66 | ">×</button> |
71 | 67 |
|
72 | | - <div style="margin-bottom: 10px; font-weight: normal; font-size: 15px;"> |
| 68 | + <div style="margin-bottom: 10px; font-size: 15px;"> |
73 | 69 | Was this page helpful? |
74 | 70 | </div> |
75 | 71 |
|
|
80 | 76 | margin-bottom: 12px; |
81 | 77 | resize: vertical; |
82 | 78 | font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
| 79 | + color: var(--md-default-fg-color); |
| 80 | + background: var(--md-default-bg-color); |
| 81 | + border: 0.05rem solid var(--md-default-fg-color--lightest); |
83 | 82 | "></textarea> |
84 | 83 |
|
85 | 84 | <label for="feedback-email" style=" |
86 | 85 | display: block; |
87 | | - font-weight: 500; |
88 | 86 | font-size: 15px; |
89 | 87 | margin-bottom: 4px; |
90 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
91 | 88 | "> |
92 | | - Email <span style="font-weight: normal; color: #666;">(optional)</span> |
| 89 | + Email <span style="color: var(--md-default-fg-color--light);">(optional)</span> |
93 | 90 | </label> |
94 | 91 |
|
95 | 92 | <input type=" email" id=" feedback-email" placeholder=" [email protected]" style=" |
|
98 | 95 | padding: 6px; |
99 | 96 | margin-bottom: 12px; |
100 | 97 | font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
| 98 | + color: var(--md-default-fg-color); |
| 99 | + background: var(--md-default-bg-color); |
| 100 | + border: 0.05rem solid var(--md-default-fg-color--lightest); |
101 | 101 | " /> |
102 | 102 |
|
103 | | - <button id="submit-feedback" style=" |
104 | | - padding: 5px 10px; |
105 | | - font-size: 14px; |
106 | | - background-color: #0E5FB5; |
107 | | - color: white; |
108 | | - border: none; |
109 | | - border-radius: 3px; |
110 | | - cursor: pointer; |
111 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
112 | | - "> |
113 | | - Send |
114 | | - </button> |
| 103 | +<button id="submit-feedback" style=" |
| 104 | + padding: 5px 10px; |
| 105 | + font-size: 14px; |
| 106 | + background-color: var(--md-typeset-a-color); |
| 107 | + border: none; |
| 108 | + border-radius: 3px; |
| 109 | + cursor: pointer; |
| 110 | + font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
| 111 | +"> |
| 112 | + Send |
| 113 | +</button> |
115 | 114 |
|
116 | 115 | <div id="feedback-status" style=" |
117 | 116 | margin-top: 8px; |
118 | 117 | font-size: 13px; |
119 | | - font-family: 'Poppins','Roboto',Arial,Helvetica,sans-serif; |
120 | 118 | "></div> |
121 | 119 | </div> |
122 | 120 | </div> |
123 | 121 |
|
| 122 | +<style> |
| 123 | + /* Hover shadow like data-banner */ |
| 124 | + .rating-widget:hover, |
| 125 | + #feedback-form:hover { |
| 126 | + box-shadow: |
| 127 | + 0px 1px 10px 0px rgba(0, 0, 0, 0.12), |
| 128 | + 0px 4px 5px 0px rgba(0, 0, 0, 0.14), |
| 129 | + 0px 2px 4px -1px rgba(0, 0, 0, 0.20); |
| 130 | + } |
| 131 | + |
| 132 | + /* Default star colors */ |
| 133 | + .rating-stars .star { |
| 134 | + color: var(--md-default-fg-color); |
| 135 | + transition: color 0.2s ease-out; |
| 136 | + } |
| 137 | + |
| 138 | + /* Active/hovered stars */ |
| 139 | + .rating-stars .star.active, |
| 140 | + .rating-stars .star.hovered { |
| 141 | + color: var(--md-typeset-a-color, #0E5FB5); |
| 142 | + } |
| 143 | + |
| 144 | + /* Rate this page text color matches stars in light mode */ |
| 145 | + .rating-widget .rating-title { |
| 146 | + color: var(--md-typeset-a-color, #0E5FB5); |
| 147 | + } |
| 148 | + |
| 149 | + /* Dark mode */ |
| 150 | + @media (prefers-color-scheme: dark) { |
| 151 | + /* Rate this page text */ |
| 152 | + .rating-widget .rating-title { |
| 153 | + color: var(--md-typeset-a-color, #93C7FF) !important; |
| 154 | + } |
| 155 | + /* Stars active and hovered fill color */ |
| 156 | + .rating-stars .star.active, |
| 157 | + .rating-stars .star.hovered { |
| 158 | + color: var(--md-typeset-a-color, #93C7FF) !important; |
| 159 | + } |
| 160 | + |
| 161 | + /* Feedback form text */ |
| 162 | + #feedback-form, |
| 163 | + #feedback-form textarea, |
| 164 | + #feedback-form input, |
| 165 | + #feedback-form label, |
| 166 | + #feedback-form button, |
| 167 | + #feedback-form div { |
| 168 | + color: var(--md-typeset-a-color, #93C7FF) !important; |
| 169 | + border-color: #666 !important; |
| 170 | + background: var(--md-default-bg-color) !important; |
| 171 | + } |
| 172 | + |
| 173 | + /* Close button color */ |
| 174 | + #close-feedback { |
| 175 | + color: var(--md-typeset-a-color, #93C7FF) !important; |
| 176 | + } |
| 177 | + } |
| 178 | +</style> |
| 179 | + |
124 | 180 | <script> |
125 | 181 | function initFeedbackWidget() { |
126 | 182 | const stars = document.querySelectorAll(".rating-stars .star"); |
|
135 | 191 | if (!stars.length || !feedbackForm) return; |
136 | 192 |
|
137 | 193 | const formURL = "https://docs.google.com/forms/d/e/1FAIpQLSfhscELpzoXB4uyh9pXNmXSeqKc10IH_DxmAoaVGID85sO0Aw/formResponse"; |
138 | | - |
139 | 194 | const fieldIds = { |
140 | 195 | rating: "entry.303027158", |
141 | 196 | pageUrl: "entry.295622433", |
|
146 | 201 | let selectedRating = 0; |
147 | 202 | let notificationTimeout; |
148 | 203 |
|
| 204 | + function showNotification(msg) { |
| 205 | + notification.textContent = msg; |
| 206 | + notification.style.display = "block"; |
| 207 | + clearTimeout(notificationTimeout); |
| 208 | + notificationTimeout = setTimeout(() => { |
| 209 | + notification.style.display = "none"; |
| 210 | + }, 3000); |
| 211 | + } |
| 212 | + |
149 | 213 | function sendRatingOnly(rating) { |
150 | 214 | const formData = new FormData(); |
151 | 215 | formData.append(fieldIds.rating, rating); |
|
160 | 224 | }); |
161 | 225 | } |
162 | 226 |
|
163 | | - function showNotification(msg) { |
164 | | - notification.textContent = msg; |
165 | | - notification.style.display = "block"; |
166 | | - clearTimeout(notificationTimeout); |
167 | | - notificationTimeout = setTimeout(() => { |
168 | | - notification.style.display = "none"; |
169 | | - }, 3000); |
170 | | - } |
171 | | - |
172 | 227 | function submitFeedback(rating, feedbackText = "", email = "") { |
173 | 228 | const formData = new FormData(); |
174 | 229 | formData.append(fieldIds.rating, rating); |
|
181 | 236 | mode: "no-cors", |
182 | 237 | body: formData |
183 | 238 | }).then(() => { |
184 | | - statusDiv.style.color = "green"; |
| 239 | + statusDiv.style.color = ""; |
185 | 240 | statusDiv.textContent = "Thanks for your feedback!"; |
186 | 241 | feedbackTextarea.value = ""; |
187 | 242 | emailInput.value = ""; |
188 | 243 | feedbackForm.style.display = "none"; |
189 | 244 | selectedRating = 0; |
190 | 245 |
|
191 | 246 | stars.forEach((s) => { |
192 | | - s.innerHTML = "☆"; |
193 | | - s.style.color = "#000"; |
| 247 | + s.textContent = "☆"; |
| 248 | + s.classList.remove("active"); |
| 249 | + s.classList.remove("hovered"); |
194 | 250 | }); |
195 | 251 | }).catch(() => { |
196 | | - statusDiv.style.color = "red"; |
| 252 | + statusDiv.style.color = ""; |
197 | 253 | statusDiv.textContent = "Error sending feedback."; |
198 | 254 | }); |
199 | 255 | } |
|
203 | 259 |
|
204 | 260 | star.addEventListener("mouseover", () => { |
205 | 261 | stars.forEach((s, index) => { |
206 | | - s.innerHTML = index < rating ? "★" : "☆"; |
207 | | - s.style.color = index < rating ? "#0E5FB5" : "#000"; |
| 262 | + s.textContent = index < rating ? "★" : "☆"; |
| 263 | + if(index < rating) { |
| 264 | + s.classList.add("hovered"); |
| 265 | + s.classList.remove("active"); |
| 266 | + } else { |
| 267 | + s.classList.remove("hovered"); |
| 268 | + s.classList.remove("active"); |
| 269 | + } |
208 | 270 | }); |
209 | 271 | }); |
210 | 272 |
|
211 | 273 | star.addEventListener("mouseleave", () => { |
212 | 274 | stars.forEach((s, index) => { |
213 | | - s.innerHTML = index < selectedRating ? "★" : "☆"; |
214 | | - s.style.color = index < selectedRating ? "#0E5FB5" : "#000"; |
| 275 | + s.textContent = index < selectedRating ? "★" : "☆"; |
| 276 | + if(index < selectedRating) { |
| 277 | + s.classList.add("active"); |
| 278 | + } else { |
| 279 | + s.classList.remove("active"); |
| 280 | + } |
| 281 | + s.classList.remove("hovered"); |
215 | 282 | }); |
216 | 283 | }); |
217 | 284 |
|
218 | 285 | star.addEventListener("click", () => { |
219 | 286 | selectedRating = rating; |
220 | 287 |
|
221 | 288 | stars.forEach((s, index) => { |
222 | | - s.innerHTML = index < rating ? "★" : "☆"; |
223 | | - s.style.color = index < rating ? "#0E5FB5" : "#000"; |
| 289 | + s.textContent = index < rating ? "★" : "☆"; |
| 290 | + if(index < rating) { |
| 291 | + s.classList.add("active"); |
| 292 | + } else { |
| 293 | + s.classList.remove("active"); |
| 294 | + } |
| 295 | + s.classList.remove("hovered"); |
224 | 296 | }); |
225 | 297 |
|
226 | 298 | sendRatingOnly(rating); |
227 | | - showNotification("Thank you for your feedback"); |
| 299 | + showNotification("Thanks for your feedback"); |
228 | 300 | feedbackForm.style.display = "block"; |
229 | 301 | statusDiv.textContent = ""; |
230 | 302 | }); |
231 | 303 | }); |
232 | 304 |
|
233 | 305 | submitButton.addEventListener("click", () => { |
234 | 306 | if (!selectedRating) return; |
235 | | - |
236 | 307 | const feedbackText = feedbackTextarea.value.trim(); |
237 | 308 | const email = emailInput.value.trim(); |
238 | 309 |
|
239 | 310 | if (selectedRating < 5 && !feedbackText) { |
240 | | - statusDiv.style.color = "red"; |
241 | | - statusDiv.textContent = "Please enter feedback before sending."; |
| 311 | + statusDiv.style.color = ""; |
| 312 | + statusDiv.textContent = "Write feedback before sending."; |
242 | 313 | return; |
243 | 314 | } |
244 | 315 |
|
|
253 | 324 | selectedRating = 0; |
254 | 325 |
|
255 | 326 | stars.forEach((s) => { |
256 | | - s.innerHTML = "☆"; |
257 | | - s.style.color = "#000"; |
| 327 | + s.textContent = "☆"; |
| 328 | + s.classList.remove("active"); |
| 329 | + s.classList.remove("hovered"); |
258 | 330 | }); |
259 | 331 | }); |
260 | 332 | } |
261 | 333 |
|
262 | | -// Run on full page load |
| 334 | +// Init on load |
263 | 335 | document.addEventListener("DOMContentLoaded", initFeedbackWidget); |
264 | 336 |
|
265 | | -// Run on every page change in MkDocs Material |
| 337 | +// Re-init on page change (MkDocs Material support) |
266 | 338 | if (typeof document$ !== 'undefined') { |
267 | 339 | document$.subscribe(() => { |
268 | 340 | initFeedbackWidget(); |
|
0 commit comments