@ludo.ninja/components 2.1.36 → 2.1.38

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.
@@ -5,129 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const link_1 = __importDefault(require("next/link"));
8
- const styled_components_1 = __importDefault(require("styled-components"));
9
- const sidebar_1 = require("@ludo.ninja/ui/build/components/sidebar");
10
- const MainButton_1 = __importDefault(require("@ludo.ninja/ui/build/system/Buttons/MainButton"));
11
- const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
12
- const data_1 = require("./data");
13
- const sidebarInviteCodeLabel_1 = __importDefault(require("./sidebarInviteCodeLabel"));
14
- const useSignOut_1 = require("../../modules/user/auth/useSignOut");
15
- const store_1 = require("../../modules/user/store");
16
- const ui_1 = require("../../store/ui");
17
- const ScreenWidth_1 = require("../../styles/ScreenWidth");
8
+ const sidebarSpa_1 = require("./sidebarSpa");
18
9
  const Userpic_1 = __importDefault(require("../../system/Img/Userpic"));
19
- const scale_1 = require("../../utils/adaptive/scale");
20
- const auth_1 = require("../../utils/auth");
21
- const screen_1 = require("../../utils/screen");
22
- const useExtension_1 = __importDefault(require("../../hooks/extension/useExtension"));
23
- const MenuItem = styled_components_1.default.div `
24
- font-size: 15px;
25
- font-weight: 500;
26
- line-height: 22px;
27
- display: flex;
28
- gap: 8px;
29
- align-items: center;
30
- padding: 12px 4px;
31
- text-indent: 4px;
32
- border-radius: 4px;
33
- cursor: pointer;
34
- color: ${({ theme }) => theme.colors.secondaryText};
35
-
36
- ${ScreenWidth_1.mediaQuery.mobile} {
37
- font-size: 14px;
38
- line-height: 20px;
39
- }
40
-
41
- transition: background-color 0.3s ease-in-out;
42
-
43
- @media (hover: hover) {
44
- &:hover {
45
- transition: background-color 0.3s ease-in;
46
- background-color: ${({ theme }) => theme.colors.secondaryBg};
47
- }
48
- }
49
-
50
- ${ScreenWidth_1.mediaQuery.minWidthFourK} {
51
- font-size: ${(0, _4k_1.adaptiveValueCalc)(15)};
52
- line-height: ${(0, _4k_1.adaptiveValueCalc)(22)};
53
- gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
54
- padding: ${(0, _4k_1.adaptiveValueCalc)(12)} ${(0, _4k_1.adaptiveValueCalc)(4)};
55
- text-indent: ${(0, _4k_1.adaptiveValueCalc)(4)};
56
- border-radius: ${(0, _4k_1.adaptiveValueCalc)(4)};
57
-
58
- img {
59
- width: ${(0, _4k_1.adaptiveValueCalc)(20)};
60
- height: ${(0, _4k_1.adaptiveValueCalc)(20)};
61
- }
62
- }
63
- `;
64
- const BeforeMenuContainer = styled_components_1.default.div `
65
- padding: 12px 0;
66
- border-bottom: 1px solid ${({ theme }) => theme.colors.divider};
67
-
68
- ${ScreenWidth_1.mediaQuery.minWidthFourK} {
69
- padding: ${(0, _4k_1.adaptiveValueCalc)(12)} 0;
70
- border-bottom: ${(0, _4k_1.adaptiveValueCalc)(1)} solid ${({ theme }) => theme.colors.divider};
71
- }
72
- `;
73
- const SLink = (0, styled_components_1.default)(link_1.default) `
74
- &:not(:last-child) svg path {
75
- fill: ${({ theme }) => theme.colors.sidebarSvgPathFill};
76
- }
77
-
78
- .icon-wrapper {
79
- width: 20px;
80
- height: 20px;
81
- display: flex;
82
- align-items: center;
83
- justify-content: center;
84
-
85
- ${ScreenWidth_1.mediaQuery.minWidthFourK} {
86
- width: ${(0, _4k_1.adaptiveValueCalc)(20)};
87
- height: ${(0, _4k_1.adaptiveValueCalc)(20)};
88
-
89
- svg {
90
- transform: ${(props) => "transform" in props.scale && props.scale.transform};
91
- }
92
- }
93
- }
94
- `;
95
- // Component
10
+ const sidebarInviteCodeLabel_1 = __importDefault(require("./sidebarInviteCodeLabel"));
96
11
  const Sidebar = () => {
97
- const redirectToLoginWindow = (0, auth_1.useRedirectToLoginWindow)();
98
- const closeSidebar = (0, ui_1.useUiStore)((state) => state.closeSidebar);
99
- const isSidebarOpen = (0, ui_1.useUiStore)((state) => state.isSidebarOpen);
100
- const isAuthorized = (0, store_1.useUserStore)((state) => state.isSignedIn);
101
- const getUser = (0, store_1.useUserStore)((state) => state.user);
102
- const signOut = (0, useSignOut_1.useSignOut)();
103
- const { deviceType } = (0, screen_1.useWindowDimensions)();
104
- const { isExtensionInstalled, openExtensionChromeStorePage, openExtension } = (0, useExtension_1.default)();
105
- const { wallets, userId } = getUser ?? [""];
106
- // Todo fav-list
107
- const sideBarData = (0, data_1.useSidebarData)();
108
- const { windowDimensions } = (0, screen_1.useWindowDimensionsWithServerInitial)();
109
- return ((0, jsx_runtime_1.jsx)(sidebar_1.Sidebar, { closeSidebar: closeSidebar, isOpen: isSidebarOpen, handle: {
110
- login: () => {
111
- closeSidebar();
112
- redirectToLoginWindow();
113
- },
114
- logout: signOut,
115
- }, isAuthorized: isAuthorized, userWallets: wallets, slots: {
116
- menu: sideBarData.map(({ title, href, icon, isExternalUrl }) => ((0, jsx_runtime_1.jsxs)(SLink, { href: href, target: isExternalUrl ? "_blank" : "_self", onClick: closeSidebar, passHref: isExternalUrl, scale: (0, scale_1.getAdaptiveScale)({ windowDimensions, currentSize: 1 }), children: [(0, jsx_runtime_1.jsx)("span", { className: "icon-wrapper", children: icon }), title] }, title))),
117
- userPicture: ({ children, height, width, isNeedBoxTransform }) => ((0, jsx_runtime_1.jsx)(Userpic_1.default, { width: width, height: height, userId: userId, isNeedBoxTransform: isNeedBoxTransform, children: children })),
118
- inviteCode: (0, jsx_runtime_1.jsx)(sidebarInviteCodeLabel_1.default, {}),
119
- ...(deviceType == "isDesktop" && isAuthorized
120
- ? {
121
- beforeMenu: ((0, jsx_runtime_1.jsx)(BeforeMenuContainer, { children: isExtensionInstalled ? ((0, jsx_runtime_1.jsxs)(MenuItem, { onClick: () => {
122
- closeSidebar();
123
- openExtension();
124
- }, children: [(0, jsx_runtime_1.jsx)("img", { src: "/sidebar/ludoX.svg", alt: "Ludo X", width: 20, height: 20 }), "Open Ludo X"] })) : ((0, jsx_runtime_1.jsx)("div", { style: { padding: "12px 0" }, children: (0, jsx_runtime_1.jsx)(MainButton_1.default, { onClick: () => {
125
- closeSidebar();
126
- openExtensionChromeStorePage();
127
- }, text: "Install Ludo X now", variant: "primaryM" }) })) })),
128
- }
129
- : {}),
130
- } }));
12
+ return ((0, jsx_runtime_1.jsx)(sidebarSpa_1.SidebarSpa, { SLink: (0, sidebarSpa_1.SLinkStyles)(link_1.default), UserPic: Userpic_1.default, SidebarInviteCodeLabel: sidebarInviteCodeLabel_1.default }));
131
13
  };
132
14
  // Export
133
15
  exports.default = Sidebar;
@@ -0,0 +1,10 @@
1
+ export declare const SLinkStyles: (Link: any) => import("styled-components").StyledComponent<any, import("styled-components").DefaultTheme, {
2
+ scale: {
3
+ transform: string;
4
+ } | object;
5
+ }, string | number | symbol>;
6
+ export declare const SidebarSpa: ({ SLink, UserPic, SidebarInviteCodeLabel }: {
7
+ SLink: any;
8
+ UserPic: any;
9
+ SidebarInviteCodeLabel: any;
10
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SidebarSpa = exports.SLinkStyles = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const sidebar_1 = require("@ludo.ninja/ui/build/components/sidebar");
10
+ const MainButton_1 = __importDefault(require("@ludo.ninja/ui/build/system/Buttons/MainButton"));
11
+ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
12
+ const data_1 = require("./data");
13
+ const useSignOut_1 = require("../../modules/user/auth/useSignOut");
14
+ const store_1 = require("../../modules/user/store");
15
+ const ui_1 = require("../../store/ui");
16
+ const ScreenWidth_1 = require("../../styles/ScreenWidth");
17
+ const scale_1 = require("../../utils/adaptive/scale");
18
+ const auth_1 = require("../../utils/auth");
19
+ const screen_1 = require("../../utils/screen");
20
+ const useExtension_1 = __importDefault(require("../../hooks/extension/useExtension"));
21
+ const MenuItem = styled_components_1.default.div `
22
+ font-size: 15px;
23
+ font-weight: 500;
24
+ line-height: 22px;
25
+ display: flex;
26
+ gap: 8px;
27
+ align-items: center;
28
+ padding: 12px 4px;
29
+ text-indent: 4px;
30
+ border-radius: 4px;
31
+ cursor: pointer;
32
+ color: ${({ theme }) => theme.colors.secondaryText};
33
+
34
+ ${ScreenWidth_1.mediaQuery.mobile} {
35
+ font-size: 14px;
36
+ line-height: 20px;
37
+ }
38
+
39
+ transition: background-color 0.3s ease-in-out;
40
+
41
+ @media (hover: hover) {
42
+ &:hover {
43
+ transition: background-color 0.3s ease-in;
44
+ background-color: ${({ theme }) => theme.colors.secondaryBg};
45
+ }
46
+ }
47
+
48
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
49
+ font-size: ${(0, _4k_1.adaptiveValueCalc)(15)};
50
+ line-height: ${(0, _4k_1.adaptiveValueCalc)(22)};
51
+ gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
52
+ padding: ${(0, _4k_1.adaptiveValueCalc)(12)} ${(0, _4k_1.adaptiveValueCalc)(4)};
53
+ text-indent: ${(0, _4k_1.adaptiveValueCalc)(4)};
54
+ border-radius: ${(0, _4k_1.adaptiveValueCalc)(4)};
55
+
56
+ img {
57
+ width: ${(0, _4k_1.adaptiveValueCalc)(20)};
58
+ height: ${(0, _4k_1.adaptiveValueCalc)(20)};
59
+ }
60
+ }
61
+ `;
62
+ const BeforeMenuContainer = styled_components_1.default.div `
63
+ padding: 12px 0;
64
+ border-bottom: 1px solid ${({ theme }) => theme.colors.divider};
65
+
66
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
67
+ padding: ${(0, _4k_1.adaptiveValueCalc)(12)} 0;
68
+ border-bottom: ${(0, _4k_1.adaptiveValueCalc)(1)} solid ${({ theme }) => theme.colors.divider};
69
+ }
70
+ `;
71
+ const SLinkStyles = (Link) => (0, styled_components_1.default)(Link) `
72
+ &:not(:last-child) svg path {
73
+ fill: ${({ theme }) => theme.colors.sidebarSvgPathFill};
74
+ }
75
+
76
+ .icon-wrapper {
77
+ width: 20px;
78
+ height: 20px;
79
+ display: flex;
80
+ align-items: center;
81
+ justify-content: center;
82
+
83
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
84
+ width: ${(0, _4k_1.adaptiveValueCalc)(20)};
85
+ height: ${(0, _4k_1.adaptiveValueCalc)(20)};
86
+
87
+ svg {
88
+ transform: ${(props) => "transform" in props.scale && props.scale.transform};
89
+ }
90
+ }
91
+ }
92
+ `;
93
+ exports.SLinkStyles = SLinkStyles;
94
+ // Component
95
+ const SidebarSpa = ({ SLink, UserPic, SidebarInviteCodeLabel }) => {
96
+ const redirectToLoginWindow = (0, auth_1.useRedirectToLoginWindow)();
97
+ const closeSidebar = (0, ui_1.useUiStore)((state) => state.closeSidebar);
98
+ const isSidebarOpen = (0, ui_1.useUiStore)((state) => state.isSidebarOpen);
99
+ const isAuthorized = (0, store_1.useUserStore)((state) => state.isSignedIn);
100
+ const getUser = (0, store_1.useUserStore)((state) => state.user);
101
+ const signOut = (0, useSignOut_1.useSignOut)();
102
+ const { deviceType } = (0, screen_1.useWindowDimensions)();
103
+ const { isExtensionInstalled, openExtensionChromeStorePage, openExtension } = (0, useExtension_1.default)();
104
+ const { wallets, userId } = getUser ?? [""];
105
+ // Todo fav-list
106
+ const sideBarData = (0, data_1.useSidebarData)();
107
+ const { windowDimensions } = (0, screen_1.useWindowDimensionsWithServerInitial)();
108
+ return ((0, jsx_runtime_1.jsx)(sidebar_1.Sidebar, { closeSidebar: closeSidebar, isOpen: isSidebarOpen, handle: {
109
+ login: () => {
110
+ closeSidebar();
111
+ redirectToLoginWindow();
112
+ },
113
+ logout: signOut,
114
+ }, isAuthorized: isAuthorized, userWallets: wallets, slots: {
115
+ menu: sideBarData.map(({ title, href, icon, isExternalUrl }) => ((0, jsx_runtime_1.jsxs)(SLink, { href: href, target: isExternalUrl ? "_blank" : "_self", onClick: closeSidebar, passHref: isExternalUrl, scale: (0, scale_1.getAdaptiveScale)({ windowDimensions, currentSize: 1 }), children: [(0, jsx_runtime_1.jsx)("span", { className: "icon-wrapper", children: icon }), title] }, title))),
116
+ userPicture: ({ children, height, width, isNeedBoxTransform }) => ((0, jsx_runtime_1.jsx)(UserPic, { width: width, height: height, userId: userId, isNeedBoxTransform: isNeedBoxTransform, children: children })),
117
+ inviteCode: (0, jsx_runtime_1.jsx)(SidebarInviteCodeLabel, {}),
118
+ ...(deviceType == "isDesktop" && isAuthorized
119
+ ? {
120
+ beforeMenu: ((0, jsx_runtime_1.jsx)(BeforeMenuContainer, { children: isExtensionInstalled ? ((0, jsx_runtime_1.jsxs)(MenuItem, { onClick: () => {
121
+ closeSidebar();
122
+ openExtension();
123
+ }, children: [(0, jsx_runtime_1.jsx)("img", { src: "/sidebar/ludoX.svg", alt: "Ludo X", width: 20, height: 20 }), "Open Ludo X"] })) : ((0, jsx_runtime_1.jsx)("div", { style: { padding: "12px 0" }, children: (0, jsx_runtime_1.jsx)(MainButton_1.default, { onClick: () => {
124
+ closeSidebar();
125
+ openExtensionChromeStorePage();
126
+ }, text: "Install Ludo X now", variant: "primaryM" }) })) })),
127
+ }
128
+ : {}),
129
+ } }));
130
+ };
131
+ exports.SidebarSpa = SidebarSpa;
@@ -1,30 +1,17 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.AppLayout = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
5
  const styled_components_1 = require("styled-components");
9
- const browser_1 = __importDefault(require("@marker.io/browser"));
10
- const utils_1 = require("@ludo.ninja/utils");
11
- const react_1 = require("react");
12
6
  const ui_1 = require("../store/ui");
13
7
  const client_1 = require("@apollo/client");
14
8
  const apollo_1 = require("../hooks/apollo");
15
9
  const GlobalLayout_1 = require("./GlobalLayout");
16
10
  const store_1 = require("../modules/user/store");
17
11
  const index_1 = require("../store/index");
18
- const env_1 = require("../store/env");
19
12
  const AppLayout = ({ children, pageProps }) => {
20
13
  const apolloClient = (0, apollo_1.useApollo)(pageProps);
21
14
  const theme = (0, ui_1.useUiStore)((state) => state.theme);
22
- const NODE_ENV = (0, env_1.useEnvStore)(state => state.NODE_ENV);
23
- (0, react_1.useEffect)(() => {
24
- if (!utils_1.isServer && NODE_ENV === "production") {
25
- browser_1.default.loadWidget({ project: "65f2e310e9298c9dca4d4ca9" });
26
- }
27
- }, []);
28
15
  return ((0, jsx_runtime_1.jsx)(index_1.SSRProvider, { initialState: {
29
16
  isMobile: pageProps.isMobile,
30
17
  }, children: (0, jsx_runtime_1.jsx)(client_1.ApolloProvider, { client: apolloClient, children: (0, jsx_runtime_1.jsx)(styled_components_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(store_1.UserProvider, { initialState: {
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ declare const UserPicSpa: ({ userId, width, height, isNeedBoxTransform, children, Image, Link }: {
3
+ userId: string;
4
+ width: number;
5
+ height: number;
6
+ isNeedBoxTransform: boolean;
7
+ children?: React.ReactNode;
8
+ Image: any;
9
+ Link: any;
10
+ }) => import("react/jsx-runtime").JSX.Element;
11
+ export default UserPicSpa;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
9
+ const styled_components_1 = __importDefault(require("styled-components"));
10
+ const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
11
+ const store_1 = require("../../../modules/user/store");
12
+ const env_1 = require("../../../store/env");
13
+ const ScreenWidth_1 = require("../../../styles/ScreenWidth");
14
+ const boxTransform_1 = __importDefault(require("../../../styles/mixins/boxTransform"));
15
+ const ImageInterceptor_1 = require("../ImageInterceptor");
16
+ const useFetchUserPic_1 = __importDefault(require("../../../api/server-medias/queries/useFetchUserPic"));
17
+ const defaultUserpic_svg_1 = __importDefault(require("../../../public/defaultUserpics/defaultUserpic"));
18
+ const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
19
+ // Styles
20
+ const StyledHeaderUserPic = styled_components_1.default.div `
21
+ ${(props) => (props.isNeedBoxTransform ? boxTransform_1.default : null)}
22
+ .userPicBlock {
23
+ display: flex;
24
+ }
25
+
26
+ .userPicImage {
27
+ border-radius: 50%;
28
+ width: ${(props) => props.imageWidth};
29
+ height: ${(props) => props.imageHeight};
30
+
31
+ ${ScreenWidth_1.mediaQuery.minWidthFourK} {
32
+ width: ${(props) => (0, _4k_1.adaptiveValueCalc)(Number(props.imageWidth.replace('px', '')))};
33
+ height: ${(props) => (0, _4k_1.adaptiveValueCalc)(Number(props.imageHeight.replace('px', '')))};
34
+ }
35
+ }
36
+ `;
37
+ // Component
38
+ const UserPicSpa = ({ userId, width, height, isNeedBoxTransform, children, Image, Link }) => {
39
+ const getMediaENVDomain = (0, env_1.useEnvStore)((state) => state.getMediaDomain);
40
+ const { isSignedIn, isLoadingProfileData, profileData } = (0, store_1.useUserStore)((state) => ({
41
+ isSignedIn: state.isSignedIn,
42
+ isLoadingProfileData: state.isLoadingProfileData,
43
+ profileData: state.profileData,
44
+ }));
45
+ const { load, userPic, loading } = (0, useFetchUserPic_1.default)();
46
+ const profileUserPic = profileData
47
+ ?.getUserPic({
48
+ mediaDomain: getMediaENVDomain(),
49
+ })
50
+ .includes('1.svg')
51
+ ? null
52
+ : profileData?.getUserPic({
53
+ mediaDomain: getMediaENVDomain(),
54
+ });
55
+ (0, react_1.useEffect)(() => {
56
+ if (isSignedIn &&
57
+ !isLoadingProfileData &&
58
+ profileData
59
+ ?.getUserPic({
60
+ mediaDomain: getMediaENVDomain(),
61
+ })
62
+ .includes('1.svg')) {
63
+ load(userId);
64
+ }
65
+ }, [userId, isSignedIn, isLoadingProfileData, profileData]);
66
+ const renderDefaultUserPic = () => {
67
+ return (0, jsx_runtime_1.jsx)(defaultUserpic_svg_1.default, { className: 'userPicImage' });
68
+ };
69
+ const renderImage = () => {
70
+ return ((0, jsx_runtime_1.jsx)(ImageInterceptor_1.ImageInterceptor, { borderRadiusSkeleton: '50%', children: (0, jsx_runtime_1.jsx)(Image, { src: (profileUserPic || userPic), className: 'userPicImage', width: width, height: height, priority: true, alt: 'ludo ninja userPick' }) }));
71
+ };
72
+ const renderImageOrDefaultUserPic = () => {
73
+ return profileUserPic || userPic ? renderImage() : renderDefaultUserPic();
74
+ };
75
+ const renderSkeleton = () => {
76
+ return (0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { className: 'userPicImage' });
77
+ };
78
+ const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
79
+ return ((0, jsx_runtime_1.jsx)(StyledHeaderUserPic, { isNeedBoxTransform: isNeedBoxTransform, imageWidth: `${width}px`, imageHeight: `${height}px`, children: (0, jsx_runtime_1.jsxs)(Link, { href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["profile"]}/${userId}/nfts`, className: 'userPicBlock', children: [loading || isLoadingProfileData
80
+ ? renderSkeleton()
81
+ : renderImageOrDefaultUserPic(), children] }) }));
82
+ };
83
+ exports.default = UserPicSpa;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  declare const UserPic: ({ userId, width, height, isNeedBoxTransform, children, }: {
3
3
  userId: string;
4
4
  width: number;
@@ -4,83 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = require("react");
8
7
  const image_1 = __importDefault(require("next/image"));
9
8
  const link_1 = __importDefault(require("next/link"));
10
- const react_loading_skeleton_1 = __importDefault(require("react-loading-skeleton"));
11
- const styled_components_1 = __importDefault(require("styled-components"));
12
- const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
13
- const store_1 = require("../../../modules/user/store");
14
- const env_1 = require("../../../store/env");
15
- const ScreenWidth_1 = require("../../../styles/ScreenWidth");
16
- const boxTransform_1 = __importDefault(require("../../../styles/mixins/boxTransform"));
17
- const ImageInterceptor_1 = require("../ImageInterceptor");
18
- const useFetchUserPic_1 = __importDefault(require("../../../api/server-medias/queries/useFetchUserPic"));
19
- const defaultUserpic_svg_1 = __importDefault(require("../../../public/defaultUserpics/defaultUserpic"));
20
- const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
21
- // Styles
22
- const StyledHeaderUserPic = styled_components_1.default.div `
23
- ${(props) => (props.isNeedBoxTransform ? boxTransform_1.default : null)}
24
- .userPicBlock {
25
- display: flex;
26
- }
27
-
28
- .userPicImage {
29
- border-radius: 50%;
30
- width: ${(props) => props.imageWidth};
31
- height: ${(props) => props.imageHeight};
32
-
33
- ${ScreenWidth_1.mediaQuery.minWidthFourK} {
34
- width: ${(props) => (0, _4k_1.adaptiveValueCalc)(Number(props.imageWidth.replace('px', '')))};
35
- height: ${(props) => (0, _4k_1.adaptiveValueCalc)(Number(props.imageHeight.replace('px', '')))};
36
- }
37
- }
38
- `;
9
+ const UserPicSpa_1 = __importDefault(require("./UserPicSpa"));
39
10
  // Component
40
11
  const UserPic = ({ userId, width, height, isNeedBoxTransform, children, }) => {
41
- const getMediaENVDomain = (0, env_1.useEnvStore)((state) => state.getMediaDomain);
42
- const { isSignedIn, isLoadingProfileData, profileData } = (0, store_1.useUserStore)((state) => ({
43
- isSignedIn: state.isSignedIn,
44
- isLoadingProfileData: state.isLoadingProfileData,
45
- profileData: state.profileData,
46
- }));
47
- const { load, userPic, loading } = (0, useFetchUserPic_1.default)();
48
- const profileUserPic = profileData
49
- ?.getUserPic({
50
- mediaDomain: getMediaENVDomain(),
51
- })
52
- .includes('1.svg')
53
- ? null
54
- : profileData?.getUserPic({
55
- mediaDomain: getMediaENVDomain(),
56
- });
57
- (0, react_1.useEffect)(() => {
58
- if (isSignedIn &&
59
- !isLoadingProfileData &&
60
- profileData
61
- ?.getUserPic({
62
- mediaDomain: getMediaENVDomain(),
63
- })
64
- .includes('1.svg')) {
65
- load(userId);
66
- }
67
- }, [userId, isSignedIn, isLoadingProfileData, profileData]);
68
- const renderDefaultUserPic = () => {
69
- return (0, jsx_runtime_1.jsx)(defaultUserpic_svg_1.default, { className: 'userPicImage' });
70
- };
71
- const renderImage = () => {
72
- return ((0, jsx_runtime_1.jsx)(ImageInterceptor_1.ImageInterceptor, { borderRadiusSkeleton: '50%', children: (0, jsx_runtime_1.jsx)(image_1.default, { src: (profileUserPic || userPic), className: 'userPicImage', width: width, height: height, priority: true, alt: 'ludo ninja userPick' }) }));
73
- };
74
- const renderImageOrDefaultUserPic = () => {
75
- return profileUserPic || userPic ? renderImage() : renderDefaultUserPic();
76
- };
77
- const renderSkeleton = () => {
78
- return (0, jsx_runtime_1.jsx)(react_loading_skeleton_1.default, { className: 'userPicImage' });
79
- };
80
- const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
81
- return ((0, jsx_runtime_1.jsx)(StyledHeaderUserPic, { isNeedBoxTransform: isNeedBoxTransform, imageWidth: `${width}px`, imageHeight: `${height}px`, children: (0, jsx_runtime_1.jsxs)(link_1.default, { href: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["profile"]}/${userId}/nfts`, className: 'userPicBlock', children: [loading || isLoadingProfileData
82
- ? renderSkeleton()
83
- : renderImageOrDefaultUserPic(), children] }) }));
12
+ return ((0, jsx_runtime_1.jsx)(UserPicSpa_1.default, { userId: userId, Link: link_1.default, height: height, Image: image_1.default, width: width, isNeedBoxTransform: isNeedBoxTransform, children: children }));
84
13
  };
85
14
  // Export
86
15
  exports.default = UserPic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.1.36",
3
+ "version": "2.1.38",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",