Skip to content

Commit

Permalink
WIP: add feedback widget to docs with flarelytics integration (#9129)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
  • Loading branch information
sydney-runkle and samuelcolvin committed Mar 28, 2024
1 parent 3ad2018 commit b900fe2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/extra/feedback.js
@@ -0,0 +1,21 @@
var feedback = document.forms.feedback
feedback.hidden = false

feedback.addEventListener("submit", function(ev) {
ev.preventDefault()

var data = ev.submitter.getAttribute("data-md-value")
feedback.firstElementChild.disabled = true

var note = feedback.querySelector(
`.md-feedback__note [data-md-value='${data}']`
)
if (note)
note.hidden = false

if (data == 1) {
window.flarelytics_event('thumbsUp');
} else if (data == 0) {
window.flarelytics_event('thumbsDown');
}
})
15 changes: 15 additions & 0 deletions mkdocs.yml
Expand Up @@ -36,6 +36,20 @@ edit_uri: edit/main/docs/
extra:
version:
provider: mike
analytics:
feedback:
title: Was this page helpful?
ratings:
- icon: material/thumb-up-outline
name: This page was helpful
data: 1
note: >-
Thanks for your feedback!
- icon: material/thumb-down-outline
name: This page could be improved
data: 0
note: >-
Thanks for your feedback!
# https://www.mkdocs.org/user-guide/configuration/#validation
validation:
Expand All @@ -47,6 +61,7 @@ extra_css:
- 'extra/terminal.css'
- 'extra/tweaks.css'
extra_javascript:
- 'extra/feedback.js'
- 'extra/fluff.js'
- 'https://samuelcolvin.github.io/mkdocs-run-code/run_code_main.js'

Expand Down

0 comments on commit b900fe2

Please sign in to comment.