A collection of components used to populate product review information on adobe.com.
There are two main parts to this project:
Review
- A component used to display review data.HelixReview
- Used to wrapReview
and handle GET and POST requests of Helix-based data.
1.7.2 - Ability to set initialValue, comments are now sanitized 1.6.2 - IE11 Bug Fixes
npm install acom-review-component
This assumes you are using Helix to retrieve and store your data.
import React from 'react';
import { render } from 'react-dom';
import { HelixReview } from 'acom-review-component';
render(
<HelixReview
// How long to wait before submitting rating above commentThreshold (in ms)
clickTimeout = 5000
// Ratings above this number will not require a comment
commentThreshold = 3
// Once a rating has been selected, should the title be displayed on reload
hideTitleOnReload = true
// How long before tooltips should display on hover (in ms)
tooltipDelay="300"
lang = "en_US"
maxRating = 5 // maximum number of ratings (stars)
onRatingHover = {({ rating }) => {
// current rating user is hovering over
console.log('onRatingHover rating:', rating);
}}
onRatingSet={({ rating, comment }) => {
// callback when user has selected a rating
console.log('onRatingSet rating:', rating, 'comment:', comment);
}}
onReviewLoad={({ hasRated, rating }) => {
// callback when rating loads. Rating only set if the user has already selected a rating
console.log('onReviewLoad hasRated:', hasRated, ' rating:', rating);
}}
postAuth="" // only used for dev endpoint
postUrl=""
productJson={{}}
reviewDomain=""
reviewPath=""
sheet="" // only used for dev endpoint
strings={{}} // see below
visitorId=""
/>,
document.getElementById('root');
);
const strings = {
commentLabel: 'Review Feedback',
placeholder: 'Please give us your feedback',
review: 'vote',
reviewPlural: 'votes',
reviewTitle: 'Rate Your Experience',
sendCta: 'Send',
star: 'star',
starPlural: 'stars',
starsLegend: 'Choose a star rating',
tooltips: ['Horrible', 'Poor', 'Ok', 'Good', 'Great'],
thankYou: 'Thank you for your feedback!',
};
This assumes you are providing your own data store and json.
import React from 'react';
import { render } from 'react-dom';
import { Review } from 'acom-review-component';
render(
<Review
averageRating
clickTimeout
commentThreshold
displayRatingSummary
hideTitleOnReload
initialRating
maxRating
onRatingSet
onRatingHover
setAverageRating
setTotalReviews
strings
staticRating
totalReviews
/>,
document.getElementById('root');
);
- Using Parcel
- Clone this repo.
- Type
npm install
to install npm dependencies. - Type
npm run dev
to run a Parcel dev server.
- Using Helix
- Clone this repo.
- Install the Helix CLI if you haven't already:
npm i -g @adobe/helix-cli
- Type
npm install
to install npm dependencies. - Type
npm run hlx
to run a Helix dev server.
To have the build and tests automatically verified on commit, run the following command to enable the pre-commit hook:
git config core.hooksPath .githooks
Note that if you already have hooks setup in your .git/hooks
directory those will need to be moved to ./githooks