Skip to content

Commit ca9b223

Browse files
antfuclaude
andcommitted
feat: add tooltips to edge buttons and dock mode setting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c8e9031 commit ca9b223

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

packages/core/src/client/webcomponents/components/DockEdge.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { DocksContext } from '@vitejs/devtools-kit/client'
33
import type { CSSProperties } from 'vue'
44
import { computed, h, markRaw, useTemplateRef } from 'vue'
5-
import { setEdgePositionDropdown, useEdgePositionDropdown } from '../state/floating-tooltip'
5+
import { setEdgePositionDropdown, setFloatingTooltip, useEdgePositionDropdown } from '../state/floating-tooltip'
66
import { PersistedDomViewsManager } from '../utils/PersistedDomViewsManager'
77
import { openDockContextMenu } from './DockContextMenu'
88
import DockEntriesWithCategories from './DockEntriesWithCategories.vue'
@@ -47,8 +47,18 @@ function switchPosition(pos: 'top' | 'right' | 'bottom' | 'left') {
4747
}
4848
4949
const positionButton = useTemplateRef<HTMLButtonElement>('positionButton')
50+
const floatButton = useTemplateRef<HTMLButtonElement>('floatButton')
5051
const edgePositionDropdown = useEdgePositionDropdown()
5152
53+
function showTooltip(el: HTMLElement | null, text: string) {
54+
if (!el)
55+
return
56+
setFloatingTooltip({ content: text, el })
57+
}
58+
function hideTooltip() {
59+
setFloatingTooltip(null)
60+
}
61+
5262
function togglePositionDropdown() {
5363
if (!positionButton.value)
5464
return
@@ -204,14 +214,19 @@ const contentClass = computed(() => {
204214
<button
205215
ref="positionButton"
206216
class="p1.5 rounded hover:bg-active transition op75 hover:op100"
207-
title="Switch edge position"
217+
@pointerenter="showTooltip(positionButton, 'Edge position')"
218+
@pointerleave="hideTooltip"
219+
@pointerdown="hideTooltip"
208220
@click="togglePositionDropdown"
209221
>
210222
<div :class="positionIcons[store.position]" class="w-4.5 h-4.5" />
211223
</button>
212224
<button
225+
ref="floatButton"
213226
class="p1.5 rounded hover:bg-active transition op50 hover:op100"
214-
title="Switch to float mode"
227+
@pointerenter="showTooltip(floatButton, 'Float mode')"
228+
@pointerleave="hideTooltip"
229+
@pointerdown="hideTooltip"
215230
@click="switchToFloat"
216231
>
217232
<div class="i-ph-cards-three-duotone w-4.5 h-4.5" />

packages/core/src/client/webcomponents/components/ViewBuiltinSettings.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DEFAULT_STATE_USER_SETTINGS } from '@vitejs/devtools-kit/constants'
55
import { computed } from 'vue'
66
import { docksGroupByCategories } from '../state/dock-settings'
77
import { sharedStateToRef } from '../state/docks'
8+
import { isDockPopupSupported, requestDockPopupOpen } from '../state/popup'
89
import DockIcon from './DockIcon.vue'
910
1011
const props = defineProps<{
@@ -14,6 +15,30 @@ const props = defineProps<{
1415
1516
const settingsStore = props.context.docks.settings
1617
const settings = sharedStateToRef(settingsStore)
18+
const panelStore = props.context.panel.store
19+
const isEmbedded = props.context.clientType === 'embedded'
20+
21+
const dockModeOptions = computed(() => {
22+
const options = [
23+
{ value: 'float', label: 'Float', icon: 'i-ph-cards-three-duotone' },
24+
{ value: 'edge', label: 'Edge', icon: 'i-ph-square-half-bottom-duotone' },
25+
]
26+
if (isDockPopupSupported()) {
27+
options.push({ value: 'popup', label: 'Popup', icon: 'i-ph-arrow-square-out-duotone' })
28+
}
29+
return options
30+
})
31+
32+
const currentDockMode = computed(() => panelStore.mode)
33+
34+
function setDockMode(mode: string) {
35+
if (mode === 'popup') {
36+
requestDockPopupOpen(props.context)
37+
}
38+
else {
39+
panelStore.mode = mode as 'float' | 'edge'
40+
}
41+
}
1742
1843
const categories = computed(() => {
1944
return docksGroupByCategories(props.context.docks.entries, settingsStore.value(), { includeHidden: true })
@@ -146,7 +171,29 @@ function resetSettings() {
146171
Appearance
147172
</h2>
148173

149-
<div class="flex flex-col gap-3">
174+
<div class="flex flex-col gap-4">
175+
<!-- Dock mode -->
176+
<div v-if="isEmbedded" class="flex flex-col gap-2">
177+
<div class="flex flex-col">
178+
<span class="text-sm">Dock mode</span>
179+
<span class="text-xs op50">How the DevTools panel is displayed</span>
180+
</div>
181+
<div class="flex items-center gap-1 bg-gray/10 rounded-lg p1 w-fit">
182+
<button
183+
v-for="option of dockModeOptions"
184+
:key="option.value"
185+
class="flex items-center gap-1.5 px3 py1.5 rounded-md text-sm transition-all"
186+
:class="currentDockMode === option.value
187+
? 'bg-base shadow text-primary font-medium'
188+
: 'op60 hover:op100 hover:bg-gray/10'"
189+
@click="setDockMode(option.value)"
190+
>
191+
<div :class="option.icon" class="w-4 h-4" />
192+
{{ option.label }}
193+
</button>
194+
</div>
195+
</div>
196+
150197
<!-- Show iframe address bar toggle -->
151198
<label class="flex items-center gap-3 cursor-pointer group">
152199
<button

0 commit comments

Comments
 (0)