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

Make like/unlike buttons more accessible #5278

Merged
merged 6 commits into from
Oct 24, 2023
Merged

Make like/unlike buttons more accessible #5278

merged 6 commits into from
Oct 24, 2023

Conversation

javierm
Copy link
Member

@javierm javierm commented Oct 11, 2023

References

Objectives

  • Make icons to like/unlike votes more distinguishable, following WCAG recommendations regarding contrast
  • Make it easier to notice that these buttons can be unpressed
  • Make it possible to use the like/unlike buttons without JavaScript enabled

Visual Changes

Before these changes

The like/unlike buttons use light colors that don't offer contrast, and there's no indicator that these buttons can be unpressed

After these changes

The like/unlike buttons use darker colors and a slight 3D effect makes pressed buttons look different

Notes

I'm not sure the techniques used in this pull request are enough to make these buttons usable/accessible 🤔, since it might still not be obvious that pressed buttons can be unpressed. In particular, the fact that buttons to like/unlike comments can be unpressed is still unintuitive IMHO.

@javierm javierm requested a review from taitus October 11, 2023 01:25
@javierm javierm self-assigned this Oct 11, 2023
@taitus taitus self-assigned this Oct 11, 2023
@javierm javierm added the 2.1 label Oct 11, 2023
We were keeping the same style and width when they were pressed, so we
can simply overwrite the color.
We were using the same selectors three times. Since we're going to
change that part of the code, we're simplifying it so we don't have to
do the same changes three times.
The colors we were using (gray for unpressed buttons and green or red
for pressed buttons) didn't contrast well against a white background, so
we're now using darker colors.

However, with darker colors, using solid icons for the unpressed buttons
makes it harder to differentiate when a button is pressed and when it
isn't, particularly for color-blind people.

So we're now using regular icons for the unpressed buttons and solid
icons for the pressed ones.
Since we were styling pressed buttons the same way as buttons on hover,
a person hovering on the button and then clicking it wouldn't notice
that the buttons had been pressed unless they noticed that the number
and percentages of votes had changes. They wouldn't notice the changes
when unpressing the buttons either, since, after clicking the button,
the cursor would still be over it, and so the hover styles would apply.

Furthermore, it was hard for mouse users to realize that a button could
be unpressed, since the style of pressed buttons didn't change on hover.

So we're now changing the icons on hover without changing the
background. This way all four states (unpressed, unpressed on hover,
pressed, pressed on hover) are styled in a different way.
We added the feature to undo a vote and made it obvious for people using
screen readers using the `aria-pressed` attribute. However, for sighted
people, the only way to know a button can be unpressed is to try to
press it again and see what happens.

The most obvious way to indicate it would be to add a text indicating
that you can undo your vote. However, that'd require changing the design
quite a bit.

So, after trying a few techniques, we're using a classic approach
browsers have used by default for years: using an inset border for
pressed buttons and an outset border for unpressed ones. It might now be
enough, though; we haven't done usability tests to confirm this point.

Since icons to like/unlike comments don't have a border, I'm not sure
what to do in this case; the icons are small and that makes it hard to
style them in a distinct way. So for now we're not changing these icons.
Even if pretty much nobody uses a browser with JavaScript disabled when
navigating our sites, there might be times where JavaScript isn't loaded
for reasons like a slow internet connections not getting the JavaScript
files or a technical issue.

So we're making it possible to still use the like/unlike buttons in
these cases.
@javierm javierm merged commit ce49397 into master Oct 24, 2023
10 checks passed
@javierm javierm deleted the vote_contrast branch October 24, 2023 15:24
@javierm javierm removed the 2.1 label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants