Skip to content

Commit fbf028d

Browse files
committed
feat: Refactor DonateModal to use MUI Button for close action and improve layout
1 parent 8106006 commit fbf028d

File tree

2 files changed

+57
-50
lines changed

2 files changed

+57
-50
lines changed

src/layout/header/Header.css

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,3 @@
3333
.bulb-dark {
3434
color: #fff;
3535
}
36-
37-
.close-modal-icon {
38-
position: absolute;
39-
top: 10px;
40-
left: 10px;
41-
cursor: pointer;
42-
transition: all 0.1s;
43-
border: none;
44-
background: transparent;
45-
46-
}

src/pages/DonateModal/DonateModal.tsx

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react'
2-
import { Box, Grid, Modal, Typography, useMediaQuery, useTheme } from '@mui/material'
2+
import { Box, Button, Grid, Modal, Typography } from '@mui/material'
33
import { useTranslation } from 'react-i18next'
44
import styled from 'styled-components'
5-
import { ArrowBackIosNewRounded } from '@mui/icons-material'
5+
import { ArrowBackIosNewRounded, CloseRounded } from '@mui/icons-material'
66
interface DonateModalProps {
77
isVisible: boolean
88
onClose: () => void
@@ -19,21 +19,28 @@ const boxStyle = {
1919
width: '80%',
2020
bgcolor: 'background.paper',
2121
boxShadow: 24,
22+
borderRadius: '16px',
2223
p: 4,
2324
} as const
2425

2526
const ButtonDonate = styled.a`
27+
margin-top: 32px;
2628
direction: rtl;
2729
display: inline-flex;
2830
margin-left: auto;
2931
margin-right: 0;
3032
color: white;
33+
flex-wrap: nowrap;
3134
text-decoration: none;
3235
font-weight: bold;
36+
width: 100%;
37+
max-width: 420px;
3338
`
3439
const ButtonDonateText = styled.span`
3540
background-color: #16a9ff;
36-
padding: 8px 16px;
41+
padding: 8px 32px;
42+
width: 100%;
43+
text-align: center;
3744
border-radius: 0 1000px 1000px 0;
3845
font-size: 32px;
3946
`
@@ -47,9 +54,7 @@ const ButtonDonateIcon = styled.span`
4754
`
4855

4956
export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose }) => {
50-
const shouldImgCollapse = useMediaQuery('(max-width: 950px)')
5157
const { t } = useTranslation()
52-
const { direction } = useTheme()
5358

5459
return (
5560
<Modal
@@ -59,47 +64,60 @@ export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose })
5964
role="dialog"
6065
aria-labelledby="modal-modal-title"
6166
aria-describedby="modal-modal-description"
62-
sx={{
63-
textAlign: `${direction === 'ltr' ? 'right' : 'left'}` as const,
64-
color: 'text.primary', // Dynamically uses the theme’s text color
65-
}}>
67+
sx={{ color: 'text.primary' }} // Dynamically uses the theme’s text color
68+
>
6669
<Box sx={boxStyle}>
67-
<button onClick={onClose} className="close-modal-icon">
68-
X
69-
</button>
70-
<Typography id="modal-modal-title" variant="h6" component="h2">
71-
{t('how_to_donate_title')}
70+
<Typography sx={{ display: 'flex', justifyContent: 'space-between' }}>
71+
<h1 id="modal-modal-title" style={{ margin: 0 }}>
72+
{t('how_to_donate_title')}
73+
</h1>
74+
<Button
75+
color="inherit"
76+
sx={{
77+
borderRadius: 1000,
78+
minWidth: '36px',
79+
width: '36px',
80+
height: '36px',
81+
82+
padding: '4px',
83+
}}
84+
onClick={onClose}>
85+
<CloseRounded sx={{ height: '100%', width: '100%' }} />
86+
</Button>
7287
</Typography>
7388
<p>{t('how_to_donate_text')}</p>
74-
<Grid container spacing={2} direction={shouldImgCollapse ? 'column-reverse' : 'row'}>
75-
<Grid size={{ xs: 6 }}>
89+
<Grid container spacing={2}>
90+
<Grid size={{ xs: 12, md: 6 }}>
7691
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
7792
<h2>{t('donate_through_jgive.com_title')}</h2>
78-
<a
79-
href="https://www.jgive.com/new/he/ils/donation-targets/3268"
80-
target="_blank"
81-
rel="noreferrer"
82-
style={{ textDecoration: 'none', color: 'inherit' }}>
83-
<img
84-
src="https://www.hasadna.org.il/wp-content/uploads/2017/12/%D7%AA%D7%A8%D7%95%D7%9E%D7%95%D7%AA.jpg"
85-
alt={t('donation_link')}
86-
width={'90%'}
87-
style={{ maxWidth: '420px' }}
88-
/>
89-
</a>
90-
<ButtonDonate
91-
href="https://www.jgive.com/new/he/ils/donation-targets/3268"
92-
target="_blank"
93-
rel="noreferrer">
94-
<ButtonDonateText>{t('donate')}</ButtonDonateText>
95-
<ButtonDonateIcon>
96-
<ArrowBackIosNewRounded sx={{ fontSize: 32 }} />
97-
</ButtonDonateIcon>
98-
</ButtonDonate>
9993
</Typography>
94+
<a
95+
href="https://www.jgive.com/new/he/ils/donation-targets/3268"
96+
target="_blank"
97+
rel="noreferrer"
98+
style={{ textDecoration: 'none', color: 'inherit' }}>
99+
<img
100+
src="https://www.hasadna.org.il/wp-content/uploads/2017/12/%D7%AA%D7%A8%D7%95%D7%9E%D7%95%D7%AA.jpg"
101+
alt={t('donation_link')}
102+
width={'100%'}
103+
style={{ maxWidth: '420px' }}
104+
/>
105+
</a>
106+
<br />
107+
<ButtonDonate
108+
href="https://www.jgive.com/new/he/ils/donation-targets/3268"
109+
target="_blank"
110+
rel="noreferrer">
111+
<ButtonDonateText>{t('donate')}</ButtonDonateText>
112+
<ButtonDonateIcon>
113+
<ArrowBackIosNewRounded sx={{ fontSize: 32 }} />
114+
</ButtonDonateIcon>
115+
</ButtonDonate>
100116
</Grid>
101-
<Grid dir={direction} size={{ xs: 6 }}>
102-
<h2>{t('donation_through_bank_title')}</h2>
117+
<Grid size={{ xs: 6, md: 6 }}>
118+
<Typography>
119+
<h2>{t('donation_through_bank_title')}</h2>
120+
</Typography>
103121
<p>{t('donation_through_bank_reccomendation')}</p>
104122
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
105123
{t('bank')}: {t('donation_through_bank_details_bank')}

0 commit comments

Comments
 (0)