Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/containers/LearnerDashboardHeader/LearnerDashboardMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const ICON_MAP = {
};

const NavItem = ({ icon: IconComponent, label }) => (
<span className="d-inline-flex align-items-center lw-nav-item">
<IconComponent size={18} className="lw-nav-icon" />
<>
<IconComponent size={18} className="lw-nav-icon" aria-hidden="true" />
<span>{label}</span>
</span>
</>
);

const getLearnerHeaderMenu = (
Expand All @@ -55,6 +55,8 @@ const getLearnerHeaderMenu = (
const BASE_URL = getConfig().LMS_BASE_URL;
const searchCatalogUrl = getConfig().SEARCH_CATALOG_URL;
const configNavLinks = getConfig().HEADER_NAV_LINKS;

// /dashboard redirects into this MFE, so mark it active by APP_ID.
const isLinkActive = (link) => {
if (link.url === '/dashboard' || link.url.endsWith('/dashboard')) {
return getConfig().APP_ID === 'learner-dashboard';
Expand All @@ -66,23 +68,29 @@ const getLearnerHeaderMenu = (
};

const mainMenu = configNavLinks
? configNavLinks.map((link) => ({
type: 'item',
href: link.url.startsWith('http') ? link.url : `${BASE_URL}${link.url}`,
isActive: isLinkActive(link),
content: (
<NavItem
icon={ICON_MAP[link.icon] ?? IconHome}
label={link.title}
/>
),
}))
? configNavLinks.map((link) => {
const active = isLinkActive(link);
return {
type: 'item',
href: link.url.startsWith('http') ? link.url : `${BASE_URL}${link.url}`,
isActive: active,
// Skip navigation when already on this page (avoids /dashboard redirect flicker)
onClick: active ? (e) => e.preventDefault() : undefined,
content: (
<NavItem
icon={ICON_MAP[link.icon] ?? IconHome}
label={link.title}
/>
),
};
})
: [
{
type: 'item',
href: '/',
content: formatMessage(messages.course),
isActive: true,
onClick: (e) => e.preventDefault(),
},
...(getConfig().ENABLE_PROGRAMS ? [{
type: 'item',
Expand Down
40 changes: 24 additions & 16 deletions src/containers/LearnerDashboardHeader/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,27 @@
height: 40px;
}

// ─── Header layout: logo left | nav center | account right ───────────────────
// ─── Same as LMS: logo shrink-0 | nav flex:1 + center | secondary auto ───────
.site-header-desktop .nav-container {
display: flex;
align-items: center;

// True-center the main nav using absolute positioning.
// .nav-container already carries position-relative from Bootstrap.
.main-nav {
position: absolute;
left: 50%;
transform: translateX(-50%);
.logo {
flex: 0 0 auto;
}

.main-nav {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
min-width: 0;
}

// Push secondary menu to the far right
.secondary-menu-container {
flex: 0 0 auto;
margin-left: auto;
}
}
Expand Down Expand Up @@ -86,11 +93,10 @@

// ─── Navigation link styling overrides ───────────────────────────────────────
.site-header-desktop .main-nav {
display: flex;
justify-content: center;
align-items: center;

.nav-link {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 5px 10px !important;
margin: 0.25rem 0.125rem;
font-size: 0.9rem;
Expand Down Expand Up @@ -119,15 +125,17 @@
color: #059669;
font-weight: 600 !important;
}

.lw-nav-icon {
width: 1rem;
height: 1rem;
flex-shrink: 0;
}
}

// ─────────────────────────────────────────────────────────────────────────────

// Nav icon + label pairing
.lw-nav-item {
gap: 0.375rem;
}

// Nav icon (direct child of .nav-link)
.lw-nav-icon {
width: 1rem;
height: 1rem;
Expand Down