From 7b8c70716dac0d919c7b0102c680f581f1a7f8a5 Mon Sep 17 00:00:00 2001 From: Davide Carpini Date: Wed, 6 Dec 2023 09:14:02 +0100 Subject: [PATCH] feat: add translations and clean props (#145) --- packages/dapp-kit-ui/index.html | 4 +- .../dapp-kit-ui/src/assets/icons/index.ts | 1 + .../components/address-button-with-modal.ts | 18 ++--- .../src/components/address-modal.ts | 28 +++++--- .../dapp-kit-ui/src/components/base/modal.ts | 6 +- .../components/connect-button-with-modal.ts | 35 ++++++---- .../src/components/connect-button.ts | 15 ++-- .../src/components/connect-modal.ts | 30 ++++---- .../provider/dapp-kit-context-provider.ts | 8 ++- .../dapp-kit-ui/src/components/source-card.ts | 12 +--- .../components/vechain-dapp-connect-kit.ts | 14 ++-- .../src/components/wallet-connect-qr-code.ts | 45 +++++++----- packages/dapp-kit-ui/src/constants/i18n.ts | 68 +++++++++++++++++++ packages/dapp-kit-ui/src/constants/index.ts | 2 +- packages/dapp-kit-ui/src/constants/theme.ts | 2 - packages/dapp-kit-ui/src/utils/index.ts | 2 + .../dapp-kit-ui/src/utils/use-translate.ts | 7 ++ .../dapp-kit-ui/test/utils/listeners.test.ts | 2 +- .../test/utils/use-translate.test.ts | 17 +++++ 19 files changed, 220 insertions(+), 96 deletions(-) create mode 100644 packages/dapp-kit-ui/src/constants/i18n.ts create mode 100644 packages/dapp-kit-ui/src/utils/use-translate.ts create mode 100644 packages/dapp-kit-ui/test/utils/use-translate.test.ts diff --git a/packages/dapp-kit-ui/index.html b/packages/dapp-kit-ui/index.html index 3071e131..fa0a5027 100644 --- a/packages/dapp-kit-ui/index.html +++ b/packages/dapp-kit-ui/index.html @@ -8,8 +8,6 @@ - + diff --git a/packages/dapp-kit-ui/src/assets/icons/index.ts b/packages/dapp-kit-ui/src/assets/icons/index.ts index 2ed8f481..1ae8b64f 100644 --- a/packages/dapp-kit-ui/src/assets/icons/index.ts +++ b/packages/dapp-kit-ui/src/assets/icons/index.ts @@ -3,3 +3,4 @@ export * from './chevron-left'; export * from './copy'; export * from './check'; export * from './disconnect'; +export * from './wallet-connect'; diff --git a/packages/dapp-kit-ui/src/components/address-button-with-modal.ts b/packages/dapp-kit-ui/src/components/address-button-with-modal.ts index cbccb3e5..1966b85c 100644 --- a/packages/dapp-kit-ui/src/components/address-button-with-modal.ts +++ b/packages/dapp-kit-ui/src/components/address-button-with-modal.ts @@ -1,15 +1,17 @@ -import type { TemplateResult } from 'lit'; -import { html, LitElement } from 'lit'; +import { html, LitElement, type TemplateResult } from 'lit'; import { customElement, property } from 'lit/decorators.js'; -import type { Theme, ThemeMode } from '../constants'; +import { defaultI18n, type I18n, type ThemeMode } from '../constants'; @customElement('vwk-connected-address-button-with-modal') export class AddressButtonWithModal extends LitElement { - @property({ type: String }) + @property() mode: ThemeMode = 'LIGHT'; - @property({ type: String }) - theme: Theme = 'DEFAULT'; + @property() + i18n: I18n = defaultI18n; + + @property() + language = 'en'; @property({ type: String }) address?: string; @@ -26,13 +28,13 @@ export class AddressButtonWithModal extends LitElement { void = () => nothing; override render(): TemplateResult { + const translate = useTranslate(this.i18n, this.language); let copyIcon = this.mode === 'LIGHT' ? LightCopySvg : DarkCopySvg; if (this.showCopiedIcon) { copyIcon = CheckSvg; @@ -151,12 +160,11 @@ export class AddressModal extends LitElement { .open=${this.open} .onClose=${this.handleClose} .mode=${this.mode} - .theme=${this.theme} >