From 67041a0f5d41ef6dfeae63f222a7f186fc73576b Mon Sep 17 00:00:00 2001 From: Jai-Marothiya Date: Fri, 16 Aug 2024 12:13:52 +0530 Subject: [PATCH 1/2] Make project responsive to all screen sizes --- client/src/components/Auth/GoogleAuth.js | 14 +- client/src/components/Auth/Login.js | 75 +++- client/src/components/UserView/Dashboard.js | 15 +- client/src/components/UserView/Footer.js | 16 +- client/src/components/UserView/Navbar.js | 323 ++++++++++++------ .../src/components/UserView/ProblemsTable.js | 20 +- client/src/components/UserView/ProgressBar.js | 16 +- .../UserView/SideBar/FilterSidebar.js | 13 +- .../UserView/SideBar/PlatformFilter.js | 2 +- .../components/UserView/SideBar/TagsFilter.js | 2 +- .../UserView/TableRow/PlatformLogo.js | 2 +- .../components/UserView/TableRow/TableRow.js | 237 +++++++++---- client/src/components/icons/GoogleIcon.js | 2 +- client/src/components/icons/Logo.js | 4 +- 14 files changed, 519 insertions(+), 222 deletions(-) diff --git a/client/src/components/Auth/GoogleAuth.js b/client/src/components/Auth/GoogleAuth.js index ed2f6ef..244040b 100644 --- a/client/src/components/Auth/GoogleAuth.js +++ b/client/src/components/Auth/GoogleAuth.js @@ -43,21 +43,21 @@ const GoogleAuth = ({ loading, setLoading }) => { }); return ( - + {loading ? ( { width: "90%", textAlign: "center", fontFamily: "Jost, sans-serif", - fontSize: "25px", + fontSize: { xs: "16px", sm: "22px", md: "25px" }, fontWeight: "400", - lineHeight: "32.0px", + lineHeight: { xs: "20px", sm: "24px", md: "32.0px" }, letterSpacing: " 1px", color: "rgba(0, 0, 0, 0.54)", WebkitFontSmoothing: "antialiased", // Smooths font on Webkit browsers (Chrome, Safari) diff --git a/client/src/components/Auth/Login.js b/client/src/components/Auth/Login.js index 60c9448..7b54707 100644 --- a/client/src/components/Auth/Login.js +++ b/client/src/components/Auth/Login.js @@ -1,4 +1,4 @@ -import { Box, Typography } from "@mui/material"; +import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; import React, { useContext, useEffect, useState } from "react"; import GoogleAuth from "./GoogleAuth"; import ALogo from "../icons/ALogo"; @@ -8,6 +8,7 @@ import axios from "axios"; import { endpoints } from "../../constants/endpoints"; import LoaderDialog from "./LoaderDialog"; import LoadingSkeleton from "./LoadingSkeleton"; +import Logo from "../icons/Logo"; const Login = ({ loading, setLoading, refreshLoading, setRefreshLoading }) => { const { @@ -18,6 +19,8 @@ const Login = ({ loading, setLoading, refreshLoading, setRefreshLoading }) => { userProblems, setUserProblems, } = useContext(DataContext); + const theme = useTheme(); + const isLargeScreen = useMediaQuery(theme.breakpoints.up("sm")); const navigate = useNavigate(); useEffect(() => { @@ -59,8 +62,10 @@ const Login = ({ loading, setLoading, refreshLoading, setRefreshLoading }) => { display: "flex", justifyContent: "center", alignItems: "center", - height: "100%", + height: { xs: "100vh", sm: "100%" }, width: "100%", + flexDirection: { xs: "column", sm: "row" }, // Stack column on small screens, row on larger screens + overflow: "hidden", // Ensures no overflow issues on smaller screens }} > {!refreshLoading ? ( @@ -69,28 +74,75 @@ const Login = ({ loading, setLoading, refreshLoading, setRefreshLoading }) => { component="img" src="SideImage.jpeg" // Update this path to your PNG file sx={{ - width: "30%", - height: "100%", + width: { xs: "100%", sm: "30%" }, + height: { xs: "30vh", sm: "100%" }, + objectFit: "cover", + display: { xs: "none", sm: "block" }, }} /> - - - + + + {isLargeScreen ? ( + + ) : ( + + + + )} + + { { ) : ( - // )} diff --git a/client/src/components/UserView/Dashboard.js b/client/src/components/UserView/Dashboard.js index 25b55e4..9863a81 100644 --- a/client/src/components/UserView/Dashboard.js +++ b/client/src/components/UserView/Dashboard.js @@ -1,4 +1,4 @@ -import { Box } from "@mui/material"; +import { Box, useMediaQuery, useTheme } from "@mui/material"; import React, { useEffect } from "react"; import Navbar from "./Navbar"; import ProblemsTable from "./ProblemsTable"; @@ -10,25 +10,28 @@ const Dashboard = ({ setLoading }) => { useEffect(() => { setLoading(false); }, []); + const theme = useTheme(); + const isLargeScreen = useMediaQuery(theme.breakpoints.up("md")); return ( - + - + {isLargeScreen && } - + {isLargeScreen && }