Skip to content

Commit bd4e78f

Browse files
committed
Sidebar: Fixed all bugs + improved UX
1 parent 68bd3a9 commit bd4e78f

File tree

3 files changed

+56
-15
lines changed

3 files changed

+56
-15
lines changed

assets/css/v2/style.css

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
--sidebar-line-box-left: 12px;
9292
--sidebar-width: 22rem;
9393
--sidebar-line-width: 11.5px;
94+
--sidebar-mobile-top-displacement: 3rem;
9495
--side-gutter-width: 20rem;
9596
--table-top-bottom-spacing: 1rem;
9697
--table-row-space-between: 1.5rem;
@@ -527,39 +528,68 @@ nav {
527528
}
528529

529530
body:has(#sidebar-v2[style*="block"]) {
531+
/* Disable scrolling in main content + hide footer if the sidebar is visible */
530532
overflow-y: hidden;
533+
534+
.sidebar-layout {
535+
position: absolute;
536+
height: 100%;
537+
}
538+
539+
footer {
540+
display: none;
541+
}
542+
543+
.sidebar-layout .sidebar-mobile-toggle {
544+
display: flex !important;
545+
align-items: center;
546+
position: sticky;
547+
top: 1rem;
548+
margin-top: 2rem;
549+
padding: 0.5rem;
550+
color: white;
551+
background-color: oklch(var(--color-brand));
552+
}
553+
}
554+
555+
.breadcrumb .sidebar-mobile-toggle {
556+
display: inline !important;
557+
}
558+
559+
.sidebar-mobile-toggle {
560+
background-color: transparent;
561+
border: none;
562+
563+
.lucide {
564+
width: 1rem;
565+
height: 1rem;
566+
margin-right: 1rem;
567+
}
531568
}
532569

533570
.main-layout {
571+
/* Mobile support for sidebar */
534572
display: flex;
535573
flex-direction: column;
536574
position: relative;
537575

538576
.sidebar-layout {
539577
min-height: fit-content;
540-
position: sticky;
541-
top: 0;
542-
padding: 1rem;
543-
background-color: white;
578+
background: white;
579+
z-index: 3;
544580
width: calc(100% + 4rem);
545581
margin-left: -2rem;
546-
overflow-y: scroll;
547582

548583
&::before {
549584
display: none;
550585
}
551586

552-
.sidebar-mobile-toggle {
553-
background-color: oklch(var(--color-brand));
554-
color: white;
555-
border: none;
556-
display: block !important;
557-
}
558-
559587
nav {
560588
width: 100%;
561-
height: 100vh;
562589
display: none;
590+
padding: 0;
591+
top: var(--sidebar-mobile-top-displacement);
592+
max-height: calc(100vh - var(--sidebar-mobile-top-displacement));
563593

564594
.sidebar__container {
565595
width: 100%;
@@ -981,6 +1011,16 @@ p {
9811011
line-height: 1.5rem;
9821012
}
9831013

1014+
.breadcrumb-layout {
1015+
position: sticky;
1016+
top: 0;
1017+
z-index: 3;
1018+
background-color: white;
1019+
width: calc(100% + 4rem);
1020+
margin-left: -2rem;
1021+
padding: 1rem 2rem;
1022+
}
1023+
9841024
.breadcrumb {
9851025
color: var(--color-foreground);
9861026
text-decoration: none;

layouts/_default/docs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969

7070
<section class="main-layout">
7171
<div class="sidebar-layout" id="sidebar-layout">
72-
<button class="sidebar-mobile-toggle" aria-expanded="false" style="display: none;"><p>Click</p></button>
73-
<nav data-mf="true" id="sidebar-v2" class="sidebar" style="display:none;">
72+
<button class="sidebar-mobile-toggle" style="display: none;" aria-expanded="false">{{ partial "lucide" (dict "context" . "icon" "x")}}Close</button>
73+
<nav data-mf="true" id="sidebar-v2" class="sidebar">
7474
{{ partial "sidebar-v2.html" . }}
7575
</nav>
7676
</div>

layouts/partials/breadcrumb.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<nav aria-label="breadcrumb" class="breadcrumb navbar">
22
<div class="nav flex-md-row">
33
<ol class="breadcrumb">
4+
<button class="sidebar-mobile-toggle" aria-expanded="false" style="display: none;">{{ partial "lucide" (dict "context" . "icon" "align-justify") }}</button>
45
<li><a href="/" alt="NGINX Docs Home">Home</a></li>
56
{{- define "breadcrumb" -}}
67
{{- with .Parent -}}

0 commit comments

Comments
 (0)