Skip to content

Commit

Permalink
feat: refactor components, close #227
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 11, 2023
1 parent 97f5b1a commit 0caa4de
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 40 deletions.
Expand Up @@ -95,7 +95,6 @@ const selectedTab = ref(tabs[0])
{{ item.name }}
</NTextExternalLink>
</div>
<!-- TODO: use icons instead, show link to documentation -->
<div w-full p2 op75>
{{ item.description }}
</div>
Expand Down
26 changes: 18 additions & 8 deletions packages/devtools/client/components/SideNav.vue
Expand Up @@ -4,12 +4,21 @@ const categories = useCategorizedTabs()
const show = ref(false)
const panel = ref()
const button = ref<HTMLButtonElement>()
onClickOutside(panel, () => {
show.value = false
}, {
detectIframe: true,
})
function toggle() {
show.value = !show.value
}
onClickOutside(
panel,
(e) => {
if (e.target === button.value)
return
show.value = false
},
{ detectIframe: true },
)
</script>

<template>
Expand All @@ -20,13 +29,14 @@ onClickOutside(panel, () => {
:distance="20"
:triggers="[]"
:shown="show"
:auto-hide="false"
:auto-hide="true"
>
<button
i-logos-nuxt-icon my3 h-6 w-6 pb-2 text-lg
ref="button"
i-logos-nuxt-icon my3 h-6 w-6 pb-2 text-lg outline-none
:class="client ? '' : 'saturate-0'"
:title="client ? 'Nuxt DevTools' : 'DevTools Client not connected, try open it in iframe mode'"
@click="show = !show"
@click="toggle"
/>
<template #popper>
<DockingPanel ref="panel" />
Expand Down
12 changes: 5 additions & 7 deletions packages/devtools/client/pages/modules/assets.vue
Expand Up @@ -57,15 +57,13 @@ function refreshAssets() {}
<div h-full of-auto>
<Navbar ref="navbar" v-model:search="search" pb2>
<template #actions>
<!-- TODO: Use NIconButton -->
<div flex-none flex="~ gap4">
<button
<div flex-none flex="~ gap2 items-center">
<NIconButton
text-lg
:icon="view === 'grid' ? 'i-carbon-list' : 'i-carbon-grid'"
title="Toggle view"
@click="toggleView"
>
<NIcon v-if="view === 'grid'" icon="i-carbon-list" />
<NIcon v-else icon="i-carbon-grid" />
</button>
/>
</div>
</template>
<div op50>
Expand Down
20 changes: 9 additions & 11 deletions packages/devtools/client/pages/modules/components.vue
Expand Up @@ -35,22 +35,20 @@ function toggleView() {
:is="view === 'list' ? ComponentsList : ComponentsGraph"
:components="components"
>
<div flex-none flex="~ gap4">
<!-- TODO: Use NIconButton -->
<button
<div flex-none flex="~ gap3">
<NIconButton
text-lg
:icon="view === 'graph' ? 'i-carbon-list' : 'i-carbon-network-4'"
title="Toggle view"
@click="toggleView"
>
<NIcon v-if="view === 'graph'" icon="i-carbon-list" />
<NIcon v-else icon="i-carbon-network-4" />
</button>
<button
/>
<NIconButton
v-if="client?.inspector?.instance"
text-lg
icon="i-carbon-select-window"
title="Inspect Vue components"
@click="openComponentInspector"
>
<NIcon icon="i-carbon-select-window" />
</button>
/>
</div>
</component>
</div>
Expand Down
28 changes: 15 additions & 13 deletions packages/devtools/client/pages/modules/open-graph.vue
Expand Up @@ -102,26 +102,28 @@ until(router).toBeTruthy().then((v) => {
/>
</template>
<template #actions>
<div flex-none flex="~ gap4">
<button
<div flex-none flex="~ gap2 items-center">
<NIconButton
v-if="routeMatchedFilePath"
text-lg
icon="carbon:launch"
title="Open file in editor"
@click="openInEditor(routeMatchedFilePath)"
>
<NIcon icon="carbon:launch" />
</button>
<button
/>

<NIconButton
text-lg
icon="carbon:reset"
title="Refresh Data"
@click="refresh"
>
<NIcon icon="carbon:reset" />
</button>
<button
/>

<NIconButton
text-lg
:icon="showPreview ? 'carbon:side-panel-open' : 'carbon:open-panel-right'"
title="Toggle Preview"
@click="showPreview = !showPreview"
>
<NIcon :icon="showPreview ? 'carbon:side-panel-open' : 'carbon:open-panel-right'" />
</button>
/>
</div>
</template>
</Navbar>
Expand Down

0 comments on commit 0caa4de

Please sign in to comment.