Skip to content

Commit

Permalink
Merge pull request #139 from bcnmy/feedback
Browse files Browse the repository at this point in the history
Add feedback tool in docs
  • Loading branch information
himanshugarg06 authored Dec 22, 2023
2 parents c38ed04 + 0efa1a6 commit f9eeecb
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/issue_templates/feedback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Feedback
description: Help us improve the Biconomy documentation site by leaving your feedback
title: "[Feedback]"
labels: ["documentation", "feedback", "community"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to leave your feedback!
- type: textarea
id: improvements
attributes:
label: How could we improve the Biconomy documentation site?
placeholder: Send us your ideas!
- type: markdown
attributes:
value: |
We welcome documentation contributions!
72 changes: 72 additions & 0 deletions src/components/Feedback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// src/components/Feedback.js

import React, { useState } from 'react';
import {useLocation} from '@docusaurus/router';

const Feedback = () => {
const location = useLocation();
const [showYesCommentDiv, setShowYesCommentDiv] = useState(false);
const [showNoCommentDiv, setShowNoCommentDiv] = useState(false);
const handleFeedback = (isHelpful: boolean) => {
// Implement logic to handle user feedback (e.g., send to analytics or API)
console.log(`User feedback: ${isHelpful ? 'Helpful' : 'Not helpful'}`);
if(isHelpful) {
setShowYesCommentDiv(true);
setShowNoCommentDiv(false);
} else {
setShowYesCommentDiv(false);
setShowNoCommentDiv(true);
}
// You can customize this logic based on your needs
};

return (
<div>
<p style={{marginBottom: 6 }}>Was this page helpful?</p>
<label>
<input
type="radio"
name="feedback"
value="yes"
checked={showYesCommentDiv === true}
onChange={() => handleFeedback(true)}
/>
Yes
</label>
<div className="gap-2"></div>
<label>
<input
type="radio"
name="feedback"
value="no"
checked={showNoCommentDiv === true}
onChange={() => handleFeedback(false)}
/>
No
</label>
{
showYesCommentDiv && (
<div>
<p>Thanks!</p>
</div>
)
}
{

showNoCommentDiv && (
<div>
<p>Thanks! Help us improve by leaving a comment:{' '}
<a
href={`https://github.com/bcnmy/docs/issues/new?assignees=&amp;labels=documentation%2Cfeedback%2Ccommunity&amp;template=feedback.yml&amp;title=%5BFeedback%5D%20Page:%20${location.pathname}`}
target="_blank"
rel="noreferrer noopener"
>Leave a comment
</a>
</p>
</div>
)}
</div>
);
};

export default Feedback;
15 changes: 15 additions & 0 deletions src/theme/TOCItems/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import TOCItems from '@theme-original/TOCItems';
import Feedback from '../../components/Feedback';

export default function TOCItemsWrapper(props) {
return (
<>
<TOCItems {...props} />
<div className="table-of-contents">
<Feedback />
</div>

</>
);
}

0 comments on commit f9eeecb

Please sign in to comment.