cover: Handle covers with specific heights:

- Have an explicit contextual class on `cover-container`.
- Use more flexible, consistent and searchable variable name for passing classes to covers.
- Consistently use `'…'` with django variables.
- Give the option to not hide covers to screen readers.
- consitently give a title to the cover container if `alt_text` exists.
- [lists] Remove `.content` which is applying too extensive default styles.
This commit is contained in:
Fabien Basmaison 2021-04-24 21:16:30 +02:00
parent 783cc6edf0
commit eea8b4e750
16 changed files with 47 additions and 36 deletions

View file

@ -124,6 +124,14 @@ body {
position: relative; position: relative;
} }
.cover-container.is-small {
height: 100px;
}
.cover-container.is-medium {
height: 150px;
}
/* /*
.cover-container.is-large { .cover-container.is-large {
height: max-content; height: max-content;
@ -135,14 +143,6 @@ body {
height: auto; height: auto;
} }
.cover-container.is-medium {
height: 150px;
}
.cover-container.is-small {
height: 100px;
}
@media only screen and (max-width: 768px) { @media only screen and (max-width: 768px) {
.cover-container { .cover-container {
height: 200px; height: 200px;
@ -163,6 +163,11 @@ body {
image-rendering: optimizeQuality; image-rendering: optimizeQuality;
} }
[class~="has-height"] .book-cover {
width: auto;
height: 100%;
}
.no-cover .cover_caption { .no-cover .cover_caption {
position: absolute; position: absolute;
padding: 1em; padding: 1em;

View file

@ -49,7 +49,7 @@
<div class="columns"> <div class="columns">
<div class="column is-one-fifth"> <div class="column is-one-fifth">
<div class="is-clipped"> <div class="is-clipped">
{% include 'snippets/book_cover.html' with book=book size=large %} {% include 'snippets/book_cover.html' with book=book cover_class='is-large' %}
{% include 'snippets/rate_action.html' with user=request.user book=book %} {% include 'snippets/rate_action.html' with user=request.user book=book %}
</div> </div>
<div class="mb-3"> <div class="mb-3">

View file

@ -170,7 +170,7 @@
<h2 class="title is-4">{% trans "Cover" %}</h2> <h2 class="title is-4">{% trans "Cover" %}</h2>
<div class="columns"> <div class="columns">
<div class="column is-narrow"> <div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=book size="small" %} {% include 'snippets/book_cover.html' with book=book cover_class='is-small' %}
</div> </div>
<div class="column is-narrow"> <div class="column is-narrow">
<div class="block"> <div class="block">

View file

@ -16,7 +16,7 @@
<div class="columns"> <div class="columns">
<div class="column is-2"> <div class="column is-2">
<a href="/book/{{ book.id }}"> <a href="/book/{{ book.id }}">
{% include 'snippets/book_cover.html' with book=book size="medium" %} {% include 'snippets/book_cover.html' with book=book cover_class='is-medium' %}
</a> </a>
</div> </div>
<div class="column is-7"> <div class="column is-7">

View file

@ -8,7 +8,7 @@
<div class="column"> <div class="column">
<a <a
href="{{ book.local_path }}" href="{{ book.local_path }}"
>{% include 'snippets/book_cover.html' with size="large" %}</a> >{% include 'snippets/book_cover.html' with cover_class='is-large' %}</a>
{% include 'snippets/stars.html' with rating=book|rating:request.user %} {% include 'snippets/stars.html' with rating=book|rating:request.user %}
</div> </div>

View file

@ -6,7 +6,7 @@
{% with book=book %} {% with book=book %}
<a <a
href="{{ book.local_path }}" href="{{ book.local_path }}"
>{% include 'snippets/book_cover.html' with size="small" %}</a> >{% include 'snippets/book_cover.html' with cover_class='is-small' %}</a>
{% include 'snippets/stars.html' with rating=book|rating:request.user %} {% include 'snippets/stars.html' with rating=book|rating:request.user %}

View file

@ -37,7 +37,7 @@
aria-label="{{ book.title }}" aria-label="{{ book.title }}"
aria-selected="{% if active_book == book.id|stringformat:'d' %}true{% elif shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}" aria-selected="{% if active_book == book.id|stringformat:'d' %}true{% elif shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}"
aria-controls="book-{{ book.id }}"> aria-controls="book-{{ book.id }}">
{% include 'snippets/book_cover.html' with book=book size="medium" %} {% include 'snippets/book_cover.html' with book=book cover_class='is-medium' %}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}

View file

@ -125,7 +125,7 @@
<td> <td>
{% if item.book %} {% if item.book %}
<a href="/book/{{ item.book.id }}"> <a href="/book/{{ item.book.id }}">
{% include 'snippets/book_cover.html' with book=item.book size='small' %} {% include 'snippets/book_cover.html' with book=item.book cover_class='is-small' %}
</a> </a>
{% endif %} {% endif %}
</td> </td>

View file

@ -32,7 +32,7 @@
href="{{ book.local_path }}" href="{{ book.local_path }}"
aria-hidden="true" aria-hidden="true"
> >
{% include 'snippets/book_cover.html' with size="small" %} {% include 'snippets/book_cover.html' with cover_class='is-small' %}
</a> </a>
<div class="column is-9-mobile is-10-tablet ml-3"> <div class="column is-9-mobile is-10-tablet ml-3">

View file

@ -8,11 +8,19 @@
<a href="{{ list.local_path }}">{{ list.name }}</a> <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=list %}</span> <a href="{{ list.local_path }}">{{ list.name }}</a> <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=list %}</span>
</h4> </h4>
</header> </header>
<div class="card-image is-flex is-clipped">
{% for book in list.listitem_set.all|slice:5 %} {% with list_books=list.listitem_set.all|slice:5 %}
<a href="{{ book.book.local_path }}">{% include 'snippets/book_cover.html' with book=book.book size="small" %}</a> {% if list_books %}
{% endfor %} <div class="card-image columns is-mobile is-gapless is-clipped has-height">
</div> {% for book in list_books %}
<a class="column is-narrow" href="{{ book.book.local_path }}">
{% include 'snippets/book_cover.html' with book=book.book cover_class='is-small' aria='show' %}
</a>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<div class="card-content is-flex-grow-0"> <div class="card-content is-flex-grow-0">
<div {% if list.description %}title="{{ list.description }}"{% endif %}> <div {% if list.description %}title="{{ list.description }}"{% endif %}>
{% if list.description %} {% if list.description %}

View file

@ -28,7 +28,7 @@
</div> </div>
{% if lists %} {% if lists %}
<section class="block content"> <section class="block">
{% include 'lists/list_items.html' with lists=lists %} {% include 'lists/list_items.html' with lists=lists %}
</section> </section>

View file

@ -9,21 +9,20 @@
is-clipped is-clipped
is-flex is-flex
is-align-items-center is-align-items-center
{{ cover_class }}
{% if not book.cover %} {% if not book.cover %}
no-cover no-cover
{% endif %} {% endif %}
{% if size %}
is-{{ size }}
{% endif %}
{% if container_class %}
{{ container_class }}
{% endif %}
" "
aria-hidden="true"
{% if aria != "show" %}
aria-hidden="true"
{% endif %}
{% if book.alt_text %}
title="{{ book.alt_text }}"
{% endif %}
> >
<img <img
class="book-cover" class="book-cover"
@ -34,7 +33,6 @@
{% if book.alt_text %} {% if book.alt_text %}
alt="{{ book.alt_text }}" alt="{{ book.alt_text }}"
title="{{ book.alt_text }}"
{% endif %} {% endif %}
{% else %} {% else %}
src="/static/images/no_cover.jpg" src="/static/images/no_cover.jpg"

View file

@ -1,6 +1,6 @@
{% load i18n %} {% load i18n %}
<div class="columns is-mobile is-gapless"> <div class="columns is-mobile is-gapless">
{% include 'snippets/book_cover.html' with book=result container_class='column' img_path=false %} {% include 'snippets/book_cover.html' with book=result cover_class='column' img_path=false %}
<div class="column is-10 ml-3"> <div class="column is-10 ml-3">
<p> <p>

View file

@ -8,7 +8,7 @@
<div class="columns is-mobile"> <div class="columns is-mobile">
<div class="column is-narrow"> <div class="column is-narrow">
<div> <div>
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book size="small" %}</a> <a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book cover_class='is-small' %}</a>
</div> </div>
</div> </div>
<div class="column"> <div class="column">

View file

@ -86,7 +86,7 @@
{% for book in books %} {% for book in books %}
<tr class="book-preview"> <tr class="book-preview">
<td> <td>
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book size="small" %}</a> <a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book cover_class='is-small' %}</a>
</td> </td>
<td> <td>
<a href="{{ book.local_path }}">{{ book.title }}</a> <a href="{{ book.local_path }}">{{ book.title }}</a>

View file

@ -36,7 +36,7 @@
{% for book in shelf.books %} {% for book in shelf.books %}
<div class="control"> <div class="control">
<a href="{{ book.local_path }}"> <a href="{{ book.local_path }}">
{% include 'snippets/book_cover.html' with book=book size="medium" %} {% include 'snippets/book_cover.html' with book=book cover_class='is-medium' %}
</a> </a>
</div> </div>
{% endfor %} {% endfor %}