1+ <template >
2+ <div class =" min-w-40" >
3+ <div class =" cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black
4+ hover:bg-html dark:text-darkSidebarTextHover dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextActive
5+ w-full select-none "
6+ :class =" { 'bg-black bg-opacity-10 ': showDropdown }"
7+ @click =" showDropdown = !showDropdown"
8+ >
9+ <span >Settings</span >
10+ <IconCaretDownSolid class =" h-5 w-5 text-lightPrimary dark:text-gray-400 opacity-50 transition duration-150 ease-in"
11+ :class =" { 'transform rotate-180': showDropdown }"
12+ />
13+ </div >
14+
15+ <div v-if =" showDropdown" >
16+
17+ <div class =" cursor-pointer flex items-center gap-1 block px-4 py-1 text-sm
18+ text-black dark:text-darkSidebarTextHover
19+ bg-black bg-opacity-10
20+ hover:brightness-110
21+ hover:text-lightPrimary dark:hover:text-darkPrimary
22+ hover:bg-lightPrimaryContrast dark:hover:bg-darkPrimaryContrast
23+ w-full text-select-none pl-5 select-none"
24+ v-for =" option in options"
25+ @click =" navigateTo(option)"
26+ >
27+ <span class =" mr-1" >
28+ <component v-if =" option.icon" :is =" getIcon(option.icon)" class =" w-5 h-5 transition duration-75" ></component >
29+ </span >
30+ <span class =" text-gray-900 dark:text-white" >{{ option.pageLabel }}</span >
31+ </div >
32+ </div >
33+
34+
35+ </div >
36+ </template >
37+
38+ <script setup lang="ts">
39+ import ' flag-icon-css/css/flag-icons.min.css' ;
40+ import { IconCaretDownSolid } from ' @iconify-prerendered/vue-flowbite' ;
41+ import { computed , ref , onMounted , watch } from ' vue' ;
42+ import { useCoreStore } from ' @/stores/core' ;
43+ import { getIcon } from ' @/utils' ;
44+ import { useRouter } from ' vue-router' ;
45+
46+ const router = useRouter ();
47+ const coreStore = useCoreStore ();
48+
49+ const showDropdown = ref (false );
50+ const props = defineProps ([' meta' , ' resource' ]);
51+
52+ const options = computed (() => {
53+ console .log (' Returning setting pages' , coreStore .config ?.settingPages );
54+ return coreStore .config ?.settingPages ?.map ((page ) => {
55+ return {
56+ pageLabel: page .pageLabel ,
57+ slug: page .slug || null ,
58+ icon: page .icon || null ,
59+ };
60+ });
61+ });
62+
63+ function slugifyString(str : string ): string {
64+ return str
65+ .toString ()
66+ .toLowerCase ()
67+ .replace (/ \s + / g , ' -' )
68+ .replace (/ [^ a-z0-9 -_] / g , ' -' );
69+ }
70+
71+ function navigateTo(option : { slug? : string | null | undefined , pageLabel: string }) {
72+ console .log (' Navigating to option' , option );
73+ if (option .slug ) {
74+ console .log (' Navigating to settings page' , option .slug );
75+ router .push ({ name: ' settings' , query: { page: option .slug } });
76+ } else {
77+ const destinationSlug = slugifyString (option .pageLabel );
78+ console .log (' Navigating to settings page by label' , destinationSlug );
79+ router .push ({ name: ' settings' , params: { page: destinationSlug } });
80+ }
81+ }
82+
83+ </script >
0 commit comments