-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#116 htmx gallery layout for bootstrap4 + some tests
- Loading branch information
Showing
4 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<h5>HTMX Gallery</h5> | ||
<div class="cast-gallery-container"> | ||
{% for image in images %} | ||
<a | ||
hx-get="{% url 'cast:gallery-modal' template_base_dir=template_base_dir %}?image_pks={{ image_pks }}¤t_image_pk={{ image.pk }}&block_id={{ block.id }}" | ||
hx-trigger="click" | ||
hx-target="#imageGalleryModal-{{ block.id }}" | ||
class="cast-image-gallery-thumbnail cast-gallery-modal" | ||
data-full="{{ image.file.url }}" | ||
data-toggle="modal" | ||
data-target="#imageGalleryModal-{{ block.id }}" | ||
> | ||
<picture> | ||
<source | ||
srcset="{{ image.thumbnail.srcset.avif }}" | ||
type="image/avif" | ||
sizes="{{ image.thumbnail.sizes }}" | ||
data-modal-src="{{ image.modal.src.avif }}" | ||
data-modal-srcset="{{ image.modal.srcset.avif }}" | ||
data-modal-sizes="{{ image.modal.sizes }}" | ||
> | ||
<img | ||
id="img-{{image.pk}}" | ||
class="cast-gallery-thumbnail" | ||
alt="{{ image.default_alt_text }}" | ||
src="{{ image.thumbnail.src.jpeg }}" | ||
srcset="{{ image.thumbnail.srcset.jpeg }}" | ||
sizes="{{ image.thumbnail.sizes }}" | ||
width="{{ image.thumbnail.width }}" | ||
height="{{ image.thumbnail.height }}" | ||
data-modal-src="{{ image.modal.src.jpeg }}" | ||
data-modal-srcset="{{ image.modal.srcset.jpeg }}" | ||
data-modal-sizes="{{ image.modal.sizes }}" | ||
data-modal-width="{{ image.modal.width }}" | ||
data-modal-height="{{ image.modal.height }}" | ||
data-prev="{{ image.prev }}" | ||
data-next="{{ image.next }}" | ||
loading="lazy" | ||
/> | ||
</picture> | ||
</a> | ||
{% endfor %} | ||
<!-- Modal --> | ||
<div class="modal fade" id="imageGalleryModal-{{ block.id }}" tabindex="-1" role="dialog" | ||
aria-labelledby="galleryModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog modal-lg cast-gallery-lg" role="document"> | ||
<div class="modal-content cast-gallery-content"> | ||
<div class="modal-header cast-gallery-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body cast-gallery-body"> | ||
<picture class="modal-picture"> | ||
<source class="modal-source" srcset="" sizes="" type="image/avif"> | ||
<img class="modal-image cast-image" alt="modal image placeholder" src="" srcset="" sizes="100vw"> | ||
</picture> | ||
</div> | ||
<div class="modal-footer cast-gallery-footer"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<div class="modal-dialog modal-lg cast-gallery-lg" role="document"> | ||
<div class="modal-content cast-gallery-content"> | ||
<div class="modal-header cast-gallery-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body cast-gallery-body"> | ||
<a href="{{ current_image.file.url }}"> | ||
<picture class="modal-picture"> | ||
<source | ||
class="modal-source" | ||
srcset="{{ current_image.modal.srcset.avif }}" | ||
sizes="{{ current_image.modal.sizes }}" | ||
type="image/avif" | ||
> | ||
<img | ||
class="modal-image cast-image" | ||
alt="{{ current_image.default_alt_text }}" | ||
src="{{ current_image.modal.src.jpeg }}" | ||
srcset="{{ current_image.modal.srcset.jpeg }}" | ||
sizes="{{ current_image.modal.sizes }}" | ||
> | ||
</picture> | ||
</a> | ||
</div> | ||
<div class="modal-footer cast-gallery-footer"> | ||
<button | ||
id="data-prev" | ||
type="button" | ||
class="btn btn-primary {% if not prev_image %}disabled{% endif %}" | ||
{% if prev_image %} | ||
hx-get="{% url 'cast:gallery-modal' template_base_dir=template_base_dir %}?image_pks={{ image_pks }}¤t_image_pk={{ prev_image.pk }}&block_id={{ block_id }}" | ||
hx-trigger="click, keyup[key=='ArrowLeft'] from:body" | ||
hx-target="#imageGalleryModal-{{ block_id }}" | ||
{% endif %} | ||
> | ||
Prev | ||
</button> | ||
<button | ||
id="data-next" | ||
type="button" | ||
class="btn btn-primary {% if not next_image %}disabled{% endif %}" | ||
{% if next_image %} | ||
hx-get="{% url 'cast:gallery-modal' template_base_dir=template_base_dir %}?image_pks={{ image_pks }}¤t_image_pk={{ next_image.pk }}&block_id={{ block_id }}" | ||
hx-trigger="click, keyup[key=='ArrowRight'] from:body" | ||
hx-target="#imageGalleryModal-{{ block_id }}" | ||
{% endif %} | ||
> | ||
Next | ||
</button> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters