Skip to content

Commit 8935459

Browse files
authored
Merge pull request #98 from azrael3199/theme-modal-layout-fix
fix: Theme modal mobile layout
2 parents 17683e7 + d67393d commit 8935459

File tree

1 file changed

+57
-29
lines changed

1 file changed

+57
-29
lines changed

src/components/Themes/ThemeModal.tsx

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ const ThemeModal: React.FC<{
2727
onClose: () => void;
2828
theme: Theme;
2929
updateFavorites: (theme: Theme, isFavoriting: boolean) => void;
30-
}> = ({
31-
onClose,
32-
theme,
33-
updateFavorites
34-
}) => {
30+
}> = ({ onClose, theme, updateFavorites }) => {
3531
const { t } = useTranslation("components/themes");
3632
const modalRef = useRef<HTMLDivElement>(null);
3733

@@ -64,24 +60,38 @@ const ThemeModal: React.FC<{
6460
backgroundColor: "background.paper",
6561
borderRadius: 2,
6662
boxShadow: 24,
67-
p: 4,
63+
p: 2,
64+
paddingTop: 1,
6865
maxWidth: "800px",
66+
maxHeight: "80vh",
67+
overflow: "auto",
6968
width: "90%",
69+
marginTop: { xs: 4, md: 0 },
7070
}}
7171
>
72-
<IconButton
73-
onClick={onClose}
72+
<Box sx={{ display: "flex", justifyContent: "flex-end" }}>
73+
<IconButton onClick={onClose}>
74+
<CloseIcon />
75+
</IconButton>
76+
</Box>
77+
78+
<Grid
79+
container
80+
spacing={2}
7481
sx={{
75-
position: "absolute",
76-
top: 16,
77-
right: 16,
82+
p: 2,
83+
flexDirection: { xs: "column-reverse", md: "row" },
7884
}}
7985
>
80-
<CloseIcon />
81-
</IconButton>
82-
83-
<Grid container spacing={4}>
84-
<Grid item xs={12} md={6}>
86+
<Grid
87+
item
88+
xs={12}
89+
md={6}
90+
sx={{
91+
paddingRight: { xs: 0, md: 2 },
92+
}}
93+
spacing={0}
94+
>
8595
<Typography
8696
id="theme-modal-title"
8797
variant="h5"
@@ -179,42 +189,51 @@ const ThemeModal: React.FC<{
179189
sx={{
180190
display: "flex",
181191
alignItems: "center",
182-
gap: 3,
192+
gap: 1,
183193
width: { xs: "100%", md: "auto" },
194+
py: 2,
184195
}}
185196
>
186197
<Button
187198
onClick={onDownload}
188199
variant="contained"
189200
color="primary"
190201
sx={{
191-
width: { xs: "100%", md: "auto" },
202+
width: "auto",
203+
flexGrow: 1,
192204
}}
193205
>
194206
{t("theme_modal.download_theme")}
195207
</Button>
196208

197-
<Box sx={{ display: "flex", alignItems: "center", gap: 0 }}>
198-
<IconButton
209+
<Box
210+
sx={{
211+
display: "flex",
212+
alignItems: "center",
213+
alignSelf: { xs: "flex-start", md: "flex-end" },
214+
gap: 0,
215+
}}
216+
>
217+
<IconButton
199218
aria-label="favorite"
200219
onClick={handleFavoriteClick}
201220
sx={{
202221
padding: 1,
203-
'&:hover': {
204-
backgroundColor: 'action.hover'
205-
}
222+
"&:hover": {
223+
backgroundColor: "action.hover",
224+
},
206225
}}
207226
>
208227
<Heart
209228
size={20}
210-
color={theme.isFavorite ? 'red' : 'currentColor'}
211-
fill={theme.isFavorite ? 'red' : 'none'}
229+
color={theme.isFavorite ? "red" : "currentColor"}
230+
fill={theme.isFavorite ? "red" : "none"}
212231
/>
213232
</IconButton>
214233
<Typography
215234
sx={{
216-
color: 'text.primary',
217-
fontSize: '1rem'
235+
color: "text.primary",
236+
fontSize: "1rem",
218237
}}
219238
>
220239
{theme.favoritesCount} {t("theme_modal.likes")}
@@ -223,7 +242,16 @@ const ThemeModal: React.FC<{
223242
</Box>
224243
</Grid>
225244

226-
<Grid item xs={12} md={6} display="flex" justifyContent="center">
245+
<Grid
246+
item
247+
xs={12}
248+
md={6}
249+
display="flex"
250+
justifyContent="center"
251+
sx={{
252+
paddingRight: { xs: 0, md: 2 },
253+
}}
254+
>
227255
<Box
228256
component="img"
229257
src={theme.themeImg}
@@ -248,4 +276,4 @@ const ThemeModal: React.FC<{
248276
);
249277
};
250278

251-
export default ThemeModal;
279+
export default ThemeModal;

0 commit comments

Comments
 (0)