-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added feedback section for each page (#350)
* feat: added feedback section for each page * fix: update content set id * fix: added environment variables * fix: removed typesense from env
- Loading branch information
1 parent
0eb5b7c
commit 81b2fe5
Showing
9 changed files
with
202 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1 @@ | ||
TYPESENSE_COLLECTION_NAME= | ||
TYPESENSE_SERVER_HOST= | ||
TYPESENSE_SEARCH_ONLY_APIKEY= | ||
FEEDBACK_CONTENT_SET_ID= |
This file contains 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 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 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 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 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 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,50 @@ | ||
import React from "react"; | ||
import Translate, { translate } from "@docusaurus/Translate"; | ||
import PaginatorNavLink from "@theme/PaginatorNavLink"; | ||
import type { Props } from "@theme/DocPaginator"; | ||
import Feedback from "../Feedback"; | ||
|
||
export default function DocPaginator(props: Props): JSX.Element { | ||
const { previous, next } = props; | ||
return ( | ||
<nav> | ||
<div | ||
className="pagination-nav docusaurus-mt-lg" | ||
aria-label={translate({ | ||
id: "theme.docs.paginator.navAriaLabel", | ||
message: "Docs pages", | ||
description: "The ARIA label for the docs pagination", | ||
})} | ||
> | ||
{previous && ( | ||
<PaginatorNavLink | ||
{...previous} | ||
subLabel={ | ||
<Translate | ||
id="theme.docs.paginator.previous" | ||
description="The label used to navigate to the previous doc" | ||
> | ||
Previous | ||
</Translate> | ||
} | ||
/> | ||
)} | ||
{next && ( | ||
<PaginatorNavLink | ||
{...next} | ||
subLabel={ | ||
<Translate | ||
id="theme.docs.paginator.next" | ||
description="The label used to navigate to the next doc" | ||
> | ||
Next | ||
</Translate> | ||
} | ||
isNext | ||
/> | ||
)} | ||
</div> | ||
<Feedback /> | ||
</nav> | ||
); | ||
} |
This file contains 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,86 @@ | ||
import { useState } from "react"; | ||
import { | ||
FeelbackTaggedMessage, | ||
Question, | ||
PRESET_YESNO_LIKE_DISLIKE, | ||
} from "@feelback/react"; | ||
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; | ||
|
||
const YES_TAGS = [ | ||
{ | ||
value: "accurate", | ||
title: "Accurate", | ||
description: "Accurately describes the product or feature.", | ||
}, | ||
{ | ||
value: "problem-solved", | ||
title: "Solved my problem", | ||
description: "Helped me resolve an issue.", | ||
}, | ||
{ | ||
value: "clear", | ||
title: "Easy to understand", | ||
description: "Easy to follow and comprehend.", | ||
}, | ||
{ | ||
value: "product-chosen", | ||
title: "Helped me decide to use the product", | ||
description: "Convinced me to adopt the product or feature.", | ||
}, | ||
{ value: "other-yes", title: "Another reason" }, | ||
]; | ||
|
||
const NO_TAGS = [ | ||
{ | ||
value: "inaccurate", | ||
title: "Inaccurate", | ||
description: "Doesn't accurately describe the product or feature.", | ||
}, | ||
{ | ||
value: "missing-info", | ||
title: "Couldn't find what I was looking for", | ||
description: "Missing important information.", | ||
}, | ||
{ | ||
value: "unclear", | ||
title: "Hard to understand", | ||
description: "Too complicated or unclear.", | ||
}, | ||
{ | ||
value: "bad-examples", | ||
title: "Code samples errors", | ||
description: "One or more code samples are incorrect.", | ||
}, | ||
{ value: "other-no", title: "Another reason" }, | ||
]; | ||
|
||
const Feedback = () => { | ||
const [choice, setChoice] = useState<"y" | "n">(); | ||
const { siteConfig } = useDocusaurusContext(); | ||
const { FEEDBACK_CONTENT_SET_ID } = siteConfig.customFields; | ||
|
||
return ( | ||
<div className="alert alert--info feedback-component"> | ||
<div className="feelback-container"> | ||
{!choice ? ( | ||
<Question | ||
text="Was this page helpful?" | ||
items={PRESET_YESNO_LIKE_DISLIKE} | ||
showLabels | ||
onClick={(option: "y" | "n") => setChoice(option)} | ||
/> | ||
) : ( | ||
<FeelbackTaggedMessage | ||
contentSetId={FEEDBACK_CONTENT_SET_ID as string} | ||
layout="radio-group" | ||
tags={choice === "y" ? YES_TAGS : NO_TAGS} | ||
title={choice === "y" ? "What did you like?" : "What went wrong?"} | ||
placeholder="(optional) Please, further detail the feedback" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Feedback; |