Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add user feedback widget to python docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
ys2843 committed Jun 29, 2020
1 parent d839251 commit 6c21306
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
37 changes: 37 additions & 0 deletions docs/python_docs/_static/feedback.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.feedback-container {
text-align: center;
}

.feedback-answer-container {
display: inline-block;
}

.feedback-question {
display: inline-block;
padding: 0.5em 1em 0.5em 1em;
}

.feedback-answer {
display: inline-block;
padding: 0.5em 1em 0.5em 1em;
color: #048ccc;
cursor: pointer;
}

.feedback-answer:hover {
color: #ffffff;
background-color: #048ccc;
}

.feedback-thank-you {
display: none;
padding: 0.5em 1em 0.5em 1em;
}

.feedback-hr-top {
margin-top: 50px;
}

.feedback-hr-bottom {
margin-bottom: 30px;
}
13 changes: 13 additions & 0 deletions docs/python_docs/_static/feedback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function() {
$(".feedback-answer").on("click", function () {
$(".feedback-question").remove();
$(".feedback-answer-container").remove();
$(".feedback-thank-you").show();
ga("send", {
hitType: "event",
eventCategory: "Did this page help you?",
eventAction: $(this).attr("data-response"),
eventLabel: window.location.pathname || "unknown",
});
});
});
15 changes: 14 additions & 1 deletion docs/python_docs/themes/mx-theme/mxtheme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@
'_static/sphinx_materialdesign_theme.css',
'_static/fontawesome/all.css',
'_static/fonts.css',
'_static/feedback.css',
] %}

{%- block header %}
<script type="text/javascript" src="{{ pathto('_static/sphinx_materialdesign_theme.js', 1) }} "></script>
<script type="text/javascript" src="{{ pathto('_static/sphinx_materialdesign_theme.js', 1) }} "></script>
<script type="text/javascript" src="{{ pathto('_static/feedback.js', 1) }}"></script>
{% endblock %}
{%- block relbar1 %}{% endblock %}
{%- block relbar2 %}{% include "relations.html" %}{% endblock %}
Expand All @@ -85,6 +87,17 @@
{%- block document %}
<div class="page-content" role="main">
{% block body %} {% endblock %}
<hr class="feedback-hr-top" />
<div class="feedback-container">
<div class="feedback-question">Did this page help you?</div>
<div class="feedback-answer-container">
<div class="feedback-answer yes-link" data-response="yes">Yes</div>
<div class="feedback-answer no-link" data-response="no">No</div>
</div>
<div class="feedback-thank-you">Thanks for your feedback</div>
</div>
<hr class="feedback-hr-bottom" />

</div>
<div class="side-doc-outline">
<div class="side-doc-outline--content">
Expand Down

0 comments on commit 6c21306

Please sign in to comment.