first commit
This commit is contained in:
54
resources/js/@core/components/ThemeSwitcher.vue
Normal file
54
resources/js/@core/components/ThemeSwitcher.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<script setup>
|
||||
import { useConfigStore } from '@core/stores/config'
|
||||
|
||||
const props = defineProps({
|
||||
themes: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const configStore = useConfigStore()
|
||||
const selectedItem = ref([configStore.theme])
|
||||
|
||||
// Update icon if theme is changed from other sources
|
||||
watch(() => configStore.theme, () => {
|
||||
selectedItem.value = [configStore.theme]
|
||||
}, { deep: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<IconBtn>
|
||||
<VIcon :icon="props.themes.find(t => t.name === configStore.theme)?.icon" />
|
||||
|
||||
<VTooltip
|
||||
activator="parent"
|
||||
open-delay="1000"
|
||||
scroll-strategy="close"
|
||||
>
|
||||
<span class="text-capitalize">{{ configStore.theme }}</span>
|
||||
</VTooltip>
|
||||
<VMenu
|
||||
activator="parent"
|
||||
offset="15px"
|
||||
width="160"
|
||||
>
|
||||
<VList
|
||||
v-model:selected="selectedItem"
|
||||
mandatory
|
||||
>
|
||||
<VListItem
|
||||
v-for="{ name, icon } in props.themes"
|
||||
:key="name"
|
||||
:value="name"
|
||||
:prepend-icon="icon"
|
||||
color="primary"
|
||||
class="text-capitalize"
|
||||
@click="() => { configStore.theme = name }"
|
||||
>
|
||||
{{ name }}
|
||||
</VListItem>
|
||||
</VList>
|
||||
</VMenu>
|
||||
</IconBtn>
|
||||
</template>
|
Reference in New Issue
Block a user