From 15a2988ccbfec04b8d9093ccde97decfc095d947 Mon Sep 17 00:00:00 2001 From: MoritzWeber0 Date: Sun, 12 Jul 2026 08:36:58 +0200 Subject: [PATCH 1/2] feat: Add anchorlink buttons to expanders" This reverts commit a85b78de0a6ffa09a1dd98c4b65a9c43cd035569. --- assets/js/anchorlinks.js | 14 +++++++++++--- assets/sass/anchorlink.scss | 6 ++++++ layouts/_partials/anchorlink-button.html | 7 +++++++ layouts/_partials/booking/links.html | 1 + layouts/_partials/train-category.html | 4 +++- 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 layouts/_partials/anchorlink-button.html diff --git a/assets/js/anchorlinks.js b/assets/js/anchorlinks.js index 6cce91868..2b587cdc9 100644 --- a/assets/js/anchorlinks.js +++ b/assets/js/anchorlinks.js @@ -1,5 +1,7 @@ function initAnchorlinkEventListener() { - const anchorLinks = document.querySelectorAll(".a-anchorlink__link"); + const anchorLinks = document.querySelectorAll( + ".a-anchorlink__link, .a-anchorlink__button", + ); const snackbar = document.getElementById("snackbar"); const snackbarButton = document.getElementById("snackbar-button"); @@ -38,12 +40,18 @@ function closeSnackbar() { } if (document.readyState === "interactive") { - if (document.querySelectorAll(".a-anchorlink__link").length) { + if ( + document.querySelectorAll(".a-anchorlink__link, .a-anchorlink__button") + .length + ) { initAnchorlinkEventListener(); } } else { window.addEventListener("DOMContentLoaded", () => { - if (document.querySelectorAll(".a-anchorlink__link").length) { + if ( + document.querySelectorAll(".a-anchorlink__link, .a-anchorlink__button") + .length + ) { initAnchorlinkEventListener(); } }); diff --git a/assets/sass/anchorlink.scss b/assets/sass/anchorlink.scss index c9a22e6d3..81d26a0c2 100644 --- a/assets/sass/anchorlink.scss +++ b/assets/sass/anchorlink.scss @@ -74,6 +74,12 @@ } } +.a-anchorlink__button { + @media print { + display: none; + } +} + .a-snackbar { position: fixed; bottom: 0; diff --git a/layouts/_partials/anchorlink-button.html b/layouts/_partials/anchorlink-button.html new file mode 100644 index 000000000..3f72caa32 --- /dev/null +++ b/layouts/_partials/anchorlink-button.html @@ -0,0 +1,7 @@ + diff --git a/layouts/_partials/booking/links.html b/layouts/_partials/booking/links.html index 1947fcbbc..3047425d9 100644 --- a/layouts/_partials/booking/links.html +++ b/layouts/_partials/booking/links.html @@ -15,4 +15,5 @@ ) -}} {{- end -}} + {{- partial "anchorlink-button" (dict "id" .id) -}} diff --git a/layouts/_partials/train-category.html b/layouts/_partials/train-category.html index 9d9fc87a2..5f90cded2 100644 --- a/layouts/_partials/train-category.html +++ b/layouts/_partials/train-category.html @@ -123,7 +123,9 @@

{{- $content := partial "transformations/increase-headings" (dict "content" .content "offset" 1) -}} {{- $content := partial "transformations/transform-expander-headings" (dict "content" $content "id" .id) -}} {{- $content | safeHTML -}} - +
+ {{- partial "anchorlink-button" (dict "id" .id) -}} +
{{- if or .route_overview_url .additional_information_url -}}
{{- if .route_overview_url -}} From c8b56cc61e54c2f17aa0b9a7035f5e0cb7016046 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Thu, 23 Jul 2026 23:09:02 +0200 Subject: [PATCH 2/2] feat: Simplify anchorlinks in expanders --- assets/js/anchorlinks.js | 14 +++----------- assets/sass/anchorlink.scss | 6 ------ assets/sass/booking.scss | 18 ------------------ assets/sass/expander.scss | 23 +++++++++++++++++++++++ layouts/_markup/render-heading.html | 8 +------- layouts/_partials/anchorlink-button.html | 6 +++--- layouts/_partials/booking/links.html | 4 ++-- layouts/_partials/expander.html | 5 +++++ layouts/_partials/train-category.html | 10 ++++------ 9 files changed, 41 insertions(+), 53 deletions(-) diff --git a/assets/js/anchorlinks.js b/assets/js/anchorlinks.js index 2b587cdc9..6cce91868 100644 --- a/assets/js/anchorlinks.js +++ b/assets/js/anchorlinks.js @@ -1,7 +1,5 @@ function initAnchorlinkEventListener() { - const anchorLinks = document.querySelectorAll( - ".a-anchorlink__link, .a-anchorlink__button", - ); + const anchorLinks = document.querySelectorAll(".a-anchorlink__link"); const snackbar = document.getElementById("snackbar"); const snackbarButton = document.getElementById("snackbar-button"); @@ -40,18 +38,12 @@ function closeSnackbar() { } if (document.readyState === "interactive") { - if ( - document.querySelectorAll(".a-anchorlink__link, .a-anchorlink__button") - .length - ) { + if (document.querySelectorAll(".a-anchorlink__link").length) { initAnchorlinkEventListener(); } } else { window.addEventListener("DOMContentLoaded", () => { - if ( - document.querySelectorAll(".a-anchorlink__link, .a-anchorlink__button") - .length - ) { + if (document.querySelectorAll(".a-anchorlink__link").length) { initAnchorlinkEventListener(); } }); diff --git a/assets/sass/anchorlink.scss b/assets/sass/anchorlink.scss index 81d26a0c2..c9a22e6d3 100644 --- a/assets/sass/anchorlink.scss +++ b/assets/sass/anchorlink.scss @@ -74,12 +74,6 @@ } } -.a-anchorlink__button { - @media print { - display: none; - } -} - .a-snackbar { position: fixed; bottom: 0; diff --git a/assets/sass/booking.scss b/assets/sass/booking.scss index a46a162d6..2d6e495c3 100644 --- a/assets/sass/booking.scss +++ b/assets/sass/booking.scss @@ -68,24 +68,6 @@ } } -.o-booking__links { - margin-top: 1.5rem; - display: flex; - gap: 1rem; - flex-wrap: wrap; - - @media print { - > a { - flex-wrap: wrap; - font-weight: bold; - - &::after { - font-weight: normal; - } - } - } -} - .o-booking__info { margin-bottom: 1.5rem; } diff --git a/assets/sass/expander.scss b/assets/sass/expander.scss index e3b94471d..5d424b185 100644 --- a/assets/sass/expander.scss +++ b/assets/sass/expander.scss @@ -82,6 +82,29 @@ details[open] > .o-expander__summary { } } +.o-expander__actions { + margin-top: 1.5rem; + display: flex; + gap: 1rem; + flex-wrap: wrap; + align-items: center; + + > .a-anchorlink__link { + margin-left: auto; + } + + @media print { + > a { + flex-wrap: wrap; + font-weight: bold; + + &::after { + font-weight: normal; + } + } + } +} + details { position: relative; background-color: var(--bg-neutral); diff --git a/layouts/_markup/render-heading.html b/layouts/_markup/render-heading.html index b85eac95e..f044c3683 100644 --- a/layouts/_markup/render-heading.html +++ b/layouts/_markup/render-heading.html @@ -11,13 +11,7 @@ {{- partial "intersector" -}} {{- $heading | safeHTML -}} - + {{- partial "anchorlink-button" $id -}} {{- else -}} {{- $heading | safeHTML -}} diff --git a/layouts/_partials/anchorlink-button.html b/layouts/_partials/anchorlink-button.html index 3f72caa32..e1af91679 100644 --- a/layouts/_partials/anchorlink-button.html +++ b/layouts/_partials/anchorlink-button.html @@ -1,7 +1,7 @@ diff --git a/layouts/_partials/booking/links.html b/layouts/_partials/booking/links.html index 3047425d9..5627da382 100644 --- a/layouts/_partials/booking/links.html +++ b/layouts/_partials/booking/links.html @@ -1,4 +1,4 @@ -