-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Docs Site] Add feedback prompt #18129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5fed982
[Docs Site] Add feedback prompt
KianNH c828626
Fix min width, add the rest of the values
KianNH 72c3931
max not min
KianNH e5b4aa0
fix min-width unit, add additional info into payload
KianNH 7d5b518
rename other-answer to info
KianNH 64c35a7
Update src/components/FeedbackPrompt.astro
KianNH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| --- | ||
| import { AstroIcon } from "~/components"; | ||
| --- | ||
|
|
||
| <feedback-prompt class="not-content"> | ||
| <div id="feedback-thumbs"> | ||
| <h2>Was this helpful?</h2> | ||
| <div class="not-content"> | ||
| <AstroIcon name="material-symbols:thumb-up-outline-rounded" title="Yes" /> | ||
| <AstroIcon | ||
| name="material-symbols:thumb-down-outline-rounded" | ||
| title="No" | ||
| /> | ||
| </div> | ||
| </div> | ||
| <div id="feedback-yes" class="hidden"> | ||
| <h2>What did you like?</h2> | ||
| <form> | ||
| <fieldset> | ||
| <div> | ||
| <input type="radio" id="accurate" value="accurate" name="reason" /> | ||
| <label for="accurate">Accurate</label> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="radio" | ||
| id="easy-to-understand" | ||
| value="easy-to-understand" | ||
| name="reason" | ||
| /> | ||
| <label for="easy-to-understand">Easy to understand</label> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="radio" | ||
| id="solved-my-problem" | ||
| value="solved-my-problem" | ||
| name="reason" | ||
| /> | ||
| <label for="solved-my-problem">Solved my problem</label> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="radio" | ||
| id="helped-me-decide-to-use-the-product" | ||
| value="solved-my-problem" | ||
| name="reason" | ||
| /> | ||
| <label for="helped-me-decide-to-use-the-product" | ||
| >Helped me decide to use the product</label | ||
| > | ||
| </div> | ||
| <div> | ||
| <input type="radio" id="other" name="reason" /> | ||
| <label for="other">Other</label> | ||
| <input | ||
| type="text" | ||
| placeholder="Tell us more about your experience." | ||
| id="info" | ||
| name="info" | ||
| /> | ||
| </div> | ||
| <input type="submit" value="Submit" /> | ||
| </fieldset> | ||
| </form> | ||
| </div> | ||
| <div id="feedback-no" class="hidden"> | ||
| <h2>What went wrong?</h2> | ||
| <form> | ||
| <fieldset> | ||
| <div> | ||
| <input | ||
| type="radio" | ||
| id="hard-to-understand" | ||
| value="hard-to-understand" | ||
| name="reason" | ||
| /> | ||
| <label for="hard-to-understand">Hard to understand</label> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="radio" | ||
| id="incorrect-information" | ||
| value="incorrect-information" | ||
| name="reason" | ||
| /> | ||
| <label for="incorrect-information">Incorrect information</label> | ||
| </div> | ||
| <div> | ||
| <input | ||
| type="radio" | ||
| id="missing-the-information" | ||
| value="missing-the-information" | ||
| name="reason" | ||
| /> | ||
| <label for="missing-the-information">Missing the information</label> | ||
| </div> | ||
| <div> | ||
| <input type="radio" id="other" value="other" name="reason" /> | ||
| <label for="other">Other</label> | ||
| <input | ||
| type="text" | ||
| placeholder="Tell us more about your experience." | ||
| id="info" | ||
| name="info" | ||
| /> | ||
| </div> | ||
| <input type="submit" value="Submit" /> | ||
| </fieldset> | ||
| </form> | ||
| </div> | ||
|
|
||
| <div id="feedback-thanks" class="hidden"> | ||
| <h2>Thank you for helping improve Cloudflare's documentation!</h2> | ||
| </div> | ||
| </feedback-prompt> | ||
|
|
||
| <style> | ||
| fieldset { | ||
| padding-top: 0; | ||
| padding-left: 0; | ||
| } | ||
|
|
||
| label { | ||
| font-size: small; | ||
| color: var(--sl-color-gray-3); | ||
| } | ||
|
|
||
| input[type="submit"], | ||
| input::placeholder { | ||
| font-size: x-small; | ||
| } | ||
|
|
||
| h2 { | ||
| color: var(--sl-color-white); | ||
| font-size: var(--sl-text-h5); | ||
| font-weight: 600; | ||
| line-height: var(--sl-line-height-headings); | ||
| margin-bottom: 0.5rem; | ||
| } | ||
|
|
||
| #info { | ||
| display: none; | ||
| } | ||
|
|
||
| #other:checked ~ #info { | ||
| display: flex; | ||
| } | ||
|
|
||
| [data-icon] { | ||
| cursor: pointer; | ||
| color: var(--sl-color-gray-3); | ||
| font-size: 1.5rem; | ||
| margin-right: 0.5rem; | ||
|
|
||
| &:hover { | ||
| color: var(--sl-color-text-accent); | ||
| border-color: var(--sl-color-text-accent); | ||
| } | ||
| } | ||
| </style> | ||
|
|
||
| <script> | ||
| class FeedbackPrompt extends HTMLElement { | ||
| connectedCallback() { | ||
| const icons = { | ||
| '[data-icon="material-symbols:thumb-up-outline-rounded"]': | ||
| "#feedback-yes", | ||
| '[data-icon="material-symbols:thumb-down-outline-rounded"]': | ||
| "#feedback-no", | ||
| }; | ||
|
|
||
| const thumbsDiv = this.querySelector("#feedback-thumbs"); | ||
| const thanksDiv = this.querySelector("#feedback-thanks"); | ||
|
|
||
| if (!thumbsDiv || !thanksDiv) return; | ||
|
|
||
| for (const [button, questions] of Object.entries(icons)) { | ||
| this.querySelector(button)?.addEventListener("click", () => { | ||
| thumbsDiv.classList.add("hidden"); | ||
|
|
||
| const questionsDiv = this.querySelector(questions); | ||
|
|
||
| if (!questionsDiv) return; | ||
|
|
||
| questionsDiv.classList.remove("hidden"); | ||
|
|
||
| const form = questionsDiv.querySelector("form"); | ||
|
|
||
| if (!form) return; | ||
|
|
||
| form.addEventListener("submit", async (e) => { | ||
| e.preventDefault(); | ||
|
|
||
| const formData = new FormData(e.target as HTMLFormElement); | ||
| formData.set("page", window.location.pathname); | ||
| formData.set("option", questions.split("-")[1]); | ||
|
|
||
| fetch("https://feedback.developers.cloudflare.com", { | ||
| method: "POST", | ||
| body: formData, | ||
| }); | ||
|
|
||
| questionsDiv.classList.add("hidden"); | ||
| thanksDiv.classList.remove("hidden"); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| customElements.define("feedback-prompt", FeedbackPrompt); | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| import type { Props } from "@astrojs/starlight/props"; | ||
| import Default from "@astrojs/starlight/components/TableOfContents.astro"; | ||
|
|
||
| import { FeedbackPrompt } from "~/components"; | ||
| --- | ||
|
|
||
| <Default {...Astro.props} /> | ||
| <br /> | ||
| <FeedbackPrompt /> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.