Skip to content

Commit 670df7a

Browse files
authored
fix: allow donate modal to dynamically change for devices (#945)
1 parent f6bf925 commit 670df7a

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/pages/DonateModal/DonateModal.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import React from 'react'
2-
import { Box, Grid, Modal, Typography } from '@mui/material'
2+
import { Box, Grid, Modal, Typography, useMediaQuery } from '@mui/material'
33
import i18n from 'src/locale/allTranslations'
44

55
interface DonateModalProps {
66
isVisible: boolean
77
onClose: () => void
88
}
99

10-
const style = {
10+
const boxStyle = {
1111
position: 'fixed',
1212
top: '50%',
1313
left: '50%',
1414
transform: 'translate(-50%, -50%)',
15-
maxWidth: 1000,
16-
width: '90%',
15+
maxWidth: '1250px',
16+
maxHeight: 'calc(100vh - 210px)',
17+
overflowY: 'auto',
18+
width: '80%',
1719
bgcolor: 'background.paper',
20+
textAlign: 'left',
1821
boxShadow: 24,
1922
p: 4,
2023
} as const
2124

2225
export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose }) => {
26+
/**
27+
* @description This hook is used to determine if the image should collapse or not based on if the user is a mobile, tablet user or not.
28+
*/
29+
const shouldImgCollapse = useMediaQuery('(max-width: 950px)')
30+
2331
return (
2432
<Modal
2533
open={isVisible}
@@ -31,7 +39,7 @@ export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose })
3139
sx={{
3240
color: 'text.primary', // Dynamically uses the theme’s text color
3341
}}>
34-
<Box dir={i18n.dir()} sx={style}>
42+
<Box dir={i18n.dir()} sx={boxStyle}>
3543
<button onClick={onClose} className="close-modal-icon">
3644
X
3745
</button>
@@ -45,7 +53,7 @@ export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose })
4553
ועושה עוד המון עבודה שוטפת כדי שהפרוייקטים שלנו ייצרו שינוי בעולם. אנחנו זקוקים לתמיכה של
4654
הקהילה כדי להמשיך ולפעול למען ממשל פתוח יותר. היו אבירי שקיפות והצטרפו בתמיכה חודשית.
4755
</p>
48-
<Grid container spacing={2}>
56+
<Grid container spacing={2} direction={shouldImgCollapse ? 'column-reverse' : 'row'}>
4957
<Grid item xs={6}>
5058
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
5159
<h2>תרומה דרך אתר jgive.com</h2>
@@ -56,10 +64,15 @@ export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose })
5664
<img
5765
src="https://www.hasadna.org.il/wp-content/uploads/2017/12/%D7%AA%D7%A8%D7%95%D7%9E%D7%95%D7%AA.jpg"
5866
alt="קישור לתרומה"
67+
width={'90%'}
68+
style={{ maxWidth: '420px' }}
5969
/>
6070
<img
71+
width={'90%'}
6172
src="https://www.hasadna.org.il/wp-content/uploads/2018/08/button-300x73.png"
6273
alt="תרום עכשיו"
74+
// style={{ margin: shouldImgCollapse ? 'auto' : '', display: 'block' }}
75+
style={{ display: 'block', maxWidth: '300px' }}
6376
/>
6477
</a>
6578
</Typography>

0 commit comments

Comments
 (0)