Debian Codegraph @

src/pydata_sphinx_theme/assets/styles/components/_sidebar-collapse.scss

raw
1 /**
2 * The collapse/expand primary sidebar button
3 */
4
5 .bd-sidebar-primary {
6 .sidebar-primary-item.pst-sidebar-collapse {
7 padding-top: 0;
8 }
9
10 #pst-collapse-sidebar-button {
11 // Only show this button when there's enough width for both sidebar and main
12 // content. Do not show the button in the mobile menu where it would not
13 // make any sense.
14 @include media-breakpoint-down($breakpoint-sidebar-primary) {
15 display: none;
16 }
17
18 border: 0; // reset
19 padding: 0; // reset
20 text-align: start; // reset;
21 background-color: transparent;
22 outline-offset: $focus-ring-offset;
23 display: flex;
24 flex-direction: row;
25 align-items: center;
26 gap: 0.25rem;
27
28 // min width and height of the button must be 24px to meet WCAG Success Criterion 2.5.8
29 min-width: 24px;
30 min-height: 24px;
31 position: relative;
32 bottom: 0.2em;
33
34 .pst-icon {
35 color: var(--pst-color-link);
36
37 // The padding value was chosen by trial and error. For reference, the
38 // svg-inline--fa class normally applies a -.125em adjustment but this
39 // adjustment doesn't work when the icon is within a flex box. Important:
40 // the padding top value must match the padding bottom value because the
41 // icon undergoes a 180deg rotation when the sidebar is collapsed.
42 padding: 0.4em 0;
43
44 // This value was also chosen by trial and error until it looked good.
45 height: 1.3em;
46 }
47
48 .pst-collapse-sidebar-label {
49 // // inline-flex so we can set dimensions (width, height)
50 // display: inline-flex;
51 width: 100%;
52 height: 100%;
53
54 @include link-style-default;
55 }
56
57 .pst-expand-sidebar-label {
58 // inline-flex so we can set dimensions (width, height)
59 // display: inline-flex;
60
61 // When the sidebar is squeezed, there is no space to show the "expand
62 // sidebar" label. However, the label text is copied to a Bootstrap
63 // tooltip. It's also exposed to screen readers with this
64 // `visually-hidden` mixin from Bootstrap.
65 @include visually-hidden;
66
67 // Turn off for screen readers initially because the sidebar starts off in the expanded state.
68 // When the
69 visibility: hidden;
70 }
71
72 &:hover {
73 .pst-icon {
74 color: var(--pst-color-link-hover);
75 }
76
77 .pst-collapse-sidebar-label {
78 @include link-style-hover;
79 }
80 }
81 }
82
83 // Define transitions (if the environment permits animation)
84 @media (prefers-reduced-motion: no-preference) {
85 $duration: 400ms;
86
87 transition: width $duration ease;
88
89 #pst-collapse-sidebar-button {
90 .pst-icon {
91 transition:
92 transform $duration ease,
93 padding $duration ease;
94 }
95 }
96
97 @each $selector,
98 $delay
99 in (
100 // When the sidebar is collapsing, we need to delay the transition of
101 // properties that make the elements invisible so the user can see the
102 // opacity transition from 1 to 0 first.
103 ".pst-squeeze": $duration,
104 // When the sidebar is expanding, it's the opposite: we need to transition
105 // the properties that make the elements visible immediately so the user
106 // can watch the opacity transition from 0 to 1.
107 ":not(.pst-squeeze)": "0s"
108 )
109 {
110 &#{$selector} {
111 .pst-collapse-sidebar-label {
112 transition:
113 opacity $duration linear,
114 visibility 0s linear $delay,
115 width 0s linear $delay,
116 height 0s linear $delay;
117 }
118
119 .sidebar-primary-item:not(.pst-sidebar-collapse) {
120 transition:
121 opacity $duration linear,
122 visibility 0s linear $delay;
123 }
124
125 // There is no need to transition any other properties on the expand
126 // label (width, height, opacity) because it is always visually hidden
127 // (i.e., width 0, height 0, etc), but toggles its availability to
128 // screen readers as the sidebar collapses or expands via the
129 // `visibility` property.
130 .pst-expand-sidebar-label {
131 transition: visibility 0s linear $delay;
132 }
133 }
134 }
135 }
136
137 // Why "squeeze" and not "collapse"? Bootstrap uses the class name `collapse`
138 // so it seemed best to avoid possible confusion. (Later the class name was
139 // prefixed with `pst-`.)
140 &.pst-squeeze {
141 width: 4rem;
142 overflow: hidden;
143
144 #pst-collapse-sidebar-button {
145 .pst-icon {
146 transform: translateX(0.25em) rotate(180deg);
147 }
148
149 .pst-collapse-sidebar-label {
150 opacity: 0;
151 visibility: hidden;
152 width: 0;
153 height: 0;
154 }
155
156 .pst-expand-sidebar-label {
157 visibility: visible;
158 }
159 }
160
161 .sidebar-primary-item:not(.pst-sidebar-collapse) {
162 opacity: 0;
163 visibility: hidden;
164 }
165 }
166
167 &:not(.pst-squeeze) {
168 // When the sidebar is expanded, hide the "Expand Sidebar" label.
169 .pst-expand-sidebar-label {
170 visibility: hidden;
171 }
172
173 // This block is shorter than its counterpart above because there's no need,
174 // for example, to explicitly set `visibility: visible` or `opacity: 1` on
175 // the collapse label and sidebar subsections because those are the default
176 // values.
177 }
178 }