-
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.
feat(bridge-ui-v2): bridge form (#14056)
- Loading branch information
1 parent
1ef2126
commit b39b328
Showing
77 changed files
with
1,484 additions
and
144 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
7 changes: 7 additions & 0 deletions
7
packages/bridge-ui-v2/src/components/Activities/Activities.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,7 @@ | ||
<script> | ||
import { t } from 'svelte-i18n'; | ||
import { Card } from '$components/Card'; | ||
</script> | ||
|
||
<Card title={$t('activities.title')} text={$t('activities.subtitle')}>TODO: Activities</Card> |
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 Activities } from './Activities.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,56 @@ | ||
<script lang="ts"> | ||
import { classNames } from '$libs/util/classNames'; | ||
import { Icon, type IconType } from '../Icon'; | ||
type AlertType = 'success' | 'warning' | 'error' | 'info'; | ||
type AlertTypeDetails = { | ||
class: string; | ||
iconType: IconType; | ||
iconFillClass: string; | ||
}; | ||
export let type: AlertType; | ||
export let forceColumnFlow = false; | ||
let typeMap: Record<AlertType, AlertTypeDetails> = { | ||
success: { | ||
class: 'alert-success', | ||
iconType: 'check-circle', | ||
iconFillClass: 'fill-success-content', | ||
}, | ||
warning: { | ||
class: 'alert-warning', | ||
iconType: 'exclamation-circle', | ||
iconFillClass: 'fill-warning-content', | ||
}, | ||
error: { | ||
class: 'alert-danger', | ||
iconType: 'x-close-circle', | ||
iconFillClass: 'fill-error-content', | ||
}, | ||
info: { | ||
class: 'alert-info', | ||
iconType: 'info-circle', | ||
iconFillClass: 'fill-info-content', | ||
}, | ||
}; | ||
const classes = classNames( | ||
'alert gap-[5px] py-[12px] px-[20px] rounded-[10px]', | ||
type ? typeMap[type].class : null, | ||
forceColumnFlow ? 'grid-flow-col text-left' : null, | ||
$$props.class, | ||
); | ||
const iconType = typeMap[type].iconType; | ||
const iconFillClass = typeMap[type].iconFillClass; | ||
</script> | ||
|
||
<div class={classes}> | ||
<div class="self-start"> | ||
<Icon type={iconType} fillClass={iconFillClass} size={24} /> | ||
</div> | ||
<div class="callout-regular"> | ||
<slot /> | ||
</div> | ||
</div> |
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 Alert } from './Alert.svelte'; |
27 changes: 27 additions & 0 deletions
27
packages/bridge-ui-v2/src/components/AmountInput/AmountInput.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,27 @@ | ||
<script lang="ts"> | ||
import { t } from 'svelte-i18n'; | ||
import { InputBox } from '$components/InputBox'; | ||
import { uid } from '$libs/util/uid'; | ||
let inputId = `input-${uid()}`; | ||
</script> | ||
|
||
<div class="f-col space-y-2"> | ||
<div class="f-between-center text-secondary-content body-regular"> | ||
<label for={inputId}>{$t('amount_input.label')}</label> | ||
<div> | ||
<span>{$t('amount_input.balance')}:</span> | ||
<span>399.92 ETH</span> | ||
</div> | ||
</div> | ||
<div class="relative f-items-center"> | ||
<InputBox | ||
id={inputId} | ||
type="number" | ||
placeholder="0.01" | ||
min="0" | ||
class="w-full input-box outline-none py-6 pr-16 px-[26px] title-subsection-bold placeholder:text-tertiary-content" /> | ||
<button class="absolute right-6 uppercase">{$t('amount_input.max_button')}</button> | ||
</div> | ||
</div> |
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 } from './AmountInput.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,45 @@ | ||
<script> | ||
import { t } from 'svelte-i18n'; | ||
import AmountInput from '$components/AmountInput'; | ||
import Button from '$components/Button/Button.svelte'; | ||
import { Card } from '$components/Card'; | ||
import { ChainSelector } from '$components/ChainSelector'; | ||
import Icon from '$components/Icon/Icon.svelte'; | ||
import { ProcessingFee } from '$components/ProcessingFee'; | ||
import { RecipientInput } from '$components/RecipientInput'; | ||
import { TokenDropdown } from '$components/TokenDropdown'; | ||
import { tokens } from '$libs/token'; | ||
</script> | ||
|
||
<Card title={$t('bridge.title')} text={$t('bridge.subtitle')}> | ||
<div class="space-y-[35px]"> | ||
<div class="space-y-4"> | ||
<div class="space-y-2"> | ||
<ChainSelector label={$t('chain.from')} /> | ||
<TokenDropdown {tokens} /> | ||
</div> | ||
|
||
<AmountInput /> | ||
|
||
<div class="f-justify-center"> | ||
<button> | ||
<Icon type="up-down-circle" size={36} /> | ||
</button> | ||
</div> | ||
|
||
<div class="space-y-2"> | ||
<ChainSelector label={$t('chain.to')} /> | ||
<RecipientInput /> | ||
</div> | ||
</div> | ||
|
||
<ProcessingFee /> | ||
|
||
<div class="h-sep" /> | ||
|
||
<Button type="primary" class="px-[28px] py-[14px]"> | ||
<span class="body-bold">{$t('bridge.bridge_button')}</span> | ||
</Button> | ||
</div> | ||
</Card> |
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 Bridge } from './Bridge.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
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 +1 @@ | ||
export { default } from './Button.svelte'; | ||
export { default as Button } from './Button.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,16 @@ | ||
<script lang="ts"> | ||
export let title: string; | ||
export let text = ''; | ||
</script> | ||
|
||
<div class="card w-full md:w-[524px] md:bg-elevated-background rounded-[20px] md:border md:border-neutral-background"> | ||
<div class="card-body p-4 md:p-12 body-regular"> | ||
<h2 class="card-title title-screen-bold">{title}</h2> | ||
{#if text} | ||
<p>{text}</p> | ||
{/if} | ||
<div class="f-col mt-[35px]"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</div> |
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 Card } from './Card.svelte'; |
102 changes: 102 additions & 0 deletions
102
packages/bridge-ui-v2/src/components/ChainSelector/ChainSelector.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,102 @@ | ||
<script lang="ts"> | ||
import type { ComponentType } from 'svelte'; | ||
import { noop, onDestroy } from 'svelte/internal'; | ||
import { t } from 'svelte-i18n'; | ||
import { EthIcon, Icon, TaikoIcon } from '$components/Icon'; | ||
import { PUBLIC_L1_CHAIN_ID, PUBLIC_L2_CHAIN_ID } from '$env/static/public'; | ||
import { chains, type ExtendedChain } from '$libs/chain'; | ||
import { uid } from '$libs/util/uid'; | ||
export let label: string; | ||
export let onChange: (chain: ExtendedChain) => void = noop; | ||
let chainToIconMap: Record<string, ComponentType> = { | ||
[PUBLIC_L1_CHAIN_ID]: EthIcon, | ||
[PUBLIC_L2_CHAIN_ID]: TaikoIcon, | ||
}; | ||
let buttonId = `button-${uid()}`; | ||
let dialogId = `dialog-${uid()}`; | ||
let selectedChain: ExtendedChain; | ||
let modalOpen = false; | ||
function closeModal() { | ||
modalOpen = false; | ||
} | ||
function openModal() { | ||
modalOpen = true; | ||
} | ||
function selectChain(chain: ExtendedChain) { | ||
selectedChain = chain; | ||
onChange?.(chain); // TODO: data binding? 🤔 | ||
closeModal(); | ||
} | ||
function onChainKeydown(event: KeyboardEvent, chain: ExtendedChain) { | ||
if (event.key === 'Enter') { | ||
selectChain(chain); | ||
} | ||
} | ||
onDestroy(closeModal); | ||
</script> | ||
|
||
<div class="ChainSelector"> | ||
<div class="f-items-center space-x-[10px]"> | ||
<label class="text-secondary-content body-regular" for={buttonId}>{label}:</label> | ||
<button | ||
id={buttonId} | ||
type="button" | ||
aria-haspopup="dialog" | ||
aria-controls={dialogId} | ||
aria-expanded={modalOpen} | ||
class="px-2 py-[6px] body-small-regular bg-neutral-background rounded-md min-w-[150px]" | ||
on:click={openModal}> | ||
<div class="f-items-center space-x-2"> | ||
{#if !selectedChain} | ||
<span>{$t('chain_selector.placeholder')}…</span> | ||
{/if} | ||
{#if selectedChain} | ||
<i role="img" aria-label={selectedChain.name}> | ||
<svelte:component this={chainToIconMap[selectedChain.id]} size={20} /> | ||
</i> | ||
<span>{selectedChain.name}</span> | ||
{/if} | ||
</div> | ||
</button> | ||
</div> | ||
|
||
<dialog id={dialogId} class="modal" class:modal-open={modalOpen}> | ||
<div class="modal-box relative px-6 py-[21px] bg-primary-base-background text-primary-base-content"> | ||
<button class="absolute right-6 top-[21px]" on:click={closeModal}> | ||
<Icon type="x-close" fillClass="fill-secondary-icon" /> | ||
</button> | ||
<h3 class="title-body-bold">{$t('chain_selector.placeholder')}</h3> | ||
<ul class="menu space-y-4"> | ||
{#each chains as chain (chain.id)} | ||
<li | ||
role="menuitem" | ||
tabindex="0" | ||
on:click={() => selectChain(chain)} | ||
on:keydown={(event) => onChainKeydown(event, chain)}> | ||
<!-- TODO: agree on hover:bg color --> | ||
<div class="f-row justify-between hover:text-primary-base-content hover:bg-grey-10"> | ||
<div class="f-items-center space-x-4"> | ||
<i role="img" aria-label={chain.name}> | ||
<svelte:component this={chainToIconMap[chain.id]} size={32} /> | ||
</i> | ||
<span class="body-bold">{chain.name}</span> | ||
</div> | ||
<span class="body-regular">{chain.network}</span> | ||
</div> | ||
</li> | ||
{/each} | ||
</ul> | ||
</div> | ||
|
||
<div class="overlay-backdrop" /> | ||
</dialog> | ||
</div> |
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 ChainSelector } from './ChainSelector.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,29 @@ | ||
<script> | ||
import { t } from 'svelte-i18n'; | ||
import { Alert } from '$components/Alert'; | ||
import { Button } from '$components/Button'; | ||
import { Card } from '$components/Card'; | ||
import { ChainSelector } from '$components/ChainSelector'; | ||
import { TokenDropdown } from '$components/TokenDropdown'; | ||
import { testERC20Tokens } from '$libs/token'; | ||
</script> | ||
|
||
<Card title={$t('faucet.title')} text={$t('faucet.subtitle')}> | ||
<div class="space-y-[35px]"> | ||
<div class="space-y-2"> | ||
<ChainSelector label={$t('faucet.currently_on')} /> | ||
<TokenDropdown tokens={testERC20Tokens} /> | ||
</div> | ||
|
||
<Button type="primary" class="px-[28px] py-[14px]"> | ||
<span class="body-bold">{$t('faucet.mint_button')}</span> | ||
</Button> | ||
|
||
<div class="h-sep" /> | ||
|
||
<Alert type="warning" forceColumnFlow> | ||
{$t('faucet.warning_message')} | ||
</Alert> | ||
</div> | ||
</Card> |
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 Faucet } from './Faucet.svelte'; |
Oops, something went wrong.