Skip to content

Commit 25584b9

Browse files
arashsheydaantfu
andauthored
feat: add Eye Dropper command (#530)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent d1ef3d0 commit 25584b9

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

packages/devtools/client/app.vue

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'floating-vue/dist/style.css'
33
import 'vanilla-jsoneditor/themes/jse-theme-dark.css'
44
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
55
import './styles/global.css'
6+
import { useEyeDropper } from '@vueuse/core'
67
import { setupClientRPC } from './setup/client-rpc'
78
import { splitScreenAvailable } from '~/composables/storage'
89
@@ -72,19 +73,33 @@ onMounted(async () => {
7273
}
7374
})
7475
75-
registerCommands(() =>
76-
splitScreenAvailable.value
77-
? [
78-
{
79-
id: 'action:split-screen',
80-
title: `${splitScreenEnabled.value ? 'Close' : 'Open'} Split Screen`,
81-
icon: 'i-carbon-split-screen',
82-
action: () => {
83-
splitScreenEnabled.value = !splitScreenEnabled.value
84-
},
76+
const copy = useCopy()
77+
const eyeDropper = useEyeDropper({})
78+
79+
registerCommands(() => [
80+
...(splitScreenAvailable.value
81+
? [{
82+
id: 'action:split-screen',
83+
title: `${splitScreenEnabled.value ? 'Close' : 'Open'} Split Screen`,
84+
icon: 'i-carbon-split-screen',
85+
action: () => {
86+
splitScreenEnabled.value = !splitScreenEnabled.value
87+
},
88+
}]
89+
: []),
90+
...(eyeDropper.isSupported.value
91+
? [{
92+
id: 'action:eye-dropper',
93+
title: 'Eye Dropper',
94+
icon: 'i-carbon-eyedropper',
95+
action: async () => {
96+
const { sRGBHex } = await eyeDropper.open() || {}
97+
if (sRGBHex)
98+
copy(sRGBHex)
8599
},
86-
]
87-
: [])
100+
}]
101+
: []),
102+
])
88103
</script>
89104

90105
<template>

0 commit comments

Comments
 (0)