From aec6b8165930e4ed1458c4a55135eb7a30af037b Mon Sep 17 00:00:00 2001 From: wuzhenbin <1137057407@qq.com> Date: Tue, 29 Aug 2023 16:52:55 +0800 Subject: [PATCH] feat: add bridge luanguage and update ui --- packages/bridge-ui/src/App.svelte | 19 +- packages/bridge-ui/src/app.ts | 18 +- packages/bridge-ui/src/assets/locales.svg | 1 + packages/bridge-ui/src/chain/chains.ts | 7 + .../BridgeForm/ActionButtons.svelte | 53 ++- .../BridgeForm/AddCustomERC20.svelte | 12 +- .../src/components/BridgeForm/Memo.svelte | 11 +- .../BridgeForm/ProcessingFee.svelte | 6 +- .../src/components/ConnectWallet.svelte | 2 +- .../src/components/LanguageModal.svelte | 54 +++ .../bridge-ui/src/components/Navbar.svelte | 62 ++-- .../src/components/NoticeModal.svelte | 5 +- packages/bridge-ui/src/i18n.ts | 53 +-- packages/bridge-ui/src/i18nLocal.ts | 55 +++ packages/bridge-ui/src/locales/en.json | 66 ++++ packages/bridge-ui/src/locales/zh_CN.json | 50 +++ packages/bridge-ui/src/pages/home/Home.svelte | 24 +- .../src/pages/home/HomeMainnet.svelte | 303 ----------------- .../src/pages/home/HomeTestnet.svelte | 313 ------------------ packages/bridge-ui/src/store/modalLanguage.ts | 3 + packages/bridge-ui/src/styles/app.css | 19 ++ packages/bridge-ui/src/styles/common.css | 226 +++++++++++++ .../bridge-ui/src/styles/lanuageModal.css | 46 +++ packages/bridge-ui/src/styles/override.css | 4 + 24 files changed, 662 insertions(+), 750 deletions(-) create mode 100644 packages/bridge-ui/src/assets/locales.svg create mode 100644 packages/bridge-ui/src/components/LanguageModal.svelte create mode 100644 packages/bridge-ui/src/i18nLocal.ts create mode 100644 packages/bridge-ui/src/locales/en.json create mode 100644 packages/bridge-ui/src/locales/zh_CN.json delete mode 100644 packages/bridge-ui/src/pages/home/HomeMainnet.svelte delete mode 100644 packages/bridge-ui/src/pages/home/HomeTestnet.svelte create mode 100644 packages/bridge-ui/src/store/modalLanguage.ts create mode 100644 packages/bridge-ui/src/styles/common.css create mode 100644 packages/bridge-ui/src/styles/lanuageModal.css diff --git a/packages/bridge-ui/src/App.svelte b/packages/bridge-ui/src/App.svelte index 5f976b9ed..ab4da1cc7 100644 --- a/packages/bridge-ui/src/App.svelte +++ b/packages/bridge-ui/src/App.svelte @@ -1,11 +1,14 @@ - diff --git a/packages/bridge-ui/src/components/LanguageModal.svelte b/packages/bridge-ui/src/components/LanguageModal.svelte new file mode 100644 index 000000000..6216741dc --- /dev/null +++ b/packages/bridge-ui/src/components/LanguageModal.svelte @@ -0,0 +1,54 @@ + + + + + +
+
+ +
+
+ {#each Object.keys(locales) as item (item)} + + {/each} +
+
+
\ No newline at end of file diff --git a/packages/bridge-ui/src/components/Navbar.svelte b/packages/bridge-ui/src/components/Navbar.svelte index 531253636..745a93f02 100644 --- a/packages/bridge-ui/src/components/Navbar.svelte +++ b/packages/bridge-ui/src/components/Navbar.svelte @@ -1,39 +1,47 @@ - -
- +
diff --git a/packages/bridge-ui/src/i18n.ts b/packages/bridge-ui/src/i18n.ts index a1c873601..d4a3a013e 100644 --- a/packages/bridge-ui/src/i18n.ts +++ b/packages/bridge-ui/src/i18n.ts @@ -1,57 +1,6 @@ -import { _, dictionary, locale } from 'svelte-i18n'; +import { _, locale } from 'svelte-i18n'; function setupI18n({ withLocale: _locale } = { withLocale: 'en' }) { - dictionary.set({ - en: { - home: { - title: 'Taiko Bridge', - selectToken: 'Select Token', - to: 'To', - bridge: 'Bridge', - approve: 'Approve', - }, - bridgeForm: { - fieldLabel: 'Amount', - maxLabel: 'Max', - balance: 'Balance', - processingFeeLabel: 'Processing Fee', - bridge: 'Bridge', - approve: 'Approve', - }, - nav: { - connect: 'Connect Wallet', - }, - transaction: { - pending: 'Pending', - claim: 'Claim', - retry: 'Retry', - release: 'Release', - claimed: 'Claimed', - released: 'Released', - failed: 'Failed', - }, - toast: { - transactionSent: 'Transaction sent', - transactionCompleted: 'Transaction completed!', - errorWrongNetwork: - 'You are connected to the wrong chain in your wallet', - errorSendingTransaction: 'Error sending transaction', - errorDisconnecting: 'Could not disconnect', - errorInsufficientBalance: 'Insufficient ETH balance', - errorCheckingAllowance: 'Error checking allowance', - fundsClaimed: 'Funds claimed successfully!', - fundsReleased: 'Funds released successfully!', - }, - switchChainModal: { - title: 'Not on the right network', - subtitle: 'Your current network is not supported. Please select one:', - }, - connectModal: { - title: 'Connect Wallet', - }, - }, - }); - locale.set(_locale); } diff --git a/packages/bridge-ui/src/i18nLocal.ts b/packages/bridge-ui/src/i18nLocal.ts new file mode 100644 index 000000000..0150ab64b --- /dev/null +++ b/packages/bridge-ui/src/i18nLocal.ts @@ -0,0 +1,55 @@ + +export const locales: any = { + en: "English", + de: "Deutsch", + nl: "Nederlands", + tr: "Türkçe", + zh_CN: "简体中文", + zh_TW: "繁体中文", + ko: "한국어", + ro: "Română", + es: "Español", + fr: "Français", + it: "Italiano", + ja: "日本語", + ru: "Русский", + pt: "Portugués", + id: "Indonesio", + vi: "Tiếng Việt", +}; + + +export const browserLangToLocaleKey = { + 'en': 'en', + 'en-US': 'en', + 'en-GB': 'en', + 'de': 'de', + 'de-DE': 'de', + 'nl': 'nl', + 'nl-NL': 'nl', + 'tr': 'tr', + 'tr-TR': 'tr', + 'zh-CN': 'zh_CN', + 'zh-TW': 'zh_TW', + 'ko': 'ko', + 'ko-KR': 'ko', + 'ro': 'ro', + 'ro-RO': 'ro', + 'es': 'es', + 'es-ES': 'es', + 'fr': 'fr', + 'fr-FR': 'fr', + 'it': 'it', + 'it-IT': 'it', + 'ja': 'ja', + 'ja-JP': 'ja', + 'ru': 'ru', + 'ru-RU': 'ru', + 'pt': 'pt', + 'pt-PT': 'pt', + 'pt-BR': 'pt', + 'id': 'id', + 'id-ID': 'id', + 'vi': 'vi', + 'vi-VN': 'vi' +} diff --git a/packages/bridge-ui/src/locales/en.json b/packages/bridge-ui/src/locales/en.json new file mode 100644 index 000000000..3e18271b2 --- /dev/null +++ b/packages/bridge-ui/src/locales/en.json @@ -0,0 +1,66 @@ +{ + "home": { + "title": "Wannsee Bridge", + "selectToken": "Select Token", + "to": "To", + "bridge": "Bridge", + "approve": "Approve" + }, + "buttton": { + "add": "Add", + "confirm": "Confirm" + }, + "bridgeForm": { + "fieldLabel": "Amount", + "maxLabel": "Max", + "balance": "Balance", + "processingFeeLabel": "Processing Fee", + "bridge": "Bridge", + "approve": "Approve", + "approved": "Approved", + "approving": "Approving…", + "bridging": "Bridging…", + "approveToken": "Approve token", + "notFetchToken": "Could not fetch token details.", + "invalidAddress": "Invalid token address.", + "enterAddress": "Enter valid ERC20 Address", + "tokenAreadyAdd": "Tokens already added", + "memo": "Memo", + "enterMemo": "Enter memo here…", + "mxcLimit": "Max limit reached", + "memoDesc": "You can attach an arbitrary message to your bridge transaction by using a memo — it will slightly increase gas costs.", + "errorComp": "Error computing", + "selectNoneDesc": "Selecting None means that you'll require MXC on the receiving chain in order to claim the bridged token. Please, come back later to manually claim.", + "notShowMessage": "Do not show this message again" + }, + "nav": { + "connect": "Connect Wallet" + }, + "transaction": { + "pending": "Pending", + "claim": "Claim", + "retry": "Retry", + "release": "Release", + "claimed": "Claimed", + "released": "Released", + "failed": "Failed" + }, + "toast": { + "transactionSent": "Transaction sent", + "transactionCompleted": "Transaction completed!", + "errorWrongNetwork": "You are connected to the wrong chain in your wallet", + "errorSendingTransaction": "Error sending transaction", + "errorDisconnecting": "Could not disconnect", + "errorInsufficientBalance": "Insufficient ETH balance", + "errorCheckingAllowance": "Error checking allowance", + "fundsClaimed": "Funds claimed successfully!", + "fundsReleased": "Funds released successfully!" + }, + "switchChainModal": { + "title": "Not on the right network", + "subtitle": "Your current network is not supported. Please select one:" + }, + "connectModal": { + "title": "Connect Wallet" + } +} \ No newline at end of file diff --git a/packages/bridge-ui/src/locales/zh_CN.json b/packages/bridge-ui/src/locales/zh_CN.json new file mode 100644 index 000000000..c67077fad --- /dev/null +++ b/packages/bridge-ui/src/locales/zh_CN.json @@ -0,0 +1,50 @@ +{ + "home": { + "title": "Wannsee Bridge", + "selectToken": "Select Token", + "to": "To", + "bridge": "Bridge", + "approve": "Approve" + }, + "test": { + "hello": "你好世界" + }, + "bridgeForm": { + "fieldLabel": "数量", + "maxLabel": "最高", + "balance": "余额", + "processingFeeLabel": "交易费用", + "bridge": "桥接", + "approve": "授权" + }, + "nav": { + "connect": "Connect Wallet" + }, + "transaction": { + "pending": "Pending", + "claim": "Claim", + "retry": "Retry", + "release": "Release", + "claimed": "Claimed", + "released": "Released", + "failed": "Failed" + }, + "toast": { + "transactionSent": "Transaction sent", + "transactionCompleted": "Transaction completed!", + "errorWrongNetwork": "You are connected to the wrong chain in your wallet", + "errorSendingTransaction": "Error sending transaction", + "errorDisconnecting": "Could not disconnect", + "errorInsufficientBalance": "Insufficient ETH balance", + "errorCheckingAllowance": "Error checking allowance", + "fundsClaimed": "Funds claimed successfully!", + "fundsReleased": "Funds released successfully!" + }, + "switchChainModal": { + "title": "Not on the right network", + "subtitle": "Your current network is not supported. Please select one:" + }, + "connectModal": { + "title": "Connect Wallet" + } +} \ No newline at end of file diff --git a/packages/bridge-ui/src/pages/home/Home.svelte b/packages/bridge-ui/src/pages/home/Home.svelte index 2698cf482..e6a595cbd 100644 --- a/packages/bridge-ui/src/pages/home/Home.svelte +++ b/packages/bridge-ui/src/pages/home/Home.svelte @@ -3,7 +3,7 @@ import BridgeForm from '../../components/BridgeForm'; import SelectChain from '../../components/BridgeForm/SelectChain.svelte'; - // import Faucet from '../../components/Faucet/Faucet.svelte'; + import Faucet from '../../components/Faucet/Faucet.svelte'; import Loading from '../../components/Loading.svelte'; import { Tab, TabList, TabPanel, Tabs } from '../../components/Tabs'; import Transactions from '../../components/Transactions'; @@ -38,7 +38,10 @@ warningToast, } from '../../components/NotificationToast.svelte'; - // const is_testnet = ISTESTNET == '1'; + import { _ } from 'svelte-i18n'; + import { get } from 'svelte/store'; + + const isTestnet = ISTESTNET == '1'; enum LogLevel { DEBUG = 'DEBUG', @@ -167,9 +170,9 @@ const tabsRoute = [ { name: 'bridge', href: '/' }, { name: 'transactions', href: '/transactions' }, + { name: 'faucet', href: '/faucet' }, { name: 'stake', href: '/stake' }, - // Add more tabs if needed - ]; + ] async function setBridge() { // in l1, set the BridgeType.ERC20 @@ -200,9 +203,11 @@ md:min-h-[650px] p-2" bind:activeTab> + {@const tab1 = tabsRoute[0]} {@const tab2 = tabsRoute[1]} {@const tab3 = tabsRoute[2]} + {@const tab4 = tabsRoute[3]} Bridge @@ -214,8 +219,11 @@ () {/if} + {#if isTestnet} + Faucet + {/if} {#if $srcChain && $srcChain.id == L1_CHAIN_ID} - Stake + Stake {/if} @@ -235,6 +243,12 @@ +
+ +
+
+ + diff --git a/packages/bridge-ui/src/pages/home/HomeMainnet.svelte b/packages/bridge-ui/src/pages/home/HomeMainnet.svelte deleted file mode 100644 index 2698cf482..000000000 --- a/packages/bridge-ui/src/pages/home/HomeMainnet.svelte +++ /dev/null @@ -1,303 +0,0 @@ - - -
- - {@const tab1 = tabsRoute[0]} - {@const tab2 = tabsRoute[1]} - {@const tab3 = tabsRoute[2]} - - - Bridge - - Transactions - {#if $paginationInfo || !$signer} - ({$transactions.length}) - {:else} - () - {/if} - - {#if $srcChain && $srcChain.id == L1_CHAIN_ID} - Stake - {/if} - - - -
- -
-
- -
-
- - -
- -
-
- - - - -
- - - -

- The current bridge is incompatible with L1 MXC. Please click "Claim" to - transform your L1 MXC into the latest version of L2 MXC, which will then - allow you to seamlessly bridge to L3 zkEVM. -

- {#if loadingApprove} - - {:else} - - {/if} - - {#if loadingClaim} - - {:else} - - {/if} -
-
-
diff --git a/packages/bridge-ui/src/pages/home/HomeTestnet.svelte b/packages/bridge-ui/src/pages/home/HomeTestnet.svelte deleted file mode 100644 index c758c1a63..000000000 --- a/packages/bridge-ui/src/pages/home/HomeTestnet.svelte +++ /dev/null @@ -1,313 +0,0 @@ - - -
- - {@const tab1 = tabsRoute[0]} - {@const tab2 = tabsRoute[1]} - {@const tab3 = tabsRoute[2]} - {@const tab4 = tabsRoute[3]} - - - Bridge - - Transactions - {#if $paginationInfo || !$signer} - ({$transactions.length}) - {:else} - () - {/if} - - Faucet - {#if $srcChain && $srcChain.id == L1_CHAIN_ID} - Stake - - {/if} - - - -
- -
-
- -
-
- - -
- -
-
- - -
- -
-
- - - - -
- - - -

- The current bridge is incompatible with L1 MXC. Please click "Claim" to - transform your L1 MXC into the latest version of L2 MXC, which will then - allow you to seamlessly bridge to L3 zkEVM. -

- {#if loadingApprove} - - {:else} - - {/if} - - {#if loadingClaim} - - {:else} - - {/if} -
-
-
diff --git a/packages/bridge-ui/src/store/modalLanguage.ts b/packages/bridge-ui/src/store/modalLanguage.ts new file mode 100644 index 000000000..7d9ce50ce --- /dev/null +++ b/packages/bridge-ui/src/store/modalLanguage.ts @@ -0,0 +1,3 @@ +import { writable } from 'svelte/store'; + +export const isLanguageModalOpen = writable(false); diff --git a/packages/bridge-ui/src/styles/app.css b/packages/bridge-ui/src/styles/app.css index 68a72ee33..ecf1279c3 100644 --- a/packages/bridge-ui/src/styles/app.css +++ b/packages/bridge-ui/src/styles/app.css @@ -4,6 +4,8 @@ @import './override.css'; @import './logo.css'; +@import './common.css'; +@import './lanuageModal.css'; [data-theme='dark'] .switch-to-dark-mode { display: none; @@ -12,3 +14,20 @@ [data-theme='light'] .switch-to-light-mode { display: none; } + +.connect-button, +.connect-button:hover { + background-color: #f43178; +} + +button.border-accent { + border: 1px solid #6300ff; +} + +button.action-button { + background-color: #6300ff; +} + +button[disabled].action-button { + background-color: #5b5b5b38; +} diff --git a/packages/bridge-ui/src/styles/common.css b/packages/bridge-ui/src/styles/common.css new file mode 100644 index 000000000..ba26bed20 --- /dev/null +++ b/packages/bridge-ui/src/styles/common.css @@ -0,0 +1,226 @@ +.dividerline { + border-bottom: 1px solid #ffffff29; +} + +.circle-marker { + text-align: center; + line-height: 10px; +} + +/*换行省略*/ +.break_ellipsis { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/*多行省略*/ +.break_ellipsis_more { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; +} + +.usn { + user-select: none; +} + +.tlc { + text-align: center; +} +.tll { + text-align: left; +} +.tlr { + text-align: right; +} + +/*换行*/ +.wbb { + word-break: break-all; +} + +.bbox { + box-sizing: border-box; +} + +.csp { + cursor: pointer; +} + +/* color S*/ +.c000 { + color: #000; +} +.c333 { + color: #333; +} +.c666 { + color: #666; +} +.c999 { + color: #999; +} +.c_white { + color: #fff; +} +.c_red { + color: #ff0101; +} +.c_gray { + color: #9fa4b9; +} +/* color E */ + +/* width S */ +.w100 { + width: 100%; +} +.w14 { + width: 14px; +} +.w16 { + width: 16px; +} +.w18 { + width: 18px; +} +/* width E */ + +/* padding S*/ +.pd5 { + padding: 5px; +} +.pd10 { + padding: 10px; +} +.pd15 { + padding: 15px; +} +/* padding E*/ + +/* margin S */ +.mr10 { + margin-right: 10px; +} +.mt5 { + margin-top: 5px; +} +.mt8 { + margin-top: 8px; +} +.mt10 { + margin-top: 10px; +} +/* margin E */ + +/* font size S */ +.fs10 { + font-size: 10px; +} +.fs11 { + font-size: 11px; +} +.fs12 { + font-size: 12px; +} +.fs13 { + font-size: 13px; +} +.fs14 { + font-size: 14px; +} +.fs15 { + font-size: 15px; +} +.fs16 { + font-size: 16px; +} +.fs17 { + font-size: 17px; +} +.fs18 { + font-size: 18px; +} +.fs20 { + font-size: 20px; +} +.fs21 { + font-size: 21px; +} +.fs24 { + font-size: 24px; +} +.fs30 { + font-size: 30px; +} +.fw400 { + font-weight: 400; +} +.fw500 { + font-weight: 500; +} +.fw600 { + font-weight: 600; +} +.fwb { + font-weight: bold; +} +/* font size E */ + +/* flex S */ +.flex { + display: flex; +} +.flexbox { + display: flex; + align-items: center; +} +.flex1 { + flex: 1; +} +.flex_c { + display: flex; + align-items: center; + justify-content: center; +} +.flex_s { + display: flex; + justify-content: space-between; +} +.flex_cs { + display: flex; + align-items: center; +} +.flex_sc { + display: flex; + justify-content: space-between; + align-items: center; +} +.flex_ec { + display: flex; + align-items: center; + justify-content: flex-end; +} +.flex_wrap { + display: flex; + flex-wrap: wrap; +} +.flex_wrap_sb { + display: flex; + flex-wrap: wrap; + justify-content: space-between; +} +.flex_y_js { + display: flex; + flex-direction: column; + justify-content: center; +} +.flex_css { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +/* flex E */ diff --git a/packages/bridge-ui/src/styles/lanuageModal.css b/packages/bridge-ui/src/styles/lanuageModal.css new file mode 100644 index 000000000..0d2a6fabd --- /dev/null +++ b/packages/bridge-ui/src/styles/lanuageModal.css @@ -0,0 +1,46 @@ +.language_modal { + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + z-index: 100; + background: #000000e6; + display: flex; + align-items: center; + justify-content: center; +} +.language_modal .inner { + width: 320px; + background-color: #16182e; + border-radius: 4px; +} +.language_modal .Modal-header-wrapper { + margin: 10px 15px; +} +.language_modal .Modal-title-bar { + align-items: center; + display: flex; + justify-content: space-between; +} +.language_modal .Modal-title { + font-size: 15px; + line-height: 1; + text-align: left; +} +.language_modal .Modal-close-button { + text-align: right; + position: relative; +} +.language_modal .languagebox { + padding: 15px; + grid-gap: 1rem; + display: grid; + grid-template-columns: repeat(2, 1fr); +} +.language_modal .menu-item { + border: 1px solid #ffffff29; + cursor: pointer; + justify-content: space-between; + padding: 5px 8px; +} diff --git a/packages/bridge-ui/src/styles/override.css b/packages/bridge-ui/src/styles/override.css index f3a501d72..cd943fe51 100644 --- a/packages/bridge-ui/src/styles/override.css +++ b/packages/bridge-ui/src/styles/override.css @@ -1,5 +1,9 @@ /* Remove Arrows/Spinners */ +html, body, :root { + background-color: #2a0f69; +} + /* Chrome, Safari, Edge, Opera */ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {