From 6e4c0aa2e5944c4b387506f0ac851ee521a64cf6 Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Wed, 4 Dec 2024 13:21:11 +0100 Subject: [PATCH 1/3] Pull the existing components one level up If there's only an index file, there's no need to have a directory with an index.* file. The idea with using index.tsx is that imports can remain unchanged in cases where we upgrade from having a single-file component to needing scoped sibling components. --- .../src/components/{DocsDrawer/index.tsx => DocsDrawer.tsx} | 0 .../components/{GlobalStyles/index.tsx => GlobalStyles.tsx} | 0 .../{BlockExplorerLink/index.tsx => BlockExplorerLink.tsx} | 0 .../shared/{ButtonLink/index.tsx => ButtonLink.tsx} | 0 .../{CurrencyBalance/index.tsx => CurrencyBalance.tsx} | 2 +- .../index.tsx => CurrencyBalanceWithConversion.tsx} | 2 +- .../{NumberFormatInput/index.tsx => NumberFormatInput.tsx} | 0 .../components/shared/{Skeleton/index.tsx => Skeleton.tsx} | 0 .../components/shared/{Spinner/index.tsx => Spinner.tsx} | 0 .../{TokenBalanceInput/index.tsx => TokenBalanceInput.tsx} | 6 +++--- 10 files changed, 5 insertions(+), 5 deletions(-) rename dapp/src/components/{DocsDrawer/index.tsx => DocsDrawer.tsx} (100%) rename dapp/src/components/{GlobalStyles/index.tsx => GlobalStyles.tsx} (100%) rename dapp/src/components/shared/{BlockExplorerLink/index.tsx => BlockExplorerLink.tsx} (100%) rename dapp/src/components/shared/{ButtonLink/index.tsx => ButtonLink.tsx} (100%) rename dapp/src/components/shared/{CurrencyBalance/index.tsx => CurrencyBalance.tsx} (98%) rename dapp/src/components/shared/{CurrencyBalanceWithConversion/index.tsx => CurrencyBalanceWithConversion.tsx} (85%) rename dapp/src/components/shared/{NumberFormatInput/index.tsx => NumberFormatInput.tsx} (100%) rename dapp/src/components/shared/{Skeleton/index.tsx => Skeleton.tsx} (100%) rename dapp/src/components/shared/{Spinner/index.tsx => Spinner.tsx} (100%) rename dapp/src/components/shared/{TokenBalanceInput/index.tsx => TokenBalanceInput.tsx} (96%) diff --git a/dapp/src/components/DocsDrawer/index.tsx b/dapp/src/components/DocsDrawer.tsx similarity index 100% rename from dapp/src/components/DocsDrawer/index.tsx rename to dapp/src/components/DocsDrawer.tsx diff --git a/dapp/src/components/GlobalStyles/index.tsx b/dapp/src/components/GlobalStyles.tsx similarity index 100% rename from dapp/src/components/GlobalStyles/index.tsx rename to dapp/src/components/GlobalStyles.tsx diff --git a/dapp/src/components/shared/BlockExplorerLink/index.tsx b/dapp/src/components/shared/BlockExplorerLink.tsx similarity index 100% rename from dapp/src/components/shared/BlockExplorerLink/index.tsx rename to dapp/src/components/shared/BlockExplorerLink.tsx diff --git a/dapp/src/components/shared/ButtonLink/index.tsx b/dapp/src/components/shared/ButtonLink.tsx similarity index 100% rename from dapp/src/components/shared/ButtonLink/index.tsx rename to dapp/src/components/shared/ButtonLink.tsx diff --git a/dapp/src/components/shared/CurrencyBalance/index.tsx b/dapp/src/components/shared/CurrencyBalance.tsx similarity index 98% rename from dapp/src/components/shared/CurrencyBalance/index.tsx rename to dapp/src/components/shared/CurrencyBalance.tsx index bf7f65750..1b5aa3be7 100644 --- a/dapp/src/components/shared/CurrencyBalance/index.tsx +++ b/dapp/src/components/shared/CurrencyBalance.tsx @@ -12,7 +12,7 @@ import { numberToLocaleString, } from "#/utils" import { CurrencyType, AmountType } from "#/types" -import Tooltip from "../Tooltip" +import Tooltip from "./Tooltip" export type CurrencyBalanceProps = { currency: CurrencyType diff --git a/dapp/src/components/shared/CurrencyBalanceWithConversion/index.tsx b/dapp/src/components/shared/CurrencyBalanceWithConversion.tsx similarity index 85% rename from dapp/src/components/shared/CurrencyBalanceWithConversion/index.tsx rename to dapp/src/components/shared/CurrencyBalanceWithConversion.tsx index 5d19dd126..ea9f64850 100644 --- a/dapp/src/components/shared/CurrencyBalanceWithConversion/index.tsx +++ b/dapp/src/components/shared/CurrencyBalanceWithConversion.tsx @@ -1,6 +1,6 @@ import React from "react" import { useCurrencyConversion } from "#/hooks" -import { CurrencyBalance, CurrencyBalanceProps } from "../CurrencyBalance" +import { CurrencyBalance, CurrencyBalanceProps } from "./CurrencyBalance" export function CurrencyBalanceWithConversion({ from, diff --git a/dapp/src/components/shared/NumberFormatInput/index.tsx b/dapp/src/components/shared/NumberFormatInput.tsx similarity index 100% rename from dapp/src/components/shared/NumberFormatInput/index.tsx rename to dapp/src/components/shared/NumberFormatInput.tsx diff --git a/dapp/src/components/shared/Skeleton/index.tsx b/dapp/src/components/shared/Skeleton.tsx similarity index 100% rename from dapp/src/components/shared/Skeleton/index.tsx rename to dapp/src/components/shared/Skeleton.tsx diff --git a/dapp/src/components/shared/Spinner/index.tsx b/dapp/src/components/shared/Spinner.tsx similarity index 100% rename from dapp/src/components/shared/Spinner/index.tsx rename to dapp/src/components/shared/Spinner.tsx diff --git a/dapp/src/components/shared/TokenBalanceInput/index.tsx b/dapp/src/components/shared/TokenBalanceInput.tsx similarity index 96% rename from dapp/src/components/shared/TokenBalanceInput/index.tsx rename to dapp/src/components/shared/TokenBalanceInput.tsx index cd92ff160..69067f35d 100644 --- a/dapp/src/components/shared/TokenBalanceInput/index.tsx +++ b/dapp/src/components/shared/TokenBalanceInput.tsx @@ -21,9 +21,9 @@ import { useCurrencyConversion } from "#/hooks" import NumberFormatInput, { NumberFormatInputValues, NumberFormatInputProps, -} from "../NumberFormatInput" -import { CurrencyBalance } from "../CurrencyBalance" -import HelperErrorText, { HelperErrorTextProps } from "../Form/HelperErrorText" +} from "./NumberFormatInput" +import { CurrencyBalance } from "./CurrencyBalance" +import HelperErrorText, { HelperErrorTextProps } from "./Form/HelperErrorText" type FiatCurrencyBalanceProps = { amount: bigint From ef61f7dc8a47b7330dc67e8dcd59354857fcc8e5 Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Wed, 4 Dec 2024 14:22:18 +0100 Subject: [PATCH 2/3] Update component file names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should not decouple file name from component name—these should match. --- .../ActiveStakingStep/StakeFormModal/StakeDetails.tsx | 4 ++-- .../ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx | 4 ++-- .../FeesDetails/{FeesItem.tsx => FeesDetailsAmountItem.tsx} | 0 .../{AmountItem.tsx => TransactionDetailsAmountItem.tsx} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename dapp/src/components/shared/FeesDetails/{FeesItem.tsx => FeesDetailsAmountItem.tsx} (100%) rename dapp/src/components/shared/TransactionDetails/{AmountItem.tsx => TransactionDetailsAmountItem.tsx} (100%) diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx index ac51f54cd..05fb8ad5c 100644 --- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx +++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx @@ -1,7 +1,7 @@ import React from "react" import { List } from "@chakra-ui/react" -import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/AmountItem" -import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesItem" +import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/TransactionDetailsAmountItem" +import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesDetailsAmountItem" import { TOKEN_AMOUNT_FIELD_NAME } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" import { FeesTooltip } from "#/components/TransactionModal/FeesTooltip" import { diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx index b457f1347..b69ce1a4a 100644 --- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx +++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx @@ -1,6 +1,6 @@ import React from "react" import { Flex, List } from "@chakra-ui/react" -import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/AmountItem" +import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/TransactionDetailsAmountItem" import { TOKEN_AMOUNT_FIELD_NAME } from "#/components/shared/TokenAmountForm/TokenAmountFormBase" import { useFormField, @@ -9,7 +9,7 @@ import { } from "#/hooks" import { ACTION_FLOW_TYPES, CurrencyType } from "#/types" import { DESIRED_DECIMALS_FOR_FEE, featureFlags } from "#/constants" -import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesItem" +import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesDetailsAmountItem" import WithdrawWarning from "./WithdrawWarning" import { FeesTooltip } from "../../FeesTooltip" diff --git a/dapp/src/components/shared/FeesDetails/FeesItem.tsx b/dapp/src/components/shared/FeesDetails/FeesDetailsAmountItem.tsx similarity index 100% rename from dapp/src/components/shared/FeesDetails/FeesItem.tsx rename to dapp/src/components/shared/FeesDetails/FeesDetailsAmountItem.tsx diff --git a/dapp/src/components/shared/TransactionDetails/AmountItem.tsx b/dapp/src/components/shared/TransactionDetails/TransactionDetailsAmountItem.tsx similarity index 100% rename from dapp/src/components/shared/TransactionDetails/AmountItem.tsx rename to dapp/src/components/shared/TransactionDetails/TransactionDetailsAmountItem.tsx From 86dc681e74aac1ae45b2afdf25f7e9e0acd59bac Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Fri, 6 Dec 2024 08:55:05 +0100 Subject: [PATCH 3/3] Fix eslint issue --- .../ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx index 1879c7100..4ac3b86ad 100644 --- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx +++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx @@ -8,9 +8,9 @@ import { } from "#/hooks" import { ACTION_FLOW_TYPES, CurrencyType } from "#/types" import { DESIRED_DECIMALS_FOR_FEE } from "#/constants" -import { FeesTooltip } from "../../FeesTooltip" import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesDetailsAmountItem" import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/TransactionDetailsAmountItem" +import { FeesTooltip } from "../../FeesTooltip" function UnstakeDetails({ currency }: { currency: CurrencyType }) { const { value = 0n } = useFormField(