Skip to content

Commit 0d9e01b

Browse files
committed
Advanced Form Field errors improvements
1 parent b693184 commit 0d9e01b

7 files changed

Lines changed: 45 additions & 13 deletions

File tree

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"vue": "^3.5.24",
4848
"vue-i18n": "11.2.8",
4949
"vue-router": "^4.6.3",
50-
"web-components": "github:nolus-protocol/web-components#v2.0.59",
50+
"web-components": "github:nolus-protocol/web-components#v2.0.60",
5151
"zod": "^4.3.6"
5252
},
5353
"devDependencies": {

src/common/components/MultipleCurrencyComponent.vue

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:itemsHeadline="itemsHeadline"
1717
:item-template="itemTemplate"
1818
:valueOnly="firstInputValue"
19+
:inputClass="errorInsufficientBalance? 'text-typography-error' : undefined"
1920
searchable
2021
/>
2122
<div class="relative">
@@ -56,19 +57,36 @@
5657
:itemsHeadline="itemsHeadline"
5758
:item-template="itemTemplate"
5859
:valueOnly="secondInputValue"
60+
:inputClass="errorInsufficientBalance? 'text-typography-error' : undefined"
5961
searchable
6062
/>
61-
<span
62-
:class="{ hidden: !errorMsg?.length }"
63-
class="px-6 py-4 text-14 text-typography-error"
64-
>
65-
{{ errorMsg }}
66-
</span>
63+
<AnimatePresence>
64+
<Motion
65+
v-if="errorMsg?.length"
66+
:initial="{ opacity: 0, y: 4, overflow: 'hidden' }"
67+
:animate="{ opacity: 1, y: 0, overflow: 'hidden', transition: { type: 'spring', stiffness: 400, damping: 20 } }"
68+
:exit="{ opacity: 0, y: 4, overflow: 'hidden', transition: { type: 'spring', stiffness: 400, damping: 40 } }"
69+
tag="div"
70+
class="px-6 py-4 text-14 text-typography-error flex items-center gap-1"
71+
>
72+
<SvgIcon size="s" name="warning" class="fill-typography-error" />
73+
<AnimatePresence mode="wait">
74+
<Motion
75+
:key="errorMsg"
76+
:initial="{ opacity: 0, y: 4 }"
77+
:animate="{ opacity: 1, y: 0, transition: { type: 'spring', stiffness: 400, damping: 20 } }"
78+
:exit="{ opacity: 0, y: 4, transition: { type: 'spring', stiffness: 400, damping: 40 } }"
79+
tag="span"
80+
>{{ errorMsg }}</Motion>
81+
</AnimatePresence>
82+
</Motion>
83+
</AnimatePresence>
6784
</template>
6885

6986
<script lang="ts" setup>
7087
import { ref, watch, type Component } from "vue";
71-
import { type AdvancedCurrencyFieldOption, AdvancedFormControl } from "web-components";
88+
import { type AdvancedCurrencyFieldOption, AdvancedFormControl, SvgIcon } from "web-components";
89+
import { AnimatePresence, Motion } from "motion-v";
7290
import DownArrow from "@/common/components/icons/down-arrow.vue";
7391
import Swap from "@/common/components/icons/swap.vue";
7492
import { MultipleCurrencyEventType } from "../types";
@@ -89,6 +107,7 @@ const props = defineProps<{
89107
selectedSecondCurrencyOption: AdvancedCurrencyFieldOption | undefined;
90108
currencyOptions: AdvancedCurrencyFieldOption[];
91109
errorMsg?: string;
110+
errorInsufficientBalance?: boolean;
92111
disabled?: boolean;
93112
isLoading?: boolean;
94113
itemsHeadline?: string[];

src/modules/assets/components/SendForm.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
:disabled-input-field="isDisabled"
4242
:disabled-currency-picker="disablePicker || isDisabled"
4343
:error-msg="amountErrorMsg"
44+
:input-class="errorInsufficientBalance ? 'text-typography-error' : undefined"
4445
:selected-currency-option="currency"
4546
:itemsHeadline="[$t('message.assets'), $t('message.balance')]"
4647
:item-template="
@@ -204,6 +205,7 @@ const networkCurrencies = ref<ExternalCurrency[] | AssetBalance[]>(balancesStore
204205
const selectedCurrency = ref(0);
205206
const amount = ref("");
206207
const amountErrorMsg = ref("");
208+
const errorInsufficientBalance = computed(() => amountErrorMsg.value === i18n.t("message.invalid-balance-big"));
207209
const txHashes = ref<{ hash: string; status: SwapStatus; url: string | null }[]>([]);
208210
209211
const step = ref(CONFIRM_STEP.CONFIRM);

src/modules/assets/components/SwapForm.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:first-calculated-balance="firstCalculatedBalance"
1717
:second-calculated-balance="secondCalculatedBalance"
1818
:error-msg="error"
19+
:error-insufficient-balance="errorInsufficientBalance"
1920
@swap="onSwapItems"
2021
:item-template="
2122
(item) =>
@@ -27,15 +28,17 @@
2728
})
2829
"
2930
/>
30-
<div class="flex justify-end border-t border-b border-border-color px-6 py-4">
31+
<div
32+
class="flex justify-end border-t border-b border-border-color px-6 py-4"
33+
>
3134
<div class="flex flex-[3] flex-col gap-3 text-right text-16 font-normal text-typography-secondary">
3235
<p class="flex gap-1 self-end">{{ $t("message.price-impact") }}:</p>
3336
<p class="flex gap-1 self-end">
3437
{{ $t("message.estimated-tx-fee") }}:
3538
<span class="w-[18px]"> </span>
3639
</p>
3740
</div>
38-
<div
41+
<div
3942
class="ml-2 flex flex-[1] flex-col justify-between gap-2 text-right text-16 font-semibold text-typography-default"
4043
>
4144
<template v-if="loading">
@@ -176,6 +179,8 @@ const loadingTx = ref(false);
176179
const priceImapact = ref(0);
177180
const onClose = inject("close", () => {});
178181
182+
const errorInsufficientBalance = computed(() => error.value === i18n.t("message.invalid-balance-big"));
183+
179184
const disabledByWallet = computed(() => {
180185
switch (wallet.wallet?.signer?.type) {
181186
case WalletTypes.evm: {

src/modules/earn/components/SupplyForm.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:calculatedBalance="stable"
1616
@input="onInput"
1717
:error-msg="error"
18+
:input-class="errorInsufficientBalance ? 'text-typography-error' : undefined"
1819
:searchable="true"
1920
:itemsHeadline="[$t('message.assets'), $t('message.your-balance')]"
2021
:item-template="
@@ -179,6 +180,7 @@ const i18n = useI18n();
179180
180181
const input = ref("0");
181182
const error = ref("");
183+
const errorInsufficientBalance = ref(false);
182184
const loading = ref(false);
183185
const disabled = ref(false);
184186
const supply = ref<{ [key: string]: boolean }>({});
@@ -360,10 +362,12 @@ function validateInputs() {
360362
361363
if (verr.length > 0) {
362364
error.value = verr;
365+
errorInsufficientBalance.value = true;
363366
return error.value;
364367
}
365368
366369
error.value = validateAmountV2(input.value, currency.balance.value);
370+
errorInsufficientBalance.value = error.value === i18n.t("message.invalid-balance-big");
367371
return error.value;
368372
}
369373
</script>

src/modules/earn/components/WithdrawForm.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:calculatedBalance="stable"
1616
@input="onInput"
1717
:error-msg="error"
18+
:input-class="errorInsufficientBalance ? 'text-typography-error' : undefined"
1819
:searchable="true"
1920
:itemsHeadline="[$t('message.assets'), $t('message.supplied')]"
2021
:item-template="
@@ -151,6 +152,7 @@ const onShowToast = inject("onShowToast", (_data: { type: ToastType; message: st
151152
152153
const input = ref("0");
153154
const error = ref("");
155+
const errorInsufficientBalance = computed(() => error.value === i18n.t("message.invalid-balance-big"));
154156
const loading = ref(false);
155157
const disabled = ref(false);
156158
const selectedCurrency = ref(0);

0 commit comments

Comments
 (0)