Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions assets/js/imageGallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const gallery = document.querySelector(".m-image-gallery");
const galleryPictures = gallery.querySelector(".m-image-gallery__pictures");

const nextButton = gallery.querySelector("#next");
const prevButton = gallery.querySelector("#prev");

// There is an problem with the scroll-snap on mobile devices, so we need to add the gap between the items when scrolling to make it work properly.
const galleryGap = 15;

const getItemWidth = () =>
galleryPictures.children[0]?.getBoundingClientRect().width ??
galleryPictures.clientWidth;

const updateButtonState = () => {
console.log("updateButtonState");
const maxScrollLeft =
galleryPictures.scrollWidth - galleryPictures.clientWidth;

prevButton.disabled = galleryPictures.scrollLeft === 0;
nextButton.disabled = galleryPictures.scrollLeft >= maxScrollLeft;
};

nextButton.addEventListener("click", () => {
galleryPictures.scrollTo({
left: galleryPictures.scrollLeft + getItemWidth() + galleryGap,
behavior: "smooth",
});
});

prevButton.addEventListener("click", () => {
galleryPictures.scrollTo({
left: galleryPictures.scrollLeft - getItemWidth() - galleryGap,
behavior: "smooth",
});
});

galleryPictures.addEventListener("scroll", updateButtonState, {
passive: true,
});
window.addEventListener("resize", updateButtonState);

updateButtonState();
1 change: 1 addition & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ import "./expander.js";
import "./dialog.js";
import "./fipValidityComparison.js";
import "./search.js";
import "./imageGallery.js";
47 changes: 47 additions & 0 deletions assets/sass/imageGallery.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.m-image-gallery {
display: flex;
flex-direction: column;
gap: 0.4rem;
}

.m-image-gallery__pictures {
display: flex;
margin: 0;
padding: 0;
gap: 1.5rem;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
list-style: none;
border-radius: var(--border-radius-l);

-ms-overflow-style: none;
scrollbar-width: none;

&::-webkit-scrollbar {
display: none;
}

@media (prefers-reduced-motion: reduce) {
scroll-behavior: auto;
}

@include focus-indicator(0.2rem);
}

.m-image-gallery__item {
flex: 0 0 100%;
scroll-snap-align: center;
list-style: none;
}

.m-image-gallery__controls {
display: flex;
gap: 1rem;
align-self: center;
margin-bottom: 1rem;

.a-button:disabled {
opacity: 0.35;
}
}
1 change: 1 addition & 0 deletions assets/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@import "trainCategory.scss";
@import "tag.scss";
@import "floatImage.scss";
@import "imageGallery.scss";
@import "teamMember.scss";
@import "dialog.scss";
@import "fip-validity.scss";
Expand Down
2 changes: 1 addition & 1 deletion assets/sass/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ figure {
display: flex;
flex-direction: column;
gap: 1.5rem;
overflow-x: auto;
overflow-x: visible;

p {
text-align: justify;
Expand Down
Binary file added content/operator/sz/image2.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions i18n/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ fipValidity:
footer-love:
aria-label: Made with love in Europe
text: Made with ♥️ in Europe
gallery:
aria-label: Bildgalerie
next: Nächstes Bild
previous: Vorheriges Bild
highlight:
confusion: Verwechslungsgefahr
important: Wichtige Information
Expand Down
4 changes: 4 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ fipValidity:
footer-love:
aria-label: Made with love in Europe
text: Made with ♥️ in Europe
gallery:
aria-label: Image gallery
next: Next Image
previous: Previous Image
highlight:
confusion: Risk of Confusion
important: Important Information
Expand Down
4 changes: 4 additions & 0 deletions i18n/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ fipValidity:
footer-love:
aria-label: Fait avec amour en Europe
text: Fait avec ♥️ en Europe
gallery:
aria-label: Galerie d'images
next: Image suivante
previous: Image précédente
general: Général
highlight:
confusion: Risque de confusion
Expand Down
2 changes: 2 additions & 0 deletions layouts/_partials/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
href="{{ .Destination }}"
target="_blank"
rel="noopener noreferrer"
{{- with .ID }}id="{{ . }}"{{- end -}}
class="a-button a-button__external o-link__external"
>
{{- .Text -}}{{- partial "icon" "arrow_outward" -}}
</a>
{{- else -}}
<button
class="a-button a-button__internal"
{{- with .ID }}id="{{ . }}"{{- end -}}
{{- with .Title }}title="{{ . }}"{{- end -}}
>
{{- .Text -}}
Expand Down
17 changes: 13 additions & 4 deletions layouts/_partials/helper/contentImage.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{{ $contentImage := .Page.Resources.GetMatch "image.webp" }}
{{ if not $contentImage }}
{{ $contentImage = resources.Get "images/default.webp" }}
{{ $allImages := .Page.Resources.ByType "image" }}
{{ $contentImages := slice }}
{{ range $allImages }}
{{ $name := lower .Name }}
{{ if and (in $name "image") (eq (lower .MediaType.SubType) "webp") }}
{{ $contentImages = $contentImages | append . }}
{{ end }}
{{ end }}
{{ if not $contentImages }}
{{ $contentImages = slice (resources.Get "images/default.webp") }}
{{ end }}

{{ $firstImage := index $contentImages 0 }}

{{ return dict "image" $contentImage }}
{{ return dict "image" $firstImage "firstImage" $firstImage "images" $contentImages }}
16 changes: 16 additions & 0 deletions layouts/_partials/imageGallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="m-image-gallery">
<ul
class="m-image-gallery__pictures"
aria-label="{{ i18n "gallery.aria-label" }}"
>
{{- range .images -}}
<li class="m-image-gallery__item">
{{ partial "image" (dict "image" .) }}
</li>
{{- end -}}
</ul>
<div class="m-image-gallery__controls">
{{- partial "button" (dict "Text" (partial "icon" "keyboard_arrow_left") "Title" (i18n "gallery.previous") "ID" "prev") -}}
{{- partial "button" (dict "Text" (partial "icon" "keyboard_arrow_right") "Title" (i18n "gallery.next") "ID" "next") -}}
</div>
</div>
2 changes: 1 addition & 1 deletion layouts/_partials/structuredData.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ $mainEntity = "FAQPage" }}
{{ end }}

{{ $image := (partial "helper/contentImage" .).Permalink }}
{{ $image := (partial "helper/contentImage" .).firstImage.Permalink }}

<script type="application/ld+json">{
"@context": "https://schema.org",
Expand Down
7 changes: 6 additions & 1 deletion layouts/country/single.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ define "main" }}
{{ $related := .Site.RegularPages.RelatedIndices . "country" }}
{{ $contentImage := partial "helper/contentImage" . }}


<article class="o-single o-single--with-sidemenu">
Expand Down Expand Up @@ -41,7 +42,11 @@ <h3 id="operators-without-fip-title">
</ul>
{{ end }}
</div>
{{ partial "image" (partial "helper/contentImage" . ) }}
{{ if gt (len $contentImage.images) 1 }}
{{ partial "imageGallery" (dict "images" $contentImage.images) }}
{{ else }}
{{ partial "image" $contentImage }}
{{ end }}
</div>
</article>
{{ end }}
7 changes: 6 additions & 1 deletion layouts/operator/single.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ define "main" }}
{{ $contentImage := partial "helper/contentImage" . }}
<article class="o-single o-single--with-sidemenu">
{{ partial "contentNavigation" . }}
<div class="o-single__content-wrapper">
Expand All @@ -18,7 +19,11 @@ <h1 data-pagefind-meta="title">{{ .Title }}</h1>
{{ partial "content" . }}
</div>
</div>
{{ partial "image" (partial "helper/contentImage" .) }}
{{ if gt (len $contentImage.images) 1 }}
{{ partial "imageGallery" (dict "images" $contentImage.images) }}
{{ else }}
{{ partial "image" $contentImage }}
{{ end }}
</div>
</article>
{{ end }}
4 changes: 3 additions & 1 deletion layouts/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
{{ $cleanedHTML := .Summary | plainify | transform.XMLEscape | safeHTML }}
<description>{{ $cleanedHTML }}</description>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<enclosure url="{{ (partial "helper/contentImage" . ).Permalink }}" />
{{- with (partial "helper/contentImage" .).firstImage -}}
<enclosure url="{{- .Permalink -}}" />
{{- end -}}
</item>
{{ end }}
</channel>
Expand Down
Loading