Move result percentages out of the voting buttons
Having buttons (previously links) with the text "I agree 75%" is confusing; people might believe they're saying they only partially agree with the content. Besides, the results percentages is a different piece of information which shouldn't be related to whether one person agrees/disagrees with the content. This problem might be solved for people using screen readers since we added the aria-label attribute. However, for sighted keyboard users, the percentage was being outlined on focus as part of the button, which might be confusing.
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
.in-favor-against {
|
.in-favor-against {
|
||||||
display: inline-block;
|
|
||||||
|
&,
|
||||||
|
.in-favor,
|
||||||
|
.against,
|
||||||
|
form {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.icon-like,
|
.icon-like,
|
||||||
.icon-unlike {
|
.icon-unlike {
|
||||||
@@ -41,23 +47,22 @@
|
|||||||
|
|
||||||
.like,
|
.like,
|
||||||
.unlike {
|
.unlike {
|
||||||
line-height: rem-calc(48);
|
|
||||||
vertical-align: super;
|
vertical-align: super;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
.percentage {
|
.percentage {
|
||||||
color: $text;
|
color: $text;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: $small-font-size;
|
font-size: $small-font-size;
|
||||||
line-height: $line-height * 2;
|
line-height: $line-height * 2;
|
||||||
padding-right: $line-height / 2;
|
padding-right: $line-height / 2;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
|
||||||
@include breakpoint(medium) {
|
@include breakpoint(medium) {
|
||||||
display: block;
|
display: block;
|
||||||
line-height: $line-height;
|
line-height: $line-height;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="in-favor-against">
|
<div class="in-favor-against">
|
||||||
<div class="in-favor inline-block">
|
<div class="in-favor">
|
||||||
<%= button_to polymorphic_path(votable, action: :vote, value: "yes"),
|
<%= button_to polymorphic_path(votable, action: :vote, value: "yes"),
|
||||||
class: "like #{voted_classes[:in_favor]}",
|
class: "like #{voted_classes[:in_favor]}",
|
||||||
title: t("votes.agree"),
|
title: t("votes.agree"),
|
||||||
@@ -10,13 +10,13 @@
|
|||||||
<span class="icon-like">
|
<span class="icon-like">
|
||||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="percentage"><%= votes_percentage("likes", votable) %></span>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<span class="percentage"><%= votes_percentage("likes", votable) %></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="divider"></span>
|
<span class="divider"></span>
|
||||||
|
|
||||||
<div class="against inline-block">
|
<div class="against">
|
||||||
<%= button_to polymorphic_path(votable, action: :vote, value: "no"),
|
<%= button_to polymorphic_path(votable, action: :vote, value: "no"),
|
||||||
class: "unlike #{voted_classes[:against]}",
|
class: "unlike #{voted_classes[:against]}",
|
||||||
title: t("votes.disagree"),
|
title: t("votes.disagree"),
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<span class="icon-unlike">
|
<span class="icon-unlike">
|
||||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="percentage"><%= votes_percentage("dislikes", votable) %></span>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<span class="percentage"><%= votes_percentage("dislikes", votable) %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,5 +25,19 @@ describe Debates::VotesComponent do
|
|||||||
expect(page).to have_button "I don't agree with What about the 2030 agenda?"
|
expect(page).to have_button "I don't agree with What about the 2030 agenda?"
|
||||||
expect(page).not_to have_content "You must sign in or sign up to continue."
|
expect(page).not_to have_content "You must sign in or sign up to continue."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not include result percentages" do
|
||||||
|
create(:vote, votable: debate)
|
||||||
|
sign_in(create(:user))
|
||||||
|
|
||||||
|
render_inline component
|
||||||
|
|
||||||
|
expect(page).to have_button count: 2
|
||||||
|
expect(page).to have_button "I agree"
|
||||||
|
expect(page).to have_button "I disagree"
|
||||||
|
expect(page).not_to have_button text: "%"
|
||||||
|
expect(page).not_to have_button text: "100"
|
||||||
|
expect(page).not_to have_button text: "0"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,5 +38,19 @@ describe Legislation::Proposals::VotesComponent do
|
|||||||
expect(page).to have_button "I don't agree with Require wearing masks at home"
|
expect(page).to have_button "I don't agree with Require wearing masks at home"
|
||||||
expect(page).not_to have_content "You must sign in or sign up to continue."
|
expect(page).not_to have_content "You must sign in or sign up to continue."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not include result percentages" do
|
||||||
|
create(:vote, votable: proposal)
|
||||||
|
sign_in(create(:user))
|
||||||
|
|
||||||
|
render_inline component
|
||||||
|
|
||||||
|
expect(page).to have_button count: 2
|
||||||
|
expect(page).to have_button "I agree"
|
||||||
|
expect(page).to have_button "I disagree"
|
||||||
|
expect(page).not_to have_button text: "%"
|
||||||
|
expect(page).not_to have_button text: "100"
|
||||||
|
expect(page).not_to have_button text: "0"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user