From f12ba8609f1c1ef40b372d4cfb71dc86d5dd67c7 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 29 Dec 2021 16:40:19 +0100 Subject: [PATCH] Front-end: On book page, click on cover to show/add image Closes #1009 --- bookwyrm/static/css/bookwyrm.css | 23 +++++++++++++ bookwyrm/templates/book/book.html | 34 ++++++++++++------- ...{cover_modal.html => cover_add_modal.html} | 0 bookwyrm/templates/book/cover_show_modal.html | 17 ++++++++++ bookwyrm/templates/snippets/book_cover.html | 3 ++ 5 files changed, 65 insertions(+), 12 deletions(-) rename bookwyrm/templates/book/{cover_modal.html => cover_add_modal.html} (100%) create mode 100644 bookwyrm/templates/book/cover_show_modal.html diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index f8d3b5316..098424cc1 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -30,6 +30,9 @@ button { /* Corrects inability to style clickable `input` types in iOS */ -webkit-appearance: none; + + /* Generalizes pointer cursor */ + cursor: pointer; } button::-moz-focus-inner { @@ -64,6 +67,14 @@ button::-moz-focus-inner { overflow-x: auto; } +.modal-card { + pointer-events: none; +} + +.modal-card > * { + pointer-events: all; +} + /* stylelint-disable no-descending-specificity */ .modal-card:focus { outline-style: auto; @@ -148,6 +159,16 @@ button::-moz-focus-inner { display: inline !important; } +img.is-fit-cover { + object-fit: cover; + object-position: center; +} + +img.is-fit-contain { + object-fit: contain; + object-position: center; +} + /** File input styles ******************************************************************************/ @@ -429,6 +450,8 @@ details.dropdown .dropdown-menu a:focus-visible { display: flex; align-items: center; justify-content: center; + flex-direction: column; + gap: 1em; white-space: initial; text-align: center; } diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 27d061a28..e6823812a 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -61,24 +61,34 @@
- {% include 'snippets/book_cover.html' with size='xxlarge' size_mobile='medium' book=book cover_class='is-h-m-mobile' %} + {% if not book.cover %} + {% if user_authenticated %} + {% trans "Click to add cover" as button_text %} + + {% include 'book/cover_add_modal.html' with book=book controls_text="add_cover" controls_uid=book.id %} + {% if request.GET.cover_error %} +

{% trans "Failed to load cover" %}

+ {% endif %} + {% else %} + {% include 'snippets/book_cover.html' with size='xxlarge' size_mobile='medium' book=book cover_class='is-h-m-mobile' %} + {% endif %} + {% endif %} + + {% if book.cover %} + + {% include 'book/cover_show_modal.html' with book=book id="cover_show_modal" %} + {% endif %} + {% include 'snippets/rate_action.html' with user=request.user book=book %}
{% include 'snippets/shelve_button/shelve_button.html' %}
- {% if user_authenticated and not book.cover %} -
- {% trans "Add cover" as button_text %} - {% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="add_cover" controls_uid=book.id focus="modal_title_add_cover" class="is-small" %} - {% include 'book/cover_modal.html' with book=book controls_text="add_cover" controls_uid=book.id %} - {% if request.GET.cover_error %} -

{% trans "Failed to load cover" %}

- {% endif %} -
- {% endif %} -
{% with book=book %}
diff --git a/bookwyrm/templates/book/cover_modal.html b/bookwyrm/templates/book/cover_add_modal.html similarity index 100% rename from bookwyrm/templates/book/cover_modal.html rename to bookwyrm/templates/book/cover_add_modal.html diff --git a/bookwyrm/templates/book/cover_show_modal.html b/bookwyrm/templates/book/cover_show_modal.html new file mode 100644 index 000000000..8625962ab --- /dev/null +++ b/bookwyrm/templates/book/cover_show_modal.html @@ -0,0 +1,17 @@ +{% load i18n %} +{% load static %} + + \ No newline at end of file diff --git a/bookwyrm/templates/snippets/book_cover.html b/bookwyrm/templates/snippets/book_cover.html index 0f6844822..829fbb658 100644 --- a/bookwyrm/templates/snippets/book_cover.html +++ b/bookwyrm/templates/snippets/book_cover.html @@ -62,6 +62,9 @@ >

{{ book.alt_text }}

+ {% if text_append %} +

{{ text_append }}

+ {% endif %}
{% endif %}