@vnejs/plugins.views.screens.mainmenu.socials 0.1.2 → 0.1.3
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/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modules/controller.d.ts +15 -0
- package/dist/modules/controller.js +22 -0
- package/dist/modules/view.d.ts +10 -0
- package/dist/modules/view.js +9 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +1 -0
- package/dist/utils/mainmenu.socials.d.ts +13 -0
- package/dist/utils/mainmenu.socials.js +1 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +11 -0
- package/package.json +38 -6
- package/src/index.ts +7 -0
- package/src/modules/controller.ts +41 -0
- package/src/modules/view.ts +21 -0
- package/src/types.ts +22 -0
- package/src/utils/mainmenu.socials.ts +16 -0
- package/src/view/index.tsx +51 -0
- package/tsconfig.json +10 -0
- package/const/const.js +0 -5
- package/const/events.js +0 -3
- package/const/params.js +0 -7
- package/index.js +0 -10
- package/modules/controller.js +0 -28
- package/modules/view.js +0 -13
- package/view/index.jsx +0 -41
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.mainmenu.socials.contract";
|
|
3
|
+
import { MainMenuSocialsController } from "./modules/controller.js";
|
|
4
|
+
import { MainMenuSocialsView } from "./modules/view.js";
|
|
5
|
+
regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [MainMenuSocialsController, MainMenuSocialsView]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { MainMenuSocialsPluginConstants, MainMenuSocialsPluginEvents, MainMenuSocialsPluginParams, MainMenuSocialsPluginSettings } from "../types.js";
|
|
3
|
+
import type { MainMenuSocialsMapItemPayload, MainMenuSocialsPluginState, MainMenuSocialsViewItem } from "../utils/mainmenu.socials.js";
|
|
4
|
+
export declare class MainMenuSocialsController extends ModuleController<MainMenuSocialsPluginEvents, MainMenuSocialsPluginConstants, MainMenuSocialsPluginSettings, MainMenuSocialsPluginParams, MainMenuSocialsPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
updateEvent: "vne:mainmenu_socials:update";
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
beforeShow: () => Promise<void>;
|
|
9
|
+
getItems: () => Promise<(import("../utils/mainmenu.socials.js").MainMenuSocialsItem & {
|
|
10
|
+
mediaSrc?: string;
|
|
11
|
+
})[]>;
|
|
12
|
+
mapItems: ({ href, media }: MainMenuSocialsMapItemPayload) => Promise<MainMenuSocialsViewItem>;
|
|
13
|
+
loadIconMedia: (media: string) => Promise<HTMLImageElement>;
|
|
14
|
+
onMemoryCleared: () => Promise<false | unknown[] | undefined>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
export class MainMenuSocialsController extends ModuleController {
|
|
3
|
+
name = "mainmenu.socials.controller";
|
|
4
|
+
updateEvent = this.EVENTS.MAINMENU_SOCIALS_VIEW.UPDATE;
|
|
5
|
+
subscribe = () => {
|
|
6
|
+
this.on(this.EVENTS.MAINMENU.SHOW, this.onShow);
|
|
7
|
+
this.on(this.EVENTS.MAINMENU.HIDE, this.onHide);
|
|
8
|
+
this.on(this.EVENTS.STATE.CLEAR, this.onHideForce);
|
|
9
|
+
this.on(this.EVENTS.STATE.SET, this.onHideForce);
|
|
10
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
11
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.getItems);
|
|
12
|
+
};
|
|
13
|
+
beforeShow = async () => this.updateState({ items: await this.getItems() });
|
|
14
|
+
getItems = () => Promise.all(this.PARAMS.MAINMENU_SOCIALS_VIEW.ITEMS.map(this.mapItems));
|
|
15
|
+
mapItems = async ({ href, media }) => ({
|
|
16
|
+
href,
|
|
17
|
+
media,
|
|
18
|
+
mediaSrc: (await this.loadIconMedia(media)).src,
|
|
19
|
+
});
|
|
20
|
+
loadIconMedia = (media) => this.loadImageMedia(`socials/${media}`, "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY]);
|
|
21
|
+
onMemoryCleared = async () => this.state.isShow && this.updateStateAndViewFast({ items: await this.getItems() });
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import type { MainMenuSocialsPluginConstants, MainMenuSocialsPluginEvents, MainMenuSocialsPluginParams, MainMenuSocialsPluginSettings } from "../types.js";
|
|
3
|
+
import type { MainMenuSocialsPluginState } from "../utils/mainmenu.socials.js";
|
|
4
|
+
export declare class MainMenuSocialsView extends ModuleView<MainMenuSocialsPluginEvents, MainMenuSocialsPluginConstants, MainMenuSocialsPluginSettings, MainMenuSocialsPluginParams, MainMenuSocialsPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
animationTime: number;
|
|
7
|
+
updateEvent: "vne:mainmenu_socials:update";
|
|
8
|
+
renderFunc: import("@vnejs/module.components").ViewRenderFunc<MainMenuSocialsPluginState>;
|
|
9
|
+
updateHandler: (state?: MainMenuSocialsPluginState | undefined) => Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import { render } from "../view/index.js";
|
|
3
|
+
export class MainMenuSocialsView extends ModuleView {
|
|
4
|
+
name = "mainmenu.socials.view";
|
|
5
|
+
animationTime = this.PARAMS.MAINMENU.TRANSITION;
|
|
6
|
+
updateEvent = this.EVENTS.MAINMENU_SOCIALS_VIEW.UPDATE;
|
|
7
|
+
renderFunc = render;
|
|
8
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
9
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/plugins.canvas.layer.contract";
|
|
3
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
|
|
4
|
+
import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/plugins.core.state.contract";
|
|
5
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
6
|
+
import type { Params as MainMenuParams, PluginName as MainMenuPluginName, SubscribeEvents as MainMenuSubscribeEvents } from "@vnejs/plugins.views.screens.mainmenu.contract";
|
|
7
|
+
import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.mainmenu.socials.contract";
|
|
8
|
+
export type MainMenuSocialsPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<MainMenuPluginName, MainMenuSubscribeEvents> & Record<StatePluginName, StateSubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents>;
|
|
9
|
+
export type MainMenuSocialsPluginConstants = ModuleComponentsConstants & Record<PluginName, Constants>;
|
|
10
|
+
export type MainMenuSocialsPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
11
|
+
export type MainMenuSocialsPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<MainMenuPluginName, MainMenuParams>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MainMenuSocialsItem = {
|
|
2
|
+
href: string;
|
|
3
|
+
media: string;
|
|
4
|
+
};
|
|
5
|
+
export type MainMenuSocialsPluginState = {
|
|
6
|
+
isShow: boolean;
|
|
7
|
+
isForce: boolean;
|
|
8
|
+
items?: MainMenuSocialsViewItem[];
|
|
9
|
+
};
|
|
10
|
+
export type MainMenuSocialsViewItem = MainMenuSocialsItem & {
|
|
11
|
+
mediaSrc?: string;
|
|
12
|
+
};
|
|
13
|
+
export type MainMenuSocialsMapItemPayload = MainMenuSocialsItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { Flex, Icon, View, createRenderFunc, useMemo, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
const iconOnClick = (href) => void window.open(String(href ?? ""), "_blank");
|
|
5
|
+
const renderOneIcon = ({ href = "", mediaSrc = "", propsIcon = {} }) => (_createElement(Icon, { ...propsIcon, key: mediaSrc, src: mediaSrc, isDisabled: !href, opacity: !href ? 0.5 : null, onClick: iconOnClick, value: href }));
|
|
6
|
+
const MainMenuSocials = ({ store, onMount, PARAMS }) => {
|
|
7
|
+
const { isShow = false, isForce = false, items = [] } = useStoreState(store, onMount);
|
|
8
|
+
const itemsWithProps = useMemo(() => items.map((item) => ({ ...item, propsIcon: PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.icon })), [items, PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.icon]);
|
|
9
|
+
return (_jsx(View, { ...PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.position, isShow: isShow, isForce: isForce, transition: PARAMS.MAINMENU.TRANSITION, zIndex: PARAMS.MAINMENU.ZINDEX + 100, children: _jsx(Flex, { ...PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.flex, children: itemsWithProps.map(renderOneIcon) }) }));
|
|
10
|
+
};
|
|
11
|
+
export const render = createRenderFunc(MainMenuSocials);
|
package/package.json
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.views.screens.mainmenu.socials",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
5
20
|
"scripts": {
|
|
6
21
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
7
23
|
"publish:major:plugin": "npm run publish:major",
|
|
8
24
|
"publish:minor:plugin": "npm run publish:minor",
|
|
9
25
|
"publish:patch:plugin": "npm run publish:patch",
|
|
10
|
-
"publish:major": "
|
|
11
|
-
"publish:minor": "
|
|
12
|
-
"publish:patch": "
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
13
29
|
},
|
|
14
30
|
"author": "",
|
|
15
31
|
"license": "ISC",
|
|
16
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/plugins.views.screens.mainmenu.socials.contract": "~0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/module": "~0.0.1",
|
|
37
|
+
"@vnejs/module.components": "~0.0.1",
|
|
38
|
+
"@vnejs/plugins.canvas.layer.contract": "~0.0.1",
|
|
39
|
+
"@vnejs/plugins.core.memory.contract": "~0.0.1",
|
|
40
|
+
"@vnejs/plugins.core.state.contract": "~0.0.1",
|
|
41
|
+
"@vnejs/plugins.core.system.contract": "~0.0.1",
|
|
42
|
+
"@vnejs/plugins.views.screens.mainmenu.contract": "~0.0.1",
|
|
43
|
+
"@vnejs/shared": "~0.0.9",
|
|
44
|
+
"@vnejs/uis.react": "~0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vnejs/configs.ts-common": "~0.0.1"
|
|
48
|
+
}
|
|
17
49
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.mainmenu.socials.contract";
|
|
3
|
+
|
|
4
|
+
import { MainMenuSocialsController } from "./modules/controller.js";
|
|
5
|
+
import { MainMenuSocialsView } from "./modules/view.js";
|
|
6
|
+
|
|
7
|
+
regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [MainMenuSocialsController, MainMenuSocialsView]);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type { MainMenuSocialsPluginConstants, MainMenuSocialsPluginEvents, MainMenuSocialsPluginParams, MainMenuSocialsPluginSettings } from "../types.js";
|
|
4
|
+
import type { MainMenuSocialsMapItemPayload, MainMenuSocialsPluginState, MainMenuSocialsViewItem } from "../utils/mainmenu.socials.js";
|
|
5
|
+
|
|
6
|
+
export class MainMenuSocialsController extends ModuleController<
|
|
7
|
+
MainMenuSocialsPluginEvents,
|
|
8
|
+
MainMenuSocialsPluginConstants,
|
|
9
|
+
MainMenuSocialsPluginSettings,
|
|
10
|
+
MainMenuSocialsPluginParams,
|
|
11
|
+
MainMenuSocialsPluginState
|
|
12
|
+
> {
|
|
13
|
+
name = "mainmenu.socials.controller";
|
|
14
|
+
|
|
15
|
+
updateEvent = this.EVENTS.MAINMENU_SOCIALS_VIEW.UPDATE;
|
|
16
|
+
|
|
17
|
+
subscribe = () => {
|
|
18
|
+
this.on(this.EVENTS.MAINMENU.SHOW, this.onShow);
|
|
19
|
+
this.on(this.EVENTS.MAINMENU.HIDE, this.onHide);
|
|
20
|
+
|
|
21
|
+
this.on(this.EVENTS.STATE.CLEAR, this.onHideForce);
|
|
22
|
+
this.on(this.EVENTS.STATE.SET, this.onHideForce);
|
|
23
|
+
|
|
24
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
25
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.getItems);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
beforeShow = async () => this.updateState({ items: await this.getItems() });
|
|
29
|
+
|
|
30
|
+
getItems = () => Promise.all(this.PARAMS.MAINMENU_SOCIALS_VIEW.ITEMS.map(this.mapItems));
|
|
31
|
+
|
|
32
|
+
mapItems = async ({ href, media }: MainMenuSocialsMapItemPayload): Promise<MainMenuSocialsViewItem> => ({
|
|
33
|
+
href,
|
|
34
|
+
media,
|
|
35
|
+
mediaSrc: (await this.loadIconMedia(media)).src,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
loadIconMedia = (media: string) => this.loadImageMedia(`socials/${media}`, "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY]);
|
|
39
|
+
|
|
40
|
+
onMemoryCleared = async () => this.state.isShow && this.updateStateAndViewFast({ items: await this.getItems() });
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import { render } from "../view/index.js";
|
|
4
|
+
import type { MainMenuSocialsPluginConstants, MainMenuSocialsPluginEvents, MainMenuSocialsPluginParams, MainMenuSocialsPluginSettings } from "../types.js";
|
|
5
|
+
import type { MainMenuSocialsPluginState } from "../utils/mainmenu.socials.js";
|
|
6
|
+
|
|
7
|
+
export class MainMenuSocialsView extends ModuleView<
|
|
8
|
+
MainMenuSocialsPluginEvents,
|
|
9
|
+
MainMenuSocialsPluginConstants,
|
|
10
|
+
MainMenuSocialsPluginSettings,
|
|
11
|
+
MainMenuSocialsPluginParams,
|
|
12
|
+
MainMenuSocialsPluginState
|
|
13
|
+
> {
|
|
14
|
+
name = "mainmenu.socials.view";
|
|
15
|
+
|
|
16
|
+
animationTime = this.PARAMS.MAINMENU.TRANSITION;
|
|
17
|
+
updateEvent = this.EVENTS.MAINMENU_SOCIALS_VIEW.UPDATE;
|
|
18
|
+
|
|
19
|
+
renderFunc = render;
|
|
20
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
21
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/plugins.canvas.layer.contract";
|
|
3
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
|
|
4
|
+
import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/plugins.core.state.contract";
|
|
5
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
6
|
+
import type { Params as MainMenuParams, PluginName as MainMenuPluginName, SubscribeEvents as MainMenuSubscribeEvents } from "@vnejs/plugins.views.screens.mainmenu.contract";
|
|
7
|
+
import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.mainmenu.socials.contract";
|
|
8
|
+
|
|
9
|
+
export type MainMenuSocialsPluginEvents = ModuleComponentsEvents &
|
|
10
|
+
Record<PluginName, SubscribeEvents> &
|
|
11
|
+
Record<MainMenuPluginName, MainMenuSubscribeEvents> &
|
|
12
|
+
Record<StatePluginName, StateSubscribeEvents> &
|
|
13
|
+
Record<SystemPluginName, SystemSubscribeEvents> &
|
|
14
|
+
Record<MemoryPluginName, MemorySubscribeEvents>;
|
|
15
|
+
|
|
16
|
+
export type MainMenuSocialsPluginConstants = ModuleComponentsConstants & Record<PluginName, Constants>;
|
|
17
|
+
|
|
18
|
+
export type MainMenuSocialsPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
19
|
+
|
|
20
|
+
export type MainMenuSocialsPluginParams = ModuleComponentsParams &
|
|
21
|
+
Record<PluginName, Params> &
|
|
22
|
+
Record<MainMenuPluginName, MainMenuParams>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type MainMenuSocialsItem = {
|
|
2
|
+
href: string;
|
|
3
|
+
media: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type MainMenuSocialsPluginState = {
|
|
7
|
+
isShow: boolean;
|
|
8
|
+
isForce: boolean;
|
|
9
|
+
items?: MainMenuSocialsViewItem[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type MainMenuSocialsViewItem = MainMenuSocialsItem & {
|
|
13
|
+
mediaSrc?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type MainMenuSocialsMapItemPayload = MainMenuSocialsItem;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ViewRenderFunc } from "@vnejs/module.components";
|
|
2
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
3
|
+
import { Flex, Icon, View, createRenderFunc, useMemo, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import type { MainMenuSocialsPluginConstants, MainMenuSocialsPluginEvents, MainMenuSocialsPluginParams, MainMenuSocialsPluginSettings } from "../types.js";
|
|
6
|
+
import type { MainMenuSocialsPluginState, MainMenuSocialsViewItem } from "../utils/mainmenu.socials.js";
|
|
7
|
+
|
|
8
|
+
type MainMenuSocialsComponentProps = ReactComponentProps<
|
|
9
|
+
MainMenuSocialsPluginEvents,
|
|
10
|
+
MainMenuSocialsPluginConstants,
|
|
11
|
+
MainMenuSocialsPluginSettings,
|
|
12
|
+
MainMenuSocialsPluginParams,
|
|
13
|
+
MainMenuSocialsPluginState
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
const iconOnClick = (href?: unknown) => void window.open(String(href ?? ""), "_blank");
|
|
17
|
+
|
|
18
|
+
const renderOneIcon = ({ href = "", mediaSrc = "", propsIcon = {} }: MainMenuSocialsViewItem & { propsIcon: Record<string, unknown> }) => (
|
|
19
|
+
<Icon
|
|
20
|
+
{...propsIcon}
|
|
21
|
+
key={mediaSrc}
|
|
22
|
+
src={mediaSrc}
|
|
23
|
+
isDisabled={!href}
|
|
24
|
+
opacity={!href ? 0.5 : null}
|
|
25
|
+
onClick={iconOnClick}
|
|
26
|
+
value={href}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const MainMenuSocials = ({ store, onMount, PARAMS }: MainMenuSocialsComponentProps) => {
|
|
31
|
+
const { isShow = false, isForce = false, items = [] } = useStoreState<MainMenuSocialsPluginState>(store, onMount);
|
|
32
|
+
|
|
33
|
+
const itemsWithProps = useMemo(
|
|
34
|
+
() => items.map((item) => ({ ...item, propsIcon: PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.icon })),
|
|
35
|
+
[items, PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.icon],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View
|
|
40
|
+
{...PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.position}
|
|
41
|
+
isShow={isShow}
|
|
42
|
+
isForce={isForce}
|
|
43
|
+
transition={PARAMS.MAINMENU.TRANSITION}
|
|
44
|
+
zIndex={PARAMS.MAINMENU.ZINDEX + 100}
|
|
45
|
+
>
|
|
46
|
+
<Flex {...PARAMS.MAINMENU_SOCIALS_VIEW.VIEW_PROPS.flex}>{itemsWithProps.map(renderOneIcon)}</Flex>
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const render: ViewRenderFunc<MainMenuSocialsPluginState> = createRenderFunc(MainMenuSocials);
|
package/tsconfig.json
ADDED
package/const/const.js
DELETED
package/const/events.js
DELETED
package/const/params.js
DELETED
package/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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]);
|
package/modules/controller.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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/view/index.jsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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} />);
|