Files
ComfyUI_frontend/src/components/sidebar/SidebarThemeToggleIcon.vue
Chenlei Hu a4e08f60fe Extract theme toggle as command (#1161)
* Extract theme toggle as command

* nit
2024-10-07 21:54:58 -04:00

27 lines
710 B
Vue

<template>
<SidebarIcon
:icon="icon"
@click="toggleTheme"
:tooltip="$t('sideToolbar.themeToggle')"
class="comfy-vue-theme-toggle"
/>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import SidebarIcon from './SidebarIcon.vue'
import { useSettingStore } from '@/stores/settingStore'
import { useCommandStore } from '@/stores/commandStore'
const settingStore = useSettingStore()
const currentTheme = computed(() => settingStore.get('Comfy.ColorPalette'))
const icon = computed(() =>
currentTheme.value !== 'light' ? 'pi pi-moon' : 'pi pi-sun'
)
const commandStore = useCommandStore()
const toggleTheme = () => {
commandStore.execute('Comfy.ToggleTheme')
}
</script>