@vnejs/plugins.view.coralina.settings.defaults 0.0.1

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/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { regPlugin } from "@vnejs/shared";
2
+
3
+ import { SettingsDefaultsController } from "./modules/controller";
4
+ import { SettingsDefaultsView } from "./modules/view";
5
+
6
+ regPlugin("SETTINGS_DEFAULTS_VIEW", {}, [SettingsDefaultsController, SettingsDefaultsView]);
@@ -0,0 +1,20 @@
1
+ import { Module } from "@vnejs/module";
2
+
3
+ export class SettingsDefaultsController extends Module.Controller {
4
+ name = "settings.defaults.controller";
5
+
6
+ updateEvent = this.EVENTS.SETTINGS_DEFAULTS.UPDATE;
7
+
8
+ subscribe = () => {
9
+ this.on(this.EVENTS.SETTINGS_DEFAULTS.SHOW, this.onShow);
10
+
11
+ this.on(this.EVENTS.LOCS.LANG_CHANGED, this.onSettingChange);
12
+ this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
13
+ };
14
+
15
+ beforeShow = () => this.updateState({ defaultSettingsItems: window.VNESettingsDefaultsItems.map(this.emitFunc) });
16
+
17
+ emitFunc = (func) => func({ SETTINGS: this.SETTINGS, CONST: this.CONST, platform: window.VneCore.getPlatform() });
18
+
19
+ onSettingChange = () => this.state.isShow && this.updateViewFast();
20
+ }
@@ -0,0 +1,12 @@
1
+ import { Module } from "@vnejs/module";
2
+
3
+ import { render } from "../view";
4
+
5
+ export class SettingsDefaultsView extends Module.View {
6
+ name = "settings.defaults.view";
7
+ locLabel = "settings_defaults";
8
+ animationTime = 300;
9
+ renderFunc = render;
10
+ updateEvent = this.EVENTS.SETTINGS_DEFAULTS.UPDATE;
11
+ updateHandler = this.onUpdateReactComponent;
12
+ }
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@vnejs/plugins.view.coralina.settings.defaults",
3
+ "version": "0.0.1",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "publish:major": "npm version major && npm publish --access public",
8
+ "publish:minor": "npm version minor && npm publish --access public",
9
+ "publish:patch": "npm version patch && npm publish --access public"
10
+ },
11
+ "author": "",
12
+ "license": "ISC",
13
+ "description": "",
14
+ "peerDependencies": {
15
+ "@vnejs/shared": "*",
16
+ "@vnejs/module": "*"
17
+ }
18
+ }
package/view/index.jsx ADDED
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom";
3
+
4
+ import { cn } from "@bem-react/classname";
5
+
6
+ import "./index.styl";
7
+
8
+ const b = cn("SettingsDefaults");
9
+
10
+ class SettingsDefaults extends React.Component {
11
+ state = { locs: {} };
12
+
13
+ onClickValue = (e) => {
14
+ const { value, settingKey } = e.currentTarget.dataset;
15
+
16
+ return this.props.emit(this.props.EVENTS.SETTINGS.SET, { name: settingKey, value });
17
+ };
18
+
19
+ onClickConfirm = () => this.props.emit(this.props.EVENTS.SETTINGS_DEFAULTS.CONFIRM);
20
+
21
+ renderValues = ({ titleKey = "", value = "" } = {}, settingKey = "") => (
22
+ <div
23
+ className={b("value", { current: this.props.shared.settings[settingKey] === value }, ["textWrap_120"])}
24
+ onClick={this.onClickValue}
25
+ data-value={value}
26
+ data-setting-key={settingKey}
27
+ key={value}
28
+ >
29
+ <span className="text">{this.state.locs[titleKey]}</span>
30
+ </div>
31
+ );
32
+
33
+ renderItem = ({ titleKey = "", settingKey = "", values = [] } = {}, i) => (
34
+ <div className={b("item")} key={settingKey}>
35
+ <div className={b("name", ["textWrap_120"])}>
36
+ <span className="text">{this.state.locs[titleKey]}</span>
37
+ </div>
38
+ <div className={b("values")}>{values.map((value) => this.renderValues(value, settingKey))}</div>
39
+ </div>
40
+ );
41
+
42
+ render() {
43
+ const { isShow = false, defaultSettingsItems = [], locs = {} } = this.state;
44
+
45
+ return (
46
+ <div className={b({ isShow })} data-html2canvas-ignore="1">
47
+ <div className={b("title", ["textWrap_120"])}>
48
+ <span className="text">{locs.title}</span>
49
+ </div>
50
+ <div className={b("items")}>{defaultSettingsItems.map(this.renderItem)}</div>
51
+ <div className={b("confirm", ["textWrap_120"])} onClick={this.onClickConfirm}>
52
+ <span className="text">{locs.confirm}</span>
53
+ </div>
54
+ </div>
55
+ );
56
+ }
57
+ }
58
+
59
+ export const render = (props, root, resolve) => ReactDOM.render(<SettingsDefaults {...props} />, root, resolve);
@@ -0,0 +1,62 @@
1
+ .SettingsDefaults
2
+ position: absolute
3
+ top: 0
4
+ right: 0
5
+ bottom: 0
6
+ left: 0
7
+
8
+ display: flex
9
+ align-items: center
10
+ justify-content: center
11
+ flex-direction: column;
12
+ gap: calc(180 / 2160* 100%);
13
+
14
+ color: rgba(255,255,255,0.6);
15
+ font-family: Montserrat;
16
+ text-align: center
17
+
18
+ opacity: 0
19
+ pointer-events: none
20
+
21
+ transition: color 300ms, opacity 1000ms
22
+
23
+ &-items
24
+ width: 100%
25
+
26
+ &-item
27
+ display: flex
28
+ justify-content: space-evenly
29
+
30
+ &-item ~ &-item
31
+ margin-top: 2.345%
32
+
33
+ &-name
34
+ width: 20%
35
+
36
+ &-values
37
+ width: 65%
38
+ display: flex
39
+ justify-content: space-evenly
40
+
41
+ &-value
42
+ cursor: pointer
43
+ transition: color 300ms
44
+
45
+ &:hover
46
+ color: rgba(255,255,255,0.75);
47
+
48
+ &_current
49
+ color: rgba(255,255,255,0.9);
50
+
51
+ &-confirm
52
+ color: rgba(255,255,255,0.6);
53
+ cursor: pointer
54
+ transition: color 300ms
55
+
56
+ &:hover
57
+ color: rgba(255,255,255,1);
58
+
59
+ &_isShow
60
+ pointer-events: all
61
+ opacity: 1
62
+