Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 13b054e

Browse files
authored
feat: collapsible sidebar (#236)
1 parent 6e3e58f commit 13b054e

File tree

7 files changed

+92
-32
lines changed

7 files changed

+92
-32
lines changed

packages/client/App.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { initPinia } from './logic/pinia'
66
77
const route = useRoute()
88
const router = useRouter()
9-
const { scale } = useDevToolsSettings()
9+
const { scale, sidebarExpanded } = useDevToolsSettings()
1010
const { route: _route, isFirstVisit } = useFrameState()
1111
1212
useColorMode()
@@ -63,7 +63,10 @@ router.replace(_route.value)
6363
<template>
6464
<main fixed inset-0 h-screen w-screen>
6565
<Notification />
66-
<div grid="~ cols-[50px_1fr]" h-full h-screen of-hidden font-sans bg-base>
66+
<div
67+
:class="sidebarExpanded ? 'grid grid-cols-[250px_1fr]' : 'grid grid-cols-[50px_1fr]'"
68+
h-full h-screen of-hidden font-sans bg-base
69+
>
6770
<SideNav v-if="!route.path.startsWith('/__')" of-x-hidden of-y-auto />
6871
<RouterView />
6972
</div>

packages/client/components/DockingPanel.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script setup lang="ts">
22
import { isInPopup } from '~/logic/state'
3+
4+
const { sidebarExpanded } = useDevToolsSettings()
35
</script>
46

57
<template>
@@ -9,10 +11,14 @@ import { isInPopup } from '~/logic/state'
911
<FullscreenButton v-if="!isInPopup" />
1012
<VDDarkToggle v-slot="{ toggle, isDark }">
1113
<VDButton n="sm primary" @click="toggle">
12-
<div carbon-sun translate-y--1px dark:carbon-moon />
14+
<div carbon-sun dark:carbon-moon translate-y--1px />
1315
{{ isDark.value ? "Dark" : "Light" }}
1416
</VDButton>
1517
</VDDarkToggle>
18+
<VDButton n="sm primary" @click="sidebarExpanded = !sidebarExpanded">
19+
<VDIcon :icon="sidebarExpanded ? 'i-carbon-side-panel-close' : 'i-carbon-side-panel-open'" />
20+
{{ sidebarExpanded ? 'Minimize Sidebar' : 'Expand Sidebar' }}
21+
</VDButton>
1622
<RouterLink
1723
replace
1824
class="n-button-base active:n-button-active focus-visible:n-focus-base n-transition n-primary n-sm hover:n-button-hover n-disabled:n-disabled"

packages/client/components/SideNav.vue

+36-10
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,68 @@ import { getSortedTabs } from '~/store'
33
44
const groupedTabs = useGroupedTabs()
55
6+
const { sidebarExpanded } = useDevToolsSettings()
7+
68
const renderedGroupedTabs = computed(() => {
79
return groupedTabs.value.filter(([, { tabs, show }]) => tabs.length && show)
810
})
911
</script>
1012

1113
<template>
12-
<div border="r base" flex="~ col gap-0.5" z-100 h-full items-center bg-base class="no-scrollbar">
13-
<div flex="~ col" sticky top-0 z-1 mb1 items-center pt3 bg-base>
14+
<div border="r base" flex="~ col gap-0.5" z-100 h-full w-full items-center bg-base class="no-scrollbar">
15+
<div sticky top-0 z-1 w-full p1 bg-base border="b base">
1416
<VDropdown placement="left-start" :distance="20">
1517
<button
16-
i-logos-vue h-6 w-6 text-lg
18+
flex="~ items-center justify-center gap-2"
19+
hover="bg-active"
20+
relative h-10 select-none p2 text-secondary
21+
:class="[
22+
sidebarExpanded ? 'w-full rounded pl2.5' : '',
23+
]"
1724
title="Vue DevTools"
18-
/>
25+
>
26+
<div class="i-logos-vue h-6 w-6" />
27+
<template v-if="sidebarExpanded">
28+
<span text="lg white" font-600>
29+
Vue DevTools
30+
</span>
31+
<div flex-auto />
32+
<div i-carbon-overflow-menu-vertical />
33+
</template>
34+
</button>
1935
<template #popper>
2036
<DockingPanel />
2137
</template>
2238
</VDropdown>
2339

24-
<div mt-2 h-1px w-8 border="b base" />
40+
<div mt-2 h-1px w-full border="b base" />
2541
</div>
2642

27-
<div flex="~ auto col gap-0.5 items-center" of-auto class="no-scrollbar" py1>
43+
<div
44+
flex="~ auto col gap-0.5 items-center" w-full p1 class="no-scrollbar"
45+
:class="sidebarExpanded ? '' : 'of-x-hidden of-y-auto'"
46+
>
2847
<template v-for="[name, { tabs }], idx of renderedGroupedTabs" :key="name">
2948
<SideNavItem
3049
v-for="tab of getSortedTabs(tabs)"
3150
:key="tab.path"
3251
:tab="tab"
52+
:minimized="!sidebarExpanded"
3353
/>
34-
<div v-if="idx !== renderedGroupedTabs.length - 1" my1 h-1px w-8 border="b base" />
54+
<div v-if="idx !== renderedGroupedTabs.length - 1" my1 h-1px w-full border="b base" />
3555
</template>
3656
<div flex-auto />
3757
</div>
3858

39-
<div flex="~ none col items-center">
40-
<div h-1px w-8 border="b base" />
59+
<div flex="~ none col items-center" :class="{ 'w-full': sidebarExpanded }">
60+
<div h-1px w-full border="b base" />
4161
<RouterLink
4262
replace
4363
to="/settings"
44-
flex="~ items-center justify-center"
64+
:flex="`~ items-center ${!sidebarExpanded ? 'justify-center' : 'justify-start'}`"
65+
:w="!sidebarExpanded ? '10' : 'full'"
66+
:rounded="!sidebarExpanded ? 'xl' : ''"
67+
:p="!sidebarExpanded ? '1' : 'x3'"
4568
hover="bg-active"
4669
relative my1 block h-10 w-10 select-none rounded-xl p1 text-secondary
4770
exact-active-class="!text-primary bg-active"
@@ -50,6 +73,9 @@ const renderedGroupedTabs = computed(() => {
5073
text-xl
5174
icon="i-carbon-settings" title="Settings" :show-title="false"
5275
/>
76+
<span v-if="sidebarExpanded" ml-2 overflow-hidden text-ellipsis ws-nowrap>
77+
Settings
78+
</span>
5379
</RouterLink>
5480
</div>
5581
</div>

packages/client/components/SideNavItem.vue

+20-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import type { Tab } from '~/types'
33
import { useDevToolsClient } from '~/logic/client'
44
import { getMappedBuiltinTabs } from '~/store'
55
6-
defineProps<{
6+
withDefaults(defineProps<{
77
tab: Tab
8-
}>()
8+
minimized?: boolean
9+
}>(), {
10+
minimized: true,
11+
})
912
const client = useDevToolsClient()
1013
const router = useRouter()
1114
@@ -17,21 +20,30 @@ function handleClick(tab: Tab) {
1720
</script>
1821

1922
<template>
20-
<VTooltip placement="right">
23+
<VTooltip :disabled="!minimized" placement="right" :class="{ 'w-full': !minimized }">
2124
<Component
2225
:is="tab.path ? 'RouterLink' : 'button'"
2326
replace
2427
:to="`/${tab.path}`"
25-
flex="~"
28+
:flex="`~ items-center ${minimized ? 'justify-center' : 'justify-between'}`"
29+
:w="minimized ? '10' : 'full'"
30+
:rounded="minimized ? 'xl' : ''"
31+
:p="minimized ? '1' : 'x3'"
2632
hover="bg-active"
2733
h-10 w-10 select-none items-center justify-center rounded-xl p1 text-secondary
2834
exact-active-class="!text-primary bg-active"
2935
@click="() => handleClick(tab)"
3036
>
31-
<TabIcon
32-
text-xl
33-
:icon="tab.icon" :title="tab.title"
34-
/>
37+
<div>
38+
<TabIcon
39+
text-xl
40+
:icon="tab.icon"
41+
:title="tab.title"
42+
/>
43+
<span v-if="!minimized" ml-2 overflow-hidden text-ellipsis ws-nowrap>
44+
{{ tab.title }}
45+
</span>
46+
</div>
3547
</Component>
3648
<template #popper>
3749
<div>

packages/client/composables/settings.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ export interface DevToolsUISettings {
44
scale: number
55
hiddenTabs: string[]
66
hiddenTabGroups: string[]
7+
sidebarExpanded: boolean
78
}
89

910
const devToolsSettings = useLocalStorage<DevToolsUISettings>('__vue-devtools-settings__', {
1011
scale: 1,
1112
hiddenTabs: [],
1213
hiddenTabGroups: [],
14+
sidebarExpanded: true,
1315
}, { mergeDefaults: true })
1416

1517
const devToolsSettingsRefs = toRefs(devToolsSettings)

packages/client/pages/settings.vue

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
scale,
66
hiddenTabs,
77
hiddenTabGroups,
8+
sidebarExpanded,
89
} = useDevToolsSettings()
910
1011
const { closeOnOutsideClick, minimizePanelInactive } = useFrameState()
@@ -113,7 +114,7 @@ const showTabGroup = ref(false)
113114
<div>
114115
<VDDarkToggle v-slot="{ toggle, isDark }">
115116
<VDButton n="primary" @click="toggle">
116-
<div carbon-sun translate-y--1px dark:carbon-moon /> {{ isDark.value ? 'Dark' : 'Light' }}
117+
<div carbon-sun dark:carbon-moon translate-y--1px /> {{ isDark.value ? 'Dark' : 'Light' }}
117118
</VDButton>
118119
</VDDarkToggle>
119120
</div>
@@ -148,6 +149,15 @@ const showTabGroup = ref(false)
148149
@update:model-value="toggleClickOutside"
149150
/>
150151
</div>
152+
<div py3 flex="~ justify-between gap-1">
153+
<h3 mb1 text-lg>
154+
{{ sidebarExpanded ? 'Scrollable' : 'Expand' }} Sidebar
155+
</h3>
156+
<VDSwitch
157+
flex="~ row-reverse" py1 n-primary :model-value="sidebarExpanded"
158+
@update:model-value="sidebarExpanded = !sidebarExpanded"
159+
/>
160+
</div>
151161
</div>
152162
</div>
153163
</div>

packages/node/README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ English | <a href="./README.zh-CN.md">简体中文</a>
1212
<p align="center">
1313
<a href="https://www.npmjs.com/package/vite-plugin-vue-devtools" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/vite-plugin-vue-devtools" alt="NPM Version" /></a>
1414
<a href="https://www.npmjs.com/package/vite-plugin-vue-devtools" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/dt/vite-plugin-vue-devtools" alt="NPM Downloads" /></a>
15+
<a href="https://www.npmjs.com/package/vite-plugin-vue-devtools" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/node/v/vite-plugin-vue-devtools" alt="Node Compatibility" /></a>
1516
<a href="https://github.com/webfansplz/vite-plugin-vue-devtools/blob/main/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/webfansplz/vite-plugin-vue-devtools" alt="License" /></a>
1617
</p>
1718

@@ -121,31 +122,31 @@ export default defineConfig({
121122
interface AnalyzeOptions {
122123
/**
123124
* @default true
124-
*/
125+
*/
125126
rerenderTrace: boolean
126127
}
127128

128129
interface VitePluginVueDevToolsOptions {
129130
/**
130-
* append an import to the module id ending with `appendTo` instead of adding a script into body
131-
* useful for projects that do not use html file as an entry
132-
*
133-
* WARNING: only set this if you know exactly what it does.
134-
*/
131+
* append an import to the module id ending with `appendTo` instead of adding a script into body
132+
* useful for projects that do not use html file as an entry
133+
*
134+
* WARNING: only set this if you know exactly what it does.
135+
*/
135136
appendTo?: string | RegExp
136137
/**
137138
* Enable Vue DevTools to analyze the codebase by using Babel
138139
* @default
139140
* {
140141
* rerenderTrace: true, // enable rerenderTrace feature
141142
* }
142-
*/
143+
*/
143144
analyze?: Partial<AnalyzeOptions>
144145

145146
/**
146-
* Customize openInEditor host (e.g. http://localhost:3000)
147-
* @default false
148-
*/
147+
* Customize openInEditor host (e.g. http://localhost:3000)
148+
* @default false
149+
*/
149150
openInEditorHost?: string | false
150151
}
151152
```

0 commit comments

Comments
 (0)