Skip to content

Commit 477f14e

Browse files
committed
Enhance Resume Editor with responsive design improvements, including mobile drawer integration for sidebars, updated button styles, and layout adjustments for better usability across devices.
1 parent ed2718c commit 477f14e

15 files changed

Lines changed: 764 additions & 297 deletions

src/components/Editor.tsx

Lines changed: 215 additions & 68 deletions
Large diffs are not rendered by default.

src/components/Layout/Sidebar.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from 'react'
2-
import { Box, IconButton, Typography } from '@mui/material'
2+
import { Box, IconButton, Typography, useTheme, useMediaQuery } from '@mui/material'
33
import { Link, useNavigate, useLocation } from 'react-router-dom'
44
import {
55
SVGRightLine,
@@ -31,6 +31,8 @@ const Sidebar = ({ onToggle, isExpanded }: SidebarProps) => {
3131
const navigate = useNavigate()
3232
const location = useLocation()
3333
const [showNotification, setShowNotification] = useState(false)
34+
const theme = useTheme()
35+
const isMobile = useMediaQuery(theme.breakpoints.down('md'))
3436
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3537
const dispatch = useDispatch() //NOSONAR
3638
const isAuthenticated = useSelector((state: RootState) => state.auth.isAuthenticated)
@@ -44,11 +46,16 @@ const Sidebar = ({ onToggle, isExpanded }: SidebarProps) => {
4446
else setSelectedItem('')
4547
}, [location.pathname])
4648

49+
const sidebarWidth = {
50+
collapsed: isMobile ? 30 : 48,
51+
expanded: isMobile ? 160 : 200
52+
}
53+
4754
const boxStyles = {
4855
display: 'flex',
4956
alignItems: 'center',
50-
gap: '20px',
51-
width: isExpanded ? '200px' : '48px',
57+
gap: isMobile ? '10px' : '20px',
58+
width: isExpanded ? sidebarWidth.expanded : sidebarWidth.collapsed,
5259
justifyContent: 'flex-start',
5360
borderRadius: '8px'
5461
}
@@ -84,10 +91,12 @@ const Sidebar = ({ onToggle, isExpanded }: SidebarProps) => {
8491
const getIconStyles = (key: string) => ({
8592
'& svg path': { fill: selectedItem === key ? '#361F7D' : undefined }
8693
})
94+
8795
const getTextStyles = (key: string) => ({
8896
...ui,
8997
color: selectedItem === key ? '#361F7D' : '#FFF'
9098
})
99+
91100
const getButtonStyles = (key: string) => ({
92101
backgroundColor: selectedItem === key ? '#F3F4F6' : 'transparent',
93102
borderRadius: '8px',
@@ -105,7 +114,14 @@ const Sidebar = ({ onToggle, isExpanded }: SidebarProps) => {
105114
{isExpanded && (
106115
<Link to='/' style={{ display: 'flex', alignItems: 'center' }}>
107116
<img src={logo} alt='Résumé Author' style={{ height: '50px' }} />
108-
<Typography sx={{ ...ui, fontSize: '20px', mx: '10px', color: '#FFF' }}>
117+
<Typography
118+
sx={{
119+
...ui,
120+
fontSize: { xs: '14px', md: '20px' },
121+
mx: '10px',
122+
color: '#FFF'
123+
}}
124+
>
109125
Resume Author
110126
</Typography>
111127
</Link>
@@ -158,8 +174,8 @@ const Sidebar = ({ onToggle, isExpanded }: SidebarProps) => {
158174
sx={{
159175
display: 'flex',
160176
flexDirection: 'column',
161-
gap: '15px',
162-
width: isExpanded ? '200px' : '48px',
177+
gap: isMobile ? '10px' : '15px',
178+
width: isExpanded ? sidebarWidth.expanded : sidebarWidth.collapsed,
163179
transition: 'width 0.3s ease'
164180
}}
165181
>

src/components/Layout/styles.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,33 @@ export const SidebarContainer = styled(Box)(({ theme }) => ({
1010
left: 0,
1111
top: 0,
1212
transition: 'width 0.3s ease',
13+
[theme.breakpoints.down('md')]: {
14+
width: 28,
15+
padding: theme.spacing(2, 2)
16+
},
1317
'&.expanded': {
14-
width: 250
18+
width: 250,
19+
[theme.breakpoints.down('md')]: {
20+
width: 200
21+
}
1522
}
1623
}))
1724

1825
export const MainContent = styled(Box)(({ theme }) => ({
19-
marginLeft: 90,
26+
marginLeft: 75,
2027
minHeight: '100vh',
2128
width: 'calc(100% - 90px)',
2229
transition: 'width 0.3s ease',
30+
[theme.breakpoints.down('md')]: {
31+
width: 'calc(100% - 90px)',
32+
alignSelf: 'center'
33+
},
2334
'&.sidebar-expanded': {
24-
marginLeft: 300
35+
marginLeft: 300,
36+
[theme.breakpoints.down('md')]: {
37+
marginLeft: 240,
38+
width: 'calc(100% - 240px)'
39+
}
2540
}
2641
}))
2742

src/components/MyResumes.tsx

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Typography, Button } from '@mui/material'
1+
import { Box, Typography, Button, useTheme, useMediaQuery } from '@mui/material'
22
import ResumeCard from './ResumeCard'
33
import { Link, useNavigate } from 'react-router-dom'
44
import { useSelector, useDispatch } from 'react-redux'
@@ -9,6 +9,7 @@ import useDraftResume from '../hooks/useDraftResume'
99
import { logout } from '../tools/auth'
1010
import AuthErrorDisplay from './common/AuthErrorDisplay'
1111
import { clearAuth } from '../redux/slices/auth'
12+
1213
const buttonStyles = {
1314
background: '#3A35A2',
1415
padding: '10px 31px',
@@ -27,6 +28,9 @@ const buttonStyles = {
2728
const ResumeScreen: React.FC = () => {
2829
const dispatch = useDispatch<AppDispatch>()
2930
const navigate = useNavigate()
31+
const theme = useTheme()
32+
const isMobile = useMediaQuery(theme.breakpoints.down('md'))
33+
3034
const { signed, unsigned, status, error } = useSelector(
3135
(state: RootState) => state.myresumes
3236
)
@@ -56,9 +60,11 @@ const ResumeScreen: React.FC = () => {
5660
setFriendlyError(null)
5761
} else if (status === 'failed') {
5862
// Handle specific error messages from fetchUserResumes
59-
if (error?.includes('No authentication token found') ||
60-
error?.includes('Authentication expired') ||
61-
error?.includes('Session expired')) {
63+
if (
64+
error?.includes('No authentication token found') ||
65+
error?.includes('Authentication expired') ||
66+
error?.includes('Session expired')
67+
) {
6268
setFriendlyError(error)
6369
if (isAuthenticated) {
6470
handleLogout()
@@ -78,9 +84,7 @@ const ResumeScreen: React.FC = () => {
7884
setFriendlyError('Please log in to view your resumes.')
7985
} else {
8086
// For any other errors, show the error message if available
81-
setFriendlyError(
82-
error || 'An error occurred while loading your resumes.'
83-
)
87+
setFriendlyError(error || 'An error occurred while loading your resumes.')
8488
}
8589
} else if (status === 'succeeded') {
8690
setFriendlyError(null)
@@ -104,36 +108,64 @@ const ResumeScreen: React.FC = () => {
104108
<Box
105109
sx={{
106110
mx: 'auto',
107-
p: 3,
111+
p: { xs: 0, md: 3 },
108112
display: 'flex',
109113
flexDirection: 'column',
110-
marginInline: 3,
114+
marginInline: { xs: 1, md: 3 },
111115
gap: 2
112116
}}
113117
>
114118
<Box
115119
sx={{
116120
display: 'flex',
121+
flexDirection: { xs: 'column', md: 'row' },
117122
justifyContent: 'space-between',
118-
alignItems: 'center',
119-
mb: 4,
120-
mt: 2
123+
alignItems: { xs: 'flex-start', md: 'center' },
124+
mb: { xs: 2, md: 4 },
125+
mt: 2,
126+
gap: { xs: 2, md: 0 }
121127
}}
122128
>
123-
<Typography variant='h4' sx={{ color: '#2E2E48', fontWeight: 700 }}>
129+
<Typography
130+
variant='h4'
131+
sx={{
132+
color: '#2E2E48',
133+
fontWeight: 700,
134+
fontSize: { xs: '24px', sm: '28px', md: '32px' }
135+
}}
136+
>
124137
My Resumes
125138
</Typography>
126-
<Box sx={{ display: 'flex', gap: 2 }}>
139+
<Box
140+
sx={{
141+
display: 'flex',
142+
gap: { xs: 1, md: 2 },
143+
flexDirection: { xs: 'column', sm: 'row' },
144+
width: { xs: '100%', sm: 'auto' }
145+
}}
146+
>
127147
{isAuthenticated && (
128148
<>
129-
<Link style={buttonStyles} to='/resume/new'>
149+
<Link
150+
style={{
151+
...buttonStyles,
152+
padding: isMobile ? '8px 20px' : '10px 31px',
153+
fontSize: isMobile ? '14px' : '16px',
154+
textAlign: 'center',
155+
display: 'block'
156+
}}
157+
to='/resume/new'
158+
>
130159
Create new resume
131160
</Link>
132161
<Button
133162
onClick={handleLogout}
134163
sx={{
135164
...buttonStyles,
136165
textTransform: 'capitalize',
166+
padding: isMobile ? '8px 20px' : '10px 31px',
167+
fontSize: isMobile ? '14px' : '16px',
168+
width: { xs: '100%', sm: 'auto' },
137169
'&:hover': {
138170
background: '#322e8e',
139171
border: '3px solid #322e8e'
@@ -159,7 +191,15 @@ const ResumeScreen: React.FC = () => {
159191
(status === 'succeeded' || status === 'idle') &&
160192
signed.length > 0 && (
161193
<>
162-
<Typography variant='h6' sx={{ color: '#2E2E48', fontWeight: 600, mt: 2 }}>
194+
<Typography
195+
variant='h6'
196+
sx={{
197+
color: '#2E2E48',
198+
fontWeight: 600,
199+
mt: 2,
200+
fontSize: { xs: '18px', md: '20px' }
201+
}}
202+
>
163203
Signed Resumes
164204
</Typography>
165205
{signed.map(resume => (
@@ -180,7 +220,15 @@ const ResumeScreen: React.FC = () => {
180220
(status === 'succeeded' || status === 'idle') &&
181221
draftResumes.length > 0 && (
182222
<>
183-
<Typography variant='h6' sx={{ color: '#2E2E48', fontWeight: 600, mt: 2 }}>
223+
<Typography
224+
variant='h6'
225+
sx={{
226+
color: '#2E2E48',
227+
fontWeight: 600,
228+
mt: 2,
229+
fontSize: { xs: '18px', md: '20px' }
230+
}}
231+
>
184232
Draft Resumes
185233
</Typography>
186234
{draftResumes.map(resume => (

0 commit comments

Comments
 (0)