Skip to content

Commit

Permalink
feat: add Eye Dropper command (#530)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
arashsheyda and antfu committed Dec 7, 2023
1 parent d1ef3d0 commit 25584b9
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions packages/devtools/client/app.vue
Expand Up @@ -3,6 +3,7 @@ import 'floating-vue/dist/style.css'
import 'vanilla-jsoneditor/themes/jse-theme-dark.css'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import './styles/global.css'
import { useEyeDropper } from '@vueuse/core'
import { setupClientRPC } from './setup/client-rpc'
import { splitScreenAvailable } from '~/composables/storage'
Expand Down Expand Up @@ -72,19 +73,33 @@ onMounted(async () => {
}
})
registerCommands(() =>
splitScreenAvailable.value
? [
{
id: 'action:split-screen',
title: `${splitScreenEnabled.value ? 'Close' : 'Open'} Split Screen`,
icon: 'i-carbon-split-screen',
action: () => {
splitScreenEnabled.value = !splitScreenEnabled.value
},
const copy = useCopy()
const eyeDropper = useEyeDropper({})
registerCommands(() => [
...(splitScreenAvailable.value
? [{
id: 'action:split-screen',
title: `${splitScreenEnabled.value ? 'Close' : 'Open'} Split Screen`,
icon: 'i-carbon-split-screen',
action: () => {
splitScreenEnabled.value = !splitScreenEnabled.value
},
}]
: []),
...(eyeDropper.isSupported.value
? [{
id: 'action:eye-dropper',
title: 'Eye Dropper',
icon: 'i-carbon-eyedropper',
action: async () => {
const { sRGBHex } = await eyeDropper.open() || {}
if (sRGBHex)
copy(sRGBHex)
},
]
: [])
}]
: []),
])
</script>

<template>
Expand Down

0 comments on commit 25584b9

Please sign in to comment.