Skip to content

Commit 60a722b

Browse files
committed
feat:add splitpane functionality to hide sidebar
1 parent 8d9fa5c commit 60a722b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,23 @@ defineOgImageComponent('Default', {
310310
description: () => pkg.value?.license ?? '',
311311
primaryColor: '#60a5fa',
312312
})
313+
314+
// Sidebar visibility
315+
const { settings } = useSettings()
316+
const isSidebarCollapsed = computed({
317+
get: () => settings.value.sidebar.collapsed.includes('code'),
318+
set: value => {
319+
const collapsed = settings.value.sidebar.collapsed.filter(id => id !== 'code')
320+
if (value) {
321+
collapsed.push('code')
322+
}
323+
settings.value.sidebar.collapsed = collapsed
324+
},
325+
})
326+
327+
function toggleSidebar() {
328+
isSidebarCollapsed.value = !isSidebarCollapsed.value
329+
}
313330
</script>
314331

315332
<template>
@@ -349,6 +366,7 @@ defineOgImageComponent('Default', {
349366
<div v-else-if="fileTree" class="flex flex-1" dir="ltr">
350367
<!-- File tree sidebar - sticky with internal scroll -->
351368
<aside
369+
v-show="!isSidebarCollapsed"
352370
class="w-64 lg:w-72 border-ie border-border shrink-0 hidden md:block bg-bg-subtle sticky top-25 self-start h-[calc(100vh-7rem)] overflow-y-auto"
353371
>
354372
<CodeFileTree
@@ -365,6 +383,20 @@ defineOgImageComponent('Default', {
365383
class="sticky z-5 top-25 bg-bg border-b border-border px-4 py-2 flex items-center justify-between gap-2 text-nowrap overflow-x-auto max-w-full"
366384
>
367385
<div class="flex items-center gap-2">
386+
<!-- Sidebar toggle button -->
387+
<button
388+
type="button"
389+
class="hidden md:flex items-center justify-center w-8 h-8 text-fg-subtle hover:text-fg transition-colors focus-visible:outline-accent/70 rounded"
390+
:aria-label="$t(isSidebarCollapsed ? 'code.show_sidebar' : 'code.hide_sidebar')"
391+
@click="toggleSidebar"
392+
>
393+
<span
394+
class="w-4 h-4"
395+
:class="isSidebarCollapsed ? 'i-lucide:sidebar-open' : 'i-lucide:sidebar-close'"
396+
aria-hidden="true"
397+
/>
398+
</button>
399+
368400
<div
369401
v-if="fileContent?.markdownHtml"
370402
class="flex items-center gap-1 p-0.5 bg-bg-subtle border border-border-subtle rounded-md overflow-x-auto"

i18n/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,9 @@
851851
},
852852
"file_path": "File path",
853853
"binary_file": "Binary file",
854-
"binary_rendering_warning": "File type \"{contentType}\" is not supported for preview."
854+
"binary_rendering_warning": "File type \"{contentType}\" is not supported for preview.",
855+
"show_sidebar": "Show sidebar",
856+
"hide_sidebar": "Hide sidebar"
855857
},
856858
"badges": {
857859
"provenance": {

0 commit comments

Comments
 (0)