Debian Codegraph @

src/pydata_sphinx_theme/assets/styles/sections/_sidebar-primary.scss

raw
1 /**
2 * The primary sidebar on the left.
3 * e.g., between-pages navigation.
4 */
5
6 $sidebar-padding-right: 1rem;
7
8 .bd-sidebar-primary {
9 display: flex;
10 flex-direction: column;
11 gap: 1rem;
12 max-height: calc(100vh - var(--pst-header-height));
13 position: sticky;
14 top: var(--pst-header-height);
15
16 @include make-col(3);
17
18 // Borders padding and whitespace
19 padding: $sidebar-padding-right;
20 border-right: 1px solid var(--pst-color-border);
21 background-color: var(--pst-color-background);
22 overflow: hidden auto;
23 font-size: var(--pst-sidebar-font-size-mobile);
24
25 @include media-breakpoint-up($breakpoint-sidebar-primary) {
26 font-size: var(--pst-sidebar-font-size);
27 }
28
29 :focus-visible {
30 border-radius: $focus-ring-radius;
31 }
32
33 // override bootstrap when navlink are displayed in the sidebar
34 .nav-link {
35 font-size: var(--pst-sidebar-font-size-mobile);
36 }
37
38 &.no-sidebar {
39 border-right: 0;
40 }
41
42 &.hide-on-wide {
43 @include media-breakpoint-up($breakpoint-sidebar-primary) {
44 display: none;
45 }
46 }
47
48 // Headers shouldn't be colored in the sidebars and some extensions add headers
49 h1,
50 h2,
51 h3,
52 h4 {
53 color: var(--pst-color-text-base);
54 }
55
56 .sidebar-primary-items__start,
57 .sidebar-primary-items__end {
58 .sidebar-primary-item {
59 padding: 0.5rem 0;
60 }
61 }
62
63 // Hide the sidebar header items on widescreen since they are visible in the header
64 .sidebar-header-items {
65 display: flex;
66 flex-direction: column;
67
68 .sidebar-header-items__title {
69 font-weight: var(--pst-sidebar-header-font-weight);
70 font-size: var(--pst-sidebar-header-font-size);
71 color: var(--pst-color-text-base);
72 margin-bottom: 0.5rem;
73 }
74
75 .bd-navbar-elements {
76 .nav-link {
77 &:focus-visible {
78 box-shadow: none; // Override Bootstrap
79 outline: $focus-ring-outline;
80 outline-offset: $focus-ring-width;
81 }
82 }
83 }
84
85 // Center header items get displayed vertically, end items are displayed horizontally
86 .sidebar-header-items__center {
87 display: flex;
88 flex-direction: column;
89 }
90
91 // Positioning end items
92 .sidebar-header-items__end {
93 display: flex;
94 align-items: center;
95 gap: 1rem;
96 }
97
98 @include media-breakpoint-up($breakpoint-sidebar-primary) {
99 display: none;
100 }
101 }
102
103 .sidebar-primary-items__start {
104 // Add a border on mobile to separate it from the header sidebar area
105 border-top: 1px solid var(--pst-color-border);
106
107 @include media-breakpoint-up($breakpoint-sidebar-primary) {
108 border-top: none;
109 }
110 }
111
112 .sidebar-primary-items__end {
113 margin-top: auto;
114 margin-bottom: 1em;
115 }
116
117 .list-caption {
118 list-style: none;
119 padding-left: 0;
120
121 // Level 0 TOC heading is put inside the <summary> tag
122 // so let the <summary> tag take up more space
123 li.toctree-l0.has-children {
124 > details {
125 > summary {
126 position: relative;
127 height: auto;
128 width: auto;
129 display: flex;
130 justify-content: space-between;
131 align-items: baseline;
132
133 .toctree-toggle {
134 // Prevent toggle icon from getting squished by summary being a
135 // flexbox
136 flex: 0 0 auto;
137
138 // Make the level 0 chevron icon slightly bigger than descendant
139 // levels
140 .fa-chevron-down {
141 font-size: 1rem;
142 }
143 }
144 }
145 }
146 }
147 }
148
149 li.has-children {
150 $toctree-toggle-width: 30px;
151
152 position: relative;
153
154 > .reference,
155 .caption {
156 margin-right: calc(
157 $toctree-toggle-width + $focus-ring-width
158 ); // keep clear of the toggle icon
159
160 padding-top: 0.25rem; // align caption text with toggle chevron
161 }
162
163 > details {
164 > summary {
165 // Remove browser default toggle icon
166 list-style: none;
167
168 &::-webkit-details-marker {
169 display: none;
170 }
171
172 // The summary element is natively focusable, but delegate the focus state to the toggle icon
173 &:focus-visible {
174 outline: none;
175
176 > .toctree-toggle {
177 outline: $focus-ring-outline;
178 outline-offset: -$focus-ring-width; // Prevent right side of focus ring from disappearing underneath the sidebar's right edge
179 }
180 }
181
182 // Container for expand/collapse chevron icon
183 .toctree-toggle {
184 cursor: pointer;
185
186 // Position it so that it's aligned with the top right corner of the
187 // last positioned element, in this case the li.has-children
188 position: absolute;
189 top: 0;
190 right: 0;
191
192 // Give it dimensions
193 width: $toctree-toggle-width;
194 height: $toctree-toggle-width; // make it square
195
196 // Vertically and horizontally center the icon within the container
197 display: inline-flex;
198 justify-content: center;
199 align-items: center;
200
201 .fa-chevron-down {
202 font-size: 0.75rem;
203 }
204 }
205 }
206
207 // The section is open/expanded, rotate the toggle icon (chevron) so it
208 // points up instead of down
209 &[open] {
210 > summary {
211 .fa-chevron-down {
212 transform: rotate(180deg);
213 }
214 }
215 }
216 }
217 }
218 }
219
220 /* Between-page links and captions */
221 nav.bd-links {
222 margin-right: -$sidebar-padding-right; // align toctree toggle chevrons with right edge of sidebar and allow text to flow closer to the right edge
223
224 @include media-breakpoint-up($breakpoint-sidebar-primary) {
225 display: block;
226 }
227
228 ul {
229 display: block;
230 list-style: none;
231
232 // Reduce padding of nested `ul` items a bit
233 ul {
234 padding: 0 0 0 1rem;
235 }
236 }
237
238 li > a {
239 display: block;
240 padding: $toc-item-padding-y 0.65rem;
241
242 @include link-sidebar;
243
244 box-shadow: none;
245 margin-right: $focus-ring-width; // prevent the right side focus ring from disappearing under the sidebar right edge
246
247 &.reference.external {
248 &::after {
249 font: var(--fa-font-solid);
250 content: var(--pst-icon-external-link);
251 font-size: 0.75em;
252 margin-left: 0.3em;
253 }
254 }
255 }
256
257 .current > a {
258 @include link-sidebar-current;
259
260 background-color: transparent;
261 }
262
263 // Title
264 p.bd-links__title {
265 font-size: var(--pst-sidebar-header-font-size);
266 font-weight: var(--pst-sidebar-header-font-weight);
267 margin-bottom: 0.5rem;
268 }
269
270 // Toctree captions
271 p.caption {
272 font-weight: var(--pst-sidebar-header-font-weight);
273 position: relative;
274 margin-top: 1.25rem;
275 margin-bottom: 0.5rem;
276 color: var(--pst-color-text-base);
277
278 &:first-child {
279 margin-top: 0;
280 }
281
282 font-size: var(--pst-sidebar-font-size-mobile);
283
284 @include media-breakpoint-up($breakpoint-sidebar-primary) {
285 font-size: var(--pst-sidebar-font-size);
286 }
287 }
288 }