Skip to content

Commit 7407ba1

Browse files
committed
fix: Fix mobile responsiveness
1 parent f8c53ea commit 7407ba1

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/components/Themes/ThemeCard.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import useIsDesktop from "@/hooks/useIsDesktop";
12
import {
23
Box,
34
Card,
@@ -38,6 +39,8 @@ const ThemeCard: React.FC<{
3839
// lazy loads translations
3940
const { t } = useTranslation("components/themes");
4041

42+
const isDesktop = useIsDesktop();
43+
4144
const handleCheckboxChange = () => {
4245
onPreview(theme);
4346
};
@@ -53,7 +56,8 @@ const ThemeCard: React.FC<{
5356
return (
5457
<Card
5558
sx={{
56-
height: 500,
59+
height: isDesktop ? 500 : 460,
60+
width: isDesktop ? "100%" : "85vw",
5761
display: "flex",
5862
flexDirection: "column",
5963
justifyContent: "space-between",
@@ -68,7 +72,7 @@ const ThemeCard: React.FC<{
6872
image={theme.themeImg}
6973
alt={theme.name}
7074
sx={{
71-
height: 280,
75+
height: isDesktop ? 280 : 240,
7276
width: "100%",
7377
objectFit: "cover",
7478
borderRadius: 5,

src/components/Themes/ThemePreview.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import GalleryTooltip from "@/components/GalleryTooltip/GalleryTooltip";
2+
import useIsDesktop from "@/hooks/useIsDesktop";
23
import { Box, Button, Typography } from "@mui/material";
34
import { Download, Paintbrush, Trash } from "lucide-react";
45
import React, { Dispatch, SetStateAction } from "react";
@@ -23,6 +24,8 @@ const ThemePreview: React.FC<{
2324
// lazy loads translations
2425
const { t } = useTranslation("components/themes");
2526

27+
const isDesktop = useIsDesktop();
28+
2629
const navigate = useNavigate();
2730

2831
const flow = {
@@ -175,7 +178,7 @@ const ThemePreview: React.FC<{
175178
flow={flow}
176179
themes={previewIds.map((themeId) => ({ id: themeId }))}
177180
settings={{ general: { embedded: true } }}
178-
styles={{ chatWindowStyle: { height: "54vh", width: "24vw" } }}
181+
styles={{ chatWindowStyle: { height: "54vh", width: isDesktop ? "24vw" : "80vw" } }}
179182
/>
180183
</Box>
181184

src/pages/Themes.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import ThemePreview from "@/components/Themes/ThemePreview";
1212
import { useAuth } from "@/context/AuthContext";
1313
import { useGlobalModal } from "@/context/GlobalModalContext";
1414
import useActionQueue from "@/hooks/useActionQueue";
15+
import useIsDesktop from "@/hooks/useIsDesktop";
1516
import { useNotify } from "@/hooks/useNotify";
1617
import { Theme } from "@/interfaces/Theme";
1718
import { addThemeToFavorites, fetchThemesFromApi, removeThemeFromFavorites } from "@/services/themes/apiService";
@@ -28,6 +29,7 @@ const Themes: React.FC = () => {
2829
// lazy load translations
2930
const { t } = useTranslation("pages/themes");
3031
const { isLoggedIn } = useAuth();
32+
const isDesktop = useIsDesktop();
3133
const { setPromptLogin, setPromptError } = useGlobalModal();
3234
const [searchParams, setSearchParams] = useSearchParams();
3335
const { fetchThemes, isLoading, error } = useFetchThemes();
@@ -273,16 +275,17 @@ const Themes: React.FC = () => {
273275
{/* Pinned Preview Section (Sticky) */}
274276
<Box
275277
sx={{
276-
position: "sticky",
278+
position: isDesktop ? "sticky" : "fixed",
277279
top: 0,
278-
mt: -72,
280+
right: isDesktop ? "auto": 0,
281+
mt: isDesktop ? -72 : 0,
279282
height: "100vh",
280283
borderLeft: "2px solid",
281284
borderColor: "divider",
282285
backgroundColor: "background.paper",
283286
transition: "width 0.3s ease",
284287
zIndex: 1000,
285-
width: isPreviewVisible ? "30%" : "40px",
288+
width: isPreviewVisible ? (isDesktop ? "30%" : "100%") : (isDesktop ? "40px": "0px"),
286289
display: "flex",
287290
flexDirection: "column",
288291
alignItems: "flex-start",
@@ -312,7 +315,7 @@ const Themes: React.FC = () => {
312315
sx={{
313316
position: "absolute",
314317
mt: 11,
315-
left: "-110px",
318+
left: isDesktop ? "-110px" : (isPreviewVisible ? "-20px" : "-130px"),
316319
backgroundColor: "background.secondaryBtn",
317320
color: "text.primary",
318321
borderRadius: "8px",

0 commit comments

Comments
 (0)