Account detail finetuning (#474)

* fix: fixed the position of extended AccountDetails

* feat: shrink full screen content on expansion

* fix: fixed the overlap
This commit is contained in:
Linkie Link 2023-09-15 10:44:05 +02:00 committed by GitHub
parent 419f2c04b7
commit b12f5d3583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 6 deletions

View File

@ -20,7 +20,6 @@ import useHealthComputer from 'hooks/useHealthComputer'
import useLendingMarketAssetsTableData from 'hooks/useLendingMarketAssetsTableData' import useLendingMarketAssetsTableData from 'hooks/useLendingMarketAssetsTableData'
import useLocalStorage from 'hooks/useLocalStorage' import useLocalStorage from 'hooks/useLocalStorage'
import usePrices from 'hooks/usePrices' import usePrices from 'hooks/usePrices'
import useToggle from 'hooks/useToggle'
import useStore from 'store' import useStore from 'store'
import { BNCoin } from 'types/classes/BNCoin' import { BNCoin } from 'types/classes/BNCoin'
import { import {
@ -47,7 +46,7 @@ function AccountDetails(props: Props) {
const { account } = props const { account } = props
const [reduceMotion] = useLocalStorage<boolean>(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) const [reduceMotion] = useLocalStorage<boolean>(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion)
const updatedAccount = useStore((s) => s.updatedAccount) const updatedAccount = useStore((s) => s.updatedAccount)
const [isExpanded, setIsExpanded] = useToggle() const accountDetailsExpanded = useStore((s) => s.accountDetailsExpanded)
const { health } = useHealthComputer(account) const { health } = useHealthComputer(account)
const { health: updatedHealth } = useHealthComputer(updatedAccount || account) const { health: updatedHealth } = useHealthComputer(updatedAccount || account)
const { data: prices } = usePrices() const { data: prices } = usePrices()
@ -86,7 +85,7 @@ function AccountDetails(props: Props) {
<div <div
data-testid='account-details' data-testid='account-details'
className={classNames( className={classNames(
isExpanded ? 'right-5' : '-right-80', accountDetailsExpanded ? 'right-6.5' : '-right-80',
'w-100 flex items-start gap-4 absolute top-6', 'w-100 flex items-start gap-4 absolute top-6',
!reduceMotion && 'transition-all duration-300', !reduceMotion && 'transition-all duration-300',
)} )}
@ -99,7 +98,7 @@ function AccountDetails(props: Props) {
!reduceMotion && 'transition-colors duration-300', !reduceMotion && 'transition-colors duration-300',
'hover:bg-white/10 hover:cursor-pointer ', 'hover:bg-white/10 hover:cursor-pointer ',
)} )}
onClick={() => setIsExpanded(!isExpanded)} onClick={() => useStore.setState({ accountDetailsExpanded: !accountDetailsExpanded })}
> >
<div className='flex flex-wrap justify-center w-full py-4'> <div className='flex flex-wrap justify-center w-full py-4'>
<HealthGauge health={health} updatedHealth={updatedHealth} /> <HealthGauge health={health} updatedHealth={updatedHealth} />
@ -138,7 +137,7 @@ function AccountDetails(props: Props) {
'group-hover:opacity-100', 'group-hover:opacity-100',
)} )}
> >
{isExpanded ? <Cross className='w-2' /> : <ThreeDots className='h-1' />} {accountDetailsExpanded ? <Cross className='w-2' /> : <ThreeDots className='h-1' />}
</div> </div>
{glowElement(!reduceMotion)} {glowElement(!reduceMotion)}

View File

@ -9,7 +9,10 @@ import DesktopHeader from 'components/Header/DesktopHeader'
import ModalsContainer from 'components/Modals/ModalsContainer' import ModalsContainer from 'components/Modals/ModalsContainer'
import PageMetadata from 'components/PageMetadata' import PageMetadata from 'components/PageMetadata'
import Toaster from 'components/Toaster' import Toaster from 'components/Toaster'
import { DEFAULT_SETTINGS } from 'constants/defaultSettings'
import { REDUCE_MOTION_KEY } from 'constants/localStore'
import useCurrentAccount from 'hooks/useCurrentAccount' import useCurrentAccount from 'hooks/useCurrentAccount'
import useLocalStorage from 'hooks/useLocalStorage'
import useStore from 'store' import useStore from 'store'
interface Props { interface Props {
@ -38,6 +41,8 @@ function PageContainer(props: Props) {
export default function Layout({ children }: { children: React.ReactNode }) { export default function Layout({ children }: { children: React.ReactNode }) {
const location = useLocation() const location = useLocation()
const focusComponent = useStore((s) => s.focusComponent) const focusComponent = useStore((s) => s.focusComponent)
const [reduceMotion] = useLocalStorage<boolean>(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion)
const accountDetailsExpanded = useStore((s) => s.accountDetailsExpanded)
const isFullWidth = location.pathname.includes('trade') || location.pathname === '/' const isFullWidth = location.pathname.includes('trade') || location.pathname === '/'
const account = useCurrentAccount() const account = useCurrentAccount()
@ -52,7 +57,8 @@ export default function Layout({ children }: { children: React.ReactNode }) {
'lg:mt-[65px]', 'lg:mt-[65px]',
'min-h-screen gap-6 px-4 py-6 w-full relative', 'min-h-screen gap-6 px-4 py-6 w-full relative',
'flex', 'flex',
account && 'pr-24', isFullWidth && account && (accountDetailsExpanded ? 'pr-110.5' : 'pr-24'),
!reduceMotion && 'transition-all duration-300',
'justify-center', 'justify-center',
focusComponent && 'items-center', focusComponent && 'items-center',
isMobile && 'items-start', isMobile && 'items-start',

View File

@ -8,5 +8,6 @@ export default function createCommonSlice(set: SetState<CommonSlice>, get: GetSt
isOpen: true, isOpen: true,
selectedAccount: null, selectedAccount: null,
focusComponent: null, focusComponent: null,
accountDetailsExpanded: false,
} }
} }

View File

@ -7,6 +7,7 @@ interface CommonSlice {
selectedAccount: string | null selectedAccount: string | null
updatedAccount?: Account updatedAccount?: Account
focusComponent: FocusComponent | null focusComponent: FocusComponent | null
accountDetailsExpanded: boolean
} }
interface FocusComponent { interface FocusComponent {

View File

@ -204,9 +204,11 @@ module.exports = {
'2xl': '1920px', '2xl': '1920px',
}, },
spacing: { spacing: {
6.5: '26px',
24: '96px', 24: '96px',
35: '140px', 35: '140px',
80: '320px', 80: '320px',
110.5: '442px',
}, },
transitionDuration: { transitionDuration: {
3000: '3000ms', 3000: '3000ms',