feat(panel-wrapper): show modal only for smaller screens

This commit is contained in:
RadoslavDimchev 2024-04-15 17:29:26 +03:00 committed by Radoslav Dimchev
parent d2492afdba
commit 69d86c31d5
1 changed files with 34 additions and 33 deletions

View File

@ -1,11 +1,10 @@
import { Text } from '@status-im/components'
import { ExpandRsIcon } from '@status-im/icons'
import { useState } from 'react' import { useState } from 'react'
import Modal from 'react-modal' import Modal from 'react-modal'
import { useNavigate, useParams } from 'react-router-dom' import { useNavigate, useParams } from 'react-router-dom'
import { XStack, YStack } from 'tamagui'
import { PATHS } from '../../../constants' import { PATHS } from '../../../constants'
import { useWindowSize } from '../../../hooks/useWindowSize'
import PanelContent from './PanelContent'
type PanelWrapperProps = { type PanelWrapperProps = {
children: React.ReactNode children: React.ReactNode
@ -16,6 +15,8 @@ const PanelWrapper = ({ children, title }: PanelWrapperProps) => {
const [isModalOpen, setIsModalOpen] = useState(true) const [isModalOpen, setIsModalOpen] = useState(true)
const navigate = useNavigate() const navigate = useNavigate()
const { validatorName } = useParams() const { validatorName } = useParams()
const { width } = useWindowSize()
const isModalWidth = width < 1160
const closeModal = () => { const closeModal = () => {
setIsModalOpen(false) setIsModalOpen(false)
@ -23,6 +24,8 @@ const PanelWrapper = ({ children, title }: PanelWrapperProps) => {
} }
return ( return (
<>
{isModalWidth ? (
<Modal <Modal
isOpen={isModalOpen} isOpen={isModalOpen}
onRequestClose={closeModal} onRequestClose={closeModal}
@ -39,20 +42,18 @@ const PanelWrapper = ({ children, title }: PanelWrapperProps) => {
}, },
}} }}
> >
<YStack space={'$3'} style={{ padding: '30px', alignItems: 'start' }}> <PanelContent title={title} closeModal={closeModal}>
<XStack style={{ width: '100%', justifyContent: 'space-between' }}>
<Text size={19} weight={'semibold'}>
{title}
</Text>
<ExpandRsIcon
size={20}
style={{ cursor: 'pointer' }}
onClick={closeModal}
/>
</XStack>
{children} {children}
</YStack> </PanelContent>
</Modal> </Modal>
) : (
<div>
<PanelContent title={title} closeModal={closeModal}>
{children}
</PanelContent>
</div>
)}
</>
) )
} }