@ludo.ninja/components 2.1.42 → 2.1.43
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.
|
@@ -119,7 +119,7 @@ const SearchSuggestions = ({ searchTerm, assets, profiles, collections, isLoadin
|
|
|
119
119
|
// image and screenshots
|
|
120
120
|
miniatureUrl = (0, Urls_1.getAssetImage)(currentMedia?.url, '/noContent/noContent.svg', Urls_1.mediaSizes.small, NEXT_PUBLIC_STATIC_DOMAIN);
|
|
121
121
|
}
|
|
122
|
-
return ((0, jsx_runtime_1.jsx)(searchSuggestionsItem_1.default, { name: asset?.getName(), link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["asset"]}
|
|
122
|
+
return ((0, jsx_runtime_1.jsx)(searchSuggestionsItem_1.default, { name: asset?.getName(), link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["asset"]}${asset.getAssetLink().replace(`${ItemType_1.LabelKeys.asset}/`, "")}`, imgUrl: miniatureUrl, searchTerm: searchTerm }, `${asset?.getAssetId()}.${Math.random()}`));
|
|
123
123
|
}),
|
|
124
124
|
},
|
|
125
125
|
]
|
|
@@ -1,2 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const SLink: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
|
|
3
|
+
href: string | import("url").UrlObject;
|
|
4
|
+
as?: string | import("url").UrlObject;
|
|
5
|
+
replace?: boolean;
|
|
6
|
+
scroll?: boolean;
|
|
7
|
+
shallow?: boolean;
|
|
8
|
+
passHref?: boolean;
|
|
9
|
+
prefetch?: boolean;
|
|
10
|
+
locale?: string | false;
|
|
11
|
+
legacyBehavior?: boolean;
|
|
12
|
+
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
13
|
+
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
|
|
14
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
15
|
+
}> & {
|
|
16
|
+
href: string | import("url").UrlObject;
|
|
17
|
+
as?: string | import("url").UrlObject;
|
|
18
|
+
replace?: boolean;
|
|
19
|
+
scroll?: boolean;
|
|
20
|
+
shallow?: boolean;
|
|
21
|
+
passHref?: boolean;
|
|
22
|
+
prefetch?: boolean;
|
|
23
|
+
locale?: string | false;
|
|
24
|
+
legacyBehavior?: boolean;
|
|
25
|
+
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
26
|
+
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
|
|
27
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
28
|
+
} & {
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
} & React.RefAttributes<HTMLAnchorElement>>, import("styled-components").DefaultTheme, {
|
|
31
|
+
scale: {
|
|
32
|
+
transform: string;
|
|
33
|
+
} | object;
|
|
34
|
+
}, never>;
|
|
1
35
|
declare const Sidebar: () => import("react/jsx-runtime").JSX.Element;
|
|
2
36
|
export default Sidebar;
|
|
@@ -3,13 +3,131 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SLink = void 0;
|
|
6
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
8
|
const link_1 = __importDefault(require("next/link"));
|
|
8
|
-
const sidebarSpa_1 = require("./sidebarSpa");
|
|
9
9
|
const Userpic_1 = __importDefault(require("../../system/Img/Userpic"));
|
|
10
10
|
const sidebarInviteCodeLabel_1 = __importDefault(require("./sidebarInviteCodeLabel"));
|
|
11
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
const sidebar_1 = require("@ludo.ninja/ui/build/components/sidebar");
|
|
13
|
+
const MainButton_1 = __importDefault(require("@ludo.ninja/ui/build/system/Buttons/MainButton"));
|
|
14
|
+
const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
|
|
15
|
+
const data_1 = require("./data");
|
|
16
|
+
const useSignOut_1 = require("../../modules/user/auth/useSignOut");
|
|
17
|
+
const store_1 = require("../../modules/user/store");
|
|
18
|
+
const ui_1 = require("../../store/ui");
|
|
19
|
+
const ScreenWidth_1 = require("../../styles/ScreenWidth");
|
|
20
|
+
const scale_1 = require("../../utils/adaptive/scale");
|
|
21
|
+
const auth_1 = require("../../utils/auth");
|
|
22
|
+
const screen_1 = require("../../utils/screen");
|
|
23
|
+
const useExtension_1 = __importDefault(require("../../hooks/extension/useExtension"));
|
|
24
|
+
const MenuItem = styled_components_1.default.div `
|
|
25
|
+
font-size: 15px;
|
|
26
|
+
font-weight: 500;
|
|
27
|
+
line-height: 22px;
|
|
28
|
+
display: flex;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
align-items: center;
|
|
31
|
+
padding: 12px 4px;
|
|
32
|
+
text-indent: 4px;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
color: ${({ theme }) => theme.colors.secondaryText};
|
|
36
|
+
|
|
37
|
+
${ScreenWidth_1.mediaQuery.mobile} {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
line-height: 20px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
transition: background-color 0.3s ease-in-out;
|
|
43
|
+
|
|
44
|
+
@media (hover: hover) {
|
|
45
|
+
&:hover {
|
|
46
|
+
transition: background-color 0.3s ease-in;
|
|
47
|
+
background-color: ${({ theme }) => theme.colors.secondaryBg};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
${ScreenWidth_1.mediaQuery.minWidthFourK} {
|
|
52
|
+
font-size: ${(0, _4k_1.adaptiveValueCalc)(15)};
|
|
53
|
+
line-height: ${(0, _4k_1.adaptiveValueCalc)(22)};
|
|
54
|
+
gap: ${(0, _4k_1.adaptiveValueCalc)(8)};
|
|
55
|
+
padding: ${(0, _4k_1.adaptiveValueCalc)(12)} ${(0, _4k_1.adaptiveValueCalc)(4)};
|
|
56
|
+
text-indent: ${(0, _4k_1.adaptiveValueCalc)(4)};
|
|
57
|
+
border-radius: ${(0, _4k_1.adaptiveValueCalc)(4)};
|
|
58
|
+
|
|
59
|
+
img {
|
|
60
|
+
width: ${(0, _4k_1.adaptiveValueCalc)(20)};
|
|
61
|
+
height: ${(0, _4k_1.adaptiveValueCalc)(20)};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
const BeforeMenuContainer = styled_components_1.default.div `
|
|
66
|
+
padding: 12px 0;
|
|
67
|
+
border-bottom: 1px solid ${({ theme }) => theme.colors.divider};
|
|
68
|
+
|
|
69
|
+
${ScreenWidth_1.mediaQuery.minWidthFourK} {
|
|
70
|
+
padding: ${(0, _4k_1.adaptiveValueCalc)(12)} 0;
|
|
71
|
+
border-bottom: ${(0, _4k_1.adaptiveValueCalc)(1)} solid ${({ theme }) => theme.colors.divider};
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
exports.SLink = (0, styled_components_1.default)(link_1.default) `
|
|
75
|
+
&:not(:last-child) svg path {
|
|
76
|
+
fill: ${({ theme }) => theme.colors.sidebarSvgPathFill};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.icon-wrapper {
|
|
80
|
+
width: 20px;
|
|
81
|
+
height: 20px;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
|
|
86
|
+
${ScreenWidth_1.mediaQuery.minWidthFourK} {
|
|
87
|
+
width: ${(0, _4k_1.adaptiveValueCalc)(20)};
|
|
88
|
+
height: ${(0, _4k_1.adaptiveValueCalc)(20)};
|
|
89
|
+
|
|
90
|
+
svg {
|
|
91
|
+
transform: ${(props) => "transform" in props.scale && props.scale.transform};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
// Component
|
|
11
97
|
const Sidebar = () => {
|
|
12
|
-
|
|
98
|
+
const redirectToLoginWindow = (0, auth_1.useRedirectToLoginWindow)();
|
|
99
|
+
const closeSidebar = (0, ui_1.useUiStore)((state) => state.closeSidebar);
|
|
100
|
+
const isSidebarOpen = (0, ui_1.useUiStore)((state) => state.isSidebarOpen);
|
|
101
|
+
const isAuthorized = (0, store_1.useUserStore)((state) => state.isSignedIn);
|
|
102
|
+
const getUser = (0, store_1.useUserStore)((state) => state.user);
|
|
103
|
+
const signOut = (0, useSignOut_1.useSignOut)();
|
|
104
|
+
const { deviceType } = (0, screen_1.useWindowDimensions)();
|
|
105
|
+
const { isExtensionInstalled, openExtensionChromeStorePage, openExtension } = (0, useExtension_1.default)();
|
|
106
|
+
const { wallets, userId } = getUser ?? [""];
|
|
107
|
+
// Todo fav-list
|
|
108
|
+
const sideBarData = (0, data_1.useSidebarData)();
|
|
109
|
+
const { windowDimensions } = (0, screen_1.useWindowDimensionsWithServerInitial)();
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)(sidebar_1.Sidebar, { closeSidebar: closeSidebar, isOpen: isSidebarOpen, handle: {
|
|
111
|
+
login: () => {
|
|
112
|
+
closeSidebar();
|
|
113
|
+
redirectToLoginWindow();
|
|
114
|
+
},
|
|
115
|
+
logout: signOut,
|
|
116
|
+
}, isAuthorized: isAuthorized, userWallets: wallets, slots: {
|
|
117
|
+
menu: sideBarData.map(({ title, href, icon, isExternalUrl }) => ((0, jsx_runtime_1.jsxs)(exports.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))),
|
|
118
|
+
userPicture: ({ children, height, width, isNeedBoxTransform }) => ((0, jsx_runtime_1.jsx)(Userpic_1.default, { width: width, height: height, userId: userId, isNeedBoxTransform: isNeedBoxTransform, children: children })),
|
|
119
|
+
inviteCode: (0, jsx_runtime_1.jsx)(sidebarInviteCodeLabel_1.default, {}),
|
|
120
|
+
...(deviceType == "isDesktop" && isAuthorized
|
|
121
|
+
? {
|
|
122
|
+
beforeMenu: ((0, jsx_runtime_1.jsx)(BeforeMenuContainer, { children: isExtensionInstalled ? ((0, jsx_runtime_1.jsxs)(MenuItem, { onClick: () => {
|
|
123
|
+
closeSidebar();
|
|
124
|
+
openExtension();
|
|
125
|
+
}, 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: () => {
|
|
126
|
+
closeSidebar();
|
|
127
|
+
openExtensionChromeStorePage();
|
|
128
|
+
}, text: "Install Ludo X now", variant: "primaryM" }) })) })),
|
|
129
|
+
}
|
|
130
|
+
: {}),
|
|
131
|
+
} }));
|
|
13
132
|
};
|
|
14
|
-
// Export
|
|
15
133
|
exports.default = Sidebar;
|
|
@@ -4,12 +4,83 @@ 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");
|
|
7
8
|
const image_1 = __importDefault(require("next/image"));
|
|
8
9
|
const link_1 = __importDefault(require("next/link"));
|
|
9
|
-
const
|
|
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
|
+
`;
|
|
10
39
|
// Component
|
|
11
40
|
const UserPic = ({ userId, width, height, isNeedBoxTransform, children, }) => {
|
|
12
|
-
|
|
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] }) }));
|
|
13
84
|
};
|
|
14
85
|
// Export
|
|
15
86
|
exports.default = UserPic;
|