Ratings, Favourites, A11Y, SVG & Lists – HadCoffee Blog

Ratings, Favourites, A11Y, SVG & Lists

I made a nice chunk of progress on the ‘To Try’ feature of HadCoffee this weekend. This lets you bookmark cafés you’ve heard of and would like to try later. By default the list on HadCoffee will sort by proximity using your current location.

Screenshot of list of cafes to try
The list, sorted by proximity taking into account that some cafes have multiple locations. The coffee cup icon shows the cafe’s rating, and the star toggles it on your Favourites list.

Most of the recent work for this feature was on some nice-to-use buttons for toggling a cafe in your Favourites or To Try list. I had mostly built the ‘Fav star’ earlier, but improved it with a visual :focus indicator for keyboard accessibility.

See the Pen SVG Favourite by Mike (@mike_hasarms) on CodePen.0

The coffee cup icons are SVG based Vue components that receive rating data from the page and fill the cup appropriately.

I also worked on some basic animation of the button to add a cafe to the To Try list to make the transition to the active state a bit more obvious. I think little touches of movement make the thing more engaging to use as well.

screenshot of cafe action buttons
You can’t see it, but the last item on the ‘list’ animates in when clicked.

Accessibility

I spent a bit of time improving the A11Y of these (and other features). The Vue SVG components are keyboard accessible, labelled and indicate focus. I am planning to do a more thorough A11Y test before I release, but I’m certainly not leaving all of those concerns until the end of development.

Anonymous Users

Currently the Favourites and To Try lists require a user to be logged in. I had planned to allow anonymous users to begin keeping these lists for themselves in localStorage. The idea was to lower the barrier to entry to using the site. It does however add development complexity as the app needs to be able to use both local and server storage for those lists and load in data in different ways.

As this is a mostly server-rendered app all the initial page data is sent down with the page load, and populated into the Vue components. Supporting anon users will require separate logic to request their cafe data from an API endpoint.

That’s not hugely difficult, it’s just another thing to be done before launch.