Skip to content
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

implement pushfeedback #3837

Merged
merged 9 commits into from
Jul 24, 2024
134 changes: 134 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"docusaurus-plugin-openapi-docs": "^2.0.4",
"docusaurus-theme-openapi-docs": "^2.0.4",
"mixpanel-browser": "^2.47.0",
"pushfeedback-react": "^0.1.30",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-player": "^2.11.0",
Expand Down
7 changes: 7 additions & 0 deletions src/theme/DocItem/Footer/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:root {
--feedback-primary-color: #fc5806;
}
christinaausley marked this conversation as resolved.
Show resolved Hide resolved

.button--icon {
line-height: 1em;
}
101 changes: 101 additions & 0 deletions src/theme/DocItem/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Why is this swizzled?
// To add a PushFeedback widget to every doc, to solicit feedback from readers.
// Swizzled from version 2.4.1.

import React, { useEffect } from "react";
christinaausley marked this conversation as resolved.
Show resolved Hide resolved
import Footer from "@theme-original/DocItem/Footer";

import { FeedbackButton } from "pushfeedback-react";
import { defineCustomElements } from "pushfeedback/loader";
import "pushfeedback/dist/pushfeedback/pushfeedback.css";
import "./index.css";

function FeedbackWidget() {
const buttonThumbsUp = (
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"></path>
</svg>
);
const buttonThumbsDown = (
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"></path>
</svg>
);
const projectId = "m6exeps3n1";

useEffect(() => {
if (typeof window !== "undefined") {
defineCustomElements(window);
}
}, []);

return (
<div className="feedback-widget margin-top--md margin-bottom--md">
<div className="margin-bottom--sm">
<b>Was this helpful?</b>
</div>
<span class="feedback-widget-positive">
<FeedbackButton
project={projectId}
rating="1"
custom-font="True"
button-style="default"
modal-position="center"
hide-email="true"
>
<button
className="button button--outline button--primary button--sm button--icon"
title="Yes"
>
{buttonThumbsUp}
</button>
</FeedbackButton>
</span>
<span class="feedback-widget-negative margin-left--sm">
<FeedbackButton
project={projectId}
rating="0"
custom-font="True"
button-style="default"
modal-position="center"
>
<button
className="button button--outline button--primary button--sm button--icon"
title="No"
>
{buttonThumbsDown}
</button>
</FeedbackButton>
</span>
</div>
);
}

export default function FooterWrapper(props) {
return (
<>
<FeedbackWidget />
<Footer {...props} />
</>
);
}
Loading