From 482774f1e1a59190d0a1e7af0270906a29e92e13 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 21 Apr 2021 21:25:37 +0200 Subject: [PATCH 1/3] Add mobile styles for book preview table --- bookwyrm/static/css/bookwyrm.css | 38 ++++++++++ bookwyrm/templates/user/shelf.html | 115 +++++++++++++++-------------- 2 files changed, 97 insertions(+), 56 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index 67eb1ebac..a8a29fa2e 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -256,3 +256,41 @@ body { opacity: 0.5; cursor: not-allowed; } + +/* Book preview table + ******************************************************************************/ + +@media only screen and (max-width: 768px) { + table.is-mobile, table.is-mobile tbody { + display: block; + } + table.is-mobile tr { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + border-top: 1px solid #dbdbdb; + } + table.is-mobile td { + display: block; + box-sizing: border-box; + flex: 1 0 100%; + order: 2; + border-bottom: 0; + } + table.is-mobile td.book-preview-top-row { + order: 1; + flex-basis: auto; + } + table.is-mobile td[data-title]:not(:empty)::before { + content: attr(data-title); + display: block; + font-size: .75em; + font-weight: bold; + } + table.is-mobile td:empty { + padding: 0; + } + table.is-mobile th, table.is-mobile thead { + display: none; + } +} diff --git a/bookwyrm/templates/user/shelf.html b/bookwyrm/templates/user/shelf.html index 0732327be..947e9f70b 100644 --- a/bookwyrm/templates/user/shelf.html +++ b/bookwyrm/templates/user/shelf.html @@ -68,63 +68,66 @@
{% if books|length > 0 %} -
- - - - - - - - - - {% if ratings %}{% endif %} - {% if shelf.user == request.user %} - - {% endif %} - - {% for book in books %} - - - - - - {% latest_read_through book user as read_through %} - - - {% if ratings %} - - {% endif %} - {% if shelf.user == request.user %} - - {% endif %} - - {% endfor %} +
{% trans "Cover" %}{% trans "Title" %}{% trans "Author" %}{% trans "Shelved" %}{% trans "Started" %}{% trans "Finished" %}{% trans "Rating" %}
- {% include 'snippets/book_cover.html' with book=book size="small" %} - - {{ book.title }} - - {% include 'snippets/authors.html' %} - - {{ book.created_date | naturalday }} - - {{ read_through.start_date | naturalday |default_if_none:""}} - - {{ read_through.finish_date | naturalday |default_if_none:""}} - - {% include 'snippets/stars.html' with rating=ratings|dict_key:book.id %} - - {% with right=True %} - {% if not shelf.id %} - {% active_shelf book as current %} - {% include 'snippets/shelf_selector.html' with current=current.shelf class="is-small" %} - {% else %} - {% include 'snippets/shelf_selector.html' with current=shelf class="is-small" %} - {% endif %} - {% endwith %} -
+ + + + + + + + + {% if ratings %}{% endif %} + {% if shelf.user == request.user %} + + {% endif %} + + + + {% for book in books %} + {% spaceless %} + + + + + + {% latest_read_through book user as read_through %} + + + {% if ratings %} + + {% endif %} + {% if shelf.user == request.user %} + + {% endif %} + + {% endspaceless %} + {% endfor %} +
{% trans "Cover" %}{% trans "Title" %}{% trans "Author" %}{% trans "Shelved" %}{% trans "Started" %}{% trans "Finished" %}{% trans "Rating" %}
+ {% include 'snippets/book_cover.html' with book=book size="small" %} + + {{ book.title }} + + {% include 'snippets/authors.html' %} + + {{ book.created_date | naturalday }} + + {{ read_through.start_date | naturalday |default_if_none:""}} + + {{ read_through.finish_date | naturalday |default_if_none:""}} + + {% include 'snippets/stars.html' with rating=ratings|dict_key:book.id %} + + {% with right=True %} + {% if not shelf.id %} + {% active_shelf book as current %} + {% include 'snippets/shelf_selector.html' with current=current.shelf class="is-small" %} + {% else %} + {% include 'snippets/shelf_selector.html' with current=shelf class="is-small" %} + {% endif %} + {% endwith %} +
-
{% else %}

{% trans "This shelf is empty." %}

{% if shelf.id and shelf.editable %} From 2ae9085e55e8bdd25c3660560e95b4a97e3d6a3e Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 21 Apr 2021 21:26:20 +0200 Subject: [PATCH 2/3] Vertically align cells in desktop view --- bookwyrm/static/css/bookwyrm.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index a8a29fa2e..5b5b32587 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -260,6 +260,10 @@ body { /* Book preview table ******************************************************************************/ +.book-preview td { + vertical-align: middle; +} + @media only screen and (max-width: 768px) { table.is-mobile, table.is-mobile tbody { display: block; From e4836bd9b3321c79e1496cad1c9e6b6af4ed9791 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 21 Apr 2021 21:29:28 +0200 Subject: [PATCH 3/3] Fix for lint --- bookwyrm/static/css/bookwyrm.css | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index 5b5b32587..c019f996c 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -265,15 +265,18 @@ body { } @media only screen and (max-width: 768px) { - table.is-mobile, table.is-mobile tbody { + table.is-mobile, + table.is-mobile tbody { display: block; } + table.is-mobile tr { display: flex; flex-wrap: wrap; justify-content: space-between; border-top: 1px solid #dbdbdb; } + table.is-mobile td { display: block; box-sizing: border-box; @@ -281,20 +284,25 @@ body { order: 2; border-bottom: 0; } + table.is-mobile td.book-preview-top-row { order: 1; flex-basis: auto; } + table.is-mobile td[data-title]:not(:empty)::before { content: attr(data-title); display: block; - font-size: .75em; + font-size: 0.75em; font-weight: bold; } + table.is-mobile td:empty { padding: 0; } - table.is-mobile th, table.is-mobile thead { + + table.is-mobile th, + table.is-mobile thead { display: none; } }