Refactor ConnectionModal and TopUpModal: simplify body scroll locking mechanism, update modal wrapper styling for consistent padding across devices, and enhance responsiveness for improved user experience.

This commit is contained in:
PEDZEO
2026-01-20 03:26:07 +03:00
parent 61eaf30da9
commit 275fe811bb
2 changed files with 18 additions and 36 deletions

View File

@@ -231,36 +231,14 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) {
} }
}, [appConfig, detectedPlatform, selectedApp]) }, [appConfig, detectedPlatform, selectedApp])
// Lock body scroll when modal is open (works on iOS too) // Prevent body scroll when modal is open
useEffect(() => { useEffect(() => {
const scrollY = window.scrollY // Simple overflow hidden - let the modal handle its own scrolling
const body = document.body const originalOverflow = document.body.style.overflow
const html = document.documentElement document.body.style.overflow = 'hidden'
// Save original styles
const originalBodyOverflow = body.style.overflow
const originalBodyPosition = body.style.position
const originalBodyTop = body.style.top
const originalBodyWidth = body.style.width
const originalHtmlOverflow = html.style.overflow
// Lock scroll
body.style.overflow = 'hidden'
body.style.position = 'fixed'
body.style.top = `-${scrollY}px`
body.style.width = '100%'
html.style.overflow = 'hidden'
return () => { return () => {
// Restore original styles document.body.style.overflow = originalOverflow
body.style.overflow = originalBodyOverflow
body.style.position = originalBodyPosition
body.style.top = originalBodyTop
body.style.width = originalBodyWidth
html.style.overflow = originalHtmlOverflow
// Restore scroll position
window.scrollTo(0, scrollY)
} }
}, []) }, [])
@@ -327,21 +305,19 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) {
window.location.href = redirectUrl window.location.href = redirectUrl
} }
// Modal wrapper - centered on desktop, top on mobile // Modal wrapper - centered on all devices
const ModalWrapper = ({ children }: { children: React.ReactNode }) => ( const ModalWrapper = ({ children }: { children: React.ReactNode }) => (
<div <div
className="fixed inset-0 bg-black/70 z-50 flex items-start sm:items-center justify-center overflow-y-auto overscroll-contain" className="fixed inset-0 bg-black/70 z-[60] flex items-center justify-center p-4"
style={{ style={{
padding: '1rem', paddingTop: 'calc(1rem + env(safe-area-inset-top, 0px))',
paddingTop: 'calc(2.5rem + env(safe-area-inset-top, 0px))', paddingBottom: 'calc(1rem + env(safe-area-inset-bottom, 0px))',
paddingBottom: 'calc(1.5rem + env(safe-area-inset-bottom, 0px))',
WebkitOverflowScrolling: 'touch'
}} }}
onClick={onClose} onClick={onClose}
> >
<div <div
className="w-full max-w-sm bg-dark-900 rounded-2xl border border-dark-700/50 overflow-hidden animate-scale-in shadow-2xl" className="w-full max-w-sm bg-dark-900 rounded-2xl border border-dark-700/50 overflow-hidden animate-scale-in shadow-2xl"
style={{ maxHeight: 'calc(100vh - 4rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))' }} style={{ maxHeight: 'calc(100vh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))' }}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
> >
{children} {children}

View File

@@ -133,10 +133,16 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top
const isPending = topUpMutation.isPending || starsPaymentMutation.isPending const isPending = topUpMutation.isPending || starsPaymentMutation.isPending
return ( return (
<div className="fixed inset-0 bg-black/70 z-50 flex items-center justify-center px-4 pt-14 pb-28 sm:pt-0 sm:pb-0"> <div
className="fixed inset-0 bg-black/70 z-[60] flex items-center justify-center p-4"
style={{
paddingTop: 'calc(1rem + env(safe-area-inset-top, 0px))',
paddingBottom: 'calc(1rem + env(safe-area-inset-bottom, 0px))',
}}
>
<div className="absolute inset-0" onClick={onClose} /> <div className="absolute inset-0" onClick={onClose} />
<div className="relative w-full max-w-sm bg-dark-900 rounded-2xl border border-dark-700/50 shadow-2xl overflow-hidden"> <div className="relative w-full max-w-sm bg-dark-900 rounded-2xl border border-dark-700/50 shadow-2xl overflow-hidden animate-scale-in">
{/* Header */} {/* Header */}
<div className="flex items-center justify-between px-4 py-3 bg-dark-800/50"> <div className="flex items-center justify-between px-4 py-3 bg-dark-800/50">
<span className="font-semibold text-dark-100">{methodName}</span> <span className="font-semibold text-dark-100">{methodName}</span>