Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stars: Make reviews accessible #2157

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,14 @@ export function ProductListItem({ product }: ProductListItemProps) {
</Flex>
{(product.rating >= 4 || product.rating_count > 10) && (
<HStack align="center" data-testid="reviewStars">
<Rating value={product.rating} />
<Text fontSize="sm">{product.rating_count}</Text>
<Rating
value={product.rating}
aria-label={`Rated ${product.rating} out of 5 stars with ${product.rating_count} reviews`}
role="img"
/>
<Text fontSize="sm" aria-hidden={true}>
{product.rating_count}
</Text>
</HStack>
)}
{showBadges && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ export function ProductRating({ product }: ProductRatingProps) {

return (
<HStack mt="5" alignItems="unset">
<Rating value={product.reviews.rating} />
<Text color="gray.600">{product.reviews.rating}</Text>
<Rating
value={product.reviews.rating}
aria-label={`Rated ${product.reviews.rating} out of 5 stars`}
role="img"
/>
<Text color="gray.600" aria-hidden={true}>
{product.reviews.rating}
</Text>
<Box w="1px" bg="gray.300"></Box>

<Link href="#reviews" color="gray.600">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ function ProductReviewLineItem({ review }: ProductReviewLineItemProps) {
</HStack>
)}
<HStack my="4">
<Rating value={review.rating} />
<Rating
value={review.rating}
aria-label={`Rated ${review.rating} out of 5 stars`}
role="img"
/>
{review.created_date && (
<Text mt="4" color="gray.500">
{formatReviewDate(review.created_date)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ exports[`ProductListItem renders and matches the snapshot 1`] = `
data-testid="reviewStars"
>
<div
aria-label="Rated 4.5 out of 5 stars with 18 reviews"
class="chakra-stack css-fqllj7"
role="img"
>
<svg
aria-hidden="true"
Expand Down Expand Up @@ -144,6 +146,7 @@ exports[`ProductListItem renders and matches the snapshot 1`] = `
</svg>
</div>
<p
aria-hidden="true"
class="chakra-text css-itvw0n"
>
18
Expand Down