From 38e81f2858cb36e6dcf6bfad2c650851c50521a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 11 Oct 2023 02:44:37 +0200 Subject: [PATCH] Style "like" buttons to hint they can be unpressed 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. --- app/assets/stylesheets/in_favor_against.scss | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/in_favor_against.scss b/app/assets/stylesheets/in_favor_against.scss index 1fb0c288e..a4dd6972c 100644 --- a/app/assets/stylesheets/in_favor_against.scss +++ b/app/assets/stylesheets/in_favor_against.scss @@ -14,7 +14,6 @@ button { background: #fff; - border: 2px solid; border-radius: rem-calc(3); color: $dark-gray; display: inline-block; @@ -22,6 +21,26 @@ line-height: rem-calc(30); padding: rem-calc(3) rem-calc(6) rem-calc(6); position: relative; + + &[aria-pressed=true] { + border-style: inset; + border-width: 3px 2px 2px 3px; + + &:active { + border-style: outset; + border-width: 2px 3px 3px 2px; + } + } + + &[aria-pressed=false] { + border-style: outset; + border-width: 2px 3px 3px 2px; + + &:active { + border-style: inset; + border-width: 3px 2px 2px 3px; + } + } } @mixin like-unlike-icon($icon, $pressed-color) {