From 096518727b7bf6b1a49db68897fec822d8dbae09 Mon Sep 17 00:00:00 2001 From: alexzhang1030 <1642114555@qq.com> Date: Tue, 12 Dec 2023 22:42:46 +0800 Subject: [PATCH 1/8] feat: scrollable sidebar --- .vscode/settings.json | 2 +- packages/client/src/assets/styles/main.css | 29 ++++++++-- .../client/src/components/common/SideNav.vue | 53 ++++++++++++++++--- packages/client/src/composables/state-tab.ts | 34 ++++++++++++ packages/client/src/composables/state.ts | 2 + packages/client/src/pages/settings.vue | 8 +++ 6 files changed, 118 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e4ef8a10..81bd766e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "eslint.experimental.useFlatConfig": true, "prettier.enable": false, "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" }, "editor.formatOnSave": false, // Silent the stylistic rules in you IDE, but still auto fix them diff --git a/packages/client/src/assets/styles/main.css b/packages/client/src/assets/styles/main.css index 427bc954..f975578a 100644 --- a/packages/client/src/assets/styles/main.css +++ b/packages/client/src/assets/styles/main.css @@ -114,9 +114,32 @@ body::-webkit-scrollbar { background: #8885; } -.no-scrollbar { - /* Support Firefox */ - scrollbar-width: none +/* Scrollbar */ +::-webkit-scrollbar { + width: 6px; +} + +::-webkit-scrollbar:horizontal { + height: 6px; +} + +::-webkit-scrollbar-corner { + background: transparent; +} + +::-webkit-scrollbar-track { + background: var(--c-border); + border-radius: 1px; +} + +::-webkit-scrollbar-thumb { + background: #8881; + transition: background 0.2s ease; + border-radius: 1px; +} + +::-webkit-scrollbar-thumb:hover { + background: #8885; } .no-scrollbar::-webkit-scrollbar { diff --git a/packages/client/src/components/common/SideNav.vue b/packages/client/src/components/common/SideNav.vue index 7c45bef9..ef80a4fb 100644 --- a/packages/client/src/components/common/SideNav.vue +++ b/packages/client/src/components/common/SideNav.vue @@ -5,17 +5,32 @@ const showDocking = ref(false) const showMoreTabs = ref(false) const panel = ref() const buttonDocking = ref() -const buttonMoreTabs = ref() +const Tabs = ref() const sidebarExpanded = computed(() => devtoolsClientState.value.expandSidebar) -const sidebarScrollable = ref(false) +const sidebarScrollable = computed(() => devtoolsClientState.value.scrollableSidebar) -const { enabledTabs } = useAllTabs() +const { enabledTabs, flattenedTabs } = useAllTabs() + +const ITEM_HEIGHT = 45 +const { height: windowHeight } = useWindowSize() +const containerCapacity = computed(() => { + const containerHeight = windowHeight.value - 130 + return Math.max(0, Math.floor(containerHeight / ITEM_HEIGHT)) +}) +const inlineTabs = computed(() => flattenedTabs.value.slice(0, containerCapacity.value)) +const overflowTabs = computed(() => flattenedTabs.value.slice(containerCapacity.value)) +const categorizedInlineTabs = getCategorizedTabs(inlineTabs, enabledTabs) +const categorizedOverflowTabs = getCategorizedTabs(overflowTabs, enabledTabs) + +const displayedTabs = computed(() => (sidebarScrollable.value || sidebarExpanded.value) + ? enabledTabs.value + : categorizedInlineTabs.value)