@@ -302,17 +302,41 @@ body.odoc {
302
302
grid-template-columns : min-content 1fr min-content;
303
303
grid-template-areas :
304
304
"search-bar nav ."
305
- "toc-local preamble toc-global "
306
- "toc-local content toc-global " ;
305
+ "toc-global preamble toc-local "
306
+ "toc-global content toc-local " ;
307
307
column-gap : 4ex ;
308
308
grid-template-rows : auto auto 1fr ;
309
309
}
310
310
311
311
body .odoc : has (> .odoc-search : focus-within ) {
312
312
grid-template-areas :
313
- "search-bar search-bar nav"
314
- "toc-local preamble toc-global"
315
- "toc-local content toc-global" ;
313
+ "search-bar search-bar search-bar"
314
+ ". nav ."
315
+ "toc-global preamble toc-local"
316
+ "toc-global content toc-local" ;
317
+ }
318
+
319
+ body .odoc : not (: has (> .odoc-tocs .odoc-global-toc )) {
320
+ grid-template-areas :
321
+ "search-bar search-bar"
322
+ "nav ."
323
+ "preamble toc-local"
324
+ "content toc-local" ;
325
+ grid-template-columns : 1fr min-content;
326
+ }
327
+
328
+ /* When there is no global sidebar */
329
+ body .odoc : not (: has (> .odoc-tocs .odoc-global-toc )) nav .odoc-nav {
330
+ padding-top : 0 ;
331
+ }
332
+
333
+ /* When there is no global sidebbar and the searchbar is focused */
334
+ body .odoc : not (: has (> .odoc-tocs .odoc-global-toc )) nav .odoc-nav : has (+ .odoc-search : focus-within ) {
335
+ padding-top : var (--search-padding-top );
336
+ }
337
+
338
+ nav .odoc-nav : has (+ .odoc-search : focus-within ) {
339
+ padding-top : 0 ;
316
340
}
317
341
318
342
body .odoc-src {
@@ -842,7 +866,7 @@ td.def-doc *:first-child {
842
866
/* When a search bar is present, we need the sticky sidebar to be a bit lower,
843
867
so `top` is higher */
844
868
845
- .odoc-search + * + .odoc-tocs .odoc-toc {
869
+ body .odoc : has ( .odoc-search ) .odoc-toc {
846
870
--toc-top : calc (var (--search-bar-height ) + 2 * var (--search-padding-top ));
847
871
max-height : calc (100vh - 2 * var (--toc-top ));
848
872
top : var (--toc-top )
@@ -1228,42 +1252,33 @@ td.def-doc *:first-child {
1228
1252
body .odoc {
1229
1253
max-width : 132ex ;
1230
1254
grid-template-areas :
1231
- "search-bar nav"
1232
- "sidebar preamble"
1233
- "sidebar content" ;
1234
- }
1235
-
1236
- body .odoc : has (> .odoc-search : focus-within ) {
1237
- grid-template-areas :
1238
- "nav nav"
1239
- "search-bar search-bar"
1240
- "sidebar preamble"
1241
- "sidebar content" ;
1255
+ "search-bar nav"
1256
+ "sidebar preamble"
1257
+ "sidebar content" ;
1242
1258
}
1243
-
1244
- nav .odoc-nav : has (+ .odoc-search : focus-within ) {
1245
- padding-bottom : 0 ;
1246
- }
1247
-
1248
- .odoc-tocs {
1259
+ body .odoc .odoc-tocs {
1249
1260
display : flex;
1250
1261
grid-area : sidebar;
1251
1262
flex-direction : column;
1252
1263
gap : 20px ;
1253
1264
}
1254
- .odoc-toc {
1255
- position : unset;
1256
- max-height : unset;
1265
+ body .odoc .odoc-tocs .odoc-toc {
1266
+ position : unset;
1267
+ max-height : unset;
1268
+ }
1269
+ body .odoc : has (.odoc-search : focus-within ) {
1270
+ grid-template-areas :
1271
+ "search-bar search-bar"
1272
+ ". nav"
1273
+ "sidebar preamble"
1274
+ "sidebar content" ;
1257
1275
}
1258
1276
}
1259
1277
1260
1278
@media only screen and (max-width : 110ex ) {
1261
- body {
1279
+ body . odoc {
1262
1280
margin : 2em ;
1263
1281
padding : 0 ;
1264
- }
1265
-
1266
- body .odoc {
1267
1282
grid-template-areas :
1268
1283
"search-bar"
1269
1284
"nav"
@@ -1273,10 +1288,9 @@ td.def-doc *:first-child {
1273
1288
"toc-global" ;
1274
1289
grid-template-columns : 1fr ;
1275
1290
}
1276
-
1277
1291
body .odoc : has (> .odoc-search : focus-within ) {
1278
1292
/* This is the same as when there is no focus on the search bar, this is
1279
- just to prevent the full screen rule from changing anything. */
1293
+ just to prevent the default "wide layout" rule from changing anything. */
1280
1294
grid-template-areas :
1281
1295
"search-bar"
1282
1296
"nav"
@@ -1286,19 +1300,18 @@ td.def-doc *:first-child {
1286
1300
"toc-global" ;
1287
1301
grid-template-columns : 1fr ;
1288
1302
}
1289
-
1290
-
1291
- .odoc-search {
1303
+ body .odoc .odoc-search {
1292
1304
position : relative;
1293
- padding-bottom : 0 ;
1294
- height : calc (var (--search-bar-height ) + var (--search-padding-top ));
1305
+ height : calc (var (--search-bar-height ) + 2 * var (--search-padding-top ));
1295
1306
}
1296
-
1297
- . odoc-tocs {
1298
- display : contents ;
1307
+ body . odoc nav . odoc-nav {
1308
+ padding-top : 0 ;
1309
+ padding-bottom : var ( --search-padding-top ) ;
1299
1310
}
1300
-
1301
- .odoc-toc {
1311
+ body .odoc .odoc-tocs {
1312
+ display : contents;
1313
+ }
1314
+ body .odoc .odoc-tocs .odoc-toc {
1302
1315
position : static;
1303
1316
width : auto;
1304
1317
min-width : unset;
0 commit comments