From bf639876808a079f34d306bab483dd67d7fbb2b1 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Thu, 9 Nov 2023 13:51:52 +0100 Subject: [PATCH] fix: Adjust overview widget on dashboard for new design --- public/images/common/arrow-se.svg | 3 + public/images/common/arrow-top-right.svg | 3 + .../dashboard/Overview/Overview.tsx | 189 ++++++++++++------ 3 files changed, 137 insertions(+), 58 deletions(-) create mode 100644 public/images/common/arrow-se.svg create mode 100644 public/images/common/arrow-top-right.svg diff --git a/public/images/common/arrow-se.svg b/public/images/common/arrow-se.svg new file mode 100644 index 0000000000..b94a60e1f2 --- /dev/null +++ b/public/images/common/arrow-se.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/common/arrow-top-right.svg b/public/images/common/arrow-top-right.svg new file mode 100644 index 0000000000..6ec66e8b9e --- /dev/null +++ b/public/images/common/arrow-top-right.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/dashboard/Overview/Overview.tsx b/src/components/dashboard/Overview/Overview.tsx index 445b860a04..dfe7b20b9e 100644 --- a/src/components/dashboard/Overview/Overview.tsx +++ b/src/components/dashboard/Overview/Overview.tsx @@ -1,20 +1,28 @@ +import QrCodeButton from '@/components/sidebar/QrCodeButton' +import { TxModalContext } from '@/components/tx-flow' +import NewTxMenu from '@/components/tx-flow/flows/NewTx' +import { useRemoteSafeApps } from '@/hooks/safe-apps/useRemoteSafeApps' +import { OVERVIEW_EVENTS, trackEvent } from '@/services/analytics' +import { useAppSelector } from '@/store' +import { selectCurrency } from '@/store/settingsSlice' +import { formatCurrency } from '@/utils/formatNumber' import type { ReactElement } from 'react' -import { useMemo } from 'react' +import { useContext, useMemo } from 'react' import { useRouter } from 'next/router' import Link from 'next/link' import styled from '@emotion/styled' -import { Box, Button, Grid, Skeleton, Typography } from '@mui/material' +import { Box, Button, Divider, Grid, Skeleton, Typography } from '@mui/material' import { Card, WidgetBody, WidgetContainer } from '../styled' import useSafeInfo from '@/hooks/useSafeInfo' import { useCurrentChain } from '@/hooks/useChains' -import SafeIcon from '@/components/common/SafeIcon' import ChainIndicator from '@/components/common/ChainIndicator' -import EthHashInfo from '@/components/common/EthHashInfo' import { AppRoutes } from '@/config/routes' -import useSafeAddress from '@/hooks/useSafeAddress' import useCollectibles from '@/hooks/useCollectibles' import type { UrlObject } from 'url' import { useVisibleBalances } from '@/hooks/useVisibleBalances' +import AddIcon from '@mui/icons-material/Add' +import ArrowIconNW from '@/public/images/common/arrow-top-right.svg' +import ArrowIconSE from '@/public/images/common/arrow-se.svg' const IdenticonContainer = styled.div` position: relative; @@ -37,56 +45,71 @@ const NetworkLabelContainer = styled.div` } ` -const ValueSkeleton = () => +const ValueSkeleton = () => const SkeletonOverview = ( - + + + - - - - - - - - - Tokens + + + Tokens - - - - - - - NFTs + + NFTs - - - + + + + ) const Overview = (): ReactElement => { + const currency = useAppSelector(selectCurrency) const router = useRouter() - const safeAddress = useSafeAddress() - const { safe, safeLoading, safeLoaded } = useSafeInfo() + const { safeLoading, safeLoaded } = useSafeInfo() const { balances, loading: balancesLoading } = useVisibleBalances() const [nfts] = useCollectibles() const chain = useCurrentChain() const { chainId } = chain || {} + const { setTxFlow } = useContext(TxModalContext) + const [apps] = useRemoteSafeApps() + + const fiatTotal = useMemo( + () => (balances.fiatTotal ? formatCurrency(balances.fiatTotal, currency) : ''), + [currency, balances.fiatTotal], + ) + + const rampSafeApp = apps?.find((app) => app.name === 'Ramp Network') const assetsLink: UrlObject = { pathname: AppRoutes.balances.index, @@ -103,6 +126,11 @@ const Overview = (): ReactElement => { const isInitialState = !safeLoaded && !safeLoading + const handleOnSend = () => { + setTxFlow(, undefined, false) + trackEvent(OVERVIEW_EVENTS.NEW_TRANSACTION) + } + return ( @@ -115,8 +143,12 @@ const Overview = (): ReactElement => { ) : ( - - + + + Total asset value + + {fiatTotal} + @@ -124,43 +156,84 @@ const Overview = (): ReactElement => { - - {safeAddress ? ( - - ) : ( - - )} - + - - + + - - Tokens - - {balancesLoading ? : tokenCount} + palette.border.light, + gap: 0.5, + pr: 1, + }} + > + + {balancesLoading ? : tokenCount} + {' '} + + Tokens + + - - - - NFTs - - {nftsCount || } + + + {nftsCount || } + {' '} + + NFTs + + - - - - - - - - + )} + + + + + )}