@vnejs/plugins.view.coralina.confirm 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 +6 -0
- package/modules/controller.js +23 -0
- package/modules/view.js +11 -0
- package/package.json +18 -0
- package/view/index.jsx +45 -0
- package/view/index.styl +59 -0
package/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
|
|
3
|
+
export class ConfirmController extends Module.Controller {
|
|
4
|
+
name = "confirm.controller";
|
|
5
|
+
|
|
6
|
+
updateEvent = this.EVENTS.CONFIRM.UPDATE;
|
|
7
|
+
controls = {
|
|
8
|
+
[this.CONST.CONTROLS.BUTTONS.INTERACT]: () => this.emit(this.EVENTS.CONFIRM.ACCEPT),
|
|
9
|
+
[this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => this.emit(this.EVENTS.CONFIRM.ACCEPT),
|
|
10
|
+
[this.CONST.CONTROLS.BUTTONS.BACK]: () => this.emit(this.EVENTS.CONFIRM.DECLINE),
|
|
11
|
+
[this.CONST.CONTROLS.BUTTONS.GAMEMENU]: () => this.emit(this.EVENTS.CONFIRM.DECLINE),
|
|
12
|
+
};
|
|
13
|
+
controlsIndex = 5000;
|
|
14
|
+
|
|
15
|
+
subscribe = () => {
|
|
16
|
+
this.on(this.EVENTS.CONFIRM.SHOW, this.onShow);
|
|
17
|
+
this.on(this.EVENTS.CONFIRM.HIDE, this.onHide);
|
|
18
|
+
|
|
19
|
+
this.on(this.EVENTS.STATE.CLEAR, this.onHide);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
beforeShow = (args) => this.setState(args);
|
|
23
|
+
}
|
package/modules/view.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
|
|
3
|
+
import { render } from "../view";
|
|
4
|
+
|
|
5
|
+
export class ConfirmView extends Module.View {
|
|
6
|
+
name = "confirm.view";
|
|
7
|
+
animationTime = 300;
|
|
8
|
+
renderFunc = render;
|
|
9
|
+
updateEvent = this.EVENTS.CONFIRM.UPDATE;
|
|
10
|
+
updateHandler = this.onUpdateReactComponent;
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/plugins.view.coralina.confirm",
|
|
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,45 @@
|
|
|
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("ConfirmView");
|
|
9
|
+
|
|
10
|
+
class ConfirmView extends React.Component {
|
|
11
|
+
state = { isShow: false, text: "", textAccept: "", textDecline: "" };
|
|
12
|
+
|
|
13
|
+
onAccept = () => this.props.emit(this.props.EVENTS.CONFIRM.ACCEPT);
|
|
14
|
+
onDecline = () => this.props.emit(this.props.EVENTS.CONFIRM.DECLINE);
|
|
15
|
+
|
|
16
|
+
renderOneLine = (line = "", i) => (
|
|
17
|
+
<div key={i} className={b("text", ["text"])}>
|
|
18
|
+
{line}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
renderControl = (text, onClick) => (
|
|
23
|
+
<div className={b("control", ["text"])} onClick={onClick}>
|
|
24
|
+
{text}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
const { isShow = false, text = "", textAccept = "", textDecline = "" } = this.state;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className={b({ isShow })}>
|
|
33
|
+
<div className={b("wrap")}>
|
|
34
|
+
<div className={b("texts", ["textWrap_60"])}>{(text || "").split("\n").map(this.renderOneLine)}</div>
|
|
35
|
+
<div className={b("controls", ["textWrap_60"])}>
|
|
36
|
+
{this.renderControl(textAccept, this.onAccept)}
|
|
37
|
+
{this.renderControl(textDecline, this.onDecline)}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const render = (props, root, resolve) => ReactDOM.render(<ConfirmView {...props} />, root, resolve);
|
package/view/index.styl
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.ConfirmView
|
|
2
|
+
position: absolute
|
|
3
|
+
top: 0
|
|
4
|
+
right: 0
|
|
5
|
+
bottom: 0
|
|
6
|
+
left: 0
|
|
7
|
+
display: flex
|
|
8
|
+
align-items: center
|
|
9
|
+
justify-content: center
|
|
10
|
+
z-index: 9000
|
|
11
|
+
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%);
|
|
12
|
+
backdrop-filter: blur(5px) brightness(0.5)
|
|
13
|
+
font-family: Montserrat
|
|
14
|
+
pointer-events: none
|
|
15
|
+
opacity: 0
|
|
16
|
+
transition: opacity 300ms
|
|
17
|
+
|
|
18
|
+
&-wrap
|
|
19
|
+
display: flex
|
|
20
|
+
flex-direction: column
|
|
21
|
+
align-items: center
|
|
22
|
+
justify-content: center
|
|
23
|
+
|
|
24
|
+
text-align: center
|
|
25
|
+
|
|
26
|
+
height: calc(1000 / 2160 * 100%)
|
|
27
|
+
gap: calc(50 / 1000 * 100%)
|
|
28
|
+
|
|
29
|
+
&-texts
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column
|
|
32
|
+
justify-content: flex-end
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: calc(450 / 1000 * 100%)
|
|
35
|
+
|
|
36
|
+
&-text
|
|
37
|
+
color: rgba(255,255,255,0.6)
|
|
38
|
+
|
|
39
|
+
&-controls
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: space-around;
|
|
42
|
+
align-items: flex-start
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: calc(450 / 1000 * 100%)
|
|
45
|
+
|
|
46
|
+
&-control
|
|
47
|
+
cursor: pointer
|
|
48
|
+
color: rgba(255,255,255,0.6)
|
|
49
|
+
|
|
50
|
+
transition: color 300ms, text-shadow 300ms, transform 300ms
|
|
51
|
+
|
|
52
|
+
&:hover
|
|
53
|
+
text-shadow: 0px 5px 25px rgba(255,255,255,0.75)
|
|
54
|
+
transform: scale(1.5)
|
|
55
|
+
color: white
|
|
56
|
+
|
|
57
|
+
&_isShow
|
|
58
|
+
pointer-events: all
|
|
59
|
+
opacity: 1
|