Skip to content

Commit

Permalink
add rating component
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Mar 6, 2024
1 parent e73d778 commit b36a4db
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@docusaurus/plugin-sitemap": "^3.1.0",
"@docusaurus/preset-classic": "^3.1.0",
"@docusaurus/theme-mermaid": "^3.1.0",
"@feelback/react": "^0.3.4",
"@near-wallet-selector/core": "^8.5.1",
"@near-wallet-selector/here-wallet": "^8.5.1",
"@near-wallet-selector/modal-ui": "^8.5.1",
Expand Down
43 changes: 43 additions & 0 deletions website/src/components/FeedbackComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useState } from "react";
import { FeelbackTaggedMessage, FeelbackValueDefinition, Question, PRESET_YESNO_LIKE_DISLIKE } from "@feelback/react";
import "@feelback/react/styles/feelback.css";

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 = "6d4fac2e-6797-47aa-8d5c-b9318a0655e8";

export function FeedbackComponent() {
const [choice, setChoice] = useState();

return (
<div className="feelback-container">
{!choice
? <Question text="Was this page helpful?"
items={PRESET_YESNO_LIKE_DISLIKE}
showLabels
onClick={setChoice}
/>
: <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>
);
}
2 changes: 2 additions & 0 deletions website/src/css/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,5 @@ iframe+em {
margin: 0 auto 8px 0 !important;
}
}

@import "@feelback/react/styles/feelback.css";
13 changes: 13 additions & 0 deletions website/src/theme/DocItem/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import Footer from '@theme-original/DocItem/Footer';
import {FeedbackComponent } from "../../../components/FeedbackComponent";

export default function FooterWrapper(props) {
return (
<>
<Footer {...props} />
<hr />
<FeedbackComponent />
</>
);
}
12 changes: 12 additions & 0 deletions website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,18 @@
"@ethersproject/properties" "^5.7.0"
"@ethersproject/strings" "^5.7.0"

"@feelback/js@0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@feelback/js/-/js-0.3.4.tgz#1f3c885817b2d46230e922ac84c0b79a76d1a1c4"
integrity sha512-xr7gTqSJcVUYQlELs1TntYovCBjMcYUr/hGKTnDoF64/lig5CbX4bOmqLoF50IImCy5q3oIwg9w+TSFvtBwsIA==

"@feelback/react@^0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@feelback/react/-/react-0.3.4.tgz#f53ccb830a04e209c837910e8756f9d9ca65b30b"
integrity sha512-ZWzUQAmPwl4nYR2olzBKddHzoLtGW/2pb8TiesiJCirxhaDW2E/XBx2ZaB4fL5TGXtjBt4eYq/qZxJZ0fIE0kg==
dependencies:
"@feelback/js" "0.3.4"

"@floating-ui/core@^1.5.3":
version "1.5.3"
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.5.3.tgz#b6aa0827708d70971c8679a16cf680a515b8a52a"
Expand Down

0 comments on commit b36a4db

Please sign in to comment.