Skip to content

Commit 4ac1fc8

Browse files
kushbosamiyakushbosamiya
authored andcommitted
fix: limit announcement modal height (#307)
1 parent e916290 commit 4ac1fc8

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/components/Announcement.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ const PrettyIcon = ({ color, icon }: { color?: string; icon: React.ReactNode })
2424
return (
2525
<div
2626
style={{
27-
width: '100%',
27+
width: 'calc(100% + 2rem)',
2828
display: 'flex',
2929
height: '100px',
30-
marginTop: '-1rem',
30+
margin: '-1rem -1rem 0 -1rem',
3131
alignItems: 'center',
3232
justifyContent: 'center',
3333
background: `radial-gradient(${circle}, ${gradient.join(', ')})`,

src/components/FlexCol.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface FlexColProps {
1111
padding?: string
1212
strech?: boolean
1313
testId?: string
14+
style?: React.CSSProperties
1415
}
1516

1617
export default function FlexCol({
@@ -24,6 +25,7 @@ export default function FlexCol({
2425
padding,
2526
strech,
2627
testId,
28+
style: customStyle,
2729
}: FlexColProps) {
2830
const style: any = {
2931
alignItems: centered ? 'center' : end ? 'end' : strech ? 'strech' : 'start',
@@ -36,6 +38,7 @@ export default function FlexCol({
3638
margin,
3739
padding,
3840
width: '100%',
41+
...customStyle
3942
}
4043

4144
return (

src/components/Modal.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
11
import { useEffect } from 'react'
2+
import { createPortal } from 'react-dom'
23

34
export default function Modal({ children }: { children: React.ReactNode }) {
45
const overlayStyle = {
56
top: '0',
67
left: '0',
7-
zIndex: 21,
8+
zIndex: 80,
89
opacity: 0.5,
910
width: '100%',
1011
height: '100%',
11-
position: 'absolute' as 'absolute',
12+
position: 'fixed' as 'fixed',
1213
backgroundColor: 'var(--ion-background-color)',
1314
}
1415

1516
const containerStyle = {
1617
top: '0',
1718
left: '0',
18-
zIndex: 22, // Higher than overlay
19+
zIndex: 90,
1920
width: '100%',
2021
height: '100%',
2122
display: 'flex',
2223
alignItems: 'center',
2324
justifyContent: 'center',
24-
position: 'absolute' as 'absolute',
25-
pointerEvents: 'none' as 'none', // Allow clicks to pass through to children
25+
position: 'fixed' as 'fixed',
26+
pointerEvents: 'none' as 'none',
2627
}
2728

2829
const innerStyle = {
2930
opacity: 1,
3031
padding: '1rem',
3132
maxWidth: 'min(22rem, 90%)',
33+
maxHeight: 'calc(100vh - 4rem)',
34+
position: 'relative' as 'relative',
35+
display: 'flex' as 'flex',
36+
flexDirection: 'column' as 'column',
37+
overflowY: 'auto' as 'auto',
3238
borderRadius: '0.5rem',
3339
border: '1px solid var(--dark10)',
3440
backgroundColor: 'var(--ion-background-color)',
35-
pointerEvents: 'auto' as 'auto', // Enable clicks on the modal content
41+
pointerEvents: 'auto' as 'auto',
42+
zIndex: 95,
3643
}
3744

3845
useEffect(() => {
@@ -49,12 +56,15 @@ export default function Modal({ children }: { children: React.ReactNode }) {
4956
}
5057
}, [])
5158

52-
return (
59+
return createPortal(
5360
<>
5461
<div style={overlayStyle} />
5562
<div style={containerStyle}>
56-
<div style={innerStyle}>{children}</div>
63+
<div style={innerStyle} className='modal-inner'>
64+
{children}
65+
</div>
5766
</div>
58-
</>
67+
</>,
68+
document.body
5969
)
6070
}

0 commit comments

Comments
 (0)