From 13040a9df32e0608699b23a83700e2a90cbfd818 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Tue, 26 May 2026 10:56:17 +0200 Subject: [PATCH] home > slideshow : enable --- assets/css/src/_home.scss | 41 +++++++++++++++++++ assets/css/src/_main.scss | 41 ------------------- assets/css/style.scss | 1 + assets/js/home-slideshow.js | 18 ++++++++ site/config/config.php | 8 +++- site/config/thumbs/home-slideshow.php | 20 +++++++++ site/snippets/picture.php | 59 +++++++++++++++++++++++++++ site/templates/home.php | 23 ++++++++--- 8 files changed, 163 insertions(+), 48 deletions(-) create mode 100644 assets/css/src/_home.scss create mode 100644 assets/js/home-slideshow.js create mode 100644 site/config/thumbs/home-slideshow.php create mode 100644 site/snippets/picture.php diff --git a/assets/css/src/_home.scss b/assets/css/src/_home.scss new file mode 100644 index 0000000..6444270 --- /dev/null +++ b/assets/css/src/_home.scss @@ -0,0 +1,41 @@ +#home-slideshow { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + + picture, video { + display: none; + width: 100%; + height: 100%; + + &.active { + display: block; + } + } + + img, video { + width: 100%; + height: 100%; + object-fit: cover; + } + + .main-infos { + width: calc(3 / 4 * var(--index-width)); + position: relative; + float: left; + } +} + +.skills { + width: calc(2 / 4 * var(--index-width)); + position: relative; + float: left; +} + +.clients { + width: calc(2 / 4 * var(--index-width)); + position: relative; + float: left; +} diff --git a/assets/css/src/_main.scss b/assets/css/src/_main.scss index 62d216e..b07a64e 100644 --- a/assets/css/src/_main.scss +++ b/assets/css/src/_main.scss @@ -305,47 +305,6 @@ button.next { display: block; } -/* HOME SLIDESHOW */ - -#home-slideshow { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; -} - -#home-slideshow img { - display: none; - width: 100%; - height: 100%; - object-fit: cover; -} - -#home-slideshow img:first-child { - display: block; -} - -/* HOME */ - -.main-infos { - width: calc(3 / 4 * var(--index-width)); - position: relative; - float: left; -} - -.skills { - width: calc(2 / 4 * var(--index-width)); - position: relative; - float: left; -} - -.clients { - width: calc(2 / 4 * var(--index-width)); - position: relative; - float: left; -} - /* INFOS */ [data-template="infos"] div { diff --git a/assets/css/style.scss b/assets/css/style.scss index c0f3ef0..a181de8 100644 --- a/assets/css/style.scss +++ b/assets/css/style.scss @@ -1,4 +1,5 @@ @import "src/_reset.scss"; @import "src/_main.scss"; @import "src/_nav.scss"; +@import "src/_home.scss"; @import "src/_mobile.scss"; diff --git a/assets/js/home-slideshow.js b/assets/js/home-slideshow.js new file mode 100644 index 0000000..1604aa5 --- /dev/null +++ b/assets/js/home-slideshow.js @@ -0,0 +1,18 @@ +const slideshow = document.getElementById('home-slideshow'); + +if (slideshow) { + const items = [...slideshow.querySelectorAll('picture, video')]; + const prev = slideshow.querySelector('.prev'); + const next = slideshow.querySelector('.next'); + let current = 0; + + function goTo(index) { + items[current].classList.remove('active'); + current = (index + items.length) % items.length; + items[current].classList.add('active'); + } + + items[0]?.classList.add('active'); + prev?.addEventListener('click', () => goTo(current - 1)); + next?.addEventListener('click', () => goTo(current + 1)); +} diff --git a/site/config/config.php b/site/config/config.php index 08b83ea..d1b9cb9 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -1,9 +1,15 @@ true, + 'debug' => true, 'panel' => [ 'menu' => require_once __DIR__ . '/menu.php', 'home' => 'pages/home', ], + 'thumbs' => [ + 'quality' => 80, + 'srcsets' => array_merge( + require __DIR__ . '/thumbs/home-slideshow.php', + ), + ], ]; \ No newline at end of file diff --git a/site/config/thumbs/home-slideshow.php b/site/config/thumbs/home-slideshow.php new file mode 100644 index 0000000..7cedada --- /dev/null +++ b/site/config/thumbs/home-slideshow.php @@ -0,0 +1,20 @@ + [ + '800w' => ['width' => 800], + '1200w' => ['width' => 1200], + '1600w' => ['width' => 1600], + '2000w' => ['width' => 2000], + '2560w' => ['width' => 2560], + ], + 'home-slideshow-webp' => [ + '800w' => ['width' => 800, 'format' => 'webp'], + '1200w' => ['width' => 1200, 'format' => 'webp'], + '1600w' => ['width' => 1600, 'format' => 'webp'], + '2000w' => ['width' => 2000, 'format' => 'webp'], + '2560w' => ['width' => 2560, 'format' => 'webp'], + ], +]; diff --git a/site/snippets/picture.php b/site/snippets/picture.php new file mode 100644 index 0000000..51ee8fb --- /dev/null +++ b/site/snippets/picture.php @@ -0,0 +1,59 @@ + + alt() ?? ''; + $lazy = $lazy ?? true; + $classAttr = isset($class) ? ' class="' . htmlspecialchars($class) . '"' : ''; + $spanAttr = isset($span) ? ' style="--span: ' . htmlspecialchars($span) . ';"' : ''; + ?> + mime() === 'image/gif'): ?> + data-id="uuid() ?>" orientation="orientation() ?>" data-mime="mime() ?>"> + <?= htmlspecialchars($alt) ?> + + + option('thumbs.srcsets', []); + $webpSrcset = isset($kirbyThumbs[$webpName]) + ? $file->srcset($webpName) + : $file->srcset('webp'); + + $srcset = $file->srcset($srcsetName); + $src = $file->url(); + + $resized = $file->resize(1800); + $width = $resized ? $resized->width() : $file->width(); + $height = $resized ? $resized->height() : $file->height(); + ?> + data-id="uuid() ?>" orientation="orientation() ?>" data-mime="mime() ?>"> + + <?= htmlspecialchars($alt) ?> + + + diff --git a/site/templates/home.php b/site/templates/home.php index 041922b..5d96d1b 100644 --- a/site/templates/home.php +++ b/site/templates/home.php @@ -1,12 +1,23 @@
- images() as $image): ?> - - + files()->sortBy('sort') as $file): ?> + type() === 'video'): ?> + + + $file, + 'srcsetName' => 'home-slideshow', + 'sizes' => '100vw', + 'lazy' => false, + ]) ?> + + -
+
- - \ No newline at end of file + +