Commit bb0a5808b3
Unsigned
Layout: unified · split
docs/.vitepress/theme/Layout.vue +18 −12
| @@ -22,8 +22,7 @@ import { sidebar } from '../configs/constants' | |||
| 22 | import AnnouncementPill from './components/AnnouncementPill.vue' | 22 | import AnnouncementPill from './components/AnnouncementPill.vue' |
| 23 | import NotFoundComponent from './components/NotFound.vue' | 23 | import NotFoundComponent from './components/NotFound.vue' |
| 24 | import { | 24 | import { |
| 25 | NolebaseEnhancedReadabilitiesMenu, | 25 | NolebaseEnhancedReadabilitiesMenu |
| 26 | NolebaseEnhancedReadabilitiesScreenMenu | ||
| 27 | } from './components/settings' | 26 | } from './components/settings' |
| 28 | import SidebarCard from './components/SidebarCard.vue' | 27 | import SidebarCard from './components/SidebarCard.vue' |
| 29 | import { TakodachiStorageKey } from './constants' | 28 | import { TakodachiStorageKey } from './constants' |
| @@ -173,7 +172,20 @@ const reloadTakodachi = () => { | |||
| 173 | onMounted(() => { | 172 | onMounted(() => { |
| 174 | if (import.meta.env.SSR) return | 173 | if (import.meta.env.SSR) return |
| 175 | 174 | ||
| 176 | // Arrow key scrolling + Escape close for desktop sidebar | 175 | // Arrow key scrolling + Escape close for sidebars and content |
| 176 | let activeScrollTarget: HTMLElement | Window = window | ||
| 177 | |||
| 178 | useEventListener(document, 'pointerdown', (e: PointerEvent) => { | ||
| 179 | const el = e.target as HTMLElement | ||
| 180 | if (homeSidebarOpen.value && sidebarRef.value?.contains(el)) { | ||
| 181 | activeScrollTarget = sidebarRef.value | ||
| 182 | } else if (el.closest('.VPSidebar')) { | ||
| 183 | activeScrollTarget = el.closest('.VPSidebar') as HTMLElement | ||
| 184 | } else { | ||
| 185 | activeScrollTarget = window | ||
| 186 | } | ||
| 187 | }) | ||
| 188 | |||
| 177 | useEventListener(document, 'keydown', (e: KeyboardEvent) => { | 189 | useEventListener(document, 'keydown', (e: KeyboardEvent) => { |
| 178 | if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp' && e.key !== 'Escape') return | 190 | if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp' && e.key !== 'Escape') return |
| 179 | 191 | ||
| @@ -182,13 +194,8 @@ onMounted(() => { | |||
| 182 | return | 194 | return |
| 183 | } | 195 | } |
| 184 | 196 | ||
| 185 | const target = homeSidebarOpen.value | ||
| 186 | ? sidebarRef.value | ||
| 187 | : !isHome.value ? document.querySelector<HTMLElement>('.VPSidebar') : null | ||
| 188 | if (!target) return | ||
| 189 | |||
| 190 | e.preventDefault() | 197 | e.preventDefault() |
| 191 | target.scrollBy({ top: e.key === 'ArrowDown' ? 60 : -60, behavior: 'smooth' }) | 198 | activeScrollTarget.scrollBy({ top: e.key === 'ArrowDown' ? 60 : -60, behavior: 'smooth' }) |
| 192 | }) | 199 | }) |
| 193 | 200 | ||
| 194 | // Close home NavScreen on outside click | 201 | // Close home NavScreen on outside click |
| @@ -317,9 +324,8 @@ onUnmounted(() => { | |||
| 317 | <VPSidebarGroup :items="homeSidebarGroups" /> | 324 | <VPSidebarGroup :items="homeSidebarGroups" /> |
| 318 | </nav> | 325 | </nav> |
| 319 | </template> | 326 | </template> |
| 320 | <template #nav-screen-content-after> | 327 | <template #nav-screen-content-after /> |
| 321 | <NolebaseEnhancedReadabilitiesScreenMenu v-if="!isHome" /> | 328 | |
| 322 | </template> | ||
| 323 | <template #nav-bar-title-before> | 329 | <template #nav-bar-title-before> |
| 324 | <span | 330 | <span |
| 325 | v-if="isHome" | 331 | v-if="isHome" |
docs/.vitepress/theme/styles/style.scss +1 −1
| @@ -1277,7 +1277,7 @@ table tr:nth-child(odd) { | |||
| 1277 | bottom: 0; | 1277 | bottom: 0; |
| 1278 | left: 0; | 1278 | left: 0; |
| 1279 | z-index: calc(var(--vp-z-index-backdrop, 100) + 1); | 1279 | z-index: calc(var(--vp-z-index-backdrop, 100) + 1); |
| 1280 | padding: 0 32px 96px; | 1280 | padding: 0 32px 32px; |
| 1281 | width: var(--vp-sidebar-width); | 1281 | width: var(--vp-sidebar-width); |
| 1282 | max-width: calc(100vw - 64px); | 1282 | max-width: calc(100vw - 64px); |
| 1283 | background-color: var(--vp-sidebar-bg-color); | 1283 | background-color: var(--vp-sidebar-bg-color); |