Skip to content

Commit

Permalink
Merge branch 'stardust-develop' into feat/parsed-metadata-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed Nov 29, 2022
2 parents 81a28e8 + 2986c71 commit f3ed2d6
Show file tree
Hide file tree
Showing 16 changed files with 504 additions and 56 deletions.
Expand Up @@ -4,12 +4,10 @@
</script>

<div class="w-full h-full flex flex-col flex-nowrap p-10 relative flex-1 bg-gray-50 dark:bg-gray-900">
<div class="w-full h-full grid grid-cols-1 gap-x-4 min-h-0">
{#if $collectiblesRoute === CollectiblesRoute.Gallery}
<GalleryView />
{/if}
{#if $collectiblesRoute === CollectiblesRoute.Details}
<DetailsView />
{/if}
</div>
{#if $collectiblesRoute === CollectiblesRoute.Gallery}
<GalleryView />
{/if}
{#if $collectiblesRoute === CollectiblesRoute.Details}
<DetailsView />
{/if}
</div>
Expand Up @@ -25,7 +25,7 @@
const storageDeposit = 0 // TODO: get storage deposit from corresponding activity
</script>

<div class="flex flex-row w-full space-x-4 overflow-auto">
<div class="flex flex-row w-full h-full space-x-4 overflow-auto">
<div class="w-full h-full bg-orange-300 rounded-2xl">
<!-- NFT asset goes here -->
</div>
Expand Down
@@ -1,5 +1,5 @@
<script lang="typescript">
import { Text, FontWeight, NftGalleryItem } from 'shared/components'
import { Text, FontWeight, NftGalleryItem, ReceiveButton, Illustration } from 'shared/components'
import { CollectiblesRoute, collectiblesRouter } from '@core/router'
import { INft, selectedAccountNfts } from '@core/nfts'
import { selectedNftId } from '../stores/selected-nft.store'
Expand All @@ -11,13 +11,33 @@
}
</script>

<div class="flex flex-row text-left space-x-1 items-center">
<Text fontSize="text-14" fontWeight={FontWeight.semibold}>{localize('views.collectibles.gallery.title')}</Text>
<Text fontSize="text-14" fontWeight={FontWeight.semibold} color="gray-500">• {$selectedAccountNfts.length}</Text>
</div>
<div class="flex flex-col w-full h-full space-y-4">
<div class="flex flex-row text-left space-x-1 items-center grow-0">
<Text fontSize="text-14" fontWeight={FontWeight.semibold}>{localize('views.collectibles.gallery.title')}</Text>
<Text fontSize="text-14" fontWeight={FontWeight.semibold} color="gray-500">• {$selectedAccountNfts.length}</Text
>
</div>

<div class="h-full flex flex-wrap flex-row gap-6 mt-4 scrollable-y">
{#each $selectedAccountNfts as nft}
<NftGalleryItem {nft} onClick={() => handleNftClick(nft)} />
{/each}
<div class="w-full h-full flex items-center justify-center grow-1">
{#if $selectedAccountNfts.length}
<div class="h-full flex flex-wrap flex-row gap-6 scrollable-y">
{#each $selectedAccountNfts as nft}
<NftGalleryItem {nft} onClick={() => handleNftClick(nft)} />
{/each}
</div>
{:else}
<div class="flex flex-col items-center space-y-8">
<Illustration illustration="empty-collectibles" width="134" height="134" />
<div class="flex flex-col items-center">
<Text fontSize="text-14" fontWeight={FontWeight.semibold} color="gray-500"
>{localize('views.collectibles.gallery.emptyTitle')}</Text
>
<Text fontSize="text-14" color="gray-500"
>{localize('views.collectibles.gallery.emptyDescription')}</Text
>
</div>
<ReceiveButton text={localize('actions.depositNft')} />
</div>
{/if}
</div>
</div>
45 changes: 45 additions & 0 deletions packages/shared/assets/illustrations/wallet/empty-collectibles.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/shared/components/Illustration.svelte
Expand Up @@ -75,6 +75,11 @@
lightmode: 'staking/staking-notification.svg',
darkmode: 'staking/staking-notification.svg',
},
// Wallet
'empty-collectibles': {
lightmode: 'wallet/empty-collectibles.svg',
darkmode: 'wallet/empty-collectibles.svg',
},
}
</script>

Expand Down
6 changes: 4 additions & 2 deletions packages/shared/components/atoms/buttons/ReceiveButton.svelte
Expand Up @@ -2,6 +2,8 @@
import { localize } from '@core/i18n'
import { openPopup } from '@auxiliary/popup'
export let text: string = localize('actions.receive')
function handleReceiveClick(): void {
openPopup({
type: 'receiveAddress',
Expand All @@ -10,8 +12,8 @@
</script>

<button
class="action p-3 w-full text-center rounded-lg font-medium text-14 bg-blue-500 text-white"
class="action py-3 px-8 text-center rounded-lg font-medium text-14 bg-blue-500 text-white"
on:click={handleReceiveClick}
>
{localize('actions.receive')}
{text}
</button>
119 changes: 119 additions & 0 deletions packages/shared/components/inputs/AssetAmountSliderInput.svelte
@@ -0,0 +1,119 @@
<script lang="typescript">
import { Text, FontWeight, AssetIcon, InputContainer, AmountInput, SliderInput, UnitInput } from 'shared/components'
import { convertToRawAmount, formatTokenAmountBestMatch, formatTokenAmountDefault, IAsset } from '@core/wallet'
import { IOTA_UNIT_MAP } from '@core/utils'
import { parseCurrency } from '@core/i18n/utils/parseCurrency'
import { localize } from '@core/i18n'
import Big from 'big.js'
export let inputElement: HTMLInputElement = undefined
export let disabled = false
export let isFocused = false
export let asset: IAsset
export let rawAmount: string = undefined
export let unit: string = undefined
let amountInputElement: HTMLInputElement
let error: string
let amount: string = rawAmount
? formatTokenAmountDefault(Number(rawAmount), asset?.metadata, unit, false)
: undefined
$: isFocused && (error = '')
let allowedDecimals = 0
$: if (!asset?.metadata?.useMetricPrefix) {
if (unit === asset?.metadata.unit) {
allowedDecimals = Math.min(asset?.metadata.decimals, 18)
} else if (unit === asset?.metadata?.subunit) {
allowedDecimals = 0
}
} else if (asset?.metadata?.useMetricPrefix) {
allowedDecimals = IOTA_UNIT_MAP?.[unit?.substring(0, 1)] ?? 0
}
$: bigAmount = convertToRawAmount(amount, unit, asset?.metadata)
export function validate(): Promise<void> {
const amountAsFloat = parseCurrency(amount)
const isAmountZeroOrNull = !Number(amountAsFloat)
// Zero value transactions can still contain metadata/tags
error = ''
if (isAmountZeroOrNull) {
error = localize('error.send.amountInvalidFormat')
} else if (
(unit === asset?.metadata?.subunit ||
(unit === asset?.metadata?.unit && asset?.metadata?.decimals === 0)) &&
Number.parseInt(amount, 10).toString() !== amount
) {
error = localize('error.send.amountNoFloat')
} else if (bigAmount.gt(Big(asset?.balance?.available))) {
error = localize('error.send.amountTooHigh')
} else if (bigAmount.lte(Big(0))) {
error = localize('error.send.amountZero')
} else if (!bigAmount.mod(1).eq(Big(0))) {
error = localize('error.send.amountSmallerThanSubunit')
}
if (error) {
return Promise.reject(error)
}
rawAmount = bigAmount.toString()
}
</script>

<InputContainer
bind:this={inputElement}
bind:inputElement={amountInputElement}
col
{isFocused}
{error}
classes="space-y-5"
on:clickOutside={() => (isFocused = false)}
>
<div class="flex flex-row w-full items-center space-x-0.5 relative">
<div
class="flex flex-row items-center p-2 space-x-2 text-left bg-gray-100 dark:bg-gray-700 rounded-md cursor-default"
>
<AssetIcon small {asset} />
<div class="w-full relative" style="max-width: 75px;">
<Text
color="gray-600"
darkColor="white"
fontWeight={FontWeight.semibold}
fontSize="15"
classes="overflow-hidden whitespace-nowrap overflow-ellipsis"
>
{asset?.metadata?.name ?? asset?.id}
</Text>
</div>
</div>
<AmountInput
bind:inputElement={amountInputElement}
bind:amount
bind:hasFocus={isFocused}
maxDecimals={allowedDecimals}
isInteger={allowedDecimals === 0}
clearBackground
clearPadding
clearBorder
{disabled}
/>
<UnitInput bind:unit bind:isFocused tokenMetadata={asset?.metadata} />
</div>
<div class="flex flex-col">
<SliderInput
bind:value={amount}
max={Number(formatTokenAmountDefault(asset?.balance?.available, asset.metadata, unit, false))}
decimals={asset.metadata.decimals}
/>
<div class="flex flex-row justify-between">
<Text color="gray-800" darkColor="gray-500" fontSize="xs"
>{formatTokenAmountBestMatch(0, asset?.metadata)}</Text
>
<Text color="gray-800" darkColor="gray-500" fontSize="xs"
>{formatTokenAmountBestMatch(asset?.balance?.available, asset?.metadata)}</Text
>
</div>
</div>
</InputContainer>

0 comments on commit f3ed2d6

Please sign in to comment.