Skip to content

Commit bbfa547

Browse files
refactor: Simplify expander print view styling (#455)
1. removed arrow-icon from print view (was shown in booking-expanders) 2. refactored open-status with pseudo-selector ::details-content 3. some general code refactoring --------- Co-authored-by: MoritzWeber0 <kontakt@moritz-weber.net>
1 parent 9e3e5c5 commit bbfa547

File tree

5 files changed

+41
-57
lines changed

5 files changed

+41
-57
lines changed

assets/sass/booking.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
.o-booking__title {
5454
display: flex;
5555
gap: 0.4rem;
56-
align-items: flex-start;
56+
align-items: center;
5757
font-weight: 600;
5858
}
5959

assets/sass/contentNavigation.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
li {
2626
margin-bottom: 0.3rem;
2727
}
28+
29+
@media print {
30+
display: none;
31+
}
2832
}
2933

3034
.o-aside__header {

assets/sass/expander.scss

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,23 @@
3838
}
3939
}
4040
}
41+
42+
> .material-symbols-rounded {
43+
transition: transform 0.2s;
44+
45+
@media print {
46+
display: none;
47+
}
48+
}
49+
50+
> div {
51+
display: flex;
52+
align-items: center;
53+
gap: 0.5rem;
54+
}
4155
}
4256

43-
.details-screen[open] > .o-expander__summary {
57+
details[open] > .o-expander__summary {
4458
&:hover,
4559
&:focus {
4660
border-radius: var(--border-radius-m) var(--border-radius-m) 0 0;
@@ -62,10 +76,6 @@
6276
}
6377
}
6478

65-
.details-print {
66-
display: none;
67-
}
68-
6979
details {
7080
position: relative;
7181
background-color: var(--bg-neutral);
@@ -76,46 +86,35 @@ details {
7686
width: 100%;
7787
margin-left: 0;
7888
}
79-
}
8089

81-
details > summary {
82-
list-style-type: none;
83-
}
90+
> summary {
91+
list-style-type: none;
92+
}
8493

85-
details > div {
86-
overflow-x: auto;
87-
}
94+
> div {
95+
overflow-x: auto;
96+
}
8897

89-
details > summary::-webkit-details-marker {
90-
display: none;
91-
}
98+
> summary::-webkit-details-marker {
99+
display: none;
100+
}
92101

93-
.o-expander__summary > span {
94-
transition: transform 0.2s;
95-
}
102+
@media print {
103+
border: 0.2rem solid #bbb;
104+
page-break-inside: avoid;
105+
display: block;
96106

97-
.o-expander__summary > div {
98-
display: flex;
99-
align-items: center;
100-
gap: 0.5rem;
107+
&::details-content {
108+
content-visibility: visible;
109+
height: auto !important;
110+
}
111+
}
101112
}
102113

103-
.details-screen[open] > .o-expander__summary > span {
114+
details[open] > .o-expander__summary > .material-symbols-rounded {
104115
transform: rotate(180deg);
105116
}
106117

107118
details[open] > .o-expander__summary:not(.o-expander__summary--booking) {
108119
font-weight: 700;
109120
}
110-
111-
@media print {
112-
.details-screen {
113-
display: none;
114-
}
115-
116-
.details-print {
117-
border: 0.2rem solid #bbb;
118-
page-break-inside: avoid;
119-
display: block;
120-
}
121-
}

layouts/shortcodes/booking.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
-}}
2020

2121

22-
<details class="details-screen o-expander o-expander--booking">
23-
{{- partial "booking" $params -}}
24-
</details>
25-
26-
<details open class="details-print o-expander o-expander--booking">
22+
<details class="o-expander o-expander--booking">
2723
{{- partial "booking" $params -}}
2824
</details>

layouts/shortcodes/expander.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{ $iconMapping := dict "border" "share_location" "traincategory" "train" "info" "info" }}
33

44

5-
<details name="{{ (.Get 2) }}" class="details-screen o-expander">
5+
<details name="{{ (.Get 2) }}" class="o-expander">
66
<summary class="o-expander__summary">
77
<div>
88
{{- partial "icon" (index $iconMapping $param) -}}
@@ -15,18 +15,3 @@
1515
{{ .Inner }}
1616
</div>
1717
</details>
18-
19-
<!--
20-
Workaround for print version, otherwise the expanders would be closed.
21-
The workaround can be removed when the following issue is implemented:
22-
https://github.com/w3c/csswg-drafts/issues/2084
23-
-->
24-
<details open class="details-print o-expander">
25-
<summary class="o-expander__summary">
26-
<span class="o-expander__summary-text">{{ (.Get 0) }}</span>
27-
</summary>
28-
<hr aria-hidden="true" />
29-
<div class="o-expander__content">
30-
{{ .Inner }}
31-
</div>
32-
</details>

0 commit comments

Comments
 (0)