From 526052644750a8cc7989e1d4e9606c409c26659d Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Tue, 28 Nov 2023 18:50:50 +0100 Subject: [PATCH] Improve the use of `VStack`, `HStack` and `Flex` The Stack component and the Flex component have their children spaced out evenly but the key difference is that the Stack won't span the entire width of the container whereas the Flex will. Let's use the Stack component when it is a simple row or column of items. If we need to customize the items let's use Flex. More info: https://chakra-ui.com/docs/components/stack#notes-on-stack-vs-flex --- dapp/src/DApp.tsx | 6 ++--- dapp/src/components/Navbar/ConnectWallet.tsx | 2 +- dapp/src/components/Navbar/index.tsx | 14 +++++------ .../components/Overview/PositionDetails.tsx | 25 +++++++------------ 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/dapp/src/DApp.tsx b/dapp/src/DApp.tsx index 453c6c172..427d36de1 100644 --- a/dapp/src/DApp.tsx +++ b/dapp/src/DApp.tsx @@ -1,5 +1,5 @@ import React from "react" -import { ChakraProvider, Box } from "@chakra-ui/react" +import { ChakraProvider, Flex } from "@chakra-ui/react" import { useDetectThemeMode } from "./hooks" import theme from "./theme" import { LedgerWalletAPIProvider, WalletContextProvider } from "./contexts" @@ -10,10 +10,10 @@ function DApp() { useDetectThemeMode() return ( - + - + ) } diff --git a/dapp/src/components/Navbar/ConnectWallet.tsx b/dapp/src/components/Navbar/ConnectWallet.tsx index 14a20eae5..c632fb6e5 100644 --- a/dapp/src/components/Navbar/ConnectWallet.tsx +++ b/dapp/src/components/Navbar/ConnectWallet.tsx @@ -59,7 +59,7 @@ export default function ConnectWallet() { const { btcAccount, ethAccount } = useWalletContext() return ( - + Balance diff --git a/dapp/src/components/Navbar/index.tsx b/dapp/src/components/Navbar/index.tsx index f524f6fe5..24cd41aaf 100644 --- a/dapp/src/components/Navbar/index.tsx +++ b/dapp/src/components/Navbar/index.tsx @@ -1,22 +1,22 @@ import React from "react" -import { Box, Button, HStack, Icon, Switch } from "@chakra-ui/react" +import { Button, Flex, Icon, Switch } from "@chakra-ui/react" import ConnectWallet from "./ConnectWallet" import { ChevronRight } from "../../static/icons" import { USD } from "../../constants" export default function Navbar() { return ( - - + + - - + + {/* TODO: Handle click actions */} Show values in {USD.symbol} - - + + ) } diff --git a/dapp/src/components/Overview/PositionDetails.tsx b/dapp/src/components/Overview/PositionDetails.tsx index 9e5c4be71..8415c8910 100644 --- a/dapp/src/components/Overview/PositionDetails.tsx +++ b/dapp/src/components/Overview/PositionDetails.tsx @@ -3,32 +3,26 @@ import { Text, Button, Box, - VStack, HStack, Tooltip, Icon, useColorModeValue, + Flex, } from "@chakra-ui/react" import { BITCOIN, USD } from "../../constants" import { Info } from "../../static/icons" export default function PositionDetails() { return ( - + Your positions - + 34.75 {BITCOIN.symbol} - + 1.245.148,1 {USD.symbol} @@ -37,15 +31,14 @@ export default function PositionDetails() { - - + + - {/* Unset alignItems to get a full-width button. */} - + {/* TODO: Handle click actions */} - - + + ) }