Skip to content

Commit 71f7e10

Browse files
Merge pull request #4235 from OneCommunityGlobal/DurgaVenkataPraveen-HeaderAlignmentFixing
Durga Venkata Praveen Fix: Header responsive layout and CSS module conversion
2 parents 6cedf71 + 947f917 commit 71f7e10

2 files changed

Lines changed: 148 additions & 27 deletions

File tree

src/components/Header/Header.jsx

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
} from '../../languages/en/ui';
5555
import Logout from '../Logout/Logout';
5656
import '../../App.css';
57-
import './Header.css';
57+
import styles from './Header.module.css';
5858
import hasPermission, { cantUpdateDevAdminDetails } from '../../utils/permissions';
5959
import {
6060
getUnreadUserNotifications,
@@ -192,6 +192,44 @@ export function Header(props) {
192192
};
193193
}, [user.userid, props.auth.firstName]);
194194

195+
// Debugging Enhancement: Monitor window resize events for responsive testing
196+
useEffect(() => {
197+
const handleResize = () => {
198+
const currentWidth = window.innerWidth;
199+
// eslint-disable-next-line no-console
200+
console.log(`[Header Debug] Window resized to: ${currentWidth}px`);
201+
202+
// Log breakpoint information for debugging
203+
if (currentWidth >= 1728) {
204+
// eslint-disable-next-line no-console
205+
console.log(`[Header Debug] Breakpoint: Large screen (90%+) - Owner message below timer`);
206+
} else if (currentWidth >= 1400) {
207+
// eslint-disable-next-line no-console
208+
console.log(`[Header Debug] Breakpoint: Desktop - Centered layout`);
209+
} else if (currentWidth >= 1200) {
210+
// eslint-disable-next-line no-console
211+
console.log(`[Header Debug] Breakpoint: Medium desktop - Centered layout`);
212+
} else if (currentWidth >= 768) {
213+
// eslint-disable-next-line no-console
214+
console.log(`[Header Debug] Breakpoint: Tablet - Stacked layout`);
215+
} else {
216+
// eslint-disable-next-line no-console
217+
console.log(`[Header Debug] Breakpoint: Mobile - Compact vertical layout`);
218+
}
219+
};
220+
221+
// Log initial window size
222+
handleResize();
223+
224+
// Add resize event listener
225+
window.addEventListener('resize', handleResize);
226+
227+
// Cleanup event listener on component unmount
228+
return () => {
229+
window.removeEventListener('resize', handleResize);
230+
};
231+
}, []);
232+
195233
useEffect(() => {
196234
if (props.auth.isAuthenticated) {
197235
props.getHeaderData(props.auth.user.userid);
@@ -340,29 +378,36 @@ export function Header(props) {
340378

341379
const viewingUser = JSON.parse(window.sessionStorage.getItem('viewingUser'));
342380
return (
343-
<div className={`header-wrapper${darkMode ? ' dark-mode' : ''}`} data-testid="header">
344-
<Navbar className="py-3 navbar" color="dark" dark expand="md">
381+
<div className={`${styles.headerWrapper}${darkMode ? ` ${styles.darkMode}` : ''}`} data-testid="header">
382+
<Navbar className={`py-3 ${styles.navbar}`} color="dark" dark expand="md">
345383
{logoutPopup && <Logout open={logoutPopup} setLogoutPopup={setLogoutPopup} />}
346384
{showPromotionsPopup &&
347385
(<DisplayBox onClose={() => setShowPromotionsPopup(false)} />)}
348-
<div
349-
className="timer-message-section"
350-
style={user.role === 'Owner' ? { marginRight: '0.5rem' } : { marginRight: '1rem' }}
351-
>
352-
{isAuthenticated && <Timer darkMode={darkMode} />}
353-
{isAuthenticated && (
354-
<div className="owner-message">
355-
<OwnerMessage />
356-
</div>
357-
)}
358-
</div>
359-
<NavbarToggler onClick={toggle} />
360-
{isAuthenticated && (
361-
<Collapse isOpen={isOpen} navbar>
362-
<Nav className="ml-auto nav-links d-flex" navbar>
363-
<div
364-
className="d-flex justify-content-center align-items-center"
365-
style={{ width: '100%' }}
386+
387+
<div className="d-flex justify-content-between align-items-center w-100 p-3">
388+
{/* Left Component - Timer */}
389+
<div className={styles.leftSection}>
390+
{isAuthenticated && <Timer darkMode={darkMode} />}
391+
</div>
392+
393+
{/* Center Component - Owner Message */}
394+
<div className={`${styles.centerSection} text-center flex-grow-1`}>
395+
{isAuthenticated && (
396+
<div className={styles.ownerMessage}>
397+
<OwnerMessage />
398+
</div>
399+
)}
400+
</div>
401+
402+
{/* Right Component - Navigation */}
403+
<div className={styles.rightSection}>
404+
<NavbarToggler onClick={toggle} />
405+
{isAuthenticated && (
406+
<Collapse isOpen={isOpen} navbar>
407+
<Nav className={`${styles.navLinks} d-flex`} navbar>
408+
<div
409+
className="d-flex justify-content-center align-items-center"
410+
style={{ width: '100%' }}
366411
>
367412
{canUpdateTask && (
368413
<NavItem className="responsive-spacing">
@@ -615,6 +660,8 @@ export function Header(props) {
615660
</Nav>
616661
</Collapse>
617662
)}
663+
</div>
664+
</div>
618665
</Navbar>
619666
{!isAuthUser && (
620667
<PopUpBar
Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
justify-content: space-between;
6868
align-items: center;
6969
width: 100%;
70-
white-space: nowrap;
70+
overflow: visible;
7171
}
7272

7373
.redBackGroupHeader {
@@ -92,11 +92,6 @@
9292

9393
}
9494

95-
.navbar {
96-
z-index: 100;
97-
overflow: visible;
98-
}
99-
10095
.nav-links {
10196
display: flex;
10297
flex-direction: row;
@@ -231,4 +226,83 @@
231226
transform: scale(1) !important;
232227
vertical-align: middle !important;
233228
}
229+
}
230+
231+
/* Conservative Three Section Header Layout - Prevents icon overlap */
232+
.left-section {
233+
display: flex;
234+
align-items: center;
235+
justify-content: flex-start;
236+
flex: 0 0 auto;
237+
min-width: fit-content;
238+
}
239+
240+
.center-section {
241+
display: flex;
242+
align-items: center;
243+
justify-content: center;
244+
flex: 1;
245+
text-align: center;
246+
min-width: 200px; /* Ensure minimum visibility */
247+
overflow: hidden; /* Handle text overflow gracefully */
248+
}
249+
250+
.right-section {
251+
display: flex;
252+
align-items: center;
253+
justify-content: flex-end;
254+
flex: 0 0 auto;
255+
min-width: fit-content;
256+
}
257+
258+
/* Responsive behavior - prevent icon overlap on smaller screens */
259+
@media (max-width: 1200px) {
260+
.left-section,
261+
.center-section,
262+
.right-section {
263+
flex-wrap: nowrap;
264+
}
265+
266+
/* Ensure right section (navigation/icons) stays on the right */
267+
.right-section {
268+
margin-left: 0.5rem;
269+
flex-shrink: 0;
270+
}
271+
272+
/* Give center section minimum space but allow some compression */
273+
.center-section {
274+
flex-shrink: 0.5;
275+
min-width: 150px; /* Minimum width to stay visible */
276+
margin: 0 0.5rem; /* Add some breathing room */
277+
}
278+
279+
/* Keep left section stable but allow some compression */
280+
.left-section {
281+
flex-shrink: 0.5;
282+
margin-right: 0.5rem;
283+
}
284+
}
285+
286+
/* Medium screens - better balance */
287+
@media (max-width: 900px) {
288+
.center-section {
289+
min-width: 120px; /* Still visible but more compressed */
290+
font-size: 0.9rem; /* Slightly smaller text */
291+
}
292+
}
293+
294+
/* Mobile specific - stack vertically to prevent overlap */
295+
@media (max-width: 768px) {
296+
.navbar .d-flex {
297+
flex-direction: column !important;
298+
align-items: center !important;
299+
gap: 0.5rem !important;
300+
}
301+
302+
.left-section,
303+
.center-section,
304+
.right-section {
305+
width: 100% !important;
306+
justify-content: center !important;
307+
}
234308
}

0 commit comments

Comments
 (0)