Skip to content

Commit 6aa3210

Browse files
authored
feat(hub-ui): add a setting to expand the group sidebar (#480)
1 parent 72a4814 commit 6aa3210

15 files changed

Lines changed: 120 additions & 13 deletions

File tree

‎packages/hub-ui/src/client/components/dock/DockGroupSidebar.stories.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,42 @@ export const Overflow: Story = {
7373
),
7474
}),
7575
}
76+
77+
/**
78+
* `expandGroupSidebar` on: a wider rail that shows each member's title next
79+
* to its icon, so tools are findable without hovering for tooltips.
80+
*/
81+
export const Expanded: Story = {
82+
render: () => ({
83+
setup: () => mountWithContext(
84+
{
85+
entries: groupedEntries,
86+
selectedId: 'nuxt:overview',
87+
settings: { expandGroupSidebar: true },
88+
},
89+
ctx => stage(shell(h(DockGroupSidebar, {
90+
context: ctx,
91+
group: nuxtGroup,
92+
selectedId: ctx.docks.selectedId,
93+
}))),
94+
),
95+
}),
96+
}
97+
98+
/** Expanded with overflow: the show-more row keeps its label and count. */
99+
export const ExpandedOverflow: Story = {
100+
render: () => ({
101+
setup: () => mountWithContext(
102+
{
103+
entries: subcategorizedGroupEntries,
104+
selectedId: 'tools:graph',
105+
settings: { expandGroupSidebar: true },
106+
},
107+
ctx => stage(shell(h(DockGroupSidebar, {
108+
context: ctx,
109+
group: toolsGroup,
110+
selectedId: ctx.docks.selectedId,
111+
}), 'h-44')),
112+
),
113+
}),
114+
}

‎packages/hub-ui/src/client/components/dock/DockGroupSidebar.vue‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const RESERVED_HEIGHT = 53
3232
3333
const settings = useSettings(props.context)
3434
35+
// Expanded: a wider rail with each member's title next to its icon. Row
36+
// heights stay the same, so the capacity math below holds in both modes.
37+
const expanded = computed(() => settings.value.expandGroupSidebar)
38+
3539
// Members split by in-group sub-category so the sidebar can divide sections.
3640
const memberGroups = computed(() => getGroupMembersGrouped(
3741
props.context.docks.entries,
@@ -179,42 +183,54 @@ const moreButtonActive = computed(() => selectedInOverflow.value || isOverflowPa
179183
so the anchor + selected members' text-primary/bg-active render accent. -->
180184
<div
181185
ref="sidebar"
182-
class="devframes-group-sidebar flex flex-col flex-none w-12 h-full border-r border-base of-y-hidden of-x-hidden select-none py1.5 items-center gap-0.5"
183-
:class="group.accentColor ? 'devframes-accent-scope' : ''"
186+
class="devframes-group-sidebar flex flex-col flex-none h-full border-r border-base of-y-hidden of-x-hidden select-none py1.5 gap-0.5"
187+
:class="[
188+
expanded ? 'w-44 px1.5 items-stretch' : 'w-12 items-center',
189+
group.accentColor ? 'devframes-accent-scope' : '',
190+
]"
184191
:style="accentVarStyle(group.accentColor)"
185192
>
186193
<!-- Group anchor -->
187194
<div
188-
class="flex items-center justify-center w-8 h-8 op60"
189-
:class="group.accentColor ? 'color-active' : ''"
195+
class="flex items-center h-8 op60"
196+
:class="[
197+
expanded ? 'gap-2 px1.5' : 'justify-center w-8',
198+
group.accentColor ? 'color-active' : '',
199+
]"
190200
@pointerenter="showTooltip($event, group)"
191201
@pointerleave="hideTooltip"
192202
>
193203
<DockIcon :icon="group.icon" class="w-5 h-5 flex-none" />
204+
<span v-if="expanded" class="text-sm font-medium truncate">{{ group.title }}</span>
194205
</div>
195-
<div class="w-8 h-px border-t border-base my0.5" />
206+
<div class="h-px border-t border-base my0.5" :class="expanded ? 'w-full' : 'w-8'" />
196207

197208
<!-- Member icons, grouped by in-group sub-category -->
198209
<template v-for="([category, members], idx) of visibleGroups" :key="category">
199210
<!-- Sub-category divider, mirroring the group anchor separator -->
200-
<div v-if="idx > 0 && members.length" class="w-8 h-px border-t border-base my0.5" />
211+
<div v-if="idx > 0 && members.length" class="h-px border-t border-base my0.5" :class="expanded ? 'w-full' : 'w-8'" />
201212
<button
202213
v-for="member of members"
203214
:key="member.id"
204215
:aria-label="member.title"
205216
:aria-current="currentId === member.id ? 'page' : undefined"
206-
class="relative flex items-center justify-center w-8 h-8 rounded-lg transition"
207-
:class="selectedId === member.id ? 'text-primary bg-active' : 'op60 hover:op100 hover:bg-active'"
217+
class="relative flex items-center h-8 rounded-lg transition"
218+
:class="[
219+
expanded ? 'gap-2 px1.5' : 'justify-center w-8',
220+
selectedId === member.id ? 'text-primary bg-active' : 'op60 hover:op100 hover:bg-active',
221+
]"
208222
@pointerenter="showTooltip($event, member)"
209223
@pointerleave="hideTooltip"
210224
@pointerdown="hideTooltip"
211225
@click="select(member.id)"
212226
@contextmenu="openContextMenu($event, member)"
213227
>
214228
<DockIcon :icon="member.icon" class="w-5 h-5 flex-none" />
229+
<span v-if="expanded" class="flex-1 min-w-0 text-left text-sm truncate">{{ member.title }}</span>
215230
<div
216231
v-if="member.badge"
217-
class="absolute top-0.5 right-0.5 bg-gray-6 text-white text-0.6em px-0.5 rounded-full shadow leading-none"
232+
class="bg-gray-6 text-white text-0.6em px-0.5 rounded-full shadow leading-none"
233+
:class="expanded ? 'flex-none' : 'absolute top-0.5 right-0.5'"
218234
>
219235
{{ member.badge }}
220236
</div>
@@ -227,15 +243,22 @@ const moreButtonActive = computed(() => selectedInOverflow.value || isOverflowPa
227243
ref="moreButton"
228244
:aria-label="t('dock.showMore')"
229245
:aria-current="currentInOverflow ? 'true' : undefined"
230-
class="relative flex items-center justify-center w-8 h-8 rounded-lg transition mt-auto flex-none"
231-
:class="moreButtonActive ? 'text-primary bg-active' : 'op60 hover:op100 hover:bg-active'"
246+
class="relative flex items-center h-8 rounded-lg transition mt-auto flex-none"
247+
:class="[
248+
expanded ? 'gap-2 px1.5' : 'justify-center w-8',
249+
moreButtonActive ? 'text-primary bg-active' : 'op60 hover:op100 hover:bg-active',
250+
]"
232251
@pointerenter="showTooltip($event, t('dock.showMore'))"
233252
@pointerleave="hideTooltip"
234253
@pointerdown="hideTooltip"
235254
@click="toggleOverflowPanel"
236255
>
237256
<DockIcon icon="ph:dots-three-circle-duotone" class="w-5 h-5 flex-none" />
238-
<div class="absolute top-0.5 right-0.5 bg-gray-6 text-white text-0.6em px-0.5 rounded-full shadow leading-none">
257+
<span v-if="expanded" class="flex-1 min-w-0 text-left text-sm truncate">{{ t('dock.showMore') }}</span>
258+
<div
259+
class="bg-gray-6 text-white text-0.6em px-0.5 rounded-full shadow leading-none"
260+
:class="expanded ? 'flex-none' : 'absolute top-0.5 right-0.5'"
261+
>
239262
{{ overflowBadge }}
240263
</div>
241264
</button>

‎packages/hub-ui/src/client/components/views-builtin/SettingsAppearance.vue‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,5 +234,23 @@ function setDockMode(mode: string) {
234234
<span class="text-xs op50">{{ t('appearance.autoCollapseHint') }}</span>
235235
</div>
236236
</label>
237+
238+
<!-- Expand group sidebar toggle -->
239+
<label class="flex items-center gap-3 cursor-pointer group">
240+
<button
241+
class="w-10 h-6 rounded-full transition-colors relative shrink-0"
242+
:class="settings.expandGroupSidebar ? 'bg-primary' : 'bg-gray/30'"
243+
@click="settingsStore.mutate((s) => { s.expandGroupSidebar = !settings.expandGroupSidebar })"
244+
>
245+
<div
246+
class="absolute top-1 w-4 h-4 rounded-full bg-white shadow transition-transform"
247+
:class="settings.expandGroupSidebar ? 'translate-x-5' : 'translate-x-1'"
248+
/>
249+
</button>
250+
<div class="flex flex-col">
251+
<span class="text-sm">{{ t('appearance.expandSidebar') }}</span>
252+
<span class="text-xs op50">{{ t('appearance.expandSidebarHint') }}</span>
253+
</div>
254+
</label>
237255
</div>
238256
</template>

‎packages/hub-ui/src/client/i18n/locales/de.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "Zuletzt verwendete Tools in der Dock-Leiste",
7373
"appearance.recentDocksHint": "Zuletzt aus einer Gruppe oder dem Überlaufmenü geöffnete Tools in der Dock-Leiste behalten (nur im Float-Modus).",
7474
"appearance.recentDocksOff": "Aus",
75+
"appearance.expandSidebar": "Gruppen-Seitenleiste erweitern",
76+
"appearance.expandSidebarHint": "Zeigt in der Gruppen-Seitenleiste die Namen der Tools neben ihren Symbolen.",
7577

7678
"docks.intro": "Sichtbarkeit und Reihenfolge der Dock-Einträge verwalten. Ausgeblendete Einträge erscheinen nicht in der Dock-Leiste.",
7779
"docks.resetOrder": "Eigene Reihenfolge zurücksetzen",

‎packages/hub-ui/src/client/i18n/locales/en.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "Recent tools on the dock bar",
7373
"appearance.recentDocksHint": "Keep the tools you last opened from a group or the overflow menu on the dock bar (float mode only).",
7474
"appearance.recentDocksOff": "Off",
75+
"appearance.expandSidebar": "Expand group sidebar",
76+
"appearance.expandSidebarHint": "Show tool names next to their icons in the group sidebar.",
7577

7678
"docks.intro": "Manage visibility and order of dock entries. Hidden entries will not appear in the dock bar.",
7779
"docks.resetOrder": "Reset custom order",

‎packages/hub-ui/src/client/i18n/locales/es.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "Herramientas recientes en la barra",
7373
"appearance.recentDocksHint": "Mantén en la barra las herramientas que abriste por última vez desde un grupo o el menú de desbordamiento (solo en modo flotante).",
7474
"appearance.recentDocksOff": "Desactivado",
75+
"appearance.expandSidebar": "Expandir la barra lateral del grupo",
76+
"appearance.expandSidebarHint": "Muestra el nombre de cada herramienta junto a su icono en la barra lateral del grupo.",
7577

7678
"docks.intro": "Gestiona la visibilidad y el orden de los paneles. Los paneles ocultos no aparecerán en la barra.",
7779
"docks.resetOrder": "Restablecer orden personalizado",

‎packages/hub-ui/src/client/i18n/locales/fr.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "Outils récents dans la barre",
7373
"appearance.recentDocksHint": "Garder dans la barre les derniers outils ouverts depuis un groupe ou le menu de débordement (mode flottant uniquement).",
7474
"appearance.recentDocksOff": "Désactivé",
75+
"appearance.expandSidebar": "Développer la barre latérale du groupe",
76+
"appearance.expandSidebarHint": "Affiche le nom des outils à côté de leur icône dans la barre latérale du groupe.",
7577

7678
"docks.intro": "Gérez la visibilité et l'ordre des panneaux. Les panneaux masqués n'apparaissent pas dans la barre.",
7779
"docks.resetOrder": "Réinitialiser l'ordre personnalisé",

‎packages/hub-ui/src/client/i18n/locales/ja.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "ドックバーの最近使ったツール",
7373
"appearance.recentDocksHint": "グループやオーバーフローメニューから最後に開いたツールをドックバーに表示します(フロートモードのみ)。",
7474
"appearance.recentDocksOff": "オフ",
75+
"appearance.expandSidebar": "グループサイドバーを展開",
76+
"appearance.expandSidebarHint": "グループサイドバーでアイコンの横にツール名を表示します。",
7577

7678
"docks.intro": "ドック項目の表示と順序を管理します。非表示の項目はドックバーに表示されません。",
7779
"docks.resetOrder": "カスタム順序をリセット",

‎packages/hub-ui/src/client/i18n/locales/ko.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "도크 바의 최근 도구",
7373
"appearance.recentDocksHint": "그룹이나 오버플로 메뉴에서 마지막으로 연 도구를 도크 바에 유지합니다 (플로트 모드 전용).",
7474
"appearance.recentDocksOff": "끄기",
75+
"appearance.expandSidebar": "그룹 사이드바 펼치기",
76+
"appearance.expandSidebarHint": "그룹 사이드바에서 아이콘 옆에 도구 이름을 표시합니다.",
7577

7678
"docks.intro": "도크 항목의 표시 여부와 순서를 관리합니다. 숨긴 항목은 도크 바에 나타나지 않습니다.",
7779
"docks.resetOrder": "사용자 지정 순서 초기화",

‎packages/hub-ui/src/client/i18n/locales/pt-BR.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
"appearance.recentDocks": "Ferramentas recentes na barra",
7373
"appearance.recentDocksHint": "Manter na barra as ferramentas abertas por último a partir de um grupo ou do menu de excedentes (somente no modo flutuante).",
7474
"appearance.recentDocksOff": "Desativado",
75+
"appearance.expandSidebar": "Expandir a barra lateral do grupo",
76+
"appearance.expandSidebarHint": "Mostra o nome de cada ferramenta ao lado do ícone na barra lateral do grupo.",
7577

7678
"docks.intro": "Gerencie a visibilidade e a ordem dos painéis. Painéis ocultos não aparecem na barra.",
7779
"docks.resetOrder": "Redefinir ordem personalizada",

0 commit comments

Comments
 (0)