@vnejs/plugins.view.coralina.mainmenu 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.
- package/modules/controller.js +11 -9
- package/modules/view.js +4 -4
- package/package.json +5 -6
- package/view/index.jsx +30 -29
- package/view/index.styl +0 -46
- package/view/media/triangle.svg +0 -23
package/modules/controller.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
3
|
const toStateItem = ({ onClick, ...item }) => item;
|
|
4
4
|
const onRealItems = (item) => !item.isDisabled && !item.isHide;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
window.VneMainMenuBg = "Menu/loading";
|
|
7
|
+
|
|
8
|
+
export class MainMenuController extends ModuleController {
|
|
7
9
|
name = "mainmenu.controller";
|
|
8
10
|
|
|
11
|
+
bgName = window.VneMainMenuBg;
|
|
12
|
+
|
|
9
13
|
updateEvent = this.EVENTS.MAINMENU_VIEW.UPDATE;
|
|
10
14
|
controls = {
|
|
11
15
|
[this.CONST.CONTROLS.BUTTONS.ARROW_UP]: this.decCurrentItem,
|
|
@@ -25,14 +29,16 @@ export class MainMenuController extends Module.Controller {
|
|
|
25
29
|
|
|
26
30
|
this.on(this.EVENTS.STATE.CLEAR, this.onHideForce);
|
|
27
31
|
this.on(this.EVENTS.STATE.SET, this.onHideForce);
|
|
32
|
+
|
|
33
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.loadBgMedia);
|
|
34
|
+
this.on(this.EVENTS.STATE.CLEAR, this.loadBgMedia);
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
beforeShow = async () => {
|
|
31
38
|
const items = (await this.getItems()).map(toStateItem);
|
|
32
39
|
|
|
33
|
-
this.updateState({ items, realItems: items.filter(onRealItems) });
|
|
40
|
+
this.updateState({ items, realItems: items.filter(onRealItems), bgSrc: (await this.loadBgMedia()).src });
|
|
34
41
|
|
|
35
|
-
this.currentItem = null;
|
|
36
42
|
this.maxCurrentItem = this.state.realItems.length - 1;
|
|
37
43
|
};
|
|
38
44
|
|
|
@@ -41,10 +47,6 @@ export class MainMenuController extends Module.Controller {
|
|
|
41
47
|
|
|
42
48
|
click = (items, index) => index !== null && items[index] && items[index].onClick && items[index].onClick();
|
|
43
49
|
|
|
44
|
-
getItems =
|
|
45
|
-
const [items] = await this.emit(this.EVENTS.MAINMENU.ITEMS);
|
|
46
|
-
|
|
47
|
-
return items;
|
|
48
|
-
};
|
|
50
|
+
getItems = () => this.emitOne(this.EVENTS.MAINMENU.ITEMS);
|
|
49
51
|
getRealItems = async () => (await this.getItems()).filter(onRealItems);
|
|
50
52
|
}
|
package/modules/view.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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 MainMenuView extends
|
|
5
|
+
export class MainMenuView extends ModuleView {
|
|
6
6
|
name = "mainmenu.view";
|
|
7
7
|
locLabel = "mainMenu";
|
|
8
|
-
animationTime =
|
|
8
|
+
animationTime = TRANSITION;
|
|
9
9
|
renderFunc = render;
|
|
10
10
|
updateEvent = this.EVENTS.MAINMENU_VIEW.UPDATE;
|
|
11
11
|
updateHandler = this.onUpdateReactComponent;
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.view.coralina.mainmenu",
|
|
3
|
-
"version": "0.0
|
|
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,44 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Flex, PositionBox, Screen, TextControls } from "@vnejs/uis.base";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const b = cn("MainMenu");
|
|
6
|
+
export const TRANSITION = 500;
|
|
9
7
|
|
|
10
8
|
class MainMenu extends React.Component {
|
|
11
|
-
state = {};
|
|
12
|
-
|
|
13
|
-
onClick = ({ currentTarget: { dataset: { index = 0 } = {} } = {} }) =>
|
|
14
|
-
this.props.emit(this.props.EVENTS.MAINMENU_VIEW.CLICK, { index });
|
|
9
|
+
state = { isShow: false, items: [], bgSrc: "" };
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
!isHide && (
|
|
22
|
-
<div
|
|
23
|
-
className={`${b("button", { isDisabled, isCurrent })} textWrap_96`}
|
|
24
|
-
onClick={isDisabled ? undefined : this.onClick}
|
|
25
|
-
data-index={i}
|
|
26
|
-
key={locKey}
|
|
27
|
-
>
|
|
28
|
-
<span className="text">{locs[locKey]}</span>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
);
|
|
32
|
-
};
|
|
11
|
+
onClick = (index) => this.props.emit(this.props.EVENTS.MAINMENU_VIEW.CLICK, { index });
|
|
12
|
+
mapItems = ({ locKey, isDisabled, isHide }, i) => ({ text: this.state.locs[locKey], isDisabled, isNotRender: isHide, value: i });
|
|
13
|
+
findSelectedIndex = (value) => this.state.realItems[this.state.currentItem]?.locKey === value?.locKey;
|
|
33
14
|
|
|
34
15
|
render() {
|
|
35
|
-
const { isShow = false, items = [] } = this.state;
|
|
16
|
+
const { isShow = false, items = [], bgSrc } = this.state;
|
|
17
|
+
|
|
18
|
+
const selectedIndex = items.findIndex(this.findSelectedIndex);
|
|
19
|
+
const texts = items.map(this.mapItems);
|
|
36
20
|
|
|
37
21
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
<Screen
|
|
23
|
+
zIndex={3000}
|
|
24
|
+
isShow={isShow}
|
|
25
|
+
bgSrc={bgSrc}
|
|
26
|
+
transition={TRANSITION}
|
|
27
|
+
>
|
|
28
|
+
<PositionBox
|
|
29
|
+
bottom={240}
|
|
30
|
+
left={240}
|
|
31
|
+
>
|
|
32
|
+
<TextControls
|
|
33
|
+
selectedIndex={selectedIndex}
|
|
34
|
+
texts={texts}
|
|
35
|
+
onClick={this.onClick}
|
|
36
|
+
textSize={96}
|
|
37
|
+
flexGap={60}
|
|
38
|
+
flexDirection={Flex.DIRECTION.COLUMN}
|
|
39
|
+
/>
|
|
40
|
+
</PositionBox>
|
|
41
|
+
</Screen>
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
}
|
package/view/index.styl
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
.MainMenu
|
|
2
|
-
position: absolute
|
|
3
|
-
top: 0
|
|
4
|
-
bottom: 0
|
|
5
|
-
left: 0
|
|
6
|
-
right: 0
|
|
7
|
-
opacity: 0
|
|
8
|
-
pointer-events: none
|
|
9
|
-
transition: opacity 500ms
|
|
10
|
-
z-index: 3000
|
|
11
|
-
|
|
12
|
-
&_isShow
|
|
13
|
-
opacity: 1
|
|
14
|
-
pointer-events: all
|
|
15
|
-
|
|
16
|
-
&-menu
|
|
17
|
-
position: absolute
|
|
18
|
-
bottom: 6.25%
|
|
19
|
-
left: 6.25%
|
|
20
|
-
display: flex
|
|
21
|
-
align-items: flex-start
|
|
22
|
-
justify-content: flex-end
|
|
23
|
-
flex-direction: column
|
|
24
|
-
overflow: auto
|
|
25
|
-
gap: calc(50 / 2160 * 100%)
|
|
26
|
-
height: 100%
|
|
27
|
-
z-index: 3100
|
|
28
|
-
|
|
29
|
-
&-button
|
|
30
|
-
line-height: 125%
|
|
31
|
-
opacity: 0.5
|
|
32
|
-
color: white
|
|
33
|
-
text-align: center
|
|
34
|
-
font-family: 'Montserrat'
|
|
35
|
-
transition: color 300ms, text-shadow 300ms
|
|
36
|
-
color: rgba(255,255,255,0.6)
|
|
37
|
-
text-shadow: initial
|
|
38
|
-
|
|
39
|
-
&:not(&_isDisabled)
|
|
40
|
-
cursor: pointer
|
|
41
|
-
opacity: 1
|
|
42
|
-
|
|
43
|
-
&_isCurrent,
|
|
44
|
-
&:not(&_isDisabled):hover
|
|
45
|
-
color: rgba(255,255,255,0.85)
|
|
46
|
-
text-shadow: 0px 5px 25px rgba(255,255,255,0.75)
|
package/view/media/triangle.svg
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<svg width="3840" height="2160" viewBox="0 0 3840 2160" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<defs>
|
|
4
|
-
<clipPath id="clip_path_1">
|
|
5
|
-
<rect width="3840" height="2160" />
|
|
6
|
-
</clipPath>
|
|
7
|
-
</defs>
|
|
8
|
-
<g clip-path="url(#clip_path_1)">
|
|
9
|
-
<rect width="3840" height="2160" fill="#FFFFFF" fill-rule="evenodd" fill-opacity="0" />
|
|
10
|
-
<g fill="#512DA8" fill-rule="evenodd" fill-opacity="0" transform="translate(734 -423)">
|
|
11
|
-
<path id="Треугольник" d="M0 0L2257.32 753.47L753.469 2257.32L0 0Z" />
|
|
12
|
-
<path d="M0.395996 1.1864L753.116 2256.26L753.469 2257.32L754.26 2256.53L2256.53 754.261L2257.32 753.47L2256.26 753.116L1.1864 0.396027L0 0L0.395996 1.1864ZM1.5824 1.58243L753.906 2255.47L2255.47 753.907L1.5824 1.58243Z" fill="#FFFFFF" fill-rule="evenodd" fill-opacity="0.251" />
|
|
13
|
-
</g>
|
|
14
|
-
<g fill="#512DA8" fill-rule="evenodd" fill-opacity="0" transform="translate(734 327)">
|
|
15
|
-
<path id="Треугольник" d="M2257.32 0L0 753.47L1503.85 2257.32L2257.32 0Z" />
|
|
16
|
-
<path d="M2257.32 0L2256.14 0.395996L1.0603 753.116L0 753.47L0.790466 754.261L1503.06 2256.53L1503.85 2257.32L1504.21 2256.26L2256.93 1.18643L2257.32 0ZM2255.74 1.58243L1503.42 2255.47L1.85077 753.907L2255.74 1.58243Z" fill="#FFFFFF" fill-rule="evenodd" fill-opacity="0.251" />
|
|
17
|
-
</g>
|
|
18
|
-
<g fill="#512DA8" fill-rule="evenodd" fill-opacity="0" transform="translate(0 415)">
|
|
19
|
-
<path id="Треугольник" d="M0 1063.38L3840 2126.77L3840 0L0 1063.38Z" />
|
|
20
|
-
<path d="M1.87353 1063.9L0 1063.38L1.87353 1062.87L3839 0.276917L3840 0L3840 2126.77L3839 2126.49L1.87353 1063.9ZM3.74707 1063.38L3839 2125.45L3839 1.31458L3.74707 1063.38Z" fill="#FFFFFF" fill-rule="evenodd" fill-opacity="0.251" />
|
|
21
|
-
</g>
|
|
22
|
-
</g>
|
|
23
|
-
</svg>
|