Skip to content

Add product sorting by rating and star-range filtering #29

@GeekTrainer

Description

Summary

Add the ability to sort and filter products on the products listing page by average review rating.

Context

Currently, products on the /products page are displayed alphabetically with no way for users to sort or filter by rating. Users who want to find highly-rated coffees must scan each card individually. Adding sort and filter controls improves discoverability.

Proposed Solution

  • Create a new ProductSort.svelte component with:
    • A sort dropdown (Name / Highest Rated) that reorders product cards client-side
    • A star-range filter (min/max dropdowns) that shows/hides products based on rounded average rating
  • Add data-name and data-rating attributes to product cards for client-side DOM manipulation
  • Import and render the component in src/pages/products/index.astro

Acceptance Criteria

  • Products can be sorted by name (default) or highest rated
  • Products can be filtered by a min and max star range (0-5)
  • Min/max selects stay consistent (min never exceeds max)
  • No page reload required for sort or filter changes

Additional Information

This follows the same client-side DOM manipulation pattern used by the existing ReviewFilter.svelte component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions