mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
fix mobile nav via sidebar, hide sidebar by default on mobile
This commit is contained in:
1 parent
16d41d5428
commit
99723f1d43
2 files changed
+35
-15
No files matched your search
+19
-7
@@ -18,10 +18,16 @@ export default function Index() {
|
||||
const [projects, setProjects] = useState<Project[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(true);
|
||||
const navigate = useNavigate();
|
||||
const projectsManager = useProjectsManager();
|
||||
const isMobile = useIsMobile();
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(() => {
|
||||
// Check if we're on mobile immediately to set correct initial state
|
||||
if (typeof window !== 'undefined') {
|
||||
return window.innerWidth >= 768; // Desktop starts open, mobile starts closed
|
||||
}
|
||||
return false; // Default to closed for SSR
|
||||
});
|
||||
|
||||
useSeoMeta({
|
||||
title: 'Shakespeare - AI-Powered Nostr Development',
|
||||
@@ -64,6 +70,7 @@ export default function Index() {
|
||||
|
||||
const handleProjectSelect = (project: Project | null) => {
|
||||
if (project) {
|
||||
setIsSidebarVisible(false); // Collapse sidebar on mobile navigation
|
||||
navigate(`/project/${project.id}`);
|
||||
}
|
||||
};
|
||||
@@ -89,16 +96,21 @@ export default function Index() {
|
||||
{/* Mobile Sidebar Overlay */}
|
||||
{isSidebarVisible && (
|
||||
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
|
||||
<div className="fixed left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg">
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={handleProjectSelect}
|
||||
/>
|
||||
</div>
|
||||
{/* Backdrop - only covers the area not occupied by the sidebar */}
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
{/* Sidebar - positioned above the backdrop */}
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={null}
|
||||
onSelectProject={(project) => {
|
||||
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
|
||||
handleProjectSelect(project);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -17,11 +17,17 @@ export function ProjectView() {
|
||||
const [project, setProject] = useState<Project | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview');
|
||||
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('preview');
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(true);
|
||||
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('chat');
|
||||
const projectsManager = useProjectsManager();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
const [isSidebarVisible, setIsSidebarVisible] = useState(() => {
|
||||
// Check if we're on mobile immediately to set correct initial state
|
||||
if (typeof window !== 'undefined') {
|
||||
return window.innerWidth >= 768; // Desktop starts open, mobile starts closed
|
||||
}
|
||||
return false; // Default to closed for SSR
|
||||
});
|
||||
|
||||
const loadProject = useCallback(async () => {
|
||||
if (!projectId) return;
|
||||
@@ -85,12 +91,18 @@ export function ProjectView() {
|
||||
{/* Mobile Sidebar Overlay */}
|
||||
{isSidebarVisible && (
|
||||
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
|
||||
<div className="fixed left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg">
|
||||
{/* Backdrop - only covers the area not occupied by the sidebar */}
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
{/* Sidebar - positioned above the backdrop */}
|
||||
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
|
||||
<ProjectSidebar
|
||||
selectedProject={project}
|
||||
onSelectProject={(selectedProject) => {
|
||||
setProject(selectedProject);
|
||||
setIsSidebarVisible(false);
|
||||
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
|
||||
if (selectedProject) {
|
||||
setMobileView('chat'); // Switch to chat view when selecting a project
|
||||
navigate(`/project/${selectedProject.id}`);
|
||||
@@ -100,10 +112,6 @@ export function ProjectView() {
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
onClick={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in new issue
Block a user