Skip to content

Commit d6b2d26

Browse files
fix: setOpenWalletModal missing param (#414)
* fix: setOpenWalletModal missing param * fix: filter by wallets title * change title * feat: filter props for collection * get contract info for collection * Add collection info header for single collection selection * Update example items --------- Co-authored-by: Tolgahan Arikan <[email protected]>
1 parent f0c8444 commit d6b2d26

File tree

8 files changed

+176
-24
lines changed

8 files changed

+176
-24
lines changed

examples/react/src/components/Connected.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,23 @@ export const Connected = () => {
516516
description="View your integrated wallet"
517517
onClick={() => setOpenWalletModal(true)}
518518
/>
519+
<CardButton
520+
title="Wallet Widget Inventory"
521+
description="Open the wallet widget with a specific collection"
522+
onClick={() =>
523+
setOpenWalletModal(true, {
524+
defaultNavigation: {
525+
location: 'search-collectibles',
526+
params: {
527+
selectedCollection: {
528+
chainId: 137,
529+
contractAddress: '0x92473261F2c26F2264429C451F70b0192f858795'
530+
}
531+
}
532+
}
533+
})
534+
}
535+
/>
519536
{(sponsoredContractAddresses[chainId] || networkForCurrentChainId.testnet) && isWaasConnectionActive && (
520537
<CardButton
521538
title="Send sponsored transaction"

packages/connect/src/styles.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const styles = String.raw`
77
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
88
--font-mono: "Roboto", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
99
--color-violet-600: oklch(0.541 0.281 293.009);
10+
--color-gray-500: oklch(0.551 0.027 264.364);
1011
--color-black: #000;
1112
--color-white: #fff;
1213
--spacing: 0.25rem;
@@ -16,6 +17,8 @@ export const styles = String.raw`
1617
--text-sm--line-height: calc(1.25 / 0.875);
1718
--text-base: 1rem;
1819
--text-base--line-height: calc(1.5 / 1);
20+
--text-lg: 1.125rem;
21+
--text-lg--line-height: calc(1.75 / 1.125);
1922
--text-xl: 1.25rem;
2023
--text-xl--line-height: calc(1.75 / 1.25);
2124
--text-2xl: 1.5rem;
@@ -307,6 +310,9 @@ export const styles = String.raw`
307310
.my-4 {
308311
margin-block: calc(var(--spacing) * 4);
309312
}
313+
.mt-0 {
314+
margin-top: calc(var(--spacing) * 0);
315+
}
310316
.mt-0\.5 {
311317
margin-top: calc(var(--spacing) * 0.5);
312318
}
@@ -382,6 +388,9 @@ export const styles = String.raw`
382388
.inline-flex {
383389
display: inline-flex;
384390
}
391+
.table {
392+
display: table;
393+
}
385394
.aspect-square {
386395
aspect-ratio: 1 / 1;
387396
}
@@ -472,6 +481,9 @@ export const styles = String.raw`
472481
.min-h-full {
473482
min-height: 100%;
474483
}
484+
.w-1 {
485+
width: calc(var(--spacing) * 1);
486+
}
475487
.w-1\/2 {
476488
width: calc(1/2 * 100%);
477489
}
@@ -565,12 +577,21 @@ export const styles = String.raw`
565577
.min-w-full {
566578
min-width: 100%;
567579
}
580+
.flex-shrink {
581+
flex-shrink: 1;
582+
}
568583
.shrink-0 {
569584
flex-shrink: 0;
570585
}
586+
.flex-grow {
587+
flex-grow: 1;
588+
}
571589
.grow {
572590
flex-grow: 1;
573591
}
592+
.border-collapse {
593+
border-collapse: collapse;
594+
}
574595
.origin-top {
575596
transform-origin: top;
576597
}
@@ -939,6 +960,9 @@ export const styles = String.raw`
939960
.pt-0 {
940961
padding-top: calc(var(--spacing) * 0);
941962
}
963+
.pt-1 {
964+
padding-top: calc(var(--spacing) * 1);
965+
}
942966
.pt-1\.5 {
943967
padding-top: calc(var(--spacing) * 1.5);
944968
}
@@ -1024,6 +1048,10 @@ export const styles = String.raw`
10241048
font-size: var(--text-base);
10251049
line-height: var(--tw-leading, var(--text-base--line-height));
10261050
}
1051+
.text-lg {
1052+
font-size: var(--text-lg);
1053+
line-height: var(--tw-leading, var(--text-lg--line-height));
1054+
}
10271055
.text-sm {
10281056
font-size: var(--text-sm);
10291057
line-height: var(--tw-leading, var(--text-sm--line-height));
@@ -1137,6 +1165,9 @@ export const styles = String.raw`
11371165
.text-black {
11381166
color: var(--color-black);
11391167
}
1168+
.text-gray-500 {
1169+
color: var(--color-gray-500);
1170+
}
11401171
.text-info {
11411172
color: var(--seq-color-info);
11421173
}
@@ -1221,6 +1252,9 @@ export const styles = String.raw`
12211252
.ring-border-normal {
12221253
--tw-ring-color: var(--seq-color-border-normal);
12231254
}
1255+
.ring-white {
1256+
--tw-ring-color: var(--color-white);
1257+
}
12241258
.ring-white\/10 {
12251259
--tw-ring-color: color-mix(in oklab, var(--color-white) 10%, transparent);
12261260
}
@@ -1256,6 +1290,10 @@ export const styles = String.raw`
12561290
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
12571291
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
12581292
}
1293+
.backdrop-filter {
1294+
-webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
1295+
backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);
1296+
}
12591297
.transition {
12601298
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter;
12611299
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));

packages/wallet-widget/src/components/SearchLists/CollectiblesList.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { SearchIcon, TextInput } from '@0xsequence/design-system'
1+
import { SearchIcon, TextInput, TokenImage } from '@0xsequence/design-system' // Import TokenImage from design-system
22
import { TokenBalance } from '@0xsequence/indexer'
33
import Fuse from 'fuse.js'
44
import { useState, useMemo } from 'react'
55

66
import { useGetMoreBalances } from '../../hooks'
77
import { TokenBalanceWithPrice } from '../../utils'
88
import { FilterButton } from '../Filter/FilterButton'
9+
import { NetworkBadge } from '../NetworkBadge'
910

1011
import { CollectiblesTab } from './CollectiblesList/CollectiblesTab'
1112

@@ -14,13 +15,20 @@ export const CollectiblesList = ({
1415
isLoadingFirstPage,
1516
onTokenClick,
1617
enableFilters = true,
17-
gridColumns = 2
18+
gridColumns = 2,
19+
collectionHeaderInfo
1820
}: {
1921
tokenBalancesData: TokenBalance[]
2022
isLoadingFirstPage: boolean
2123
onTokenClick: (token: TokenBalanceWithPrice) => void
2224
enableFilters?: boolean
2325
gridColumns?: number
26+
// Used only if a single collection is selected
27+
collectionHeaderInfo?: {
28+
logoURI?: string
29+
name?: string
30+
chainId: number
31+
}
2432
}) => {
2533
const pageSize = 8
2634

@@ -101,6 +109,24 @@ export const CollectiblesList = ({
101109
</div>
102110
{enableFilters && <FilterButton label="Collectible Filters" type="collectibles" />}
103111
</div>
112+
113+
{collectionHeaderInfo && (
114+
<div className="flex flex-col items-center mb-4">
115+
<div className="my-2">
116+
<TokenImage src={collectionHeaderInfo.logoURI} symbol={collectionHeaderInfo.name} size="lg" />
117+
</div>
118+
{collectionHeaderInfo.name && (
119+
<h2 className="text-lg text-white font-medium text-center mb-2">{collectionHeaderInfo.name}</h2>
120+
)}
121+
<NetworkBadge chainId={collectionHeaderInfo.chainId} />
122+
123+
<p className="text-sm text-gray-500 mt-2">
124+
{collectibleBalances.length} Unique Collectible
125+
{collectibleBalances.length === 0 || collectibleBalances.length > 1 ? 's' : ''}
126+
</p>
127+
</div>
128+
)}
129+
104130
<div className="w-full">
105131
<CollectiblesTab
106132
displayedCollectibleBalances={search ? infiniteSearchBalances?.pages.flat() : infiniteBalances?.pages.flat()}

packages/wallet-widget/src/components/SequenceWalletProvider/utils/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ export const getContent = (navigation: Navigation) => {
5151
case 'search-tokens':
5252
return <SearchTokens />
5353
case 'search-collectibles':
54-
return <SearchCollectibles />
54+
return (
55+
<SearchCollectibles
56+
contractAddress={navigation.params?.selectedCollection?.contractAddress}
57+
chainId={navigation.params?.selectedCollection?.chainId}
58+
/>
59+
)
5560
case 'settings':
5661
return <SettingsMenu />
5762
case 'settings-wallets':

packages/wallet-widget/src/contexts/Navigation.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ export interface SendCollectibleNavigation {
8787
params: SendCollectibleParams
8888
}
8989

90+
export interface SearchCollectiblesParams {
91+
selectedCollection: {
92+
chainId: number
93+
contractAddress: string
94+
}
95+
}
96+
97+
export interface SearchCollectiblesNavigation {
98+
location: 'search-collectibles'
99+
params?: SearchCollectiblesParams
100+
}
90101
export interface BasicNavigation {
91102
location:
92103
| 'home'
@@ -108,14 +119,14 @@ export interface BasicNavigation {
108119
| 'connect-dapp'
109120
| 'search'
110121
| 'search-tokens'
111-
| 'search-collectibles'
112122
}
113123

114124
export type Navigation =
115125
| BasicNavigation
116126
| CoinDetailsNavigation
117127
| CollectibleDetailsNavigation
118128
| TransactionDetailsNavigation
129+
| SearchCollectiblesNavigation
119130
| SearchViewAllNavigation
120131
| SendCoinNavigation
121132
| SendCollectibleNavigation

packages/wallet-widget/src/hooks/useOpenWalletModal.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { useWalletModalContext } from '../contexts/WalletModal'
1+
import { useWalletModalContext, WalletOptions } from '../contexts/WalletModal'
22

33
/**
44
* Return type for the useOpenWalletModal hook.
55
*
6-
* @property {function(isOpen: boolean): void} setOpenWalletModal - Function to open or close the Wallet modal
6+
* @property {function(isOpen: boolean, options?: WalletOptions): void} setOpenWalletModal - Function to open or close the Wallet modal
77
* @property {boolean} openWalletModalState - Current open state of the Wallet modal
88
*/
99
type UseOpenWalletModalReturnType = {
10-
setOpenWalletModal: (isOpen: boolean) => void
10+
setOpenWalletModal: (isOpen: boolean, options?: WalletOptions) => void
1111
openWalletModalState: boolean
1212
}
1313

1414
/**
15-
* Hook to manage the Wallet Inventory modal that allows users to view their tokens and NFTs.
15+
* Hook to manage the Wallet Widget modal.
1616
*
17-
* This hook provides a method to open and close the wallet inventory modal, and access its current open state.
18-
* The Wallet modal displays all tokens, NFTs and collectibles present in the connected wallet.
17+
* This hook provides a method to open and close the wallet widget modal, and access its current open state.
18+
* The Wallet Widget displays your Tokens, Collectibles, Transactions, Settings, multiple connected / linked wallets and also allows
19+
* to send, receive, buy (on-ramp) and swap tokens.
1920
*
2021
* @see {@link https://docs.sequence.xyz/sdk/web/hooks/useOpenWalletModal} for more detailed documentation.
2122
*
@@ -29,17 +30,17 @@ type UseOpenWalletModalReturnType = {
2930
* // Get the function to open/close the wallet modal
3031
* const { setOpenWalletModal } = useOpenWalletModal()
3132
*
32-
* // Function to handle opening the wallet inventory
33-
* const handleViewInventory = () => {
34-
* setOpenWalletModal(true) // Open the wallet modal to view tokens
33+
* // Function to handle opening the wallet widget modal
34+
* const handleViewWallet = () => {
35+
* setOpenWalletModal(true) // Open the wallet widget modal
3536
* }
3637
*
3738
* return (
3839
* <button
39-
* onClick={handleViewInventory}
40-
* title="Inventory"
40+
* onClick={handleViewWallet}
41+
* title="Wallet"
4142
* >
42-
* View all tokens in your wallet
43+
* View your wallet
4344
* </button>
4445
* )
4546
* }

packages/wallet-widget/src/views/Home/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ export const Home = () => {
374374
</SlideupDrawer>
375375
)}
376376
{walletFilterOpen && (
377-
<SlideupDrawer onClose={() => setWalletFilterOpen(false)} label="Select active wallet">
377+
<SlideupDrawer onClose={() => setWalletFilterOpen(false)} label="Filter items by wallet">
378378
<WalletsFilter />
379379
</SlideupDrawer>
380380
)}

0 commit comments

Comments
 (0)