-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4902 from consul/permission_list_accessibility
Add account permissions hint for screen reader users
- Loading branch information
Showing
20 changed files
with
99 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.permissions-list { | ||
list-style-type: none; | ||
margin-bottom: 0; | ||
margin-left: 0; | ||
|
||
li { | ||
font-size: $small-font-size; | ||
margin-bottom: $line-height / 2; | ||
|
||
&::before { | ||
font-size: 0.9em; | ||
margin-#{$global-right}: 0.2em; | ||
} | ||
|
||
&.permission-allowed { | ||
@include has-fa-icon(check, solid); | ||
|
||
&::before { | ||
color: $check; | ||
} | ||
} | ||
|
||
&.permission-denied { | ||
@include has-fa-icon(times, solid); | ||
|
||
&::before { | ||
color: $delete; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/components/account/permissions_list_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<ul class="permissions-list"> | ||
<% permissions.each do |text, allowed| %> | ||
<li class="<%= allowed_class(allowed) %>"> | ||
<% unless allowed %> | ||
<span class="show-for-sr"><%= t("verification.verification_needed") %></span> | ||
<% end %> | ||
<%= text %> | ||
</li> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Account::PermissionsListComponent < ApplicationComponent | ||
attr_reader :user | ||
|
||
def initialize(user) | ||
@user = user | ||
end | ||
|
||
private | ||
|
||
def permissions | ||
{ | ||
t("verification.user_permission_debates") => true, | ||
t("verification.user_permission_proposal") => true, | ||
t("verification.user_permission_support_proposal") => user.level_two_or_three_verified?, | ||
t("verification.user_permission_votes") => user.level_three_verified? | ||
} | ||
end | ||
|
||
def allowed_class(allowed) | ||
if allowed | ||
"permission-allowed" | ||
else | ||
"permission-denied" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
<%# # Parameters: | ||
# message: A string explaining the permissions | ||
# permissions: An array of symbols containing the permissions | ||
# (can be :debates, :proposal, :support_proposal, :votes) %> | ||
<div class="user-permissions"> | ||
|
||
<p><%= message %></p> | ||
|
||
<ul> | ||
<% [:debates, :proposal, :support_proposal, :votes].each do |permission| %> | ||
<li> | ||
<span class="<%= permissions.include?(permission) ? "icon-check" : "icon-x" %>"></span> | ||
<%= t("verification.user_permission_#{permission}") %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
||
<%= render Account::PermissionsListComponent.new(user) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
spec/components/account/permissions_list_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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 | ||
|
||
it "adds a hint when an action cannot be performed" do | ||
render_inline Account::PermissionsListComponent.new(User.new) | ||
|
||
expect(page).to have_css "li", exact_text: "Additional verification needed Support proposals", normalize_ws: true | ||
expect(page).to have_css "li", exact_text: "Participate in debates", normalize_ws: true | ||
end | ||
end |