Skip to content

Commit

Permalink
Merge pull request #58 from thekid/feature/odd-preview
Browse files Browse the repository at this point in the history
Balance layout for odd number of preview images
  • Loading branch information
thekid authored Feb 25, 2024
2 parents 314f78e + 9bdbd19 commit 676e974
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main/handlebars/layout.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,18 @@
grid-template-columns: 1fr;
}
.images.size-1 {
.images.is-single {
grid-template-columns: 1fr;
}
.images.size-1 video {
.images.is-single video {
aspect-ratio: auto;
}
.images:where(.is-odd) .image:first-child {
grid-column: 1 / 3;
}
.image img, .image video {
aspect-ratio: 15 / 10;
object-fit: cover;
Expand Down Expand Up @@ -665,6 +669,10 @@
grid-template-columns: 1fr;
}
.images .image:first-child {
grid-column: 1;
}
.images.overview {
grid-template-columns: 1fr 1fr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/handlebars/partials/images.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="images {{style}} size-{{size in.images}}">
<div class="images {{style}} is-{{size-class (size in.images)}}">
{{#each in.images}}
<div class="image">
{{#if is.video}}
Expand Down
9 changes: 9 additions & 0 deletions src/main/php/de/thekid/dialog/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public function helpers() {
if ($time > $until) return 'passed';
return 'current';
};
yield 'size-class' => function($node, $context, $options) {
$s= (int)$options[0];
return match {
0 === $s => 'empty',
1 === $s => 'single',
1 === $s % 2 => 'odd',
default => 'even',
};
};
yield 'route' => function($node, $context, $options) {
$entry= $options[0];
if (isset($entry['is']['journey'])) {
Expand Down

0 comments on commit 676e974

Please sign in to comment.