@vnejs/plugins.views.screens.mainmenu.socials 0.1.2
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/const/const.js +5 -0
- package/const/events.js +3 -0
- package/const/params.js +7 -0
- package/index.js +10 -0
- package/modules/controller.js +28 -0
- package/modules/view.js +13 -0
- package/package.json +17 -0
- package/view/index.jsx +41 -0
package/const/const.js
ADDED
package/const/events.js
ADDED
package/const/params.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
|
|
3
|
+
import * as constants from "./const/const";
|
|
4
|
+
import { SUBSCRIBE_EVENTS } from "./const/events";
|
|
5
|
+
import * as params from "./const/params";
|
|
6
|
+
|
|
7
|
+
import { MainMenuSocials } from "./modules/controller";
|
|
8
|
+
import { MainMenuSocialsView } from "./modules/view";
|
|
9
|
+
|
|
10
|
+
regPlugin("MAINMENU_SOCIALS_VIEW", { constants, events: SUBSCRIBE_EVENTS, params }, [MainMenuSocials, MainMenuSocialsView]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
export class MainMenuSocials extends ModuleController {
|
|
4
|
+
name = "mainmenu.socials.controller";
|
|
5
|
+
|
|
6
|
+
updateEvent = this.EVENTS.MAINMENU_SOCIALS_VIEW.UPDATE;
|
|
7
|
+
|
|
8
|
+
subscribe = () => {
|
|
9
|
+
this.on(this.EVENTS.MAINMENU.SHOW, this.onShow);
|
|
10
|
+
this.on(this.EVENTS.MAINMENU.HIDE, this.onHide);
|
|
11
|
+
|
|
12
|
+
this.on(this.EVENTS.STATE.CLEAR, this.onHideForce);
|
|
13
|
+
this.on(this.EVENTS.STATE.SET, this.onHideForce);
|
|
14
|
+
|
|
15
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
16
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.getItems);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
beforeShow = async () => this.updateState({ items: await this.getItems() });
|
|
20
|
+
|
|
21
|
+
getItems = () => Promise.all(this.PARAMS.MAINMENU_SOCIALS_VIEW.ITEMS.map(this.mapItems));
|
|
22
|
+
|
|
23
|
+
mapItems = async ({ href, media }) => ({ href, mediaSrc: (await this.loadIconMedia(media)).src });
|
|
24
|
+
|
|
25
|
+
loadIconMedia = (media) => this.loadImageMedia(`socials/${media}`, "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY]);
|
|
26
|
+
|
|
27
|
+
onMemoryCleared = async () => this.state.isShow && this.updateStateAndViewFast({ items: await this.getItems() });
|
|
28
|
+
}
|
package/modules/view.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import { render } from "../view";
|
|
4
|
+
|
|
5
|
+
export class MainMenuSocialsView extends ModuleView {
|
|
6
|
+
name = "mainmenu.socials.view";
|
|
7
|
+
|
|
8
|
+
animationTime = this.PARAMS.MAINMENU.TRANSITION;
|
|
9
|
+
updateEvent = this.EVENTS.MAINMENU_SOCIALS_VIEW.UPDATE;
|
|
10
|
+
|
|
11
|
+
renderFunc = render;
|
|
12
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/plugins.views.screens.mainmenu.socials",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
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",
|
|
10
|
+
"publish:major": "npm version major && npm publish --access public",
|
|
11
|
+
"publish:minor": "npm version minor && npm publish --access public",
|
|
12
|
+
"publish:patch": "npm version patch && npm publish --access public"
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"description": ""
|
|
17
|
+
}
|
package/view/index.jsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
|
|
4
|
+
import { Flex, Icon, View } from "@vnejs/uis.react";
|
|
5
|
+
|
|
6
|
+
const iconOnClick = (href = "") => window.open(href, "_blank");
|
|
7
|
+
|
|
8
|
+
const renderOneIcon = ({ href = "", mediaSrc = "", propsIcon = {} } = {}) => (
|
|
9
|
+
<Icon
|
|
10
|
+
{...propsIcon}
|
|
11
|
+
key={mediaSrc}
|
|
12
|
+
src={mediaSrc}
|
|
13
|
+
isDisabled={!href}
|
|
14
|
+
opacity={!href ? 0.5 : null}
|
|
15
|
+
onClick={iconOnClick}
|
|
16
|
+
value={href}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const MainMenuSocials = ({ store, onMount, ...props } = {}) => {
|
|
21
|
+
const [{ isShow = false, isForce = false, items = [] }, setState] = useState({});
|
|
22
|
+
|
|
23
|
+
useEffect(() => store.subscribe(setState), []);
|
|
24
|
+
useEffect(() => void onMount(), []);
|
|
25
|
+
|
|
26
|
+
const itemsWithProps = useMemo(() => items.map((item) => ({ ...item, propsIcon: props.PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.icon })), [items]);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<View
|
|
30
|
+
{...props.PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.position}
|
|
31
|
+
isShow={isShow}
|
|
32
|
+
isForce={isForce}
|
|
33
|
+
transition={props.PARAMS.MAINMENU.TRANSITION}
|
|
34
|
+
zIndex={props.PARAMS.MAINMENU.ZINDEX + 100}
|
|
35
|
+
>
|
|
36
|
+
<Flex {...props.PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.flex}>{itemsWithProps.map(renderOneIcon)}</Flex>
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const render = (props, root) => createRoot(root).render(<MainMenuSocials {...props} />);
|