mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 19:11:09 +00:00
Show “no rating” instead of stars if the review has no rating
The stars.html template now outputs a span containing “no rating” when the stars represent a non-existent or zero rating. This text is already translated because it was previously added as a invisible text only for screen readers. The span is given a special CSS class so that it can be styled as italic in the stylesheet. There is now also an extra span in book.html to group the stars with the “(2 reviews)” text. This is needed because the outer div is using a flex layout and it eats the spacing between the two parts otherwise. Fixes #2856
This commit is contained in:
parent
ee1dd612fb
commit
603b2d9502
3 changed files with 27 additions and 22 deletions
|
@ -5,6 +5,10 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stars .no-rating {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
/** Stars in a review form
|
/** Stars in a review form
|
||||||
*
|
*
|
||||||
* Specificity makes hovering taking over checked inputs.
|
* Specificity makes hovering taking over checked inputs.
|
||||||
|
|
|
@ -190,6 +190,7 @@
|
||||||
<meta itemprop="bestRating" content="5">
|
<meta itemprop="bestRating" content="5">
|
||||||
<meta itemprop="reviewCount" content="{{ review_count }}">
|
<meta itemprop="reviewCount" content="{{ review_count }}">
|
||||||
|
|
||||||
|
<span>
|
||||||
{% include 'snippets/stars.html' with rating=rating %}
|
{% include 'snippets/stars.html' with rating=rating %}
|
||||||
|
|
||||||
{% blocktrans count counter=review_count trimmed %}
|
{% blocktrans count counter=review_count trimmed %}
|
||||||
|
@ -197,6 +198,7 @@
|
||||||
{% plural %}
|
{% plural %}
|
||||||
({{ review_count }} reviews)
|
({{ review_count }} reviews)
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% with full=book|book_description itemprop='abstract' %}
|
{% with full=book|book_description itemprop='abstract' %}
|
||||||
|
|
|
@ -2,18 +2,14 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
<span class="stars">
|
<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 %}
|
{% blocktranslate trimmed with rating=rating|floatformat:0 count counter=rating|floatformat:0|add:0 %}
|
||||||
{{ rating }} star
|
{{ rating }} star
|
||||||
{% plural %}
|
{% plural %}
|
||||||
{{ rating }} stars
|
{{ rating }} stars
|
||||||
{% endblocktranslate %}
|
{% endblocktranslate %}
|
||||||
{% else %}
|
|
||||||
{% trans "No rating" %}
|
|
||||||
{% endif %}
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{% for i in '12345'|make_list %}
|
{% for i in '12345'|make_list %}
|
||||||
<span
|
<span
|
||||||
class="
|
class="
|
||||||
|
@ -23,5 +19,8 @@
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></span>
|
></span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<span class="no-rating">{% trans "No rating" %}</span>
|
||||||
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
|
|
Loading…
Reference in a new issue