@vnejs/plugins.view.coralina.confirm 0.0.1 → 0.1.0

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.
@@ -1,16 +1,21 @@
1
- import { Module } from "@vnejs/module";
1
+ import { ModuleController } from "@vnejs/module.components";
2
2
 
3
- export class ConfirmController extends Module.Controller {
3
+ import { ZINDEX } from "../view";
4
+
5
+ export class ConfirmController extends ModuleController {
4
6
  name = "confirm.controller";
5
7
 
8
+ maxCurrentItem = 1;
9
+
6
10
  updateEvent = this.EVENTS.CONFIRM.UPDATE;
7
11
  controls = {
8
- [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => this.emit(this.EVENTS.CONFIRM.ACCEPT),
12
+ [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => this.emit(this.maxCurrentItem === 0 ? this.EVENTS.CONFIRM.ACCEPT : this.EVENTS.CONFIRM.DECLINE),
9
13
  [this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => this.emit(this.EVENTS.CONFIRM.ACCEPT),
10
14
  [this.CONST.CONTROLS.BUTTONS.BACK]: () => this.emit(this.EVENTS.CONFIRM.DECLINE),
11
- [this.CONST.CONTROLS.BUTTONS.GAMEMENU]: () => this.emit(this.EVENTS.CONFIRM.DECLINE),
15
+ [this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: this.decCurrentItem,
16
+ [this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: this.incCurrentItem,
12
17
  };
13
- controlsIndex = 5000;
18
+ controlsIndex = ZINDEX;
14
19
 
15
20
  subscribe = () => {
16
21
  this.on(this.EVENTS.CONFIRM.SHOW, this.onShow);
package/modules/view.js CHANGED
@@ -1,10 +1,10 @@
1
- import { Module } from "@vnejs/module";
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 ConfirmView extends Module.View {
5
+ export class ConfirmView extends ModuleView {
6
6
  name = "confirm.view";
7
- animationTime = 300;
7
+ animationTime = TRANSITION;
8
8
  renderFunc = render;
9
9
  updateEvent = this.EVENTS.CONFIRM.UPDATE;
10
10
  updateHandler = this.onUpdateReactComponent;
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.view.coralina.confirm",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
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,43 +1,79 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom";
3
3
 
4
- import { cn } from "@bem-react/classname";
4
+ import { Flex, PositionBox, Screen, Text, TextControls } from "@vnejs/uis.base";
5
5
 
6
- import "./index.styl";
7
-
8
- const b = cn("ConfirmView");
6
+ export const TRANSITION = 500;
7
+ export const ZINDEX = 9000;
9
8
 
10
9
  class ConfirmView extends React.Component {
11
- state = { isShow: false, text: "", textAccept: "", textDecline: "" };
10
+ state = { isShow: false, text: "", textAccept: "", textDecline: "", currentItem: null, textsArray: [] };
11
+
12
+ componentDidUpdate(props, state) {
13
+ const { textAccept = "", textDecline = "", text = "" } = this.state;
14
+
15
+ if (state.textAccept !== textAccept || state.textDecline !== textDecline || state.text !== text)
16
+ this.setState({
17
+ textsArray: [
18
+ { text: textAccept, value: true },
19
+ { text: textDecline, value: false },
20
+ ],
21
+ });
22
+ }
12
23
 
13
24
  onAccept = () => this.props.emit(this.props.EVENTS.CONFIRM.ACCEPT);
14
25
  onDecline = () => this.props.emit(this.props.EVENTS.CONFIRM.DECLINE);
15
26
 
16
- renderOneLine = (line = "", i) => (
17
- <div key={i} className={b("text", ["text"])}>
18
- {line}
19
- </div>
27
+ renderOneTitle = (text = "", i) => (
28
+ <Text
29
+ key={i}
30
+ text={text}
31
+ size={96}
32
+ width={3120}
33
+ align={Text.ALIGNS.CENTER}
34
+ />
20
35
  );
21
36
 
22
- renderControl = (text, onClick) => (
23
- <div className={b("control", ["text"])} onClick={onClick}>
24
- {text}
25
- </div>
26
- );
37
+ onClick = (isAccept) => (isAccept ? this.onAccept() : this.onDecline());
27
38
 
28
39
  render() {
29
- const { isShow = false, text = "", textAccept = "", textDecline = "" } = this.state;
40
+ const { isShow = false, text = "", textsArray = [], currentItem = null } = this.state;
41
+
42
+ const titles = (text || "").split("\n");
30
43
 
31
44
  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>
45
+ <Screen
46
+ zIndex={ZINDEX}
47
+ isShow={isShow}
48
+ withBlur={true}
49
+ withDark={true}
50
+ transition={TRANSITION}
51
+ >
52
+ <PositionBox isCentered={true}>
53
+ <Flex
54
+ direction={Flex.DIRECTION.COLUMN}
55
+ gap={60}
56
+ >
57
+ <Flex
58
+ direction={Flex.DIRECTION.COLUMN}
59
+ gap={12}
60
+ >
61
+ {titles.map(this.renderOneTitle)}
62
+ </Flex>
63
+ <TextControls
64
+ selectedIndex={currentItem}
65
+ wrapWidth={3120}
66
+ flexGap={0}
67
+ flexJustify={Flex.JUSTIFY.CENTER}
68
+ textSize={72}
69
+ textWidth={780}
70
+ textAlign={Text.ALIGNS.CENTER}
71
+ texts={textsArray}
72
+ onClick={this.onClick}
73
+ />
74
+ </Flex>
75
+ </PositionBox>
76
+ </Screen>
41
77
  );
42
78
  }
43
79
  }
package/view/index.styl DELETED
@@ -1,59 +0,0 @@
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