-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet-dashboard): add grid for visual assets (#3758)
* feat(wallet-dashboard): add protected layout * feat: add missing TopNav * fix: tests * fix: imports * feat(wallet-dashboard): add assets page * fix: add missing themes * feat: improve connect button size * revert: "feat: improve connect button size" * feat(wallet-dashboard): add grid for visual assets * refactor: remove unnecessary useMemo * fix: remove commented lines * fix: improve type * fix: update IotaLogo --------- Co-authored-by: evavirseda <[email protected]>
- Loading branch information
1 parent
bd07963
commit 0d967e5
Showing
17 changed files
with
256 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useState } from 'react'; | ||
import { type InfiniteData, type UseInfiniteQueryResult } from '@tanstack/react-query'; | ||
|
||
interface PaginationProps { | ||
hasFirst: boolean; | ||
hasPrev: boolean; | ||
hasNext: boolean; | ||
onFirst(): void; | ||
onPrev(): void; | ||
onNext(): void; | ||
} | ||
|
||
interface CursorPaginationProps extends PaginationProps { | ||
currentPage: number; | ||
} | ||
|
||
export interface PaginationResponse<Cursor = string> { | ||
nextCursor: Cursor | null; | ||
hasNextPage: boolean; | ||
} | ||
|
||
export function useCursorPagination<T>(query: UseInfiniteQueryResult<InfiniteData<T>>) { | ||
const [currentPage, setCurrentPage] = useState(0); | ||
|
||
return { | ||
...query, | ||
data: query.data?.pages[currentPage], | ||
pagination: { | ||
onFirst: () => setCurrentPage(0), | ||
onNext: () => { | ||
if (!query.data || query.isFetchingNextPage) { | ||
return; | ||
} | ||
|
||
// Make sure we are at the end before fetching another page | ||
if (currentPage >= query.data.pages.length - 1) { | ||
query.fetchNextPage(); | ||
} | ||
|
||
setCurrentPage(currentPage + 1); | ||
}, | ||
onPrev: () => { | ||
setCurrentPage(Math.max(currentPage - 1, 0)); | ||
}, | ||
hasFirst: currentPage !== 0, | ||
hasNext: | ||
!query.isFetchingNextPage && | ||
(currentPage < (query.data?.pages.length ?? 0) - 1 || !!query.hasNextPage), | ||
hasPrev: currentPage !== 0, | ||
currentPage, | ||
} satisfies CursorPaginationProps, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/ui-kit/src/lib/components/atoms/visual-asset-card/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export { VisualAssetCard } from './VisualAssetCard'; | ||
export * from './VisualAssetCard'; | ||
export * from './visual-asset-card.enums'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.