mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add "x" button to sidebar on mobile
This commit is contained in:
4 files changed
+25
-6
No files matched your search
@@ -108,6 +108,7 @@ export function AppLayout({
|
||||
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
|
||||
handleProjectSelect(project);
|
||||
}}
|
||||
onClose={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2 } from 'lucide-react';
|
||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
@@ -8,6 +8,7 @@ import { LoginArea } from '@/components/auth/LoginArea';
|
||||
import { useProjects } from '@/hooks/useProjects';
|
||||
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import type { Project } from '@/lib/ProjectsManager';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
@@ -77,17 +78,20 @@ interface ProjectSidebarProps {
|
||||
onSelectProject: (project: Project | null) => void;
|
||||
className?: string;
|
||||
onToggleSidebar?: () => void;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
export function ProjectSidebar({
|
||||
selectedProject,
|
||||
onSelectProject,
|
||||
className,
|
||||
onToggleSidebar
|
||||
onToggleSidebar,
|
||||
onClose
|
||||
}: ProjectSidebarProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const { data: projects = [], isLoading, error } = useProjects();
|
||||
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -96,6 +100,14 @@ export function ProjectSidebar({
|
||||
navigate('/');
|
||||
};
|
||||
|
||||
const handleToggleSidebar = () => {
|
||||
if (onToggleSidebar) {
|
||||
onToggleSidebar();
|
||||
} else if (onClose && isMobile) {
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['projects'] });
|
||||
}, [favorites, queryClient]);
|
||||
@@ -118,16 +130,20 @@ export function ProjectSidebar({
|
||||
Shakespeare
|
||||
</h1>
|
||||
</button>
|
||||
{onToggleSidebar && (
|
||||
{(onToggleSidebar || (onClose && isMobile)) && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0 hover:bg-primary/10 -mr-2"
|
||||
onClick={onToggleSidebar}
|
||||
aria-label="Collapse sidebar"
|
||||
onClick={handleToggleSidebar}
|
||||
aria-label={(onClose && isMobile) ? "Close sidebar" : "Collapse sidebar"}
|
||||
>
|
||||
<Columns2 className="h-4 w-4 text-primary/60 hover:text-primary" />
|
||||
{(onClose && isMobile) ? (
|
||||
<X className="h-4 w-4 text-primary/60 hover:text-primary" />
|
||||
) : (
|
||||
<Columns2 className="h-4 w-4 text-primary/60 hover:text-primary" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -125,6 +125,7 @@ export function SettingsLayout() {
|
||||
setIsSidebarVisible(false);
|
||||
handleProjectSelect(project);
|
||||
}}
|
||||
onClose={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -263,6 +263,7 @@ export function ProjectView() {
|
||||
navigate('/');
|
||||
}
|
||||
}}
|
||||
onClose={() => setIsSidebarVisible(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user