Add event for window,innerWidth

This commit is contained in:
Hristo Nedelkov 2023-10-18 18:09:54 +03:00
parent b8772ae64d
commit dda4d3d7ac
1 changed files with 63 additions and 49 deletions

View File

@ -12,7 +12,21 @@ import StorageCard from './StorageCard/StorageCard'
import NetworkCard from './NetworkCard/NetworkCard' import NetworkCard from './NetworkCard/NetworkCard'
import SyncStatusCard from './SyncStatusCards/SyncStatusCards' import SyncStatusCard from './SyncStatusCards/SyncStatusCards'
import MemoryCard from './MemoryCard/MemoryCard' import MemoryCard from './MemoryCard/MemoryCard'
const DashboardContent = () => ( import { useEffect, useState } from 'react'
const DashboardContent = () => {
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth);
};
window.addEventListener('resize', handleResize);
return () => {
window.removeEventListener('resize', handleResize);
};
}, []);
return (
<YStack <YStack
space="$4" space="$4"
alignItems="start" alignItems="start"
@ -20,29 +34,28 @@ const DashboardContent = () => (
style={{ style={{
flexGrow: '1', flexGrow: '1',
marginTop: '16px', marginTop: '16px',
width: '50%',
overflowY: 'auto', overflowY: 'auto',
maxHeight: '100vh',
}} }}
minWidth="500px" minWidth="500px"
width="50vh"
> >
<TitleLogo /> <TitleLogo />
<div style={{ <div style={{
display: 'grid', display: 'grid',
gridTemplateColumns: '1fr 1fr', gridTemplateColumns: windowWidth < 1300 ? '0.5fr' : '25fr 25fr 90fr',
gap: '16px' // You can adjust this value as per your needs gap: '16px'
}}> }}>
<YStack space="$4">
<SyncStatusCard /> <SyncStatusCard />
<AddCardsContainer /> <AddCardsContainer />
</YStack>
<BalanceChartCard /> <BalanceChartCard />
</div> </div>
<BasicInfoCards /> <BasicInfoCards />
<XStack space="$3" > <XStack space="$3" flexWrap='wrap' >
<YStack space="$4"> <YStack space="$4">
<XStack justifyContent="space-between"> <XStack justifyContent="space-between">
<ConsensusUptimeCard /> <ConsensusUptimeCard />
@ -66,7 +79,8 @@ const DashboardContent = () => (
</YStack> </YStack>
</XStack> </XStack>
</YStack> </YStack>
) )
}
export default DashboardContent export default DashboardContent