Skip to content

Commit

Permalink
Simpler code for custom rating display
Browse files Browse the repository at this point in the history
  • Loading branch information
opatry committed May 15, 2024
1 parent 643d348 commit 9770a03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions content/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ unless @items["/cover/#{book[:isbn]}.*"].nil?
<td><%= book[:author] %></td>
<td>
<p aria-label="<%= book[:rating] %>" title="<%= book[:rating] %>" style="vertical-align: middle; text-align: center;">
<% book[:rating].times do |star_on| %>
<%= star_svg(filled: true) %>
<% end %>
<% (10 - book[:rating]).times do |star_off| %>
<%= star_svg(filled: false) %>
<% 10.times do |i| %>
<%= star_svg(filled: i < book[:rating]) %>
<% end %>
</p>
</td>
Expand Down
7 changes: 2 additions & 5 deletions layouts/book.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
<h4><%= @item[:author] %></h4>

<p aria-label="<%= @item[:rating] %>" title="<%= @item[:rating] %>" style="vertical-align: middle;">
<% @item[:rating].times do |star_on| %>
<%= star_svg(filled: true) %>
<% end %>
<% (10 - @item[:rating]).times do |star_off| %>
<%= star_svg(filled: false) %>
<% 10.times do |i| %>
<%= star_svg(filled: i < @item[:rating]) -%>
<% end %>
</p>

Expand Down

0 comments on commit 9770a03

Please sign in to comment.