Skip to content

Commit b934ec9

Browse files
committed
[UPDATE] index.html, style.css, main.js
adds frontend to collect user feedback
1 parent fadc4e4 commit b934ec9

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

assets/css/style.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,17 @@ main {
651651
color: #DDDDDD;
652652
}
653653

654+
button.btn-selectable.selected {
655+
color: #000 !important;
656+
background-color: lightgreen !important;
657+
}
658+
659+
#feedback-modal {
660+
width: fit-content;
661+
min-width: 300px;
662+
height: fit-content;
663+
}
664+
654665
/* Media Queries */
655666
@media(max-width: 800px) {
656667
.container{
@@ -678,4 +689,4 @@ main {
678689
.welcome-msg {
679690
font-size: 14px;
680691
}
681-
}
692+
}

assets/js/main.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ $(document).ready(function(){
4141
$(".tabs").tabs();
4242
$(".collapsible").collapsible();
4343
$(".tooltipped").tooltip();
44+
$(".modal").modal();
4445

4546
fetchRepos();
4647
fetchTeam();
@@ -405,6 +406,46 @@ class TypeWriter {
405406
}
406407
}
407408

409+
function showToast(htmlData, classData = "blue white-text", icon = "info") {
410+
let toastIcon = getMaterialIcon(icon, "left", false);
411+
return M.toast({html: toastIcon + htmlData, classes: classData});
412+
}
413+
414+
$("button.btn-selectable").click(function() {
415+
$(this).toggleClass("selected").siblings().removeClass("selected");
416+
});
417+
418+
$("#feedback-form").on("submit", function(e) {
419+
e.preventDefault();
420+
421+
let form = $(this);
422+
let submitBtn = form.find("button[type='submit']");
423+
let modal = $("#feedback-modal");
424+
let formdata = new FormData(this);
425+
let quickFeedback = $("#feedback-form button.btn-selectable.selected").attr("data-value");
426+
quickFeedback = (typeof quickFeedback == "undefined") ? "none" : quickFeedback;
427+
formdata.append("quick-feedback", quickFeedback);
428+
429+
$.ajax({
430+
url: "url-to-submit-feedback",
431+
data: formdata,
432+
method: "POST",
433+
timeout: 15000,
434+
contentType: false,
435+
processData: false,
436+
beforeSend: function() {
437+
submitBtn.html("Submitting...").attr("disabled", true);
438+
}
439+
}).done(function() {
440+
showToast("Feedback Submitted!", "green", "done");
441+
}).fail(function() {
442+
showToast("Failed to submit feedback!", "red", "error");
443+
}).always(function() {
444+
modal.modal("close");
445+
submitBtn.html("Submit").attr("disabled", false);
446+
});
447+
});
448+
408449
function init() {
409450
const textElement = document.querySelector(".txt-type");
410451
const words = JSON.parse(textElement.getAttribute("data-words"));

index.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,36 @@ <h4 class="title">Members</h4>
139139
</section>
140140
</main>
141141

142+
<div id="feedback-modal" class="modal">
143+
<div class="modal-content">
144+
<h4>Add your feedback</h4>
145+
146+
<form id="feedback-form" method="POST">
147+
<div class="form-row mb-3">
148+
<button type="button" class="tooltipped btn-floating mx-1 white btn-selectable" data-value="liked"
149+
data-name="quick-feedback" data-position="top" data-tooltip="Liked it"><i
150+
class="material-icons text-dark">mood</i></button>
151+
<button type="button" class="tooltipped btn-floating mx-1 white btn-selectable" data-value="disliked"
152+
data-name="quick-feedback" data-position="top" data-tooltip="Disliked it"><i
153+
class="material-icons text-dark">mood_bad</i></button>
154+
</div>
155+
<div class="form-row mb-3">
156+
<div class="input-field col s12">
157+
<i class="material-icons prefix">feedback</i>
158+
<textarea id="feedback-msg" name="user-message" class="materialize-textarea" required></textarea>
159+
<label for="feedback-msg">Write here</label>
160+
</div>
161+
</div>
162+
<div class="form-row mb-3">
163+
<div class="col-12 center-align">
164+
<button type="button" class="btn btn-danger waves-effect modal-close">Cancel</button>
165+
<button type="submit" class="btn btn-success waves-effect">Submit</button>
166+
</div>
167+
</div>
168+
</form>
169+
</div>
170+
</div>
171+
142172
<footer id="footer" class="section-bg">
143173
<div class="container footer-container">
144174
<div class="row">
@@ -168,10 +198,12 @@ <h4>Contact Us</h4>
168198
<div class="col-lg-4 col-md-6 col-sm-6 col-12 footer-feedback">
169199
<h4>Feedback</h4>
170200
<p>We are happy to hear from you.</p>
171-
<button type="button" class="btn btn-primary waves-effect">Give Feedback</button>
201+
<button type="button" class="btn btn-primary waves-effect modal-trigger" data-target="feedback-modal">Give
202+
Feedback</button>
172203
</div>
173204
</div>
174205
</div>
206+
175207
<div class="footer-bottom">
176208
<div class="container">
177209
<div class="copyright">

0 commit comments

Comments
 (0)