Skip to content

Commit

Permalink
Merge pull request #2857 from bpeel/no-rating
Browse files Browse the repository at this point in the history
Show “no rating” instead of blank stars if the review has no rating
  • Loading branch information
mouse-reeve authored May 30, 2023
2 parents aec99ba + 603b2d9 commit d251f42
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
4 changes: 4 additions & 0 deletions bookwyrm/static/css/bookwyrm/components/_stars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
white-space: nowrap;
}

.stars .no-rating {
font-style: italic;
}

/** Stars in a review form
*
* Specificity makes hovering taking over checked inputs.
Expand Down
14 changes: 8 additions & 6 deletions bookwyrm/templates/book/book.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ <h1 class="title" itemprop="name" dir="auto">
<meta itemprop="bestRating" content="5">
<meta itemprop="reviewCount" content="{{ review_count }}">

{% include 'snippets/stars.html' with rating=rating %}
<span>
{% include 'snippets/stars.html' with rating=rating %}

{% blocktrans count counter=review_count trimmed %}
({{ review_count }} review)
{% plural %}
({{ review_count }} reviews)
{% endblocktrans %}
{% blocktrans count counter=review_count trimmed %}
({{ review_count }} review)
{% plural %}
({{ review_count }} reviews)
{% endblocktrans %}
</span>
</div>

{% with full=book|book_description itemprop='abstract' %}
Expand Down
31 changes: 15 additions & 16 deletions bookwyrm/templates/snippets/stars.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
{% load i18n %}

<span class="stars">
<span class="is-sr-only">
{% if rating %}
{% if rating %}
<span class="is-sr-only">
{% blocktranslate trimmed with rating=rating|floatformat:0 count counter=rating|floatformat:0|add:0 %}
{{ rating }} star
{% plural %}
{{ rating }} stars
{% endblocktranslate %}
{% else %}
{% trans "No rating" %}
{% endif %}
</span>

{% for i in '12345'|make_list %}
<span
class="
icon is-small mr-1
icon-star-{% if rating >= forloop.counter %}full{% elif rating|floatformat:0 >= forloop.counter|floatformat:0 %}half{% else %}empty{% endif %}
"
aria-hidden="true"
></span>
{% endfor %}
</span>
{% for i in '12345'|make_list %}
<span
class="
icon is-small mr-1
icon-star-{% if rating >= forloop.counter %}full{% elif rating|floatformat:0 >= forloop.counter|floatformat:0 %}half{% else %}empty{% endif %}
"
aria-hidden="true"
></span>
{% endfor %}
{% else %}
<span class="no-rating">{% trans "No rating" %}</span>
{% endif %}
</span>
{% endspaceless %}

0 comments on commit d251f42

Please sign in to comment.