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

Add account permissions hint for screen reader users #4902

Merged
merged 4 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
Render icons using CSS in user permissions
As mentioned in commit 925f04e, icon classes make screen readers
announce strange symbols and aren't properly displayed for people who
have changed their preferred font family.
  • Loading branch information
javierm committed Nov 29, 2022
commit 66c258355707e9bc6d66aebcf145fd735ae30a31
22 changes: 15 additions & 7 deletions app/assets/stylesheets/account/permissions_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
font-size: $small-font-size;
margin-bottom: $line-height / 2;

span {
color: $text-medium;
font-size: rem-calc(12);
&::before {
font-size: 0.9em;
margin-#{$global-right}: 0.2em;
}

.icon-check {
color: $check;
&.permission-allowed {
@include has-fa-icon(check, solid);

&::before {
color: $check;
}
}

.icon-x {
color: $delete;
&.permission-denied {
@include has-fa-icon(times, solid);

&::before {
color: $delete;
}
}
}
}
8 changes: 1 addition & 7 deletions app/components/account/permissions_list_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<ul class="permissions-list">
<% permissions.each do |text, allowed| %>
<li>
<% if allowed %>
<span class="icon-check"></span>
<% else %>
<span class="icon-x"></span>
<% end %>

<li class="<%= allowed_class(allowed) %>">
<%= text %>
</li>
<% end %>
Expand Down
8 changes: 8 additions & 0 deletions app/components/account/permissions_list_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ def permissions
t("verification.user_permission_votes") => user.level_three_verified?
}
end

def allowed_class(allowed)
if allowed
"permission-allowed"
else
"permission-denied"
end
end
end
10 changes: 10 additions & 0 deletions spec/components/account/permissions_list_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "rails_helper"

describe Account::PermissionsListComponent do
it "adds different classes for actions that can and cannot be performed" do
render_inline Account::PermissionsListComponent.new(User.new)

expect(page).to have_css "li.permission-allowed", text: "Participate in debates"
expect(page).to have_css "li.permission-denied", text: "Support proposals"
end
end