@vnejs/plugins.view.coralina.choose 0.0.3 → 0.1.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/modules/controller.js +13 -8
- package/modules/view.js +4 -4
- package/package.json +5 -6
- package/view/index.jsx +66 -27
- package/view/index.styl +0 -52
package/modules/controller.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { ZINDEX } from "../view";
|
|
4
|
+
|
|
5
|
+
export class ChooseController extends ModuleController {
|
|
4
6
|
name = "choose.controller";
|
|
5
7
|
|
|
6
8
|
maxCurrentItem = 0;
|
|
@@ -12,12 +14,11 @@ export class ChooseController extends Module.Controller {
|
|
|
12
14
|
[this.CONST.CONTROLS.BUTTONS.MENU]: this.emitGameMenu,
|
|
13
15
|
[this.CONST.CONTROLS.BUTTONS.GAMEMENU]: this.emitGameMenu,
|
|
14
16
|
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => this.emit(this.EVENTS.INTERFACE.HISTORY_BACK),
|
|
15
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_UP]: this.decCurrentItem,
|
|
16
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_BOTTOM]: this.incCurrentItem,
|
|
17
|
-
[this.CONST.CONTROLS.BUTTONS.ACCEPT]: () =>
|
|
18
|
-
this.currentItem !== null && this.emit(this.EVENTS.CHOOSE.OPTION, { index: this.currentItem }),
|
|
17
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_UP]: () => this.onArrow(this.decCurrentItem),
|
|
18
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_BOTTOM]: () => this.onArrow(this.incCurrentItem),
|
|
19
|
+
[this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => this.currentItem !== null && this.emit(this.EVENTS.CHOOSE.OPTION, { index: this.currentItem }),
|
|
19
20
|
};
|
|
20
|
-
controlsIndex =
|
|
21
|
+
controlsIndex = ZINDEX;
|
|
21
22
|
|
|
22
23
|
subscribe = () => {
|
|
23
24
|
this.on(this.EVENTS.CHOOSE.SHOW, this.onShow);
|
|
@@ -26,11 +27,15 @@ export class ChooseController extends Module.Controller {
|
|
|
26
27
|
|
|
27
28
|
beforeShow = async () => {
|
|
28
29
|
this.updateState({ ...this.globalState.choose });
|
|
29
|
-
this.currentItem = null;
|
|
30
30
|
this.maxCurrentItem = this.state.options.length - 1;
|
|
31
31
|
|
|
32
32
|
await this.emit(this.EVENTS.INTERFACE.HIDE);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
onArrow = (cb) => {
|
|
36
|
+
cb();
|
|
37
|
+
while (this.state.options?.[this.currentItem].hided) cb();
|
|
38
|
+
};
|
|
39
|
+
|
|
35
40
|
getDefaultState = () => ({ options: [], args: {} });
|
|
36
41
|
}
|
package/modules/view.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
import { render } from "../view";
|
|
3
|
+
import { render, TRANSITION } from "../view";
|
|
4
4
|
|
|
5
|
-
export class ChooseView extends
|
|
5
|
+
export class ChooseView extends ModuleView {
|
|
6
6
|
name = "choose.view";
|
|
7
|
-
animationTime =
|
|
7
|
+
animationTime = TRANSITION;
|
|
8
8
|
renderFunc = render;
|
|
9
9
|
updateEvent = this.EVENTS.CHOOSE.UPDATE;
|
|
10
10
|
updateHandler = this.onUpdateReactComponent;
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.view.coralina.choose",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
+
"publish:major:plugin": "npm run publish:major",
|
|
8
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
9
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
7
10
|
"publish:major": "npm version major && npm publish --access public",
|
|
8
11
|
"publish:minor": "npm version minor && npm publish --access public",
|
|
9
12
|
"publish:patch": "npm version patch && npm publish --access public"
|
|
10
13
|
},
|
|
11
14
|
"author": "",
|
|
12
15
|
"license": "ISC",
|
|
13
|
-
"description": ""
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
"@vnejs/shared": "*",
|
|
16
|
-
"@vnejs/module": "*"
|
|
17
|
-
}
|
|
16
|
+
"description": ""
|
|
18
17
|
}
|
package/view/index.jsx
CHANGED
|
@@ -1,40 +1,79 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Flex, PositionBox, Screen, Text, TextControls } from "@vnejs/uis.base";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const b = cn("Choose");
|
|
6
|
+
export const TRANSITION = 300;
|
|
7
|
+
export const ZINDEX = 1200;
|
|
9
8
|
|
|
10
9
|
class Choose extends React.Component {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
state = { isShow: false, isForce: false, options: [], optionsRegular: [], optionsWithCoords: [] };
|
|
11
|
+
|
|
12
|
+
onClick = (index) => this.props.emit(this.props.EVENTS.CHOOSE.OPTION, { index });
|
|
13
|
+
|
|
14
|
+
componentDidUpdate(props, state) {
|
|
15
|
+
if (state.options !== this.state.options || state.currentItem !== this.state.currentItem) {
|
|
16
|
+
const { options = [], currentItem = null } = this.state;
|
|
17
|
+
|
|
18
|
+
const textsInfo = options.map(({ text, hided, coords, disabled }, i) => ({
|
|
19
|
+
text,
|
|
20
|
+
isNotRender: Boolean(hided),
|
|
21
|
+
value: i,
|
|
22
|
+
isDisabled: Boolean(disabled),
|
|
23
|
+
isSelected: currentItem === i,
|
|
24
|
+
coords,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
this.setState({ optionsRegular: textsInfo.filter((e) => !e.coords), optionsWithCoords: textsInfo.filter((e) => e.coords) });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
renderOptionWithCoords = ({ text, isDisabled, isNotRender, value, coords: [x, y] } = {}) => (
|
|
32
|
+
<PositionBox
|
|
33
|
+
left={`${x}%`}
|
|
34
|
+
top={`${y}%`}
|
|
35
|
+
translateX={"-50%"}
|
|
36
|
+
translateY={"-50%"}
|
|
37
|
+
isNotRender={isNotRender}
|
|
38
|
+
key={value}
|
|
39
|
+
>
|
|
40
|
+
<Text
|
|
41
|
+
isSelected={this.state.currentItem === value}
|
|
42
|
+
isDisabled={isDisabled}
|
|
43
|
+
textSize={96}
|
|
44
|
+
text={text}
|
|
45
|
+
onClick={this.onClick}
|
|
46
|
+
value={value}
|
|
47
|
+
/>
|
|
48
|
+
</PositionBox>
|
|
49
|
+
);
|
|
30
50
|
|
|
31
51
|
render() {
|
|
32
|
-
const { isShow = false,
|
|
52
|
+
const { isShow = false, isForce = false, optionsRegular = [], optionsWithCoords = [] } = this.state;
|
|
33
53
|
|
|
34
54
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
<Screen
|
|
56
|
+
isShow={isShow}
|
|
57
|
+
isForce={isForce}
|
|
58
|
+
zIndex={ZINDEX}
|
|
59
|
+
withBlur={true}
|
|
60
|
+
withDark={true}
|
|
61
|
+
transition={TRANSITION}
|
|
62
|
+
isDisableAutoread={true}
|
|
63
|
+
isIgnoreOnScreenshot={false}
|
|
64
|
+
>
|
|
65
|
+
{optionsWithCoords.map(this.renderOptionWithCoords)}
|
|
66
|
+
<PositionBox isCentered={true}>
|
|
67
|
+
<TextControls
|
|
68
|
+
flexDirection={Flex.DIRECTION.COLUMN}
|
|
69
|
+
flexGap={60}
|
|
70
|
+
textSize={96}
|
|
71
|
+
textAlign={Text.ALIGNS.CENTER}
|
|
72
|
+
texts={optionsRegular}
|
|
73
|
+
onClick={this.onClick}
|
|
74
|
+
/>
|
|
75
|
+
</PositionBox>
|
|
76
|
+
</Screen>
|
|
38
77
|
);
|
|
39
78
|
}
|
|
40
79
|
}
|
package/view/index.styl
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
.Choose
|
|
2
|
-
position: absolute
|
|
3
|
-
top: 0
|
|
4
|
-
right: 0
|
|
5
|
-
bottom: 0
|
|
6
|
-
left: 0
|
|
7
|
-
background: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.25) 14.04%, rgba(0,0,0,0.45) 27.9%, rgba(0,0,0,0.55) 45.51%, rgba(0,0,0,0.7) 66.85%, rgba(0,0,0,0.85) 100%);
|
|
8
|
-
display: flex
|
|
9
|
-
justify-content: center
|
|
10
|
-
align-items: center
|
|
11
|
-
z-index: 3000
|
|
12
|
-
opacity: 0
|
|
13
|
-
pointer-events: none
|
|
14
|
-
font-family: Montserrat
|
|
15
|
-
|
|
16
|
-
&-options
|
|
17
|
-
display: flex
|
|
18
|
-
flex-direction: column
|
|
19
|
-
justify-content: center
|
|
20
|
-
align-items: center
|
|
21
|
-
height: 100%
|
|
22
|
-
gap: calc(50 / 2160 * 100%)
|
|
23
|
-
|
|
24
|
-
&-option
|
|
25
|
-
color: rgba(255,255,255,0.6)
|
|
26
|
-
transition: text-shadow 300ms, transform 300ms
|
|
27
|
-
|
|
28
|
-
&_coords
|
|
29
|
-
position: absolute
|
|
30
|
-
transform: translate(-50%, -50%)
|
|
31
|
-
|
|
32
|
-
&:not(&_disabled):hover,
|
|
33
|
-
&_isCurrent:not(&_disabled)
|
|
34
|
-
text-shadow: 0px 5px 25px rgba(255,255,255,0.75);
|
|
35
|
-
transform: scale(1.2)
|
|
36
|
-
|
|
37
|
-
&_coords:hover:not(&_disabled)
|
|
38
|
-
&_coords&_isCurrent:not(&_disabled)
|
|
39
|
-
transform: translate(-50%, -50%) scale(1.2)
|
|
40
|
-
|
|
41
|
-
&:not(&_disabled)
|
|
42
|
-
cursor: pointer
|
|
43
|
-
|
|
44
|
-
&_disabled
|
|
45
|
-
opacity: 0.5
|
|
46
|
-
|
|
47
|
-
&_isShow
|
|
48
|
-
opacity: 1
|
|
49
|
-
pointer-events: all
|
|
50
|
-
|
|
51
|
-
&:not(&_isForce)
|
|
52
|
-
transition: opacity 300ms
|