Skip to content

Commit

Permalink
fix: images
Browse files Browse the repository at this point in the history
feature: closes search when focusout
  • Loading branch information
therobrob committed Feb 5, 2025
1 parent 2ab046f commit be6c556
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 62 deletions.
Binary file modified themes/fiptheme/assets/images/startpage.webp
Binary file not shown.
1 change: 1 addition & 0 deletions themes/fiptheme/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import './mobileMenu.js';
import './countrySelector.js';
import './resizeObserver.js';
import './mediaqueries.js';
import './search.js';
21 changes: 21 additions & 0 deletions themes/fiptheme/assets/js/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function searchBlur() {
const searchContainer = document.querySelector('.pagefind-ui__form');

searchContainer.addEventListener('focusout', function(event) {
if (searchContainer.contains(event.relatedTarget)) {
// Der Fokus ist innerhalb des Formulars auf ein anderes Element gesprungen
return;
}

// Der Fokus ist außerhalb des Formulars gesprungen
const drawer = document.querySelector('.pagefind-ui__drawer');
drawer.classList.add('pagefind-ui__hidden');
console.log('Das Formular oder ein Element darin hat den Fokus verloren');
});
}

window.onload = function() {
searchBlur();
};


9 changes: 6 additions & 3 deletions themes/fiptheme/assets/sass/stage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
margin-bottom: 4rem;
}

.o-stage > img {
.o-stage > picture {
width: 100%;
aspect-ratio: 4/1;
max-width: 1320px;
border-radius: 0 0 1rem 1rem;

img {
border-radius: 0 0 1rem 1rem;
}
}

.o-stage {
Expand Down Expand Up @@ -48,7 +51,7 @@
}
}

.curtain:has(~ .o-stage .o-stage__search:focus-within) {
.curtain:has(~ .o-stage .o-stage__search:focus-within) {
background-color: rgba(0, 0, 0, .8);
inset: 0;
position: fixed;
Expand Down
54 changes: 25 additions & 29 deletions themes/fiptheme/layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
{{ if and .Destination (or (strings.HasPrefix .Destination "http://") (strings.HasPrefix .Destination "https://")) }}
<!-- Remote Bild: Direkt ausgeben ohne Bildverarbeitung -->
{{ $remoteImage := resources.GetRemote .Destination }}
<p class="md-image">
<img src="{{ $remoteImage.Permalink }}" alt="{{ .Title }}" title="{{ .Title }}" loading="lazy"/>
</p>
<img src="{{ $remoteImage.Permalink }}" alt="{{ .Title }}" title="{{ .Title }}" loading="lazy"/>
{{ else }}
{{/* Lokales Bild: Mit Bildverarbeitung */}}
{{ $originalImage := resources.Get "images/glider.png" }}
Expand All @@ -23,39 +21,37 @@
{{ end }}
{{ end }}

<p class="md-image">
<picture>
{{ $width := $originalImage.Width }}
<picture>
{{ $width := $originalImage.Width }}

{{ if gt $width 2200 }}
{{ with $originalImage.Resize "2200x" }}
<source media="(min-width:2200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ if gt $width 2200 }}
{{ with $originalImage.Resize "2200x" }}
<source media="(min-width:2200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ if gt $width 1500 }}
{{ with $originalImage.Resize "1500x" }}
<source media="(min-width:1500px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ if gt $width 1500 }}
{{ with $originalImage.Resize "1500x" }}
<source media="(min-width:1500px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ if gt $width 1200 }}
{{ with $originalImage.Resize "1200x" }}
<source media="(min-width:1200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ if gt $width 1200 }}
{{ with $originalImage.Resize "1200x" }}
<source media="(min-width:1200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ if gt $width 800 }}
{{ with $originalImage.Resize "800x" }}
<source media="(min-width:800px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ if gt $width 800 }}
{{ with $originalImage.Resize "800x" }}
<source media="(min-width:800px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ $tinyImage := $originalImage }}
{{ if gt $width 500 }}
{{ $tinyImage = $originalImage.Resize "500x" }}
{{ end }}
<img src="{{ $tinyImage.RelPermalink | safeURL }}" alt="{{ $myTitle }}" title="{{ $myTitle }}" loading="lazy"/>
</picture>
</p>
{{ $tinyImage := $originalImage }}
{{ if gt $width 500 }}
{{ $tinyImage = $originalImage.Resize "500x" }}
{{ end }}
<img src="{{ $tinyImage.RelPermalink | safeURL }}" alt="{{ $myTitle }}" title="{{ $myTitle }}" loading="lazy"/>
</picture>
{{ end }}
58 changes: 28 additions & 30 deletions themes/fiptheme/layouts/partials/image.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
{{ $myTitle := "" }}
<p class="md-image">
<picture>
{{ $width := .Width }}
<picture>
{{ $width := .Width }}

{{ if gt $width 2200 }}
{{ with .Resize "2200x" }}
<source media="(min-width:2200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}
{{ if gt $width 2200 }}
{{ with .Resize "2200x" }}
<source media="(min-width:2200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ if gt $width 1500 }}
{{ with .Resize "1500x" }}
<source media="(min-width:1500px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}
{{ if gt $width 1500 }}
{{ with .Resize "1500x" }}
<source media="(min-width:1500px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ if gt $width 1200 }}
{{ with .Resize "1200x" }}
<source media="(min-width:1200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}
{{ if gt $width 1200 }}
{{ with .Resize "1200x" }}
<source media="(min-width:1200px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ if gt $width 800 }}
{{ with .Resize "800x" }}
<source media="(min-width:800px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}
{{ if gt $width 800 }}
{{ with .Resize "800x" }}
<source media="(min-width:800px)" srcset="{{ .RelPermalink | safeURL }}" title="{{ $myTitle }}" loading="lazy"/>
{{ end }}
{{ end }}

{{ $tinyImage := . }}
{{ if gt $width 500 }}
{{ $tinyImage = .Resize "500x" }}
{{ end }}
<img src="{{ $tinyImage.RelPermalink | safeURL }}" alt="{{ $myTitle }}" title="{{ $myTitle }}" loading="lazy"/>
</picture>
</p>
{{ $tinyImage := . }}
{{ if gt $width 500 }}
{{ $tinyImage = .Resize "500x" }}
{{ end }}
<img src="{{ $tinyImage.RelPermalink | safeURL }}" alt="{{ $myTitle }}" title="{{ $myTitle }}" loading="lazy"/>
</picture>

0 comments on commit be6c556

Please sign in to comment.