feat: fixing sidebar on mobile

This commit is contained in:
Carlos Gutierrez
2025-09-02 19:52:01 -04:00
parent 8f9e4f54df
commit 0f0da5fb8f
3 changed files with 30 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import { Clock, BarChart3, Settings, Sun, Moon } from "lucide-react";
import { Clock, BarChart3, Settings, Sun, Moon, X } from "lucide-react";
import { Button } from "@/components/atoms/Button";
import { useTheme } from "@/lib/theme";
import { useStore } from "@/lib/store";
@@ -10,12 +10,14 @@ interface SidebarProps {
className?: string;
isMobile?: boolean;
onNavigate?: () => void;
onClose?: () => void;
}
export function Sidebar({
className = "",
isMobile = false,
onNavigate,
onClose,
}: SidebarProps) {
const { theme, toggleTheme } = useTheme();
const [location] = useLocation();
@@ -44,19 +46,30 @@ export function Sidebar({
return (
<aside
className={`w-64 bg-card border-r border-border flex-shrink-0 sidebar-transition ${
className={`w-64 bg-card border-r border-border flex-shrink-0 sidebar-transition h-screen ${
isMobile ? "sidebar-mobile" : ""
} ${className}`}
>
<div className="flex flex-col h-full">
{/* Logo/Brand */}
<div className="p-6 border-b border-border">
<div className="p-6 border-b border-border flex items-center justify-between">
<div className="flex items-center space-x-3">
<div className="w-8 h-8 bg-primary rounded-lg flex items-center justify-center">
<Clock className="text-primary-foreground text-sm" />
</div>
<h1 className="text-xl font-semibold">Pomodorian</h1>
</div>
{isMobile && onClose && (
<Button
variant="ghost"
size="icon"
onClick={onClose}
className="md:hidden"
data-testid="button-sidebar-close"
>
<X className="w-5 h-5" />
</Button>
)}
</div>
{/* Navigation Menu */}

View File

@@ -63,9 +63,10 @@ export function MainLayout({ children, title, subtitle }: MainLayoutProps) {
<div className="flex h-screen overflow-hidden">
{/* Sidebar Navigation */}
<Sidebar
className={`md:translate-x-0 ${sidebarOpen ? 'open' : ''}`}
className={`${sidebarOpen ? 'open' : ''}`}
isMobile={true}
onNavigate={closeSidebar}
onClose={closeSidebar}
/>
{/* Mobile Sidebar Overlay */}

View File

@@ -113,15 +113,26 @@
transition: transform 0.3s ease-in-out;
}
@media (max-width: 768px) {
@media (max-width: 767px) {
.sidebar-mobile {
transform: translateX(-100%);
position: fixed;
z-index: 50;
height: 100vh;
top: 0;
left: 0;
}
.sidebar-mobile.open {
transform: translateX(0);
}
}
@media (min-width: 768px) {
.sidebar-mobile {
transform: translateX(0);
}
}
div,
p {
text-wrap: auto !important;