fix: Remove top padding gap and add exit/logout to More page
Fixed 2 issues: 1. Top Padding Gap (pt-16 → removed) Problem: Mobile fullscreen had pt-16 padding creating gap at top Cause: Redundant padding when header is hidden in fullscreen Solution: Removed pt-16 from mobile fullscreen layout Before: <div className="flex flex-1 flex-col min-h-0 pt-16"> After: <div className="flex flex-1 flex-col min-h-0"> Result: No gap, submenu starts at top-0 ✓ 2. Exit/Logout Buttons in More Page Problem: No way to exit fullscreen or logout from mobile Solution: Added context-aware button to More page WP-Admin Mode: - Shows "Exit Fullscreen" button - Exits fullscreen mode (back to normal WP-admin) Standalone Mode (PWA): - Shows "Logout" button - Redirects to WP-admin login Implementation: - Created AppContext to provide isStandalone and exitFullscreen - Wrapped Shell with AppProvider - More page uses useApp() to get context - Conditional rendering based on mode Files Modified: - App.tsx: Removed pt-16, added AppProvider - AppContext.tsx: New context for app-level state - More/index.tsx: Added Exit/Logout button Result: ✅ No top gap in mobile fullscreen ✅ Exit fullscreen available in WP-admin mode ✅ Logout available in standalone mode ✅ Clean, functional mobile UX! 🎯
This commit is contained in:
@@ -31,6 +31,7 @@ import DashboardSubmenuBar from './components/nav/DashboardSubmenuBar';
|
|||||||
import { DashboardProvider } from '@/contexts/DashboardContext';
|
import { DashboardProvider } from '@/contexts/DashboardContext';
|
||||||
import { PageHeaderProvider } from '@/contexts/PageHeaderContext';
|
import { PageHeaderProvider } from '@/contexts/PageHeaderContext';
|
||||||
import { FABProvider } from '@/contexts/FABContext';
|
import { FABProvider } from '@/contexts/FABContext';
|
||||||
|
import { AppProvider } from '@/contexts/AppContext';
|
||||||
import { PageHeader } from '@/components/PageHeader';
|
import { PageHeader } from '@/components/PageHeader';
|
||||||
import { BottomNav } from '@/components/nav/BottomNav';
|
import { BottomNav } from '@/components/nav/BottomNav';
|
||||||
import { FAB } from '@/components/FAB';
|
import { FAB } from '@/components/FAB';
|
||||||
@@ -447,6 +448,7 @@ function Shell() {
|
|||||||
const { on, setOn } = useFullscreen();
|
const { on, setOn } = useFullscreen();
|
||||||
const { main } = useActiveSection();
|
const { main } = useActiveSection();
|
||||||
const toggle = () => setOn(v => !v);
|
const toggle = () => setOn(v => !v);
|
||||||
|
const exitFullscreen = () => setOn(false);
|
||||||
const isDesktop = useIsDesktop();
|
const isDesktop = useIsDesktop();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const scrollContainerRef = React.useRef<HTMLDivElement>(null);
|
const scrollContainerRef = React.useRef<HTMLDivElement>(null);
|
||||||
@@ -463,7 +465,7 @@ function Shell() {
|
|||||||
const isMorePage = location.pathname === '/more';
|
const isMorePage = location.pathname === '/more';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<AppProvider isStandalone={isStandalone} exitFullscreen={exitFullscreen}>
|
||||||
{!isStandalone && <ShortcutsBinder onToggle={toggle} />}
|
{!isStandalone && <ShortcutsBinder onToggle={toggle} />}
|
||||||
{!isStandalone && <CommandPalette toggleFullscreen={toggle} />}
|
{!isStandalone && <CommandPalette toggleFullscreen={toggle} />}
|
||||||
<div className={`flex flex-col min-h-screen ${fullscreen ? 'woonoow-fullscreen-root' : ''}`}>
|
<div className={`flex flex-col min-h-screen ${fullscreen ? 'woonoow-fullscreen-root' : ''}`}>
|
||||||
@@ -485,7 +487,7 @@ function Shell() {
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={`flex flex-1 flex-col min-h-0 ${fullscreen ? 'pt-0' : 'pt-16'}`}>
|
<div className="flex flex-1 flex-col min-h-0">
|
||||||
<PageHeader fullscreen={true} />
|
<PageHeader fullscreen={true} />
|
||||||
{!isMorePage && (isDashboardRoute ? (
|
{!isMorePage && (isDashboardRoute ? (
|
||||||
<DashboardSubmenuBar items={main.children} fullscreen={true} headerVisible={isHeaderVisible} />
|
<DashboardSubmenuBar items={main.children} fullscreen={true} headerVisible={isHeaderVisible} />
|
||||||
@@ -518,7 +520,7 @@ function Shell() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</AppProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
32
admin-spa/src/contexts/AppContext.tsx
Normal file
32
admin-spa/src/contexts/AppContext.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import React, { createContext, useContext, ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface AppContextType {
|
||||||
|
isStandalone: boolean;
|
||||||
|
exitFullscreen?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppContext = createContext<AppContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
export function AppProvider({
|
||||||
|
children,
|
||||||
|
isStandalone,
|
||||||
|
exitFullscreen
|
||||||
|
}: {
|
||||||
|
children: ReactNode;
|
||||||
|
isStandalone: boolean;
|
||||||
|
exitFullscreen?: () => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<AppContext.Provider value={{ isStandalone, exitFullscreen }}>
|
||||||
|
{children}
|
||||||
|
</AppContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useApp() {
|
||||||
|
const context = useContext(AppContext);
|
||||||
|
if (context === undefined) {
|
||||||
|
throw new Error('useApp must be used within an AppProvider');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useNavigate, Link } from 'react-router-dom';
|
import { useNavigate, Link } from 'react-router-dom';
|
||||||
import { Tag, Settings as SettingsIcon, ChevronRight } from 'lucide-react';
|
import { Tag, Settings as SettingsIcon, ChevronRight, Minimize2, LogOut } from 'lucide-react';
|
||||||
import { __ } from '@/lib/i18n';
|
import { __ } from '@/lib/i18n';
|
||||||
import { usePageHeader } from '@/contexts/PageHeaderContext';
|
import { usePageHeader } from '@/contexts/PageHeaderContext';
|
||||||
|
import { useApp } from '@/contexts/AppContext';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
interface MenuItem {
|
interface MenuItem {
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
@@ -29,12 +31,18 @@ const menuItems: MenuItem[] = [
|
|||||||
export default function MorePage() {
|
export default function MorePage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { setPageHeader, clearPageHeader } = usePageHeader();
|
const { setPageHeader, clearPageHeader } = usePageHeader();
|
||||||
|
const { isStandalone, exitFullscreen } = useApp();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPageHeader(__('More'));
|
setPageHeader(__('More'));
|
||||||
return () => clearPageHeader();
|
return () => clearPageHeader();
|
||||||
}, [setPageHeader, clearPageHeader]);
|
}, [setPageHeader, clearPageHeader]);
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
// Clear auth and redirect to login
|
||||||
|
window.location.href = window.WNW_CONFIG?.wpAdminUrl || '/wp-admin';
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background pb-20">
|
<div className="min-h-screen bg-background pb-20">
|
||||||
{/* Remove inline header - use PageHeader component instead */}
|
{/* Remove inline header - use PageHeader component instead */}
|
||||||
@@ -65,6 +73,29 @@ export default function MorePage() {
|
|||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Exit Fullscreen / Logout */}
|
||||||
|
<div className="px-4 py-6">
|
||||||
|
{isStandalone ? (
|
||||||
|
<Button
|
||||||
|
onClick={handleLogout}
|
||||||
|
variant="outline"
|
||||||
|
className="w-full justify-start gap-3"
|
||||||
|
>
|
||||||
|
<LogOut className="w-5 h-5" />
|
||||||
|
{__('Logout')}
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
onClick={exitFullscreen}
|
||||||
|
variant="outline"
|
||||||
|
className="w-full justify-start gap-3"
|
||||||
|
>
|
||||||
|
<Minimize2 className="w-5 h-5" />
|
||||||
|
{__('Exit Fullscreen')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user