adminforth 1.3.56-next.5 → 1.3.56-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,8 +30,8 @@
30
30
 
31
31
 
32
32
  <span
33
- @click="toggleTheme" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-lightHtml dark:text-darkSidebarTextHover dark:hover:bg-darkHtml dark:hover:text-darkSidebarTextActive" role="menuitem">
34
- <IconMoonSolid class="w-5 h-5 text-blue-300" v-if="theme !== 'dark'" />
33
+ @click="toggleTheme" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-lightHtml dark:text-darkSidebarTextHover dark:hover:bg-darkHtml dark:hover:text-darkSidebarTextActive" role="menuitem">
34
+ <IconMoonSolid class="w-5 h-5 text-blue-300" v-if="coreStore.theme !== 'dark'" />
35
35
  <IconSunSolid class="w-5 h-5 text-yellow-300" v-else />
36
36
  </span>
37
37
  <div>
@@ -294,9 +294,7 @@ const theme = ref('light');
294
294
 
295
295
  function toggleTheme() {
296
296
  theme.value = theme.value === 'light' ? 'dark' : 'light';
297
- document.documentElement.classList.toggle('dark');
298
- window.localStorage.setItem('af__theme', theme.value);
299
-
297
+ coreStore.toggleTheme();
300
298
  }
301
299
 
302
300
  function clickOnMenuItem (label: string) {
@@ -7,7 +7,7 @@ import { useFiltersStore } from '@/stores/filters';
7
7
  import router from '@/router'
8
8
  import type { AdminForthResourceColumn } from '@/types/AdminForthConfig';
9
9
 
10
- type FilterParams = {
10
+ type FilterParams = {
11
11
  /**
12
12
  * Field of resource to filter
13
13
  */
@@ -6,6 +6,8 @@ import type { Ref } from 'vue'
6
6
 
7
7
  export const useCoreStore = defineStore('core', () => {
8
8
  const resourceById: Ref<Object> = ref({});
9
+ const theme: Ref<'light'| 'dark'> = ref(window.localStorage.getItem('af__theme') as ('light'|'dark') || 'light');
10
+
9
11
  const menu = ref([]);
10
12
  const config = ref({});
11
13
  const record: Ref<any | null> = ref({});
@@ -23,6 +25,19 @@ export const useCoreStore = defineStore('core', () => {
23
25
  const resourceColumnsId = ref(null);
24
26
  const adminUser = ref(null);
25
27
 
28
+ async function toggleTheme() {
29
+ theme.value = theme.value === 'light' ? 'dark' : 'light';
30
+ if (theme.value === 'light') {
31
+ document.documentElement.classList.remove('dark');
32
+ } else {
33
+ document.documentElement.classList.add('dark');
34
+ }
35
+
36
+ document.documentElement.setAttribute('data-theme', theme.value);
37
+ theme.value = theme.value;
38
+ window.localStorage.setItem('af__theme', theme.value);
39
+ }
40
+
26
41
  async function fetchMenuAndResource() {
27
42
  const resp = await callAdminForthApi({
28
43
  path: '/get_base_config',
@@ -143,6 +158,8 @@ export const useCoreStore = defineStore('core', () => {
143
158
  resourceOptions,
144
159
  resource,
145
160
  adminUser,
146
- resourceColumnsWithFilters
161
+ resourceColumnsWithFilters,
162
+ toggleTheme,
163
+ theme,
147
164
  }
148
165
  })
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.3.56-next.5",
3
+ "version": "1.3.56-next.7",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
- "--main": "dist/index.js",
5
+ "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
@@ -20,6 +20,12 @@
20
20
  "docs": "typedoc",
21
21
  "postinstall": "cd ./spa/src/ && test ! -d ./types && ln -sf ../../types ./types || echo 'types linked'"
22
22
  },
23
+ "exports": {
24
+ ".": {
25
+ "import": "./dist/index.js",
26
+ "require": "./dist/index.js"
27
+ }
28
+ },
23
29
  "author": "devforth.io",
24
30
  "license": "ISC",
25
31
  "type": "module",