Skip to content

Commit

Permalink
Make sure bars are rounded when 0 men or women
Browse files Browse the repository at this point in the history
When the gender count is 0 don't show the progress bars since it breaks
the display and makes the rounded bars appear squared off.
  • Loading branch information
chrismytton committed Jul 1, 2016
1 parent c73a4d7 commit 9d85c16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions views/report.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@
<div class="country__progress">
<p class="country__progress__intro">Known gender balance for <%= legislature.name %>:</p>
<div class="progress-bar progress-bar--gendered progress-bar--labelled">
<% unless legislature.male.zero? %>
<div class="progress-bar__males" style="width: <%= legislature.male_percentage %>%">
<span class="progress-bar__label"><%= pluralize(legislature.male.to_i, 'man') %></span>
</div>
<% end %>
<% unless legislature.female.zero? %>
<div class="progress-bar__females" style="width: <%= legislature.female_percentage %>%">
<span class="progress-bar__label"><%= pluralize(legislature.female.to_i, 'woman') %></span>
</div>
<% end %>
</div>
</div>
</a>
Expand Down
6 changes: 6 additions & 0 deletions views/report_partial.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
<% end %>

<div class="progress-bar progress-bar--gendered progress-bar--labelled">
<% unless report[:total_male].zero? %>
<div class="progress-bar__males" style="width: <%= report[:total_male] / report[:total] * 100 %>%">
<span class="progress-bar__label"><%= report[:total_male].to_i %> <%= report[:total_male].to_i == 1 ? 'man' : 'men' %></span>
</div>
<% end %>

<% if (report[:total_male] + report[:total_female] != report[:total]) %>
<div class="progress-bar__empty" style="width: <%= (report[:total] - report[:total_male] - report[:total_female]) / report[:total] * 100 %>%">
</div>
<% end %>

<% unless report[:total_female].zero? %>
<div class="progress-bar__females" style="width: <%= report[:total_female] / report[:total] * 100 %>%">
<span class="progress-bar__label"><%= report[:total_female].to_i %> <%= report[:total_female].to_i == 1 ? 'woman' : 'women' %></span>
</div>
<% end %>
</div>

</div>
Expand Down

0 comments on commit 9d85c16

Please sign in to comment.