@mezo-org/passport 0.16.0-dev.3 → 0.16.0
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/src/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- package/dist/src/assets/EditIcon.d.ts +5 -0
- package/dist/src/assets/EditIcon.d.ts.map +1 -0
- package/dist/src/assets/EditIcon.js +10 -0
- package/dist/src/assets/EditIcon.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +8 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +29 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +23 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +45 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts +14 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +42 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +8 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +33 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +4 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +64 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +49 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +32 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js +28 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
- package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +43 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +49 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +66 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +88 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts +12 -0
- package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Settings/InlineEditField.js +95 -0
- package/dist/src/components/Dropdown/Settings/InlineEditField.js.map +1 -0
- package/dist/src/components/Dropdown/Settings/Settings.d.ts +4 -0
- package/dist/src/components/Dropdown/Settings/Settings.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Settings/Settings.js +36 -0
- package/dist/src/components/Dropdown/Settings/Settings.js.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.js +67 -0
- package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
- package/dist/src/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +11 -11
- package/dist/src/hooks/useSignInWithWallet.d.ts +11 -11
- package/dist/src/hooks/useSignUpWithWallet.d.ts +11 -11
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +2 -5
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/package.json +2 -1
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/assets/EditIcon.tsx +33 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
- package/src/components/Dropdown/Content.tsx +56 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
- package/src/components/Dropdown/Dropdown.tsx +100 -0
- package/src/components/Dropdown/ListingItem.tsx +176 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +88 -0
- package/src/components/Dropdown/README.md +41 -0
- package/src/components/Dropdown/Receive/Receive.tsx +144 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +99 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +69 -0
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +53 -0
- package/src/components/Dropdown/Root/AccountError.tsx +34 -0
- package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +85 -0
- package/src/components/Dropdown/Root/Root.tsx +104 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +123 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +173 -0
- package/src/components/Dropdown/Settings/InlineEditField.tsx +212 -0
- package/src/components/Dropdown/Settings/Settings.tsx +87 -0
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/hooks/useWalletAccount.ts +1 -6
- package/src/index.ts +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Block, Button, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { forwardRef, ReactNode, useMemo } from "react"
|
|
3
|
+
|
|
4
|
+
type ConnectedTriggerProps = Omit<ButtonProps, "children" | "size"> & {
|
|
5
|
+
avatar: ReactNode
|
|
6
|
+
size?: "medium" | "large"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const ConnectedTrigger = forwardRef<HTMLButtonElement, ConnectedTriggerProps>(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
const { onClick, avatar, size = "medium", ...restProps } = props
|
|
12
|
+
|
|
13
|
+
const [, theme] = useStyletron()
|
|
14
|
+
|
|
15
|
+
const avatarSize = useMemo(() => {
|
|
16
|
+
const sizeMap = {
|
|
17
|
+
medium: theme.sizing.scale950,
|
|
18
|
+
large: theme.sizing.scale1400,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return sizeMap[size]
|
|
22
|
+
}, [theme, size])
|
|
23
|
+
|
|
24
|
+
const buttonPadding = useMemo(() => {
|
|
25
|
+
const paddingMap = {
|
|
26
|
+
medium: theme.sizing.scale0,
|
|
27
|
+
large: theme.sizing.scale100,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return paddingMap[size]
|
|
31
|
+
}, [theme, size])
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Button
|
|
35
|
+
overrides={{
|
|
36
|
+
BaseButton: {
|
|
37
|
+
props: { ref, ...restProps },
|
|
38
|
+
style: {
|
|
39
|
+
borderRadius: "100%",
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
padding: buttonPadding,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}}
|
|
45
|
+
onClick={onClick}
|
|
46
|
+
>
|
|
47
|
+
{typeof avatar === "string" ? (
|
|
48
|
+
<Block
|
|
49
|
+
width={avatarSize}
|
|
50
|
+
height={avatarSize}
|
|
51
|
+
as="img"
|
|
52
|
+
src={avatar}
|
|
53
|
+
alt=""
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<Block
|
|
57
|
+
width={avatarSize}
|
|
58
|
+
height={avatarSize}
|
|
59
|
+
overrides={{
|
|
60
|
+
Block: {
|
|
61
|
+
style: {
|
|
62
|
+
borderRadius: "100%",
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{avatar}
|
|
69
|
+
</Block>
|
|
70
|
+
)}
|
|
71
|
+
</Button>
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
export default ConnectedTrigger
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Block, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { useEffect } from "react"
|
|
3
|
+
import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
|
|
4
|
+
import Root from "./Root/Root"
|
|
5
|
+
import Receive from "./Receive/Receive"
|
|
6
|
+
import Settings from "./Settings/Settings"
|
|
7
|
+
import TestnetTopBanner from "./TestnetTopBanner"
|
|
8
|
+
|
|
9
|
+
type ContentProps = {
|
|
10
|
+
onSignOut?: () => void
|
|
11
|
+
onOtherAssetsClick?: () => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function Content(props: ContentProps) {
|
|
15
|
+
const { onSignOut, onOtherAssetsClick } = props
|
|
16
|
+
|
|
17
|
+
const [_, theme] = useStyletron()
|
|
18
|
+
|
|
19
|
+
const currentView = useDropdownStore((state) => state.view)
|
|
20
|
+
const setView = useDropdownStore((state) => state.setView)
|
|
21
|
+
|
|
22
|
+
useEffect(
|
|
23
|
+
() => () => {
|
|
24
|
+
setView(DropdownView.ROOT)
|
|
25
|
+
},
|
|
26
|
+
[setView],
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Block
|
|
31
|
+
display="inline-flex"
|
|
32
|
+
flexDirection="column"
|
|
33
|
+
backgroundColor={theme.colors.backgroundPrimary}
|
|
34
|
+
width="100%"
|
|
35
|
+
overrides={{
|
|
36
|
+
Block: {
|
|
37
|
+
style: {
|
|
38
|
+
boxSizing: "border-box",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<TestnetTopBanner />
|
|
44
|
+
|
|
45
|
+
{currentView === DropdownView.ROOT && (
|
|
46
|
+
<Root onSignOut={onSignOut} onOtherAssetsClick={onOtherAssetsClick} />
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{currentView === DropdownView.RECEIVE && <Receive />}
|
|
50
|
+
|
|
51
|
+
{currentView === DropdownView.SETTINGS && <Settings />}
|
|
52
|
+
</Block>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default Content
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Button, ButtonProps, LogIn01, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { forwardRef } from "react"
|
|
3
|
+
|
|
4
|
+
type DisconnectedTriggerProps = Omit<ButtonProps, "children"> & {
|
|
5
|
+
children: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const DisconnectedTrigger = forwardRef<
|
|
9
|
+
HTMLButtonElement,
|
|
10
|
+
DisconnectedTriggerProps
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const { onClick, children, ...restProps } = props
|
|
13
|
+
|
|
14
|
+
const [, theme] = useStyletron()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Button
|
|
18
|
+
startEnhancer={
|
|
19
|
+
<LogIn01 color="currentColor" size={theme.sizing.scale600} />
|
|
20
|
+
}
|
|
21
|
+
overrides={{
|
|
22
|
+
Root: {
|
|
23
|
+
props: { ref },
|
|
24
|
+
},
|
|
25
|
+
}}
|
|
26
|
+
size="small"
|
|
27
|
+
shape="pill"
|
|
28
|
+
onClick={onClick}
|
|
29
|
+
{...restProps}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</Button>
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export default DisconnectedTrigger
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonProps,
|
|
3
|
+
StatefulPopover,
|
|
4
|
+
StatefulPopoverProps,
|
|
5
|
+
useStyletron,
|
|
6
|
+
} from "@mezo-org/mezo-clay"
|
|
7
|
+
import { useConnectModal } from "@rainbow-me/rainbowkit"
|
|
8
|
+
import React from "react"
|
|
9
|
+
import DefaultAvatar from "../../assets/DefaultAvatar"
|
|
10
|
+
import ConnectedTrigger from "./ConnectedTrigger"
|
|
11
|
+
import Content from "./Content"
|
|
12
|
+
import DisconnectedTrigger from "./DisconnectedTrigger"
|
|
13
|
+
import { useWalletAccount } from "../../hooks/useWalletAccount"
|
|
14
|
+
import { useWatchTransferEventsForAllTokens } from "../../hooks/useWatchTransferEvents"
|
|
15
|
+
|
|
16
|
+
export type DropdownProps = {
|
|
17
|
+
/** The callback to be called when the user clicks the sign-out button */
|
|
18
|
+
onSignOut?: () => void
|
|
19
|
+
/** The callback to be called when the user clicks the button in sign-in state */
|
|
20
|
+
onSignIn?: () => void
|
|
21
|
+
/** The props to be passed to the trigger button */
|
|
22
|
+
triggerProps?: {
|
|
23
|
+
signedIn?: Omit<ButtonProps, "onClick" | "size"> & {
|
|
24
|
+
size: "medium" | "large"
|
|
25
|
+
}
|
|
26
|
+
signedOut?: Omit<ButtonProps, "onClick">
|
|
27
|
+
}
|
|
28
|
+
onOtherAssetsClick?: () => void
|
|
29
|
+
} & Omit<StatefulPopoverProps, "children" | "content">
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Passport Dropdown component that displays user's wallet and assets information.
|
|
33
|
+
* @param {DropdownProps} props - Component props.
|
|
34
|
+
* @returns {JSX.Element}
|
|
35
|
+
*/
|
|
36
|
+
export function Dropdown(props: DropdownProps) {
|
|
37
|
+
const {
|
|
38
|
+
placement = "bottomRight",
|
|
39
|
+
animateOutTime = 120,
|
|
40
|
+
onSignIn,
|
|
41
|
+
onSignOut,
|
|
42
|
+
overrides,
|
|
43
|
+
triggerProps,
|
|
44
|
+
onOtherAssetsClick,
|
|
45
|
+
...restProps
|
|
46
|
+
} = props
|
|
47
|
+
|
|
48
|
+
const [, theme] = useStyletron()
|
|
49
|
+
|
|
50
|
+
const walletAccount = useWalletAccount()
|
|
51
|
+
|
|
52
|
+
useWatchTransferEventsForAllTokens()
|
|
53
|
+
|
|
54
|
+
const { openConnectModal } = useConnectModal()
|
|
55
|
+
|
|
56
|
+
if (!walletAccount?.isConnected) {
|
|
57
|
+
return (
|
|
58
|
+
<DisconnectedTrigger
|
|
59
|
+
// If connect wallet flow is not provided it fallbacks to RainbowKit's
|
|
60
|
+
// connect modal
|
|
61
|
+
onClick={onSignIn || openConnectModal}
|
|
62
|
+
{...triggerProps?.signedOut}
|
|
63
|
+
>
|
|
64
|
+
Sign in
|
|
65
|
+
</DisconnectedTrigger>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<StatefulPopover
|
|
71
|
+
content={
|
|
72
|
+
<Content
|
|
73
|
+
onSignOut={onSignOut}
|
|
74
|
+
onOtherAssetsClick={onOtherAssetsClick}
|
|
75
|
+
/>
|
|
76
|
+
}
|
|
77
|
+
placement={placement}
|
|
78
|
+
animateOutTime={animateOutTime}
|
|
79
|
+
overrides={{
|
|
80
|
+
...overrides,
|
|
81
|
+
Body: {
|
|
82
|
+
...overrides?.Body,
|
|
83
|
+
style: {
|
|
84
|
+
width: "402px",
|
|
85
|
+
borderRadius: theme.borders.radius500,
|
|
86
|
+
boxShadow: theme.lighting.shadow500,
|
|
87
|
+
overflow: "hidden",
|
|
88
|
+
...overrides?.Body?.style,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
}}
|
|
92
|
+
{...restProps}
|
|
93
|
+
>
|
|
94
|
+
<ConnectedTrigger
|
|
95
|
+
avatar={<DefaultAvatar />}
|
|
96
|
+
{...triggerProps?.signedIn}
|
|
97
|
+
/>
|
|
98
|
+
</StatefulPopover>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeOverrides,
|
|
3
|
+
Block,
|
|
4
|
+
useStyletron,
|
|
5
|
+
BlockProps,
|
|
6
|
+
Skeleton,
|
|
7
|
+
LabelMedium,
|
|
8
|
+
ParagraphSmall,
|
|
9
|
+
} from "@mezo-org/mezo-clay"
|
|
10
|
+
import React, { ReactNode } from "react"
|
|
11
|
+
import SlotNumber from "./SlotNumber"
|
|
12
|
+
import { formatUsd } from "../../utils/currency"
|
|
13
|
+
|
|
14
|
+
type ListingItemLayoutProps = Omit<BlockProps, "children"> & {
|
|
15
|
+
icon: ReactNode
|
|
16
|
+
label: ReactNode
|
|
17
|
+
value: ReactNode
|
|
18
|
+
subLabel: ReactNode
|
|
19
|
+
subValue: ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ListingItemLayout(props: ListingItemLayoutProps) {
|
|
23
|
+
const { icon, label, value, subLabel, subValue, overrides, ...restProps } =
|
|
24
|
+
props
|
|
25
|
+
const [, theme] = useStyletron()
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Block
|
|
29
|
+
display="flex"
|
|
30
|
+
alignItems="center"
|
|
31
|
+
paddingLeft={theme.sizing.scale600}
|
|
32
|
+
paddingRight={theme.sizing.scale600}
|
|
33
|
+
overrides={mergeOverrides(
|
|
34
|
+
{
|
|
35
|
+
Block: {
|
|
36
|
+
style: {
|
|
37
|
+
gap: theme.sizing.scale600,
|
|
38
|
+
minHeight: "72px",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
overrides,
|
|
43
|
+
)}
|
|
44
|
+
{...restProps}
|
|
45
|
+
>
|
|
46
|
+
{icon && icon}
|
|
47
|
+
|
|
48
|
+
<Block display="flex" flexDirection="column" alignItems="flex-start">
|
|
49
|
+
{label && label}
|
|
50
|
+
{subLabel && subLabel}
|
|
51
|
+
</Block>
|
|
52
|
+
|
|
53
|
+
<Block
|
|
54
|
+
display="flex"
|
|
55
|
+
flexDirection="column"
|
|
56
|
+
alignItems="flex-end"
|
|
57
|
+
marginLeft="auto"
|
|
58
|
+
>
|
|
59
|
+
{value && value}
|
|
60
|
+
{subValue && subValue}
|
|
61
|
+
</Block>
|
|
62
|
+
</Block>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type ListingItemProps = {
|
|
67
|
+
icon?: ReactNode
|
|
68
|
+
label?: string
|
|
69
|
+
subLabel?: string
|
|
70
|
+
value?: number
|
|
71
|
+
subValue?: number
|
|
72
|
+
overrides?: BlockProps["overrides"]
|
|
73
|
+
isLoading?: boolean
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default function ListingItem(props: ListingItemProps) {
|
|
77
|
+
const {
|
|
78
|
+
icon,
|
|
79
|
+
label,
|
|
80
|
+
subLabel,
|
|
81
|
+
value,
|
|
82
|
+
subValue,
|
|
83
|
+
overrides,
|
|
84
|
+
isLoading = false,
|
|
85
|
+
} = props
|
|
86
|
+
|
|
87
|
+
const [, theme] = useStyletron()
|
|
88
|
+
|
|
89
|
+
if (isLoading) {
|
|
90
|
+
return (
|
|
91
|
+
<ListingItemLayout
|
|
92
|
+
icon={
|
|
93
|
+
<Skeleton
|
|
94
|
+
animation
|
|
95
|
+
width={theme.sizing.scale800}
|
|
96
|
+
height={theme.sizing.scale800}
|
|
97
|
+
/>
|
|
98
|
+
}
|
|
99
|
+
label={
|
|
100
|
+
<Skeleton
|
|
101
|
+
animation
|
|
102
|
+
width={theme.sizing.scale2400}
|
|
103
|
+
height={theme.sizing.scale600}
|
|
104
|
+
overrides={{
|
|
105
|
+
Root: {
|
|
106
|
+
style: { marginBottom: theme.sizing.scale100 },
|
|
107
|
+
},
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
}
|
|
111
|
+
subLabel={
|
|
112
|
+
<Skeleton
|
|
113
|
+
animation
|
|
114
|
+
width={theme.sizing.scale1600}
|
|
115
|
+
height={theme.sizing.scale550}
|
|
116
|
+
/>
|
|
117
|
+
}
|
|
118
|
+
value={
|
|
119
|
+
<Skeleton
|
|
120
|
+
animation
|
|
121
|
+
width={theme.sizing.scale2400}
|
|
122
|
+
height={theme.sizing.scale600}
|
|
123
|
+
overrides={{
|
|
124
|
+
Root: {
|
|
125
|
+
style: { marginBottom: theme.sizing.scale100 },
|
|
126
|
+
},
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
129
|
+
}
|
|
130
|
+
subValue={
|
|
131
|
+
<Skeleton
|
|
132
|
+
animation
|
|
133
|
+
width={theme.sizing.scale1600}
|
|
134
|
+
height={theme.sizing.scale550}
|
|
135
|
+
/>
|
|
136
|
+
}
|
|
137
|
+
overrides={overrides}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<ListingItemLayout
|
|
144
|
+
icon={icon}
|
|
145
|
+
label={<LabelMedium>{label}</LabelMedium>}
|
|
146
|
+
subLabel={
|
|
147
|
+
<ParagraphSmall
|
|
148
|
+
margin={0}
|
|
149
|
+
as="div"
|
|
150
|
+
color={theme.colors.contentSecondary}
|
|
151
|
+
>
|
|
152
|
+
{subLabel}
|
|
153
|
+
</ParagraphSmall>
|
|
154
|
+
}
|
|
155
|
+
value={
|
|
156
|
+
value !== undefined && (
|
|
157
|
+
<LabelMedium>
|
|
158
|
+
<SlotNumber formatFunction={formatUsd}>{value}</SlotNumber>
|
|
159
|
+
</LabelMedium>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
subValue={
|
|
163
|
+
subValue !== undefined && (
|
|
164
|
+
<ParagraphSmall
|
|
165
|
+
margin={0}
|
|
166
|
+
as="div"
|
|
167
|
+
color={theme.colors.contentSecondary}
|
|
168
|
+
>
|
|
169
|
+
<SlotNumber formatFunction={formatUsd}>{subValue}</SlotNumber>
|
|
170
|
+
</ParagraphSmall>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
overrides={overrides}
|
|
174
|
+
/>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowLeft,
|
|
3
|
+
Block,
|
|
4
|
+
BlockProps,
|
|
5
|
+
ButtonIcon,
|
|
6
|
+
HeadingSmall,
|
|
7
|
+
useStyletron,
|
|
8
|
+
} from "@mezo-org/mezo-clay"
|
|
9
|
+
import React, { ReactNode, useCallback } from "react"
|
|
10
|
+
import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
|
|
11
|
+
|
|
12
|
+
const getHeaderTitle = (view: DropdownView) => {
|
|
13
|
+
const titleMap: Partial<Record<DropdownView, string>> = {
|
|
14
|
+
[DropdownView.RECEIVE]: "Scan to receive",
|
|
15
|
+
[DropdownView.SETTINGS]: "Settings",
|
|
16
|
+
}
|
|
17
|
+
return titleMap[view]!
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type NestedViewLayoutProps = {
|
|
21
|
+
children: ReactNode
|
|
22
|
+
} & BlockProps
|
|
23
|
+
|
|
24
|
+
function NestedViewLayout(props: NestedViewLayoutProps) {
|
|
25
|
+
const { children, ...restProps } = props
|
|
26
|
+
|
|
27
|
+
const currentView = useDropdownStore((state) => state.view)
|
|
28
|
+
const setView = useDropdownStore((state) => state.setView)
|
|
29
|
+
|
|
30
|
+
const [, theme] = useStyletron()
|
|
31
|
+
|
|
32
|
+
const handleOnButtonClick = useCallback(() => {
|
|
33
|
+
setView(DropdownView.ROOT)
|
|
34
|
+
}, [setView])
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Block
|
|
38
|
+
display="flex"
|
|
39
|
+
flexDirection="column"
|
|
40
|
+
minHeight="588px"
|
|
41
|
+
{...restProps}
|
|
42
|
+
>
|
|
43
|
+
<Block
|
|
44
|
+
display="flex"
|
|
45
|
+
alignItems="center"
|
|
46
|
+
padding={theme.sizing.scale100}
|
|
47
|
+
paddingTop={theme.sizing.scale800}
|
|
48
|
+
paddingBottom={theme.sizing.scale500}
|
|
49
|
+
marginBottom={theme.sizing.scale300}
|
|
50
|
+
overrides={{
|
|
51
|
+
Block: {
|
|
52
|
+
style: {
|
|
53
|
+
gap: theme.sizing.scale300,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<ButtonIcon
|
|
59
|
+
onClick={handleOnButtonClick}
|
|
60
|
+
shape="circle"
|
|
61
|
+
size="medium"
|
|
62
|
+
kind="tertiary"
|
|
63
|
+
>
|
|
64
|
+
<ArrowLeft />
|
|
65
|
+
</ButtonIcon>
|
|
66
|
+
|
|
67
|
+
<HeadingSmall
|
|
68
|
+
marginTop={theme.sizing.scale300}
|
|
69
|
+
marginBottom={theme.sizing.scale300}
|
|
70
|
+
>
|
|
71
|
+
{getHeaderTitle(currentView)}
|
|
72
|
+
</HeadingSmall>
|
|
73
|
+
</Block>
|
|
74
|
+
|
|
75
|
+
<Block
|
|
76
|
+
display="flex"
|
|
77
|
+
flexDirection="column"
|
|
78
|
+
padding={theme.sizing.scale600}
|
|
79
|
+
paddingTop={0}
|
|
80
|
+
flex={1}
|
|
81
|
+
>
|
|
82
|
+
{children}
|
|
83
|
+
</Block>
|
|
84
|
+
</Block>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default NestedViewLayout
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Passport Dropdown component
|
|
2
|
+
|
|
3
|
+
This component is a layer of interaction with Passport API in form of Dropdown
|
|
4
|
+
component. It allows to establish the session and interact with the API.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
- `onSignIn` (`() => void`) - The callback to be executed on trigger click when
|
|
9
|
+
the state is disconnected. It's optional since by default it triggers the
|
|
10
|
+
[Rainbow Kit's wallet connection modal](https://www.rainbowkit.com/docs/modal-hooks).
|
|
11
|
+
If the callback is not provided it will automatically establish the Passport
|
|
12
|
+
Session. If not, you have to handle it manually using `useSignInWithWallet`
|
|
13
|
+
hook. - **optional**
|
|
14
|
+
- `onSignOut` (`() => void`) - The callback to be executed on click of the
|
|
15
|
+
**Sign out** button. It's optional since by default it disconnects the current
|
|
16
|
+
wallet connector and closes the Passport session. - **optional**
|
|
17
|
+
- `triggerProps.signedIn` (`ButtonProps`) - Props to be passed to the trigger
|
|
18
|
+
button in signed-in state.
|
|
19
|
+
- `triggerProps.signedOut` (`ButtonProps`) - Props to be passed to the trigger
|
|
20
|
+
button in signed-out state
|
|
21
|
+
|
|
22
|
+
Besides that, component allows
|
|
23
|
+
[Clay's `StatefulPopover` props](https://baseweb.design/components/popover/)
|
|
24
|
+
excluding the `children` and `content`.
|
|
25
|
+
|
|
26
|
+
## Overview
|
|
27
|
+
|
|
28
|
+
The component has two distinguishable states - disconnected and connected. In
|
|
29
|
+
disconnected state the component offers the trigger to initiate the connection
|
|
30
|
+
flow. It can be fully customizable by providing your own one. As long as it's
|
|
31
|
+
compliant with Wagmi/RainbowKit it will work. Component will automatically
|
|
32
|
+
detect connected connector and change the state of component displaying the
|
|
33
|
+
avatar thumbnail instead of button.
|
|
34
|
+
|
|
35
|
+
Component has the following features:
|
|
36
|
+
|
|
37
|
+
- displays wallet address that can be copied,
|
|
38
|
+
- displays total balance in USD,
|
|
39
|
+
- displays partial balances per asset with token amounts and USD conversions,
|
|
40
|
+
- serves _Log out_ button which disconnects the wallet connector and closes
|
|
41
|
+
Passport API session.
|