feat: Reorder PageHeader and SubmenuBar using flex-col-reverse

Implemented elegant CSS-only solution for header ordering.

Solution:
- Wrapped PageHeader and SubmenuBar in flex container
- Mobile: flex-col (PageHeader first, then SubmenuBar)
- Desktop: flex-col-reverse (SubmenuBar first, then PageHeader)

Result:
 Mobile: Contextual header stays on top (better UX)
 Desktop: Submenu tabs appear above contextual header (traditional layout)
 No JavaScript logic needed
 Pure CSS flexbox solution
 Applied to both fullscreen and normal layouts

Benefits:
- Clean, maintainable code
- No conditional rendering complexity
- Responsive without media query logic
- Performance: CSS-only, no re-renders
This commit is contained in:
dwindown
2025-11-08 20:51:58 +07:00
parent 2e077372bc
commit bc5fefdf83
2 changed files with 29 additions and 21 deletions

View File

@@ -487,12 +487,15 @@ function Shell() {
</div>
) : (
<div className="flex flex-1 flex-col min-h-0">
<PageHeader fullscreen={true} />
{!isMorePage && (isDashboardRoute ? (
<DashboardSubmenuBar items={main.children} fullscreen={true} />
) : (
<SubmenuBar items={main.children} fullscreen={true} />
))}
{/* Flex wrapper: mobile = col (PageHeader first), desktop = col-reverse (SubmenuBar first) */}
<div className="flex flex-col md:flex-col-reverse">
<PageHeader fullscreen={true} />
{!isMorePage && (isDashboardRoute ? (
<DashboardSubmenuBar items={main.children} fullscreen={true} />
) : (
<SubmenuBar items={main.children} fullscreen={true} />
))}
</div>
<main className="flex-1 flex flex-col min-h-0 min-w-0 pb-14">
<div ref={scrollContainerRef} className="flex-1 overflow-auto p-4 min-w-0">
<AppRoutes />
@@ -505,12 +508,15 @@ function Shell() {
) : (
<div className="flex flex-1 flex-col min-h-0">
<TopNav />
<PageHeader fullscreen={false} />
{isDashboardRoute ? (
<DashboardSubmenuBar items={main.children} fullscreen={false} />
) : (
<SubmenuBar items={main.children} fullscreen={false} />
)}
{/* Flex wrapper: mobile = col (PageHeader first), desktop = col-reverse (SubmenuBar first) */}
<div className="flex flex-col md:flex-col-reverse">
<PageHeader fullscreen={false} />
{isDashboardRoute ? (
<DashboardSubmenuBar items={main.children} fullscreen={false} />
) : (
<SubmenuBar items={main.children} fullscreen={false} />
)}
</div>
<main className="flex-1 flex flex-col min-h-0 min-w-0">
<div className="flex-1 overflow-auto p-4 min-w-0">
<AppRoutes />