zova-module-a-style 5.0.16 → 5.0.17
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.
- package/package.json +5 -2
- package/src/bean/bean.theme.ts +27 -8
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-style",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.17",
|
|
4
4
|
"title": "a-style",
|
|
5
5
|
"zovaModule": {
|
|
6
6
|
"capabilities": {
|
|
7
7
|
"monkey": true
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"a-model": "5.0.0"
|
|
8
11
|
}
|
|
9
12
|
},
|
|
10
13
|
"type": "module",
|
|
@@ -34,5 +37,5 @@
|
|
|
34
37
|
"tsc:publish": "npm run clean && tsc -b",
|
|
35
38
|
"prepublishOnly": "npm run tsc:publish"
|
|
36
39
|
},
|
|
37
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "6b24f8fbc3857e405882791f096d19d146675077"
|
|
38
41
|
}
|
package/src/bean/bean.theme.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { Bean,
|
|
1
|
+
import { Bean, Cast, IBeanRecord } from 'zova';
|
|
2
2
|
import { ScopeModule } from '../resource/this.js';
|
|
3
3
|
import { ThemeBase, ThemeHandler } from '../types.js';
|
|
4
|
+
import { BeanModelBase } from 'zova-module-a-model';
|
|
4
5
|
|
|
5
6
|
export type ThemeDarkMode = 'auto' | boolean;
|
|
6
7
|
|
|
7
8
|
@Bean({ containerScope: 'app' })
|
|
8
|
-
export class BeanTheme extends
|
|
9
|
-
private _name:
|
|
10
|
-
public get name():
|
|
9
|
+
export class BeanTheme extends BeanModelBase<ScopeModule> {
|
|
10
|
+
private _name: keyof IBeanRecord;
|
|
11
|
+
public get name(): keyof IBeanRecord {
|
|
11
12
|
return this._name;
|
|
12
13
|
}
|
|
13
|
-
public set name(value:
|
|
14
|
+
public set name(value: keyof IBeanRecord) {
|
|
14
15
|
this.setTheme(value as any);
|
|
15
16
|
}
|
|
16
17
|
private _dark: boolean;
|
|
@@ -29,8 +30,25 @@ export class BeanTheme extends BeanBase<ScopeModule> {
|
|
|
29
30
|
private _onMediaDarkChange?;
|
|
30
31
|
|
|
31
32
|
protected async __init__() {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
this._name = this.$useQueryCookie({
|
|
34
|
+
queryKey: ['themename'],
|
|
35
|
+
});
|
|
36
|
+
this._dark = this.$useQueryCookie({
|
|
37
|
+
queryKey: ['themedark'],
|
|
38
|
+
});
|
|
39
|
+
this._darkMode = this.$useQueryCookie({
|
|
40
|
+
queryKey: ['themedarkmode'],
|
|
41
|
+
meta: {
|
|
42
|
+
persister: {
|
|
43
|
+
deserialize: value => {
|
|
44
|
+
value = value === 'true' ? true : value === 'false' ? false : !value ? undefined : value;
|
|
45
|
+
return this.$deserializeCookie(value);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
await this._setDark(this._darkMode);
|
|
51
|
+
await this._setTheme(this._name);
|
|
34
52
|
await this.applyTheme();
|
|
35
53
|
}
|
|
36
54
|
|
|
@@ -63,7 +81,8 @@ export class BeanTheme extends BeanBase<ScopeModule> {
|
|
|
63
81
|
await this.applyTheme();
|
|
64
82
|
}
|
|
65
83
|
|
|
66
|
-
async _setDark(mode
|
|
84
|
+
async _setDark(mode?: ThemeDarkMode) {
|
|
85
|
+
if (mode === undefined) mode = 'auto';
|
|
67
86
|
this._darkMode = mode;
|
|
68
87
|
if (mode === 'auto') {
|
|
69
88
|
this._listenMediaDarkChange(true);
|