From 40d863334ff3adec62028942504b42d7832addc5 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 25 Feb 2024 11:56:52 +0100 Subject: [PATCH 1/2] Balance layout for odd number of preview images --- src/main/handlebars/layout.handlebars | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/handlebars/layout.handlebars b/src/main/handlebars/layout.handlebars index 79271af..59161ed 100755 --- a/src/main/handlebars/layout.handlebars +++ b/src/main/handlebars/layout.handlebars @@ -522,6 +522,10 @@ aspect-ratio: auto; } + .images:where(.size-3, .size-5, .size-7) .image:first-child { + grid-column: 1 / 3; + } + .image img, .image video { aspect-ratio: 15 / 10; object-fit: cover; @@ -665,6 +669,10 @@ grid-template-columns: 1fr; } + .images .image:first-child { + grid-column: 1; + } + .images.overview { grid-template-columns: 1fr 1fr; } From 9bdbd19ed81178bb8a66b1f6ea319a961f4e01b4 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 25 Feb 2024 12:12:02 +0100 Subject: [PATCH 2/2] Make this work for any odd number of images --- src/main/handlebars/layout.handlebars | 6 +++--- src/main/handlebars/partials/images.handlebars | 2 +- src/main/php/de/thekid/dialog/Helpers.php | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/handlebars/layout.handlebars b/src/main/handlebars/layout.handlebars index 59161ed..b8583d4 100755 --- a/src/main/handlebars/layout.handlebars +++ b/src/main/handlebars/layout.handlebars @@ -514,15 +514,15 @@ 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(.size-3, .size-5, .size-7) .image:first-child { + .images:where(.is-odd) .image:first-child { grid-column: 1 / 3; } diff --git a/src/main/handlebars/partials/images.handlebars b/src/main/handlebars/partials/images.handlebars index fbefb55..9a26320 100755 --- a/src/main/handlebars/partials/images.handlebars +++ b/src/main/handlebars/partials/images.handlebars @@ -1,4 +1,4 @@ -
+
{{#each in.images}}
{{#if is.video}} diff --git a/src/main/php/de/thekid/dialog/Helpers.php b/src/main/php/de/thekid/dialog/Helpers.php index b8d8a55..9c2e4d5 100755 --- a/src/main/php/de/thekid/dialog/Helpers.php +++ b/src/main/php/de/thekid/dialog/Helpers.php @@ -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'])) {