-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e21dc5d
commit 4fd44e0
Showing
17 changed files
with
351 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
50 changes: 50 additions & 0 deletions
50
packages/desktop/views/dashboard/buy-sell/components/TokenTile.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,50 @@ | ||
<script lang="ts"> | ||
import { formatCurrency } from '@core/i18n/utils' | ||
import { getMarketPriceForToken, getTokenValueFromFiatAmount } from '@core/market/actions' | ||
import { formatTokenAmount } from '@core/token' | ||
import { truncateString } from '@core/utils' | ||
import { Tile, Text } from '@bloomwalletio/ui' | ||
import { TokenAvatar } from '@ui' | ||
import { selectedAccountTokens } from '@core/token/stores' | ||
import { SupportedStardustNetworkId } from '@core/network' | ||
import { MarketCurrency } from '@core/market' | ||
export let token = $selectedAccountTokens[SupportedStardustNetworkId.Iota]?.baseCoin | ||
export let onClick: (() => unknown) | undefined = undefined | ||
export let selected = false | ||
export let fiatValue = '0' | ||
export let currency: MarketCurrency | ||
$: marketPrice = token ? getMarketPriceForToken(token, currency) : undefined | ||
$: tokenAmount = token && currency ? getTokenValueFromFiatAmount(fiatValue, token, currency) : BigInt(0) | ||
</script> | ||
|
||
{#if token && token.metadata} | ||
<Tile {onClick} {selected} surface={1} width="full"> | ||
<div class="w-full flex flex-row items-center gap-2"> | ||
<TokenAvatar {token} /> | ||
<div class="flex flex-col w-full"> | ||
<div class="flex flex-row w-full justify-between"> | ||
<Text> | ||
{token.metadata.name | ||
? truncateString(token.metadata.name, 13, 0) | ||
: truncateString(token.id, 6, 7)} | ||
</Text> | ||
<Text align="right"> | ||
{token.metadata | ||
? `≈ ${formatTokenAmount(tokenAmount ?? BigInt(0), token.metadata, { round: false })}` | ||
: '-'} | ||
</Text> | ||
</div> | ||
<div class="flex flex-row w-full justify-between"> | ||
<Text fontWeight="medium" textColor="secondary"> | ||
{marketPrice ? formatCurrency(marketPrice, currency) : '-'} | ||
</Text> | ||
<Text fontWeight="medium" textColor="secondary" align="right"> | ||
{fiatValue !== undefined ? formatCurrency(fiatValue ?? '', currency) : '-'} | ||
</Text> | ||
</div> | ||
</div> | ||
</div> | ||
</Tile> | ||
{/if} |
49 changes: 0 additions & 49 deletions
49
packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
packages/desktop/views/dashboard/buy-sell/components/TransakAmountInput.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,26 @@ | ||
<script lang="ts"> | ||
import { activeProfile } from '@core/profile/stores' | ||
import { AmountInput } from '@ui' | ||
import { Text } from '@bloomwalletio/ui' | ||
export let currency = $activeProfile?.settings?.marketCurrency?.toUpperCase() | ||
export let value: string | ||
let inputLength: number | ||
const fontSize: 'text-32' | 'text-48' | 'text-64' = 'text-64' | ||
$: value, (inputLength = getInputLength()) | ||
$: maxWidth = `${(inputLength * Number(/\d+/.exec(fontSize)?.[0] ?? 0) * 2) / 3}px` | ||
function getInputLength(): number { | ||
const length = value?.length || 1 | ||
const isDecimal = value?.includes('.') || value?.includes(',') | ||
return length - (isDecimal ? 0.5 : 0) | ||
} | ||
</script> | ||
|
||
<div class="flex justify-center items-end gap-1"> | ||
<AmountInput bind:value maxDecimals={2} {fontSize} {maxWidth} /> | ||
<Text class="pb-5">{currency}</Text> | ||
</div> |
74 changes: 74 additions & 0 deletions
74
packages/desktop/views/dashboard/buy-sell/components/TransakExchangePanel.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,74 @@ | ||
<script lang="ts"> | ||
import { Platform, openUrlInBrowser } from '@core/app' | ||
import { Pane } from '@ui' | ||
import { Button, Icon, IconName, IOption, SelectInput, Tabs, Text } from '@bloomwalletio/ui' | ||
import { localize } from '@core/i18n' | ||
import { DISCORD_URL } from '@contexts/settings/constants' | ||
import { isFeatureEnabled } from '@lib/features/utils' | ||
import { TokenTile, TransakAmountInput } from './' | ||
import { FiatCurrency } from '@core/market' | ||
export let loading: boolean = false | ||
let error: boolean = false | ||
let fiatValue: string = '' | ||
Platform.onEvent('transak-loaded', () => (loading = false)) | ||
Platform.onEvent('transak-not-loaded', () => (error = true)) | ||
function onButtonClick(): void { | ||
openUrlInBrowser(DISCORD_URL) | ||
} | ||
const TABS = [ | ||
{ key: 'buy', value: localize('views.buySell.tabs.buy') }, | ||
{ key: 'sell', value: localize('views.buySell.tabs.sell') }, | ||
] | ||
let selectedTab = TABS[0] | ||
const PAYMENT_METHOD_OPTIONS: IOption[] = [ | ||
{ value: 'credit_card', label: 'Credit Card' }, | ||
{ value: 'bank_transfer', label: 'Bank Transfer' }, | ||
] | ||
const CURRENCY_OPTIONS: IOption[] = Object.keys(FiatCurrency).map((currency) => ({ | ||
value: currency, | ||
})) | ||
let selectedCurrencyOption: IOption = CURRENCY_OPTIONS[0] | ||
$: selectedCurrency = selectedCurrencyOption.value | ||
</script> | ||
|
||
<Pane classes="px-6 pb-6 pt-4 bg-surface dark:bg-surface-dark shadow-lg w-full h-full"> | ||
{#if error} | ||
<div class="flex flex-col justify-center items-center w-full h-full gap-4"> | ||
<Icon name={IconName.ArrowDownUp} size="lg" textColor="brand" /> | ||
<Text type="body1">{localize('views.buySell.error.title')}</Text> | ||
<Text textColor="secondary" align="center">{localize('views.buySell.error.description')}</Text> | ||
<Button on:click={onButtonClick} text={localize('actions.visitDiscord')} /> | ||
</div> | ||
{:else if loading} | ||
<div class="flex flex-col justify-between items-center w-full h-full gap-8"> | ||
{#if isFeatureEnabled('buySell.sell')} | ||
<div class="w-full"> | ||
<Tabs bind:selectedTab tabs={TABS} /> | ||
</div> | ||
{/if} | ||
<div class="flex flex-col items-center gap-4 w-full"> | ||
<div class="w-3/4"> | ||
<SelectInput label="Currency" options={CURRENCY_OPTIONS} bind:selected={selectedCurrencyOption} /> | ||
</div> | ||
<TransakAmountInput currency={selectedCurrency} bind:value={fiatValue} /> | ||
<TokenTile {fiatValue} currency={FiatCurrency[selectedCurrency]} /> | ||
<div class="w-full"> | ||
<SelectInput | ||
label="Payment method" | ||
options={PAYMENT_METHOD_OPTIONS} | ||
selected={PAYMENT_METHOD_OPTIONS[0]} | ||
hideValue | ||
/> | ||
</div> | ||
</div> | ||
<Button text={selectedTab.value} /> | ||
</div> | ||
{/if} | ||
</Pane> |
8 changes: 8 additions & 0 deletions
8
packages/desktop/views/dashboard/buy-sell/components/TransakHistoryPanel.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,8 @@ | ||
<script lang="ts"> | ||
import { Pill } from '@bloomwalletio/ui' | ||
import { Pane } from '@ui' | ||
</script> | ||
|
||
<Pane classes="flex flex-col justify-start items-start w-full h-full p-6 gap-4 bg-surface dark:bg-surface-dark shadow-lg"> | ||
<Pill color="brand">Order history</Pill> | ||
</Pane> |
30 changes: 0 additions & 30 deletions
30
packages/desktop/views/dashboard/buy-sell/components/TransakWindowPlaceholder.svelte
This file was deleted.
Oops, something went wrong.
6 changes: 4 additions & 2 deletions
6
packages/desktop/views/dashboard/buy-sell/components/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,4 +1,6 @@ | ||
export { default as TransakAccountPanel } from './TransakAccountPanel.svelte' | ||
export { default as TokenTile } from './TokenTile.svelte' | ||
export { default as TransakAmountInput } from './TransakAmountInput.svelte' | ||
export { default as TransakConnectionPanel } from './TransakConnectionPanel.svelte' | ||
export { default as TransakHistoryPanel } from './TransakHistoryPanel.svelte' | ||
export { default as TransakExchangePanel } from './TransakExchangePanel.svelte' | ||
export { default as TransakInfoPanel } from './TransakInfoPanel.svelte' | ||
export { default as TransakWindowPlaceholder } from './TransakWindowPlaceholder.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
Oops, something went wrong.