Skip to content

Commit e782e1d

Browse files
committed
chore: update
1 parent 4ea44d6 commit e782e1d

3 files changed

Lines changed: 22 additions & 32 deletions

File tree

plugins/data-inspector/src/spa/App.vue

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { Query, SavedQueryScope } from '../engine'
33
import Button from '@antfu/design/components/Action/ActionButton.vue'
4-
import ActionDarkToggle from '@antfu/design/components/Action/ActionDarkToggle.vue'
4+
import ActionIconButton from '@antfu/design/components/Action/ActionIconButton.vue'
55
import DisplayBadge from '@antfu/design/components/Display/DisplayBadge.vue'
66
import LayoutSplitPane from '@antfu/design/components/Layout/LayoutSplitPane.vue'
77
import { Pane } from 'splitpanes'
@@ -14,7 +14,7 @@ import ResultViewer from './components/ResultViewer.vue'
1414
import SavedQueriesPanel from './components/SavedQueriesPanel.vue'
1515
import { backend, connect, connection } from './composables/rpc'
1616
import { useSavedQueries } from './composables/saved'
17-
import { colorScheme } from './composables/scheme'
17+
import { isDark } from './composables/scheme'
1818
import { useWorkbench } from './composables/workbench'
1919
import '@antfu/design/styles.css'
2020
@@ -96,18 +96,17 @@ function queryAppend(path: string): void {
9696
:color="connection.connected ? 100 : 200"
9797
/>
9898
<div class="flex-auto" />
99-
<a
99+
<ActionIconButton
100+
icon="i-ph:book-open-duotone"
101+
as="a"
100102
href="https://devfra.me/plugins/data-inspector"
101103
target="_blank"
102104
title="Data Inspector docs — using the plugin and providing data sources"
103-
class="flex items-center gap-1 text-xs color-muted hover:color-active"
104-
>
105-
<span class="i-ph:book-open-duotone text-base" />
106-
<span>Docs</span>
107-
</a>
108-
<ActionDarkToggle
109-
:color-scheme="colorScheme"
110-
@update:color-scheme="colorScheme = $event"
105+
/>
106+
<ActionIconButton
107+
icon="i-ph:sun-duotone dark:i-ph:moon-duotone"
108+
title="Toggle dark mode"
109+
@click="isDark = !isDark"
111110
/>
112111
</div>
113112

@@ -121,13 +120,13 @@ function queryAppend(path: string): void {
121120
{{ wb.activeSource.value?.description }}
122121
</div>
123122
<div class="flex-auto" />
124-
<Button
125-
size="sm"
126-
:icon="showDataSourceDetails ? 'i-ph:eye-slash-duotone' : 'i-ph:eye-duotone'"
123+
<ActionIconButton
124+
icon="i-ph:caret-down"
125+
class="transition flex-none text-sm"
126+
:class="{ 'rotate-180': showDataSourceDetails }"
127+
:title="showDataSourceDetails ? 'Hide details' : 'Show details'"
127128
@click="showDataSourceDetails = !showDataSourceDetails"
128-
>
129-
<span>{{ showDataSourceDetails ? 'Hide' : 'Show' }} details</span>
130-
</Button>
129+
/>
131130
</div>
132131

133132
<div v-if="connection.connected && !wb.sources.value.length" class="text-xs color-muted">

plugins/data-inspector/src/spa/components/DataSourceSelect.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function iconOf(source: DataSourceMeta | undefined): string {
2626
class="text-sm px-2.5 outline-none border border-base rounded bg-base inline-flex gap-2 h-9 min-w-52 max-w-80 transition items-center justify-between data-[disabled]:op50 focus-visible:ring-2 focus-visible:ring-primary-500/40"
2727
>
2828
<span class="inline-flex items-center gap-2 min-w-0">
29+
<!-- TODO: migrate to IconifyIcon.vue in @antfu/design 0.3 -->
2930
<span class="shrink-0 color-active" :class="iconOf(active)" aria-hidden="true" />
3031
<span class="truncate font-semibold text-primary">{{ active?.title ?? placeholder ?? 'Data source' }}</span>
3132
</span>
@@ -46,6 +47,7 @@ function iconOf(source: DataSourceMeta | undefined): string {
4647
:value="source.id"
4748
class="text-sm color-base py-1.5 pl-2 pr-2 outline-none rounded-md flex gap-2 cursor-pointer select-none transition items-start relative data-[highlighted]:bg-active"
4849
>
50+
<!-- TODO: migrate to IconifyIcon.vue in @antfu/design 0.3 -->
4951
<span class="shrink-0 mt-0.5 color-active" :class="iconOf(source)" aria-hidden="true" />
5052
<span class="flex flex-col min-w-0 flex-1">
5153
<span class="flex items-center gap-1.5">
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
/** Color scheme state: OS-initialized, user-togglable. */
2-
import { ref, watchEffect } from 'vue'
1+
import { useDark } from '@vueuse/core'
2+
import { computed } from 'vue'
33

44
export type ColorScheme = 'light' | 'dark'
5-
6-
const mq = window.matchMedia('(prefers-color-scheme: dark)')
7-
export const colorScheme = ref<ColorScheme>(mq.matches ? 'dark' : 'light')
8-
mq.addEventListener('change', (e) => {
9-
colorScheme.value = e.matches ? 'dark' : 'light'
10-
})
11-
12-
// The shared design tokens flip on the `.dark` class (same approach as the
13-
// other devframe plugins).
14-
watchEffect(() => {
15-
document.documentElement.classList.toggle('dark', colorScheme.value === 'dark')
16-
document.documentElement.classList.toggle('light', colorScheme.value === 'light')
17-
})
5+
export const isDark = useDark()
6+
export const colorScheme = computed<ColorScheme>(() => isDark.value ? 'dark' : 'light')

0 commit comments

Comments
 (0)