@vnejs/plugins.view.coralina.point-and-click 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 { PointAndClickController } from "./modules/controller";
4
+ import { PointAndClickView } from "./modules/view";
5
+
6
+ regPlugin("POINT_AND_CLICK_VIEW", {}, [PointAndClickController, PointAndClickView]);
@@ -0,0 +1,32 @@
1
+ import { Module } from "@vnejs/module";
2
+
3
+ export class PointAndClickController extends Module.Controller {
4
+ name = "point-and-click.controller";
5
+
6
+ maxCurrentItem = 0;
7
+ updateEvent = this.EVENTS.POINT_AND_CLICK.UPDATE;
8
+
9
+ emitGameMenu = () => this.emit(this.EVENTS.INTERFACE.GAMEMENU);
10
+
11
+ controls = {
12
+ [this.CONST.CONTROLS.BUTTONS.MENU]: this.emitGameMenu,
13
+ [this.CONST.CONTROLS.BUTTONS.GAMEMENU]: this.emitGameMenu,
14
+ [this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => this.emit(this.EVENTS.INTERFACE.HISTORY_BACK),
15
+ };
16
+ controlsIndex = 2000;
17
+
18
+ subscribe = () => {
19
+ this.on(this.EVENTS.POINT_AND_CLICK.SHOW, this.onShow);
20
+ this.on(this.EVENTS.POINT_AND_CLICK.HIDE, this.onHide);
21
+ };
22
+
23
+ beforeShow = async () => {
24
+ this.updateState({ ...this.globalState["point-and-click"] });
25
+ this.currentItem = null;
26
+ this.maxCurrentItem = this.state.options.length - 1;
27
+
28
+ await this.emit(this.EVENTS.INTERFACE.HIDE);
29
+ };
30
+
31
+ getDefaultState = () => ({ options: [], args: {} });
32
+ }
@@ -0,0 +1,11 @@
1
+ import { Module } from "@vnejs/module";
2
+
3
+ import { render } from "../view";
4
+
5
+ export class PointAndClickView extends Module.View {
6
+ name = "point-and-click.view";
7
+ animationTime = 300;
8
+ renderFunc = render;
9
+ updateEvent = this.EVENTS.POINT_AND_CLICK.UPDATE;
10
+ updateHandler = this.onUpdateReactComponent;
11
+ }
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@vnejs/plugins.view.coralina.point-and-click",
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,42 @@
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("PointAndClick");
9
+
10
+ class PointAndClick extends React.Component {
11
+ onOptionClick = (e) =>
12
+ this.props.emit(this.props.EVENTS.POINT_AND_CLICK.OPTION, { index: Number(e.currentTarget.dataset.index) });
13
+
14
+ renderOption = ({ disabled, hided, coords: [x, y] }, index) =>
15
+ !hided && (
16
+ <div
17
+ className={b("option", {
18
+ disabled,
19
+ isCurrent: index === this.state.currentItem,
20
+ coords: Boolean(x) && Boolean(y),
21
+ })}
22
+ style={{ left: `${x}%`, top: `${y}%` }}
23
+ data-index={index}
24
+ key={index}
25
+ onClick={disabled ? undefined : this.onOptionClick}
26
+ />
27
+ );
28
+
29
+ render() {
30
+ const { isShow = false, options = [], isForce = false } = this.state || {};
31
+
32
+ console.log(99999999999, isShow, options);
33
+
34
+ return (
35
+ <div className={b({ isShow, isForce })} vne-autoread-disable={isShow ? "1" : ""}>
36
+ {options.map(this.renderOption)}
37
+ </div>
38
+ );
39
+ }
40
+ }
41
+
42
+ export const render = (props, root, resolve) => ReactDOM.render(<PointAndClick {...props} />, root, resolve);
@@ -0,0 +1,56 @@
1
+ .PointAndClick
2
+ position: absolute
3
+ top: 0
4
+ right: 0
5
+ bottom: 0
6
+ left: 0
7
+ display: flex
8
+ justify-content: center
9
+ align-items: center
10
+ z-index: 3000
11
+ opacity: 0
12
+ pointer-events: none
13
+ font-family: Montserrat
14
+
15
+ &-options
16
+ display: flex
17
+ flex-direction: column
18
+ justify-content: center
19
+ align-items: center
20
+ height: 100%
21
+ gap: calc(50 / 2160 * 100%)
22
+
23
+ &-option
24
+ transition: transform 300ms
25
+
26
+ width: 3%
27
+ aspect-ratio: 1
28
+
29
+ background: black
30
+ border-radius: 50%
31
+
32
+ &_coords
33
+ position: absolute
34
+ transform: translate(-50%, -50%)
35
+
36
+ &:not(&_disabled):hover,
37
+ &_isCurrent:not(&_disabled)
38
+ opacity: 0.85
39
+ transform: scale(1.25)
40
+
41
+ &_coords:hover:not(&_disabled)
42
+ &_coords&_isCurrent:not(&_disabled)
43
+ transform: translate(-50%, -50%) scale(1.25)
44
+
45
+ &:not(&_disabled)
46
+ cursor: pointer
47
+
48
+ &_disabled
49
+ opacity: 0.5
50
+
51
+ &_isShow
52
+ opacity: 1
53
+ pointer-events: all
54
+
55
+ &:not(&_isForce)
56
+ transition: opacity 300ms