Simplify rating form:

- Create a snippet to regroup similar code.
- Reduce and document tricky logic of CSS.
- Add i18n strings.
This commit is contained in:
Fabien Basmaison
2021-04-04 15:08:42 +02:00
parent 7b3c85f351
commit 485b0fa0f3
7 changed files with 189 additions and 132 deletions

View File

@ -27,16 +27,8 @@
{% if type == 'review' %}
<fieldset>
<legend class="is-sr-only">{% trans "Rating" %}</legend>
<div class="field is-grouped stars form-rate-stars">
<label class="is-sr-only" for="no-rating-{{ book.id }}">{% trans "No rating" %}</label>
<input class="is-sr-only" type="radio" name="rating" value="" id="no-rating-{{ book.id }}" checked>
{% for i in '12345'|make_list %}
<input class="is-sr-only" id="book{{book.id}}-star-{{ forloop.counter }}" type="radio" name="rating" value="{{ forloop.counter }}">
<label class="icon icon-star-empty" for="book{{book.id}}-star-{{ forloop.counter }}">
<span class="is-sr-only">{{ forloop.counter }} star{{ forloop.counter | pluralize }}</span>
</label>
{% endfor %}
</div>
{% include 'snippets/form_rate_stars.html' with book=book type=type|default:'summary' %}
</fieldset>
{% endif %}