Add a Vite PWA (`vite-plugin-pwa`): manifest, icons and an `autoUpdate` service worker, plus an install prompt so the app can be added to the home screen. Rework the shell for mobile: mount the bottom navigation bar and the install prompt in the authenticated layout, hide the sidebar trigger below `md`, and add a sign-out card to Settings. Drop the placeholder Tasks page together with its unused shadcn table and the `@tanstack/react-table` dependency, and remove the in-app router/query dev tools.
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
import { Link, useRouterState } from '@tanstack/react-router'
|
|
import type { LucideIcon } from 'lucide-react'
|
|
import { HomeIcon, SettingsIcon, ShoppingCartIcon } from 'lucide-react'
|
|
|
|
import { focusNewItemInput } from '@/components/items/create-item-form'
|
|
import { NavUser } from '@/components/layout/nav-user'
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarGroup,
|
|
SidebarGroupLabel,
|
|
SidebarHeader,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
SidebarRail,
|
|
} from '@/components/ui/sidebar'
|
|
|
|
type NavItem = {
|
|
title: string
|
|
to: string
|
|
icon: LucideIcon
|
|
}
|
|
|
|
const NAV_ITEMS: NavItem[] = [
|
|
{ title: 'Principal', to: '/', icon: HomeIcon },
|
|
{ title: 'Listas', to: '/lists', icon: ShoppingCartIcon },
|
|
{ title: 'Ajustes', to: '/settings', icon: SettingsIcon },
|
|
]
|
|
|
|
function isActive(pathname: string, to: string) {
|
|
if (to === '/') return pathname === '/'
|
|
return pathname === to || pathname.startsWith(`${to}/`)
|
|
}
|
|
|
|
export function AppSidebar() {
|
|
const pathname = useRouterState({ select: (state) => state.location.pathname })
|
|
|
|
return (
|
|
<Sidebar collapsible="icon">
|
|
<SidebarHeader>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton size="lg" asChild>
|
|
<Link to="/" onClick={() => focusNewItemInput(pathname)}>
|
|
<div className="bg-primary text-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg text-sm font-semibold">
|
|
SL
|
|
</div>
|
|
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
<span className="truncate font-medium">Superlist</span>
|
|
<span className="text-muted-foreground truncate text-xs">Listas compartidas</span>
|
|
</div>
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</SidebarHeader>
|
|
|
|
<SidebarContent>
|
|
<SidebarGroup>
|
|
<SidebarGroupLabel>Plataforma</SidebarGroupLabel>
|
|
<SidebarMenu>
|
|
{NAV_ITEMS.map((item) => (
|
|
<SidebarMenuItem key={item.to}>
|
|
<SidebarMenuButton
|
|
asChild
|
|
isActive={isActive(pathname, item.to)}
|
|
tooltip={item.title}
|
|
>
|
|
<Link
|
|
to={item.to}
|
|
onClick={item.to === '/' ? () => focusNewItemInput(pathname) : undefined}
|
|
>
|
|
<item.icon />
|
|
<span>{item.title}</span>
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroup>
|
|
</SidebarContent>
|
|
|
|
<SidebarFooter>
|
|
<NavUser />
|
|
</SidebarFooter>
|
|
<SidebarRail />
|
|
</Sidebar>
|
|
)
|
|
}
|