-
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
- Loading branch information
1 parent
0eb5b7c
commit 99c24a0
Showing
5 changed files
with
195 additions
and
6 deletions.
There are no files selected for viewing
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,85 @@ | ||
import { useState } from "react"; | ||
import { | ||
FeelbackTaggedMessage, | ||
Question, | ||
PRESET_YESNO_LIKE_DISLIKE, | ||
} from "@feelback/react"; | ||
|
||
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_CONTENT_SET_ID = "d069bd2e-19d3-405c-9198-a8f005883f6b"; | ||
|
||
const Feedback = () => { | ||
const [choice, setChoice] = useState<"y" | "n">(); | ||
|
||
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} | ||
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; |