Skip to content

Commit 51a0f13

Browse files
Move the sidebar to be stuck to left of the content
1 parent 653bec9 commit 51a0f13

File tree

2 files changed

+79
-42
lines changed

2 files changed

+79
-42
lines changed

src/html_support_files/odoc.css

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -263,28 +263,52 @@ body {
263263
}
264264

265265
body {
266-
margin-left: calc(10vw + 20ex);
267-
margin-right: 4ex;
268-
margin-top: 30px;
269-
margin-bottom: 50px;
266+
margin-left: auto;
267+
margin-right: auto;
268+
padding: 0 4ex;
270269
}
271270

272271
body.odoc {
273-
max-width: 100ex;
272+
max-width: 132ex;
273+
display: grid;
274+
grid-template-columns: min-content 1fr;
275+
column-gap: 4ex;
276+
row-gap: 2ex;
274277
}
275278

276279
body.odoc-src {
277280
margin-right: calc(10vw + 20ex);
278281
}
279282

283+
.odoc-content {
284+
grid-row: 4;
285+
grid-column: 2;
286+
}
287+
288+
.odoc-preamble > *:first-child {
289+
/* This make the first thing in the preamble align with the sidebar */
290+
padding-top: 0;
291+
margin-top: 0;
292+
}
293+
280294
header {
281295
margin-bottom: 30px;
282296
}
283297

298+
header.odoc-preamble {
299+
grid-column: 2;
300+
grid-row: 3;
301+
}
302+
284303
nav {
285304
font-family: "Fira Sans", sans-serif;
286305
}
287306

307+
nav.odoc-nav {
308+
grid-column: 2;
309+
grid-row: 2;
310+
}
311+
288312
/* Basic markup elements */
289313

290314
b, strong {
@@ -480,7 +504,7 @@ h4 {
480504
font-size: 1.12em;
481505
}
482506

483-
/* Comment delimiters, hidden but accessible to screen readers and
507+
/* Comment delimiters, hidden but accessible to screen readers and
484508
selected for copy/pasting */
485509

486510
/* Taken from bootstrap */
@@ -759,19 +783,29 @@ td.def-doc *:first-child {
759783
line-height: 1.2;
760784
}
761785

786+
.odoc-search + * + .odoc-toc {
787+
--toc-top: calc(var(--search-bar-height) + var(--search-padding-top) + 20px);
788+
max-height: calc(100vh - 2 * var(--toc-top));
789+
top: var(--toc-top)
790+
}
791+
762792
.odoc-toc {
763-
position: fixed;
764-
top: 0px;
765-
bottom: 0px;
766-
left: 0px;
767-
max-width: 30ex;
768-
min-width: 26ex;
769-
width: 20%;
793+
--toc-top: 20px;
794+
width: 28ex;
770795
background: var(--toc-background);
771796
overflow: auto;
772797
color: var(--toc-color);
773798
padding-left: 2ex;
774799
padding-right: 2ex;
800+
grid-row-start: 3;
801+
grid-row-end: 5;
802+
grid-column: 1;
803+
height: fit-content;
804+
border: solid 1px var(--border);
805+
border-radius: 5px;
806+
position:sticky;
807+
max-height: calc(100vh - 2 * var(--toc-top));
808+
top: var(--toc-top)
775809
}
776810

777811
.odoc-toc ul li a {
@@ -789,26 +823,31 @@ td.def-doc *:first-child {
789823
}
790824

791825
:root {
792-
--search-bar-height: 20px;
826+
--search-bar-height: 25px;
827+
--search-padding-top: 1rem;
793828
}
794829

795830
.odoc-search {
796-
--padding-top: 1rem;
797831
position: sticky;
798832
top: 0;
799833
background: var(--main-background);
800-
height: calc(var(--search-bar-height) + var(--padding-top));
834+
/* This amounts to fit-content when the search is not active, but when you
835+
have the search results displayed, you do not want the height of the search
836+
container to change. */
837+
height: calc(var(--search-bar-height) + var(--search-padding-top));
801838
width: 100%;
802-
padding-top: var(--padding-top);
839+
padding-top: var(--search-padding-top);
803840
z-index: 1;
841+
grid-row: 1;
842+
grid-column-start: 1;
843+
grid-column-end: 3;
804844
}
805845

806846

807847
.odoc-search .search-inner {
808848
width: 100%;
809849
position: relative;
810850
left: 0;
811-
transition: left 0.3s, transform 0.3s, width 0.3s;
812851
display: grid;
813852
/* The second column is for the search snake, which has 0 width */
814853
grid-template-columns: 1fr 0fr;
@@ -818,20 +857,13 @@ td.def-doc *:first-child {
818857
background: transparent;
819858
}
820859

821-
.odoc-search:focus-within .search-inner {
822-
/* Search inner is bigger than its parent, but the overflow needs to be
823-
centered. */
824-
left: 50%;
825-
transform: translateX(-50%);
826-
width: 110%;
827-
}
828-
829860
.odoc-search .search-bar {
830861
position: relative;
831862
z-index: 2;
832863
font-size: 1em;
833864
transition: font-size 0.3s;
834865
box-shadow: 0px 0px 0.2rem 0.3em var(--main-background);
866+
height: var(--search-bar-height);
835867
}
836868

837869
.odoc-search:focus-within .search-bar {
@@ -934,7 +966,7 @@ td.def-doc *:first-child {
934966
.odoc-search .search-entry {
935967
color: var(--color);
936968
display: grid;
937-
/* Possible kinds are the following :
969+
/* Possible kinds are the following :
938970
"doc" "type" "mod" "exn" "class" "meth" "cons" "sig" "cons" "field" "val"
939971
and "ext".
940972
As the longest is 5 characters (and the font monospace), we give 5
@@ -1113,6 +1145,11 @@ td.def-doc *:first-child {
11131145
@media only screen and (max-width: 110ex) {
11141146
body {
11151147
margin: 2em;
1148+
padding: 0;
1149+
}
1150+
1151+
body.odoc {
1152+
display: block;
11161153
}
11171154

11181155
.odoc-toc {

0 commit comments

Comments
 (0)