@renown/sdk 5.1.0-dev.4 → 5.1.0-dev.40
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/README.md +28 -28
- package/dist/e2e/fixtures/main.d.ts +2 -0
- package/dist/e2e/fixtures/main.d.ts.map +1 -0
- package/dist/e2e/fixtures/main.js +97 -0
- package/dist/e2e/fixtures/main.js.map +1 -0
- package/dist/e2e/fixtures/vite.config.d.ts +3 -0
- package/dist/e2e/fixtures/vite.config.d.ts.map +1 -0
- package/dist/e2e/fixtures/vite.config.js +10 -0
- package/dist/e2e/fixtures/vite.config.js.map +1 -0
- package/dist/e2e/renown-components.spec.d.ts +2 -0
- package/dist/e2e/renown-components.spec.d.ts.map +1 -0
- package/dist/e2e/renown-components.spec.js +155 -0
- package/dist/e2e/renown-components.spec.js.map +1 -0
- package/dist/playwright.config.d.ts +3 -0
- package/dist/playwright.config.d.ts.map +1 -0
- package/dist/playwright.config.js +25 -0
- package/dist/playwright.config.js.map +1 -0
- package/dist/src/assets/assets.d.ts +19 -0
- package/dist/src/assets/renown-hover.svg +17 -0
- package/dist/src/assets/renown-light.svg +15 -0
- package/dist/src/assets/renown-short-hover.png +0 -0
- package/dist/src/assets/renown-short.png +0 -0
- package/dist/src/assets/renown.svg +16 -0
- package/dist/src/components/RenownAuthButton.d.ts +3 -33
- package/dist/src/components/RenownAuthButton.d.ts.map +1 -1
- package/dist/src/components/RenownAuthButton.js +25 -65
- package/dist/src/components/RenownAuthButton.js.map +1 -1
- package/dist/src/components/RenownLoginButton.d.ts +48 -0
- package/dist/src/components/RenownLoginButton.d.ts.map +1 -0
- package/dist/src/components/RenownLoginButton.js +175 -0
- package/dist/src/components/RenownLoginButton.js.map +1 -0
- package/dist/src/components/RenownUserButton.d.ts +66 -0
- package/dist/src/components/RenownUserButton.d.ts.map +1 -0
- package/dist/src/components/RenownUserButton.js +216 -0
- package/dist/src/components/RenownUserButton.js.map +1 -0
- package/dist/src/components/icons.d.ts +25 -0
- package/dist/src/components/icons.d.ts.map +1 -0
- package/dist/src/components/icons.js +24 -0
- package/dist/src/components/icons.js.map +1 -0
- package/dist/src/components/image-data.d.ts +3 -0
- package/dist/src/components/image-data.d.ts.map +1 -0
- package/dist/src/components/image-data.js +4 -0
- package/dist/src/components/image-data.js.map +1 -0
- package/dist/src/components/index.d.ts +5 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +3 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/crypto/index.d.ts +1 -0
- package/dist/src/crypto/index.d.ts.map +1 -1
- package/dist/src/crypto/index.js +1 -0
- package/dist/src/crypto/index.js.map +1 -1
- package/dist/src/crypto/signer.d.ts +21 -0
- package/dist/src/crypto/signer.d.ts.map +1 -0
- package/dist/src/crypto/signer.js +236 -0
- package/dist/src/crypto/signer.js.map +1 -0
- package/dist/src/hooks/use-user.d.ts +4 -4
- package/dist/src/hooks/use-user.d.ts.map +1 -1
- package/dist/src/hooks/use-user.js +6 -6
- package/dist/src/hooks/use-user.js.map +1 -1
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/renown/utils.d.ts +2 -1
- package/dist/src/lib/renown/utils.d.ts.map +1 -1
- package/dist/src/lib/renown/utils.js +9 -1
- package/dist/src/lib/renown/utils.js.map +1 -1
- package/dist/src/providers/index.d.ts +2 -2
- package/dist/src/providers/index.d.ts.map +1 -1
- package/dist/src/providers/index.js +1 -1
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/{user-provider.d.ts → renown-user-provider.d.ts} +14 -8
- package/dist/src/providers/renown-user-provider.d.ts.map +1 -0
- package/dist/src/providers/{user-provider.js → renown-user-provider.js} +23 -11
- package/dist/src/providers/renown-user-provider.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -4
- package/dist/src/providers/user-provider.d.ts.map +0 -1
- package/dist/src/providers/user-provider.js.map +0 -1
|
@@ -10,11 +10,6 @@ export interface RenownAuthButtonProps {
|
|
|
10
10
|
* Custom class name for the container
|
|
11
11
|
*/
|
|
12
12
|
className?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Base URL for the profile page
|
|
15
|
-
* @default "https://www.renown.id/profile"
|
|
16
|
-
*/
|
|
17
|
-
profileBaseUrl?: string;
|
|
18
13
|
/**
|
|
19
14
|
* Custom render function when user is authenticated
|
|
20
15
|
* Receives user data, logout function, and openProfile function
|
|
@@ -32,25 +27,10 @@ export interface RenownAuthButtonProps {
|
|
|
32
27
|
* Custom render function for loading state
|
|
33
28
|
*/
|
|
34
29
|
renderLoading?: () => React.ReactNode;
|
|
35
|
-
/**
|
|
36
|
-
* Show username next to avatar
|
|
37
|
-
* @default true
|
|
38
|
-
*/
|
|
39
|
-
showUsername?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Show logout button
|
|
42
|
-
* @default false
|
|
43
|
-
*/
|
|
44
|
-
showLogoutButton?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Custom logout button text
|
|
47
|
-
* @default "Logout"
|
|
48
|
-
*/
|
|
49
|
-
logoutButtonText?: string;
|
|
50
30
|
}
|
|
51
31
|
/**
|
|
52
|
-
* Smart authentication button that adapts based on auth state
|
|
53
|
-
* Shows
|
|
32
|
+
* Smart authentication button that adapts based on auth state.
|
|
33
|
+
* Shows RenownLoginButton when not authenticated, and RenownUserButton when authenticated.
|
|
54
34
|
*
|
|
55
35
|
* @example
|
|
56
36
|
* Basic usage:
|
|
@@ -77,16 +57,6 @@ export interface RenownAuthButtonProps {
|
|
|
77
57
|
* )}
|
|
78
58
|
* />
|
|
79
59
|
* ```
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* With logout button:
|
|
83
|
-
* ```tsx
|
|
84
|
-
* <RenownAuthButton
|
|
85
|
-
* showLogoutButton
|
|
86
|
-
* logoutButtonText="Sign Out"
|
|
87
|
-
* profileBaseUrl="https://myapp.com/profile"
|
|
88
|
-
* />
|
|
89
|
-
* ```
|
|
90
60
|
*/
|
|
91
|
-
export declare function RenownAuthButton({ className,
|
|
61
|
+
export declare function RenownAuthButton({ className, renderAuthenticated, renderUnauthenticated, renderLoading, }: RenownAuthButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
92
62
|
//# sourceMappingURL=RenownAuthButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenownAuthButton.d.ts","sourceRoot":"","sources":["../../../src/components/RenownAuthButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"RenownAuthButton.d.ts","sourceRoot":"","sources":["../../../src/components/RenownAuthButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAKnD,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9E;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE;QAC9B,UAAU,EAAE,MAAM,IAAI,CAAC;QACvB,SAAS,EAAE,OAAO,CAAC;KACpB,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,GACd,EAAE,qBAAqB,2CAyFvB"}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { useUser } from "../hooks/use-user.js";
|
|
5
|
+
import { openRenown as openRenownUtil } from "../lib/renown/utils.js";
|
|
6
|
+
import { RenownLoginButton } from "./RenownLoginButton.js";
|
|
7
|
+
import { RenownUserButton } from "./RenownUserButton.js";
|
|
5
8
|
/**
|
|
6
|
-
* Smart authentication button that adapts based on auth state
|
|
7
|
-
* Shows
|
|
9
|
+
* Smart authentication button that adapts based on auth state.
|
|
10
|
+
* Shows RenownLoginButton when not authenticated, and RenownUserButton when authenticated.
|
|
8
11
|
*
|
|
9
12
|
* @example
|
|
10
13
|
* Basic usage:
|
|
@@ -31,92 +34,49 @@ import { useUser } from "../hooks/use-user.js";
|
|
|
31
34
|
* )}
|
|
32
35
|
* />
|
|
33
36
|
* ```
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* With logout button:
|
|
37
|
-
* ```tsx
|
|
38
|
-
* <RenownAuthButton
|
|
39
|
-
* showLogoutButton
|
|
40
|
-
* logoutButtonText="Sign Out"
|
|
41
|
-
* profileBaseUrl="https://myapp.com/profile"
|
|
42
|
-
* />
|
|
43
|
-
* ```
|
|
44
37
|
*/
|
|
45
|
-
export function RenownAuthButton({ className = "",
|
|
38
|
+
export function RenownAuthButton({ className = "", renderAuthenticated, renderUnauthenticated, renderLoading, }) {
|
|
46
39
|
const { user, loginStatus, isLoading, openRenown, logout } = useUser();
|
|
47
40
|
const openProfile = () => {
|
|
48
41
|
if (!user)
|
|
49
42
|
return;
|
|
50
|
-
|
|
51
|
-
if (identifier) {
|
|
52
|
-
window.open(`${profileBaseUrl}/${identifier}`, "_blank");
|
|
53
|
-
}
|
|
43
|
+
openRenownUtil(user.documentId);
|
|
54
44
|
};
|
|
55
45
|
// Loading state
|
|
56
46
|
if (isLoading && loginStatus === "initial") {
|
|
57
47
|
if (renderLoading) {
|
|
58
48
|
return _jsx("div", { className: className, children: renderLoading() });
|
|
59
49
|
}
|
|
60
|
-
return (_jsxs("div", { className: className,
|
|
61
|
-
width: "
|
|
62
|
-
height: "
|
|
63
|
-
border: "2px solid #e5e7eb",
|
|
64
|
-
borderTopColor: "#6366f1",
|
|
50
|
+
return (_jsxs("div", { className: className, children: [_jsx("div", { style: {
|
|
51
|
+
width: "40px",
|
|
52
|
+
height: "40px",
|
|
65
53
|
borderRadius: "50%",
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
backgroundColor: "#e5e7eb",
|
|
55
|
+
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
56
|
+
} }), _jsx("style", { children: `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }` })] }));
|
|
68
57
|
}
|
|
69
58
|
// Authenticated state
|
|
70
59
|
if (loginStatus === "authorized" && user) {
|
|
71
60
|
if (renderAuthenticated) {
|
|
72
61
|
return (_jsx("div", { className: className, children: renderAuthenticated({ user, logout, openProfile }) }));
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
const address = (user.ethAddress || user.address);
|
|
64
|
+
if (!address) {
|
|
65
|
+
// Fallback if no address available
|
|
66
|
+
return (_jsx("div", { className: className, children: _jsxs("button", { onClick: logout, style: {
|
|
67
|
+
fontSize: "14px",
|
|
68
|
+
color: "#4b5563",
|
|
69
|
+
background: "none",
|
|
70
|
+
border: "none",
|
|
79
71
|
cursor: "pointer",
|
|
80
|
-
}, children: [user.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
borderRadius: "50%",
|
|
84
|
-
objectFit: "cover",
|
|
85
|
-
} })) : (_jsx("div", { style: {
|
|
86
|
-
width: "2rem",
|
|
87
|
-
height: "2rem",
|
|
88
|
-
borderRadius: "50%",
|
|
89
|
-
backgroundColor: "#6366f1",
|
|
90
|
-
color: "white",
|
|
91
|
-
display: "flex",
|
|
92
|
-
alignItems: "center",
|
|
93
|
-
justifyContent: "center",
|
|
94
|
-
fontWeight: "bold",
|
|
95
|
-
fontSize: "0.75rem",
|
|
96
|
-
}, children: (user.name || user.did).substring(0, 2).toUpperCase() })), showUsername && (_jsx("span", { style: { fontSize: "0.875rem", fontWeight: "500" }, children: user.name || user.did.slice(0, 15) + "..." }))] }), showLogoutButton && (_jsx("button", { onClick: logout, style: {
|
|
97
|
-
padding: "0.25rem 0.75rem",
|
|
98
|
-
border: "1px solid #d1d5db",
|
|
99
|
-
borderRadius: "0.375rem",
|
|
100
|
-
backgroundColor: "white",
|
|
101
|
-
cursor: "pointer",
|
|
102
|
-
fontSize: "0.75rem",
|
|
103
|
-
fontWeight: "500",
|
|
104
|
-
}, children: logoutButtonText }))] }));
|
|
72
|
+
}, children: [user.name || "Connected", " (Logout)"] }) }));
|
|
73
|
+
}
|
|
74
|
+
return (_jsx("div", { className: className, children: _jsx(RenownUserButton, { address: address, username: user.name, userId: user.documentId, avatarUrl: user.avatar, onDisconnect: logout }) }));
|
|
105
75
|
}
|
|
106
76
|
// Unauthenticated state
|
|
107
77
|
if (renderUnauthenticated) {
|
|
108
78
|
return (_jsx("div", { className: className, children: renderUnauthenticated({ openRenown, isLoading }) }));
|
|
109
79
|
}
|
|
110
|
-
|
|
111
|
-
return (_jsx("button", { onClick: openRenown, disabled: isLoading, className: className, style: {
|
|
112
|
-
padding: "0.5rem 1rem",
|
|
113
|
-
border: "1px solid #d1d5db",
|
|
114
|
-
borderRadius: "0.375rem",
|
|
115
|
-
backgroundColor: "white",
|
|
116
|
-
cursor: isLoading ? "not-allowed" : "pointer",
|
|
117
|
-
fontSize: "0.875rem",
|
|
118
|
-
fontWeight: "500",
|
|
119
|
-
opacity: isLoading ? 0.6 : 1,
|
|
120
|
-
}, children: isLoading ? "Loading..." : "Login with Renown" }));
|
|
80
|
+
return (_jsx("div", { className: className, children: _jsx(RenownLoginButton, { onLogin: openRenown }) }));
|
|
121
81
|
}
|
|
122
82
|
//# sourceMappingURL=RenownAuthButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenownAuthButton.js","sourceRoot":"","sources":["../../../src/components/RenownAuthButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"RenownAuthButton.js","sourceRoot":"","sources":["../../../src/components/RenownAuthButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAgCzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,SAAS,GAAG,EAAE,EACd,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,GACS;IACtB,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;IAEvE,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,gBAAgB;IAChB,IAAI,SAAS,IAAI,WAAW,KAAK,SAAS,E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AAM,EACtB,YAAY,EAAE,MAAM,GACpB,GACE,CACP,CAAC;IACJ,CAAC;IAED,wBAAwB;IACxB,IAAI,qBAAqB,EAAE,CAAC;QAC1B,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,YACtB,qBAAqB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,GAC7C,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,YACvB,KAAC,iBAAiB,IAAC,OAAO,EAAE,UAAU,GAAI,GACtC,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
export interface RenownLoginButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* Callback when login is requested
|
|
5
|
+
*/
|
|
6
|
+
onLogin: (() => void) | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Enable dark mode styling
|
|
9
|
+
*/
|
|
10
|
+
darkMode?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Custom styles for the button
|
|
13
|
+
*/
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
/**
|
|
16
|
+
* Custom class name
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Custom render function for the trigger button
|
|
21
|
+
*/
|
|
22
|
+
renderTrigger?: (props: {
|
|
23
|
+
onMouseEnter: () => void;
|
|
24
|
+
onMouseLeave: () => void;
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Show a popover with connect option instead of triggering login directly
|
|
29
|
+
*/
|
|
30
|
+
showPopover?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A login button with Renown branding that shows a popover with connect option.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { RenownLoginButton } from '@renown/sdk'
|
|
38
|
+
*
|
|
39
|
+
* function LoginArea() {
|
|
40
|
+
* const handleLogin = () => {
|
|
41
|
+
* // Your login logic
|
|
42
|
+
* }
|
|
43
|
+
* return <RenownLoginButton onLogin={handleLogin} />
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function RenownLoginButton({ onLogin, darkMode, style, className, renderTrigger, showPopover, }: RenownLoginButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
//# sourceMappingURL=RenownLoginButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenownLoginButton.d.ts","sourceRoot":"","sources":["../../../src/components/RenownLoginButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKtD,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QACtB,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC;KACpB,KAAK,SAAS,CAAC;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA+ED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,QAAgB,EAChB,KAAK,EACL,SAAS,EACT,aAAa,EACb,WAAmB,GACpB,EAAE,sBAAsB,2CA2IxB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { RenownLogo, SpinnerIcon } from "./icons.js";
|
|
5
|
+
import { renownShortDataUrl, renownShortHoverDataUrl } from "./image-data.js";
|
|
6
|
+
const POPOVER_GAP = 8;
|
|
7
|
+
const POPOVER_HEIGHT = 120; // approximate height of popover
|
|
8
|
+
const styles = {
|
|
9
|
+
trigger: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "center",
|
|
13
|
+
padding: 0,
|
|
14
|
+
border: "none",
|
|
15
|
+
background: "transparent",
|
|
16
|
+
cursor: "pointer",
|
|
17
|
+
},
|
|
18
|
+
popoverBase: {
|
|
19
|
+
position: "absolute",
|
|
20
|
+
left: 0,
|
|
21
|
+
borderRadius: "8px",
|
|
22
|
+
width: "208px",
|
|
23
|
+
zIndex: 1000,
|
|
24
|
+
},
|
|
25
|
+
popoverLight: {
|
|
26
|
+
backgroundColor: "white",
|
|
27
|
+
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
28
|
+
},
|
|
29
|
+
popoverDark: {
|
|
30
|
+
backgroundColor: "#1f2937",
|
|
31
|
+
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)",
|
|
32
|
+
},
|
|
33
|
+
popoverContent: {
|
|
34
|
+
padding: "16px",
|
|
35
|
+
},
|
|
36
|
+
logoContainer: {
|
|
37
|
+
display: "flex",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
height: "22px",
|
|
40
|
+
width: "83px",
|
|
41
|
+
margin: "0 auto 16px",
|
|
42
|
+
overflow: "hidden",
|
|
43
|
+
},
|
|
44
|
+
connectButtonBase: {
|
|
45
|
+
display: "flex",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "28px",
|
|
50
|
+
borderRadius: "8px",
|
|
51
|
+
backgroundColor: "transparent",
|
|
52
|
+
fontSize: "14px",
|
|
53
|
+
cursor: "pointer",
|
|
54
|
+
marginTop: "16px",
|
|
55
|
+
},
|
|
56
|
+
connectButtonLight: {
|
|
57
|
+
border: "1px solid #d1d5db",
|
|
58
|
+
color: "#111827",
|
|
59
|
+
},
|
|
60
|
+
connectButtonDark: {
|
|
61
|
+
border: "1px solid #4b5563",
|
|
62
|
+
color: "#f9fafb",
|
|
63
|
+
},
|
|
64
|
+
connectButtonActive: {
|
|
65
|
+
opacity: 0.7,
|
|
66
|
+
},
|
|
67
|
+
wrapper: {
|
|
68
|
+
position: "relative",
|
|
69
|
+
display: "inline-block",
|
|
70
|
+
},
|
|
71
|
+
triggerImageLight: {
|
|
72
|
+
display: "block",
|
|
73
|
+
},
|
|
74
|
+
triggerImageDark: {
|
|
75
|
+
display: "block",
|
|
76
|
+
filter: "invert(1)",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A login button with Renown branding that shows a popover with connect option.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* import { RenownLoginButton } from '@renown/sdk'
|
|
85
|
+
*
|
|
86
|
+
* function LoginArea() {
|
|
87
|
+
* const handleLogin = () => {
|
|
88
|
+
* // Your login logic
|
|
89
|
+
* }
|
|
90
|
+
* return <RenownLoginButton onLogin={handleLogin} />
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function RenownLoginButton({ onLogin, darkMode = false, style, className, renderTrigger, showPopover = false, }) {
|
|
95
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
96
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
97
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
98
|
+
const [showAbove, setShowAbove] = useState(true);
|
|
99
|
+
const popoverRef = useRef(null);
|
|
100
|
+
const wrapperRef = useRef(null);
|
|
101
|
+
const closeTimeoutRef = useRef(null);
|
|
102
|
+
const calculatePosition = useCallback(() => {
|
|
103
|
+
if (!wrapperRef.current)
|
|
104
|
+
return;
|
|
105
|
+
const rect = wrapperRef.current.getBoundingClientRect();
|
|
106
|
+
const spaceAbove = rect.top;
|
|
107
|
+
const hasSpaceAbove = spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP;
|
|
108
|
+
setShowAbove(hasSpaceAbove);
|
|
109
|
+
}, []);
|
|
110
|
+
const handleMouseEnter = useCallback(() => {
|
|
111
|
+
setIsHovered(true);
|
|
112
|
+
if (!showPopover) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (closeTimeoutRef.current) {
|
|
116
|
+
clearTimeout(closeTimeoutRef.current);
|
|
117
|
+
closeTimeoutRef.current = null;
|
|
118
|
+
}
|
|
119
|
+
calculatePosition();
|
|
120
|
+
setIsOpen(true);
|
|
121
|
+
}, [calculatePosition, showPopover]);
|
|
122
|
+
const handleMouseLeave = useCallback(() => {
|
|
123
|
+
closeTimeoutRef.current = setTimeout(() => {
|
|
124
|
+
setIsOpen(false);
|
|
125
|
+
setIsHovered(false);
|
|
126
|
+
}, 150);
|
|
127
|
+
}, []);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
return () => {
|
|
130
|
+
if (closeTimeoutRef.current) {
|
|
131
|
+
clearTimeout(closeTimeoutRef.current);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
const handleConnect = () => {
|
|
136
|
+
if (onLogin) {
|
|
137
|
+
setIsLoading(true);
|
|
138
|
+
onLogin();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const handleDirectClick = () => {
|
|
142
|
+
if (!showPopover && onLogin && !isLoading) {
|
|
143
|
+
setIsLoading(true);
|
|
144
|
+
onLogin();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const triggerStyle = {
|
|
148
|
+
...styles.trigger,
|
|
149
|
+
cursor: onLogin ? "pointer" : "wait",
|
|
150
|
+
...style,
|
|
151
|
+
};
|
|
152
|
+
const allowLogin = !isLoading && !!onLogin;
|
|
153
|
+
const connectButtonStyle = {
|
|
154
|
+
...styles.connectButtonBase,
|
|
155
|
+
...(darkMode ? styles.connectButtonDark : styles.connectButtonLight),
|
|
156
|
+
cursor: allowLogin ? "pointer" : "wait",
|
|
157
|
+
};
|
|
158
|
+
const popoverStyle = {
|
|
159
|
+
...styles.popoverBase,
|
|
160
|
+
...(darkMode ? styles.popoverDark : styles.popoverLight),
|
|
161
|
+
...(showAbove
|
|
162
|
+
? { bottom: `calc(100% + ${POPOVER_GAP}px)` }
|
|
163
|
+
: { top: `calc(100% + ${POPOVER_GAP}px)` }),
|
|
164
|
+
};
|
|
165
|
+
const triggerImageStyle = darkMode
|
|
166
|
+
? styles.triggerImageDark
|
|
167
|
+
: styles.triggerImageLight;
|
|
168
|
+
const logoColor = darkMode ? "#f9fafb" : "#374151";
|
|
169
|
+
return (_jsxs("div", { ref: wrapperRef, style: styles.wrapper, className: className, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [renderTrigger ? (renderTrigger({
|
|
170
|
+
onMouseEnter: handleMouseEnter,
|
|
171
|
+
onMouseLeave: handleMouseLeave,
|
|
172
|
+
isLoading,
|
|
173
|
+
})) : (_jsx("button", { type: "button", style: triggerStyle, "aria-label": showPopover ? "Open Renown Login" : "Login with Renown", onClick: showPopover ? undefined : handleDirectClick, children: isLoading ? (_jsx(SpinnerIcon, { size: 42 })) : (_jsx("img", { width: 42, height: 42, src: isHovered ? renownShortHoverDataUrl : renownShortDataUrl, alt: "Renown Login", style: triggerImageStyle })) })), isOpen && showPopover && (_jsx("div", { ref: popoverRef, style: popoverStyle, children: _jsxs("div", { style: styles.popoverContent, children: [_jsx("div", { style: styles.logoContainer, children: _jsx(RenownLogo, { width: 83, height: 22, color: logoColor }) }), _jsx("button", { type: "button", onClick: allowLogin ? handleConnect : undefined, style: connectButtonStyle, children: isLoading ? _jsx(SpinnerIcon, { size: 14 }) : "Connect" })] }) }))] }));
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=RenownLoginButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenownLoginButton.js","sourceRoot":"","sources":["../../../src/components/RenownLoginButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAiC9E,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,cAAc,GAAG,GAAG,CAAC,CAAC,gCAAgC;AAE5D,MAAM,MAAM,GAAkC;IAC5C,OAAO,EAAE;QACP,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,aAAa;QACzB,MAAM,EAAE,SAAS;KAClB;IACD,WAAW,EAAE;QACX,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC;QACP,YAAY,EAAE,KAAK;QACnB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,IAAI;KACb;IACD,YAAY,EAAE;QACZ,eAAe,EAAE,OAAO;QACxB,SAAS,EACP,uEAAuE;KAC1E;IACD,WAAW,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,SAAS,EACP,sEAAsE;KACzE;IACD,cAAc,EAAE;QACd,OAAO,EAAE,MAAM;KAChB;IACD,aAAa,EAAE;QACb,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,QAAQ;QACxB,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;QACb,MAAM,E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C,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,GAAI,GACnD,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAC/C,KAAK,EAAE,kBAAkB,YAExB,SAAS,CAAC,CAAC,CAAC,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,SAAS,GAC3C,IACL,GACF,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
export interface RenownUserButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* The user's wallet address
|
|
5
|
+
*/
|
|
6
|
+
address: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional ENS name or username to display
|
|
9
|
+
*/
|
|
10
|
+
username?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional avatar URL
|
|
13
|
+
*/
|
|
14
|
+
avatarUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* User ID to view the profile on Renown
|
|
17
|
+
*/
|
|
18
|
+
userId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Callback when disconnect is requested
|
|
21
|
+
*/
|
|
22
|
+
onDisconnect: (() => void) | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Custom styles for the button
|
|
25
|
+
*/
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
/**
|
|
28
|
+
* Custom class name
|
|
29
|
+
*/
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Custom render function for the trigger button
|
|
33
|
+
*/
|
|
34
|
+
renderTrigger?: (props: {
|
|
35
|
+
onMouseEnter: () => void;
|
|
36
|
+
onMouseLeave: () => void;
|
|
37
|
+
address: string;
|
|
38
|
+
username?: string;
|
|
39
|
+
avatarUrl?: string;
|
|
40
|
+
}) => ReactNode;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A user button that shows account info in a popover with options to copy address,
|
|
44
|
+
* view profile, and disconnect.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* import { RenownUserButton } from '@renown/sdk'
|
|
49
|
+
*
|
|
50
|
+
* function UserArea() {
|
|
51
|
+
* const handleDisconnect = () => {
|
|
52
|
+
* // Your disconnect logic
|
|
53
|
+
* }
|
|
54
|
+
* return (
|
|
55
|
+
* <RenownUserButton
|
|
56
|
+
* address="0x1234...5678"
|
|
57
|
+
* username="vitalik.eth"
|
|
58
|
+
* userId="abc123"
|
|
59
|
+
* onDisconnect={handleDisconnect}
|
|
60
|
+
* />
|
|
61
|
+
* )
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function RenownUserButton({ address, username, avatarUrl, userId, onDisconnect, style, className, renderTrigger, }: RenownUserButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
//# sourceMappingURL=RenownUserButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenownUserButton.d.ts","sourceRoot":"","sources":["../../../src/components/RenownUserButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAatD,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACvC;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QACtB,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,KAAK,SAAS,CAAC;CACjB;AAyHD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,SAAS,EACT,MAAM,EACN,YAAY,EACZ,KAAK,EACL,SAAS,EACT,aAAa,GACd,EAAE,qBAAqB,2CAuJvB"}
|