Skip to content

Commit b12fac2

Browse files
committed
feat(header): new UX with merged tabs
1 parent 8ea36db commit b12fac2

File tree

2 files changed

+57
-136
lines changed

2 files changed

+57
-136
lines changed

packages/app-frontend/src/features/header/AppHeader.vue

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import AppHeaderLogo from './AppHeaderLogo.vue'
44
import AppHistoryNav from './AppHistoryNav.vue'
55
import AppSelect from '../apps/AppSelect.vue'
66
import AppHeaderSelect from './AppHeaderSelect.vue'
7-
import AppMainMenu from './AppMainMenu.vue'
87
98
import { computed, ref, watch, defineComponent } from 'vue'
109
import type { RawLocation, Route } from 'vue-router'
@@ -16,7 +15,7 @@ import { useTabs } from './tabs'
1615
import { showAppsSelector } from './header'
1716
import { useOrientation } from '../layout/orientation'
1817
19-
interface InspectorRoute {
18+
interface HeaderRoute {
2019
icon: string
2120
label: string
2221
targetRoute: RawLocation
@@ -30,7 +29,6 @@ export default defineComponent({
3029
AppHistoryNav,
3130
AppSelect,
3231
AppHeaderSelect,
33-
AppMainMenu,
3432
PluginSourceIcon,
3533
},
3634
@@ -41,27 +39,33 @@ export default defineComponent({
4139
4240
const { inspectors: customInspectors } = useInspectors()
4341
44-
const inspectorRoutes = computed(() => ([
42+
const headerRoutes = computed(() => ([
4543
{
4644
icon: 'device_hub',
4745
label: 'Components',
4846
targetRoute: { name: 'inspector-components' },
4947
matchRoute: route => route.matched.some(m => m.name === 'inspector-components'),
5048
},
51-
] as InspectorRoute[]).concat(customInspectors.value.map(i => ({
49+
{
50+
icon: 'line_style',
51+
label: 'Timeline',
52+
targetRoute: { name: 'timeline' },
53+
matchRoute: route => route.matched.some(m => m.name === 'timeline'),
54+
},
55+
] as HeaderRoute[]).concat(customInspectors.value.map(i => ({
5256
icon: i.icon || 'tab',
5357
label: i.label,
5458
pluginId: i.pluginId,
5559
targetRoute: { name: 'custom-inspector', params: { inspectorId: i.id } },
5660
matchRoute: route => route.params.inspectorId === i.id,
5761
}))))
5862
59-
const currentInspectorRoute = computed(() => inspectorRoutes.value.find(r => r.matchRoute(route.value)))
63+
const currentHeaderRoute = computed(() => headerRoutes.value.find(r => r.matchRoute(route.value)))
6064
61-
const lastInspectorRoute = ref(null)
62-
watch(currentInspectorRoute, value => {
65+
const lastHeaderRoute = ref(null)
66+
watch(currentHeaderRoute, value => {
6367
if (value) {
64-
lastInspectorRoute.value = value
68+
lastHeaderRoute.value = value
6569
}
6670
})
6771
@@ -80,9 +84,9 @@ export default defineComponent({
8084
const { orientation } = useOrientation()
8185
8286
return {
83-
inspectorRoutes,
84-
currentInspectorRoute,
85-
lastInspectorRoute,
87+
headerRoutes,
88+
currentHeaderRoute,
89+
lastHeaderRoute,
8690
showAppsSelector,
8791
orientation,
8892
}
@@ -102,58 +106,49 @@ export default defineComponent({
102106
<img src="~@front/assets/breadcrumb-separator.svg">
103107
</template>
104108

105-
<AppMainMenu
106-
:last-inspector-route="lastInspectorRoute"
107-
:label-shown="!showAppsSelector && inspectorRoutes.length * 200 < $responsive.width - 420"
108-
/>
109-
110-
<template v-if="currentInspectorRoute">
111-
<img src="~@front/assets/breadcrumb-separator.svg">
109+
<template v-if="orientation === 'portrait' || headerRoutes.length * 200 > $responsive.width - 250">
110+
<AppHeaderSelect
111+
:items="headerRoutes"
112+
:selected-item="currentHeaderRoute"
113+
@select="route => $router.push(route.targetRoute)"
114+
>
115+
<template #default="{ item }">
116+
<div class="flex items-center space-x-2">
117+
<span class="flex-1">{{ item.label }}</span>
118+
<PluginSourceIcon
119+
v-if="item.pluginId"
120+
:plugin-id="item.pluginId"
121+
class="flex-none"
122+
/>
123+
</div>
124+
</template>
125+
</AppHeaderSelect>
126+
</template>
112127

113-
<template v-if="orientation === 'portrait' || inspectorRoutes.length * 200 > $responsive.width - 420">
114-
<AppHeaderSelect
115-
:items="inspectorRoutes"
116-
:selected-item="currentInspectorRoute"
117-
@select="route => $router.push(route.targetRoute)"
118-
>
119-
<template #default="{ item }">
120-
<div class="flex items-center space-x-2">
121-
<span class="flex-1">{{ item.label }}</span>
122-
<PluginSourceIcon
123-
v-if="item.pluginId"
124-
:plugin-id="item.pluginId"
125-
class="flex-none"
126-
/>
127-
</div>
128-
</template>
129-
</AppHeaderSelect>
130-
</template>
131-
132-
<template v-else>
133-
<VueGroup
134-
:value="currentInspectorRoute"
135-
class="primary"
136-
indicator
137-
@update="route => $router.push(route.targetRoute)"
128+
<template v-else>
129+
<VueGroup
130+
:value="currentHeaderRoute"
131+
class="primary"
132+
indicator
133+
@update="route => $router.push(route.targetRoute)"
134+
>
135+
<VueGroupButton
136+
v-for="(item, index) of headerRoutes"
137+
:key="index"
138+
:value="item"
139+
:icon-left="item.icon"
140+
class="flat"
138141
>
139-
<VueGroupButton
140-
v-for="(item, index) of inspectorRoutes"
141-
:key="index"
142-
:value="item"
143-
:icon-left="item.icon"
144-
class="flat"
145-
>
146-
<div class="flex items-center space-x-2">
147-
<span class="flex-1">{{ item.label }}</span>
148-
<PluginSourceIcon
149-
v-if="item.pluginId"
150-
:plugin-id="item.pluginId"
151-
class="flex-none"
152-
/>
153-
</div>
154-
</VueGroupButton>
155-
</VueGroup>
156-
</template>
142+
<div class="flex items-center space-x-2">
143+
<span class="flex-1">{{ item.label }}</span>
144+
<PluginSourceIcon
145+
v-if="item.pluginId"
146+
:plugin-id="item.pluginId"
147+
class="flex-none"
148+
/>
149+
</div>
150+
</VueGroupButton>
151+
</VueGroup>
157152
</template>
158153

159154
<div class="flex-1" />

packages/app-frontend/src/features/header/AppMainMenu.vue

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)