Skip to content

Commit

Permalink
Fixing the extra padding issue with content tiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokenshift committed Dec 21, 2023
1 parent e838bb9 commit 61fee20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/views/PageGalleryTileImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
data-href={page.file.path}
href={page.file.path}
rel="noopener">
{@html content?.innerHTML}
<div class="page-gallery__tile-image--content-sizer"></div>
<div class="page-gallery__tile-image--content-wrapper">{@html content?.innerHTML}</div>
</a>
{:else}
{#await pageContentService.getFirstImageSrc(page)}
Expand Down Expand Up @@ -48,7 +49,8 @@
data-href={page.file.path}
href={page.file.path}
rel="noopener">
{@html content?.innerHTML}
<div class="page-gallery__tile-image--content-sizer"></div>
<div class="page-gallery__tile-image--content-wrapper">{@html content?.innerHTML}</div>
</a>
{/if}
{/await}
Expand Down
23 changes: 15 additions & 8 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,23 @@
border-radius: var(--border-radius, 10px);
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
display: block;
height: 0;
position: relative;
text-decoration: none !important;
}

.page-gallery__tile-image--content-sizer {
display: block;
padding-bottom: calc(100% * var(--aspect-ratio));
}

.page-gallery__tile-image--content-wrapper {
bottom: 0;
left: 0;
overflow: auto;
padding: 0.5em;
/*
TODO: This leaves a bunch of extra padding at the bottom of the scrollable
content tile. Can I remove that somehow? Maybe have the actual content-holding
div be *inside* the one with the calculated height (which won't be scrollable)?
*/
padding-bottom: calc(100% * var(--aspect-ratio));
text-decoration: none !important;
position: absolute;
right: 0;
top: 0;
}

.page-gallery__tile-image--content * {
Expand Down

0 comments on commit 61fee20

Please sign in to comment.