Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 7af6903

Browse files
committed
2 parents 9537680 + 0051c3b commit 7af6903

File tree

1 file changed

+62
-50
lines changed

1 file changed

+62
-50
lines changed

apps/docs/.vitepress/theme/Layout.vue

+62-50
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<BNavbar variant="primary" sticky="top" toggleable="lg">
3-
<BNavbarToggle @click="toggler" />
3+
<BNavbarToggle v-b-toggle.sidebar-menu />
44
<BNavbarBrand :to="withBase('/')" class="p-0 me-0 me-lg-2">
55
<svg
66
xmlns="http://www.w3.org/2000/svg"
@@ -73,11 +73,15 @@
7373
</BDropdown>
7474
</ClientOnly>
7575
</BNav>
76+
<BNavbarToggle v-b-toggle.otp-menu class="otp-menu-toggle">
77+
On the page <ChevronRight aria-hidden />
78+
</BNavbarToggle>
7679
</BNavbar>
7780
<BContainer fluid class="container-lg mt-3 my-md-4 bd-layout">
7881
<aside class="bd-sidebar">
7982
<ClientOnly>
8083
<BOffcanvas
84+
id="sidebar-menu"
8185
v-model="sidebar"
8286
teleport-disabled="true"
8387
backdrop="false"
@@ -107,7 +111,21 @@
107111
</BRow>
108112
<BRow v-else>
109113
<div class="bd-content">
110-
<div class="bd-toc" />
114+
<aside class="otp-sidebar">
115+
<ClientOnly>
116+
<BOffcanvas
117+
id="otp-menu"
118+
v-model="onThisPage"
119+
teleport-disabled="true"
120+
backdrop="false"
121+
placement="end"
122+
title="On this page"
123+
class="h-100"
124+
>
125+
<div class="bd-toc" />
126+
</BOffcanvas>
127+
</ClientOnly>
128+
</aside>
111129
<Content class="doc-content" />
112130
</div>
113131
</BRow>
@@ -132,13 +150,15 @@ import {
132150
BOffcanvas,
133151
BRow,
134152
useColorMode,
153+
vBToggle,
135154
} from 'bootstrap-vue-next'
136155
import {computed, inject, ref, watch} from 'vue'
137156
import GithubIcon from '~icons/bi/github'
138157
import OpencollectiveIcon from '~icons/simple-icons/opencollective'
139158
import DiscordIcon from '~icons/bi/discord'
140159
import MoonStarsFill from '~icons/bi/moon-stars-fill'
141160
import SunFill from '~icons/bi/sun-fill'
161+
import ChevronRight from '~icons/bi/chevron-right'
142162
import CircleHalf from '~icons/bi/circle-half'
143163
import {useData, withBase, useRoute} from 'vitepress'
144164
import {appInfoKey} from './keys'
@@ -151,17 +171,16 @@ const route = useRoute()
151171
152172
const isLargeScreen = useMediaQuery('(min-width: 992px)')
153173
const sidebar = ref(isLargeScreen.value)
154-
155-
const toggler = () => {
156-
sidebar.value = !sidebar.value
157-
}
174+
const onThisPage = ref(isLargeScreen.value)
158175
159176
watch(isLargeScreen, (newValue) => {
160177
if (newValue === true) {
161178
sidebar.value = true
179+
onThisPage.value = true
162180
return
163181
}
164182
sidebar.value = false
183+
onThisPage.value = false
165184
})
166185
167186
watch(
@@ -354,6 +373,10 @@ const globalData = inject(appInfoKey, {
354373
.btn {
355374
color: var(--white);
356375
}
376+
.otp-menu-toggle {
377+
border: none;
378+
font-size: small;
379+
}
357380
}
358381
[class^='language-'] {
359382
position: relative;
@@ -455,7 +478,8 @@ const globalData = inject(appInfoKey, {
455478
grid-template-areas: 'sidebar main';
456479
grid-template-columns: 1fr 5fr;
457480
gap: 1.5rem;
458-
.bd-sidebar {
481+
.bd-sidebar,
482+
.otp-sidebar {
459483
grid-area: sidebar;
460484
position: -webkit-sticky;
461485
position: sticky;
@@ -488,60 +512,22 @@ const globalData = inject(appInfoKey, {
488512
grid-area: content;
489513
min-width: 1px;
490514
}
491-
.bd-toc {
492-
&::before {
493-
content: 'On this page';
494-
display: block;
495-
margin: 0 0 0.5rem 0.8rem;
496-
padding-bottom: 0.5rem;
497-
border-bottom: var(--bs-border-width) solid rgba(255, 255, 255, 0.2);
498-
}
515+
.otp-sidebar {
499516
margin-left: 1.25rem;
500517
grid-area: toc;
501-
position: -webkit-sticky;
502-
position: sticky;
503-
top: 5rem;
504-
right: 0;
505-
z-index: 2;
506-
height: calc(100vh - 7rem);
507-
overflow-y: auto;
508-
.table-of-contents {
509-
font-size: 0.875rem;
510-
ul {
511-
padding-left: 0;
512-
margin-bottom: 0;
513-
list-style: none;
514-
a {
515-
display: block;
516-
padding: 0.125rem 0 0.125rem 0.75rem;
517-
color: inherit;
518-
text-decoration: none;
519-
border-left: 0.125rem solid transparent;
520-
&.active {
521-
color: var(--bd-toc-color);
522-
border-left-color: var(--bd-toc-color);
523-
}
524-
&:hover {
525-
color: var(--bd-toc-color);
526-
border-left-color: var(--bd-toc-color);
527-
}
528-
}
529-
ul {
530-
padding-left: 1rem;
531-
}
532-
}
533-
}
534518
}
535519
}
536520
}
537521
}
538522
}
539523
// Sidebar width.
540-
.bd-sidebar {
524+
.bd-sidebar,
525+
.otp-sidebar {
541526
@media (min-width: 992px) {
542527
min-width: 12.5rem;
543528
}
544-
.offcanvas.offcanvas-start {
529+
.offcanvas.offcanvas-start,
530+
.offcanvas.offcanvas-end {
545531
@media (min-width: 992px) {
546532
width: 12.5rem !important;
547533
}
@@ -553,6 +539,32 @@ const globalData = inject(appInfoKey, {
553539
column-gap: 1.5rem;
554540
}
555541
}
542+
.table-of-contents {
543+
font-size: 0.875rem;
544+
ul {
545+
padding-left: 0;
546+
margin-bottom: 0;
547+
list-style: none;
548+
a {
549+
display: block;
550+
padding: 0.125rem 0 0.125rem 0.75rem;
551+
color: inherit;
552+
text-decoration: none;
553+
border-left: 0.125rem solid transparent;
554+
&.active {
555+
color: var(--bd-toc-color);
556+
border-left-color: var(--bd-toc-color);
557+
}
558+
&:hover {
559+
color: var(--bd-toc-color);
560+
border-left-color: var(--bd-toc-color);
561+
}
562+
}
563+
ul {
564+
padding-left: 1rem;
565+
}
566+
}
567+
}
556568
}
557569
}
558570
</style>

0 commit comments

Comments
 (0)