mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-10 18:36:50 +00:00
Move useEffect on window size and remove sidebars in phone layout
This commit is contained in:
parent
23d3699991
commit
6602d2b90f
@ -3,13 +3,37 @@ import { XStack } from 'tamagui'
|
||||
import LeftSidebar from '../../components/General/LeftSidebar/LeftSidebar'
|
||||
import RightSidebar from '../../components/General/RightSideBar/RightSidebar'
|
||||
import DashboardContent from './DashboardContent'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
const Dashboard = () => (
|
||||
<XStack style={{ height: '100vh' }}>
|
||||
<LeftSidebar />
|
||||
<DashboardContent />
|
||||
<RightSidebar />
|
||||
</XStack>
|
||||
)
|
||||
const Dashboard = () => {
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setWindowWidth(+window.innerWidth)
|
||||
}
|
||||
|
||||
window.addEventListener('resize', handleResize)
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<XStack style={{ height: '100vh' }} >
|
||||
{windowWidth>900&&
|
||||
(
|
||||
<LeftSidebar />
|
||||
)}
|
||||
|
||||
<DashboardContent windowWidth={windowWidth} />
|
||||
{windowWidth>900&&
|
||||
(
|
||||
|
||||
<RightSidebar />
|
||||
)}
|
||||
</XStack >
|
||||
)
|
||||
}
|
||||
|
||||
export default Dashboard
|
||||
|
Loading…
x
Reference in New Issue
Block a user