-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved nft components to folder, fixed selection issues
- Loading branch information
1 parent
4b4339e
commit b7bd97e
Showing
15 changed files
with
134 additions
and
118 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
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
77 changes: 0 additions & 77 deletions
77
packages/bridge-ui-v2/src/components/NFTCard/NFTCard.svelte
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
packages/bridge-ui-v2/src/components/NFTs/NFTCards/NFTCard.svelte
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,79 @@ | ||
<script lang="ts"> | ||
import { selectedNFTs } from '$components/Bridge/state'; | ||
import { Icon } from '$components/Icon'; | ||
import NftInfoDialog from '$components/NFTs/NFTInfoDialog.svelte'; | ||
import type { NFT } from '$libs/token'; | ||
export let nft: NFT; | ||
export let selectNFT: (nft: NFT) => void; | ||
export let viewOnly = false; | ||
const placeholderUrl = 'https://placehold.co/400x400.png'; | ||
let imageUrl: string = nft.metadata?.image || placeholderUrl; | ||
let isChecked = false; | ||
let modalOpen = false; | ||
const handleDialogSelection = () => { | ||
selectNFT(nft); | ||
modalOpen = false; | ||
}; | ||
const handleImageClick = () => { | ||
selectNFT(nft); | ||
}; | ||
$: { | ||
isChecked = $selectedNFTs ? $selectedNFTs.some((selected) => selected.tokenId === nft.tokenId) : false; | ||
} | ||
</script> | ||
|
||
<div class="rounded-[10px] w-[120px] bg-white max-h-[160px] min-h-[160px] relative"> | ||
{#if !viewOnly} | ||
<label for="nft-radio" class="cursor-pointer"> | ||
<input type="radio" class="hidden" name="nft-radio" checked={isChecked} on:change={() => selectNFT(nft)} /> | ||
|
||
{#if isChecked} | ||
<div | ||
class="selected-overlay rounded-[10px]" | ||
role="button" | ||
tabindex="0" | ||
on:click={handleImageClick} | ||
on:keydown={handleImageClick}> | ||
<Icon type="check-circle" class="f-center " fillClass="fill-primary-brand" width={40} height={40} /> | ||
</div> | ||
{/if} | ||
<div role="button" tabindex="0" class="h-[125px]" on:click={handleImageClick} on:keydown={handleImageClick}> | ||
<img alt={nft.name} src={imageUrl} class="rounded-t-[10px] h-[124px]" /> | ||
</div> | ||
</label> | ||
{:else} | ||
<img alt={nft.name} src={imageUrl} class="rounded-t-[10px] h-[124px]" /> | ||
{/if} | ||
|
||
<button | ||
name="nftInfoDialog" | ||
class="px-[10px] py-[8px] h-[36px] f-between-center w-full" | ||
on:click={() => (modalOpen = true)} | ||
><span class="font-bold text-black">{nft.tokenId} </span> | ||
<Icon type="option-dots" fillClass="fill-grey-500" /></button> | ||
</div> | ||
|
||
<NftInfoDialog {nft} bind:modalOpen on:selected={() => handleDialogSelection()} {viewOnly} /> | ||
|
||
<style> | ||
.selected-overlay { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(11, 16, 27, 0.7); /* Gray-900 0.7 opacity */ | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: 3px solid var(--primary-brand); | ||
} | ||
</style> |
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
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
packages/bridge-ui-v2/src/components/NFTs/NFTDisplay.svelte
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,31 @@ | ||
<script lang="ts"> | ||
import { t } from 'svelte-i18n'; | ||
import { LoadingMask } from '$components/LoadingMask'; | ||
import type { NFT } from '$libs/token'; | ||
import { network } from '$stores/network'; | ||
import { NFTCardGrid } from './NFTCards'; | ||
import { NFTList } from './NFTList'; | ||
import { NFTView } from './types'; | ||
export let loading: boolean; | ||
export let viewOnly = false; | ||
export let nfts: NFT[] | null = []; | ||
export let nftView: NFTView = NFTView.LIST; | ||
</script> | ||
|
||
<div class="relative max-h-[350px] min-h-[350px] bg-neutral rounded-[20px] overflow-hidden"> | ||
<div class="max-h-[350px] min-h-[350px] overflow-y-auto py-2 px-[20px]"> | ||
{#if loading} | ||
<LoadingMask spinnerClass="border-white" text={$t('messages.bridge.nft_scanning')} /> | ||
{:else if nftView === NFTView.LIST && nfts} | ||
<NFTList bind:nfts chainId={$network?.id} {viewOnly} /> | ||
{:else if nftView === NFTView.CARDS && nfts} | ||
<NFTCardGrid bind:nfts {viewOnly} /> | ||
{/if} | ||
</div> | ||
</div> |
File renamed without changes.
File renamed without changes.
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,2 @@ | ||
export { default as NFTList } from './NFTList.svelte'; | ||
export { default as NFTListItem } from './NFTListItem.svelte'; |
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 @@ | ||
export { default as NFTDisplay } from './NFTDisplay.svelte'; |
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,4 @@ | ||
export enum NFTView { | ||
CARDS, | ||
LIST, | ||
} |