feat(lists): pin lists with an icon and a live pending badge

Each member can pin up to four lists and pick an icon for them (per-user
settings on shopping_list_members, PATCH /api/lists/:listId/preferences).
Pinned lists stay visible with their pending count, kept live over each
list's SSE stream: a chip bar above the bottom nav on mobile and a "Fijadas"
group in the sidebar on desktop. GET /api/lists now returns pendingCount,
isPinned and icon.

The page padding, install prompt and dictation button now read
--bottom-nav-height, which grows with the pinned bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-11-25 09:24:13 -03:00
parent dd9cf4ce43
commit b9c6ab92e3
28 changed files with 965 additions and 49 deletions

View File

@@ -9,7 +9,7 @@ export function InstallPrompt() {
if (!visible) return null
return (
<div className="fixed inset-x-0 bottom-0 z-40 px-3 pb-[calc(4.75rem+env(safe-area-inset-bottom))] md:left-auto md:right-4 md:max-w-md md:px-4 md:pb-4">
<div className="fixed inset-x-0 bottom-0 z-40 px-3 pb-[calc(var(--bottom-nav-height,4.5rem)+0.25rem+env(safe-area-inset-bottom))] md:left-auto md:right-4 md:max-w-md md:px-4 md:pb-4">
<div className="bg-card shadow-lg border rounded-xl p-3 flex items-center gap-3 w-full">
<div className="bg-primary/10 text-primary rounded-lg p-2">
{needsManualInstructions ? (

View File

@@ -57,7 +57,7 @@ export function DictateFab({ listId }: DictateFabProps) {
aria-label="Dictar ítems"
aria-haspopup="dialog"
aria-expanded={open}
className="fixed right-4 bottom-[calc(4.5rem+env(safe-area-inset-bottom)+0.75rem)] z-40 size-14 rounded-full shadow-lg md:right-6 md:bottom-6"
className="fixed right-4 bottom-[calc(var(--bottom-nav-height,4.5rem)+env(safe-area-inset-bottom)+0.75rem)] z-40 size-14 rounded-full shadow-lg md:right-6 md:bottom-6"
onClick={() => {
setOpen(true)
// Called right in the click, before any state update, so the browser still

View File

@@ -3,6 +3,7 @@ import { AppLogo } from '@/components/app-logo'
import { focusNewItemInput } from '@/components/items/create-item-form'
import { isNavItemActive, NAV_ITEMS } from '@/components/layout/nav-items'
import { NavUser } from '@/components/layout/nav-user'
import { PinnedListsSidebarGroup } from '@/components/layout/pinned-lists'
import {
Sidebar,
SidebarContent,
@@ -60,6 +61,7 @@ export function AppSidebar() {
))}
</SidebarMenu>
</SidebarGroup>
<PinnedListsSidebarGroup />
</SidebarContent>
<SidebarFooter>

View File

@@ -2,6 +2,7 @@ import { Link, useRouterState } from '@tanstack/react-router'
import { focusNewItemInput } from '@/components/items/create-item-form'
import { isNavItemActive, NAV_ITEMS } from '@/components/layout/nav-items'
import { PinnedListsBar } from '@/components/layout/pinned-lists'
import { cn } from '@/lib/utils'
export function BottomNav() {
@@ -9,6 +10,7 @@ export function BottomNav() {
return (
<footer className="fixed inset-x-0 bottom-0 z-30 border-t bg-background/95 supports-[backdrop-filter]:bg-background/60 backdrop-blur md:hidden pb-[env(safe-area-inset-bottom)]">
<PinnedListsBar />
<nav className="mx-auto flex h-18 max-w-lg items-center justify-around px-2">
{NAV_ITEMS.map((item) => {
const active = isNavItemActive(pathname, item.to)

View File

@@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query'
import { Link } from '@tanstack/react-router'
import { CheckIcon, ChevronDownIcon, ListIcon, StarIcon } from 'lucide-react'
import { ListGlyph } from '@/components/lists/list-glyph'
import {
DropdownMenu,
DropdownMenuContent,
@@ -27,12 +28,14 @@ type ListSwitcherProps = {
*/
export function ListSwitcher({ list }: ListSwitcherProps) {
const { data: lists } = useLists()
const icon = lists?.find((option) => option.id === list.id)?.icon
return (
<div className="flex min-w-0 flex-col">
<DropdownMenu>
<h1 className="flex min-w-0">
<DropdownMenuTrigger className="focus-visible:ring-ring/50 -ml-1 flex min-h-11 min-w-0 items-center gap-1 rounded-lg px-1 text-left text-xl leading-tight font-bold outline-none focus-visible:ring-3">
{icon && <ListGlyph list={{ name: list.name, icon }} className="mr-1" />}
<span className="truncate">{list.name}</span>
<ChevronDownIcon className="size-5 shrink-0" aria-hidden />
<span className="sr-only">: cambiar de lista</span>
@@ -70,6 +73,7 @@ export function ListSwitcher({ list }: ListSwitcherProps) {
function ListOption({ list, current }: { list: ShoppingListSummary; current: boolean }) {
return (
<>
<ListGlyph list={list} className="text-muted-foreground size-4" />
<span className="min-w-0 flex-1 truncate">{list.name}</span>
{list.isPrimary && <StarIcon aria-label="Principal" className="text-muted-foreground" />}
{current && <CheckIcon aria-label="Lista actual" className="text-primary" />}

View File

@@ -0,0 +1,183 @@
import type { ShoppingListSummary } from '@superlist/shared'
import { Link, useRouterState } from '@tanstack/react-router'
import { CheckIcon } from 'lucide-react'
import type { ComponentProps } from 'react'
import { ListGlyph } from '@/components/lists/list-glyph'
import {
SidebarGroup,
SidebarGroupLabel,
SidebarMenu,
SidebarMenuBadge,
SidebarMenuButton,
SidebarMenuItem,
} from '@/components/ui/sidebar'
import { pickPrimaryList, useLists, usePinnedLists } from '@/hooks/use-lists'
import { usePendingCount } from '@/hooks/use-pending-count'
import { cn } from '@/lib/utils'
/** The list the current page shows: the primary one on `/`, the one in the URL under `/lists/:id`. */
function useCurrentListId(): string | undefined {
const pathname = useRouterState({ select: (state) => state.location.pathname })
const { data: lists } = useLists()
if (pathname === '/') return lists ? pickPrimaryList(lists)?.id : undefined
return /^\/lists\/([^/]+)/.exec(pathname)?.[1]
}
function pendingLabel(list: ShoppingListSummary, count: number) {
return `${list.name}: ${count === 0 ? 'nada pendiente' : `${count} ${count === 1 ? 'pendiente' : 'pendientes'}`}`
}
/** Opens a list where the app expects it: the primary one on the home page, the rest on their own page. */
function PinnedListLink({
list,
className,
children,
...props
}: ComponentProps<'a'> & { list: ShoppingListSummary }) {
return list.isPrimary ? (
<Link to="/" className={className} {...props}>
{children}
</Link>
) : (
<Link to="/lists/$listId" params={{ listId: list.id }} className={className} {...props}>
{children}
</Link>
)
}
/**
* Mobile: the pinned lists as chips above the bottom navigation, each with its
* icon and the number of items still to buy, so the other lists stay in sight
* while shopping from one. Renders nothing when no list is pinned.
*
* It is exactly 4.5rem tall (as the navigation itself), which is what the
* authenticated layout adds to `--bottom-nav-height` while lists are pinned.
*/
export function PinnedListsBar() {
const pinned = usePinnedLists()
const currentListId = useCurrentListId()
if (pinned.length === 0) return null
return (
<nav aria-label="Listas fijadas" className="mx-auto max-w-lg px-3 pt-2.5">
<ul className="bg-muted/60 flex gap-1 rounded-2xl border p-1">
{pinned.map((list) => (
<li key={list.id} className="min-w-0 flex-1">
<PinnedChip list={list} current={list.id === currentListId} />
</li>
))}
</ul>
</nav>
)
}
function PinnedChip({ list, current }: { list: ShoppingListSummary; current: boolean }) {
const count = usePendingCount(list)
return (
<PinnedListLink
list={list}
aria-current={current ? 'page' : undefined}
aria-label={pendingLabel(list, count)}
className={cn(
'relative flex h-13 flex-col items-center justify-center gap-0.5 rounded-xl px-1 text-[11px] leading-tight transition-colors',
current
? 'bg-background text-foreground font-medium shadow-xs'
: count > 0
? 'text-foreground hover:bg-background/60'
: 'text-muted-foreground hover:bg-background/60',
)}
>
<span className="relative">
<ListGlyph list={list} />
<PendingBadge count={count} current={current} className="absolute -top-1.5 left-3.5" />
</span>
<span className="w-full truncate text-center">{list.name}</span>
</PinnedListLink>
)
}
function PendingBadge({
count,
current,
className,
}: {
count: number
current: boolean
className?: string
}) {
if (count === 0) {
return (
<span
aria-hidden
className={cn(
'bg-muted text-muted-foreground flex size-4 items-center justify-center rounded-full border',
className,
)}
>
<CheckIcon className="size-2.5" />
</span>
)
}
return (
<span
aria-hidden
className={cn(
'flex h-4.5 min-w-4.5 items-center justify-center rounded-full px-1 text-[10px] font-semibold tabular-nums',
// The open list is already in front of the user; the others are the ones to remember.
current ? 'bg-primary text-primary-foreground' : 'bg-destructive text-white',
className,
)}
>
{count > 99 ? '99+' : count}
</span>
)
}
/** Desktop: the pinned lists as a sidebar group, with the pending count (a dot when collapsed). */
export function PinnedListsSidebarGroup() {
const pinned = usePinnedLists()
const currentListId = useCurrentListId()
if (pinned.length === 0) return null
return (
<SidebarGroup>
<SidebarGroupLabel>Fijadas</SidebarGroupLabel>
<SidebarMenu>
{pinned.map((list) => (
<PinnedSidebarItem key={list.id} list={list} current={list.id === currentListId} />
))}
</SidebarMenu>
</SidebarGroup>
)
}
function PinnedSidebarItem({ list, current }: { list: ShoppingListSummary; current: boolean }) {
const count = usePendingCount(list)
return (
<SidebarMenuItem>
<SidebarMenuButton asChild isActive={current} tooltip={pendingLabel(list, count)}>
<PinnedListLink list={list}>
<ListGlyph list={list} className="size-4" />
<span>{list.name}</span>
{count > 0 && !current && (
<span
aria-hidden
className="bg-destructive absolute top-1 right-1 hidden size-2 rounded-full group-data-[collapsible=icon]:block"
/>
)}
</PinnedListLink>
</SidebarMenuButton>
<SidebarMenuBadge className={cn(count > 0 && !current && 'text-destructive')}>
{count === 0 ? <CheckIcon className="size-3.5" aria-label="Nada pendiente" /> : count}
</SidebarMenuBadge>
</SidebarMenuItem>
)
}

View File

@@ -1,11 +1,13 @@
import type { ShoppingListSummary } from '@superlist/shared'
import { MAX_PINNED_LISTS } from '@superlist/shared'
import { Link } from '@tanstack/react-router'
import { SettingsIcon, StarIcon, UsersIcon } from 'lucide-react'
import { PinIcon, PinOffIcon, SettingsIcon, StarIcon, UsersIcon } from 'lucide-react'
import { ListGlyph } from '@/components/lists/list-glyph'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Card, CardContent } from '@/components/ui/card'
import { useSetPrimaryList } from '@/hooks/use-lists'
import { usePinnedLists, useSetPrimaryList, useUpdateListPreferences } from '@/hooks/use-lists'
type ListCardProps = {
list: ShoppingListSummary
@@ -18,20 +20,34 @@ export function ListCard({ list }: ListCardProps) {
return (
<Card>
<CardContent className="flex items-center gap-1 p-4">
<Link to="/lists/$listId" params={{ listId: list.id }} className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className="truncate font-medium">{list.name}</span>
{list.isPrimary && <Badge>Principal</Badge>}
</div>
<div className="text-muted-foreground mt-1 flex items-center gap-3 text-xs">
<span className="flex items-center gap-1">
<UsersIcon className="size-3.5" />
{list.memberCount} {list.memberCount === 1 ? 'persona' : 'personas'}
</span>
<span>{list.role === 'owner' ? 'Propietario' : 'Colaborador'}</span>
</div>
<Link
to="/lists/$listId"
params={{ listId: list.id }}
className="flex min-w-0 flex-1 items-center gap-3"
>
<span className="bg-muted text-muted-foreground flex size-10 shrink-0 items-center justify-center rounded-lg">
<ListGlyph list={list} />
</span>
<span className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className="truncate font-medium">{list.name}</span>
{list.isPrimary && <Badge>Principal</Badge>}
</div>
<div className="text-muted-foreground mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs whitespace-nowrap">
<span className="flex items-center gap-1">
<UsersIcon className="size-3.5" />
{list.memberCount} {list.memberCount === 1 ? 'persona' : 'personas'}
</span>
<span>{list.role === 'owner' ? 'Propietario' : 'Colaborador'}</span>
<span>
{list.pendingCount} {list.pendingCount === 1 ? 'pendiente' : 'pendientes'}
</span>
</div>
</span>
</Link>
<PinButton list={list} />
{!list.isPrimary && (
<Button
variant="ghost"
@@ -53,3 +69,24 @@ export function ListCard({ list }: ListCardProps) {
</Card>
)
}
/** Pins or unpins the list to the always-visible bar (disabled once the limit is reached). */
function PinButton({ list }: ListCardProps) {
const updatePreferences = useUpdateListPreferences(list.id)
const pinnedCount = usePinnedLists().length
const limitReached = !list.isPinned && pinnedCount >= MAX_PINNED_LISTS
return (
<Button
variant="ghost"
size="icon"
aria-pressed={list.isPinned}
aria-label={list.isPinned ? `Desfijar ${list.name}` : `Fijar ${list.name} en la barra`}
title={limitReached ? `Puedes fijar hasta ${MAX_PINNED_LISTS} listas` : undefined}
disabled={limitReached || updatePreferences.isPending}
onClick={() => updatePreferences.mutate({ isPinned: !list.isPinned })}
>
{list.isPinned ? <PinOffIcon className="size-4" /> : <PinIcon className="size-4" />}
</Button>
)
}

View File

@@ -0,0 +1,29 @@
import type { ShoppingListSummary } from '@superlist/shared'
import { LIST_ICON_OPTIONS } from '@/lib/list-icons'
import { cn } from '@/lib/utils'
type ListGlyphProps = {
list: Pick<ShoppingListSummary, 'name' | 'icon'>
className?: string
}
/** The icon the user picked for a list, or the first letter of its name when there is none. */
export function ListGlyph({ list, className }: ListGlyphProps) {
if (list.icon) {
const { icon: Icon } = LIST_ICON_OPTIONS[list.icon]
return <Icon aria-hidden className={cn('size-5 shrink-0', className)} />
}
return (
<span
aria-hidden
className={cn(
'flex size-5 shrink-0 items-center justify-center text-sm leading-none font-semibold uppercase',
className,
)}
>
{list.name.trim().charAt(0) || '?'}
</span>
)
}

View File

@@ -0,0 +1,94 @@
import { LIST_ICONS, MAX_PINNED_LISTS, type ShoppingListDetail } from '@superlist/shared'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Switch } from '@/components/ui/switch'
import { usePinnedLists, useUpdateListPreferences } from '@/hooks/use-lists'
import { ApiError } from '@/lib/api-client'
import { LIST_ICON_OPTIONS } from '@/lib/list-icons'
import { cn } from '@/lib/utils'
type ListPreferencesCardProps = {
list: Pick<ShoppingListDetail, 'id' | 'name' | 'isPinned' | 'icon'>
}
/**
* The user's own settings for a list: pin it to the always-visible bar and pick
* its icon. Every member has their own, so it is shown to collaborators too.
*/
export function ListPreferencesCard({ list }: ListPreferencesCardProps) {
const updatePreferences = useUpdateListPreferences(list.id)
const pinnedCount = usePinnedLists().length
const pinLimitReached = !list.isPinned && pinnedCount >= MAX_PINNED_LISTS
const error = updatePreferences.error
return (
<Card>
<CardHeader>
<CardTitle className="text-base">Acceso rápido</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-5">
{error && (
<Alert variant="destructive">
<AlertDescription>
{error instanceof ApiError
? (error.problem.detail ?? error.problem.title)
: 'No pudimos guardar el cambio.'}
</AlertDescription>
</Alert>
)}
<label htmlFor="pin-list" className="flex items-start gap-3">
<span className="min-w-0 flex-1">
<span className="block text-sm font-medium">Fijar en la barra</span>
<span className="text-muted-foreground block text-sm">
{pinLimitReached
? `Ya tienes ${MAX_PINNED_LISTS} listas fijadas. Desfija otra para fijar esta.`
: `Siempre visible con sus pendientes, en cualquier pantalla. Hasta ${MAX_PINNED_LISTS} listas.`}
</span>
</span>
<Switch
id="pin-list"
className="mt-1"
checked={list.isPinned}
disabled={pinLimitReached}
onCheckedChange={(checked) => updatePreferences.mutate({ isPinned: checked })}
/>
</label>
<fieldset className="flex flex-col gap-2">
<legend className="mb-2 text-sm font-medium">Ícono</legend>
<div className="grid grid-cols-6 gap-2 sm:grid-cols-9">
{LIST_ICONS.map((key) => {
const { icon: Icon, label } = LIST_ICON_OPTIONS[key]
const selected = list.icon === key
return (
<button
key={key}
type="button"
aria-pressed={selected}
aria-label={label}
title={label}
// Tapping the selected icon again clears it (back to the initial).
onClick={() => updatePreferences.mutate({ icon: selected ? null : key })}
className={cn(
'focus-visible:ring-ring/50 flex aspect-square min-h-11 items-center justify-center rounded-lg border outline-none transition-colors focus-visible:ring-3',
selected
? 'border-primary bg-primary/10 text-primary border-2'
: 'text-muted-foreground hover:bg-muted hover:text-foreground',
)}
>
<Icon className="size-5" />
</button>
)
})}
</div>
<p className="text-muted-foreground text-xs">
Sin ícono se muestra la inicial: «{list.name.trim().charAt(0).toUpperCase()}».
</p>
</fieldset>
</CardContent>
</Card>
)
}

View File

@@ -1,4 +1,8 @@
import type { ShoppingListSummary } from '@superlist/shared'
import type {
ShoppingListDetail,
ShoppingListSummary,
UpdateListPreferencesRequest,
} from '@superlist/shared'
import { queryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { apiFetch } from '@/lib/api-client'
@@ -18,6 +22,61 @@ export function pickPrimaryList(lists: ShoppingListSummary[]): ShoppingListSumma
return lists.find((list) => list.isPrimary) ?? lists[0]
}
/** The lists pinned to the always-visible bar, in the API's order. */
export function pickPinnedLists(lists: ShoppingListSummary[]): ShoppingListSummary[] {
return lists.filter((list) => list.isPinned)
}
export function usePinnedLists(): ShoppingListSummary[] {
const { data: lists } = useLists()
return lists ? pickPinnedLists(lists) : []
}
/**
* Pins/unpins a list or changes its icon (the user's own settings). The change is
* applied to the cached lists and list detail right away and rolled back if the
* API refuses it (e.g. a fifth pinned list).
*/
export function useUpdateListPreferences(listId: string) {
const queryClient = useQueryClient()
const listsKey = listsQueryOptions().queryKey
const detailKey = ['lists', listId]
return useMutation({
mutationFn: (input: UpdateListPreferencesRequest) =>
apiFetch<ShoppingListSummary>(`/lists/${listId}/preferences`, {
method: 'PATCH',
body: JSON.stringify(input),
}),
onMutate: async (input) => {
await queryClient.cancelQueries({ queryKey: listsKey, exact: true })
await queryClient.cancelQueries({ queryKey: detailKey, exact: true })
const previousLists = queryClient.getQueryData<ShoppingListSummary[]>(listsKey)
const previousDetail = queryClient.getQueryData<ShoppingListDetail>(detailKey)
queryClient.setQueryData<ShoppingListSummary[]>(listsKey, (lists) =>
lists?.map((list) => (list.id === listId ? { ...list, ...input } : list)),
)
queryClient.setQueryData<ShoppingListDetail>(detailKey, (detail) =>
detail ? { ...detail, ...input } : detail,
)
return { previousLists, previousDetail }
},
onError: (_error, _input, context) => {
queryClient.setQueryData(listsKey, context?.previousLists)
queryClient.setQueryData(detailKey, context?.previousDetail)
},
// `exact`: only the collection and this list's detail, not every list's items.
onSettled: () =>
Promise.all([
queryClient.invalidateQueries({ queryKey: listsKey, exact: true }),
queryClient.invalidateQueries({ queryKey: detailKey, exact: true }),
]),
})
}
export function useCreateList() {
const queryClient = useQueryClient()

View File

@@ -0,0 +1,22 @@
import type { ShoppingListSummary } from '@superlist/shared'
import { useQuery } from '@tanstack/react-query'
import { itemsQueryOptions, usePendingDeletions } from '@/hooks/use-items'
import { useListEvents } from '@/hooks/use-list-events'
import { countPendingItems } from '@/lib/items'
/**
* Items still to buy in a list, kept live from any page: it reads the list's
* items (so optimistic changes and deletions waiting for undo count the same as
* on the list itself) and follows its SSE stream, shared with any other
* subscriber of that list. Until the items load it falls back to the count
* the lists endpoint returned.
*/
export function usePendingCount(list: Pick<ShoppingListSummary, 'id' | 'pendingCount'>): number {
const { data: items } = useQuery(itemsQueryOptions(list.id))
const deletingIds = usePendingDeletions()
useListEvents(list.id)
return items ? countPendingItems(items, deletingIds) : list.pendingCount
}

View File

@@ -0,0 +1,45 @@
import type { ListIcon } from '@superlist/shared'
import {
AppleIcon,
BabyIcon,
BeefIcon,
CarrotIcon,
CroissantIcon,
DogIcon,
FishIcon,
GiftIcon,
HammerIcon,
HouseIcon,
type LucideIcon,
MilkIcon,
ParkIcon,
PillIcon,
ShirtIcon,
ShoppingCartIcon,
TreesIcon,
WineIcon,
} from 'lucide-react'
/**
* The icons a list can show, in picker order. Keys come from `LIST_ICONS` in
* `@superlist/shared` (the API validates them); the labels are for screen readers.
*/
export const LIST_ICON_OPTIONS: Record<ListIcon, { icon: LucideIcon; label: string }> = {
'shopping-cart': { icon: ShoppingCartIcon, label: 'Carrito' },
carrot: { icon: CarrotIcon, label: 'Zanahoria' },
apple: { icon: AppleIcon, label: 'Manzana' },
house: { icon: HouseIcon, label: 'Casa' },
trees: { icon: TreesIcon, label: 'Árboles' },
park: { icon: ParkIcon, label: 'Parque' },
beef: { icon: BeefIcon, label: 'Carne' },
fish: { icon: FishIcon, label: 'Pescado' },
milk: { icon: MilkIcon, label: 'Leche' },
croissant: { icon: CroissantIcon, label: 'Panadería' },
wine: { icon: WineIcon, label: 'Bebidas' },
pill: { icon: PillIcon, label: 'Farmacia' },
baby: { icon: BabyIcon, label: 'Bebé' },
dog: { icon: DogIcon, label: 'Mascotas' },
shirt: { icon: ShirtIcon, label: 'Ropa' },
hammer: { icon: HammerIcon, label: 'Ferretería' },
gift: { icon: GiftIcon, label: 'Regalos' },
}

View File

@@ -6,6 +6,7 @@ import { useState } from 'react'
import { useForm } from 'react-hook-form'
import { z } from 'zod'
import { ListPreferencesCard } from '@/components/lists/list-preferences-card'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
import { Avatar, AvatarFallback } from '@/components/ui/avatar'
import { Badge } from '@/components/ui/badge'
@@ -77,6 +78,8 @@ function ListSettingsPage() {
{!list.isPrimary && <SetPrimaryButton listId={list.id} />}
<ListPreferencesCard list={list} />
{list.role === 'owner' && <RenameListCard list={list} />}
{list.role === 'owner' && <InviteCollaboratorCard listId={list.id} />}

View File

@@ -1,4 +1,5 @@
import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'
import type { CSSProperties } from 'react'
import { AppBadge } from '@/components/app-badge'
import { InstallPrompt } from '@/components/install-prompt'
import { AppHeader } from '@/components/layout/app-header'
@@ -6,6 +7,7 @@ import { AppSidebar } from '@/components/layout/app-sidebar'
import { BottomNav } from '@/components/layout/bottom-nav'
import { SidebarInset, SidebarProvider } from '@/components/ui/sidebar'
import { Skeleton } from '@/components/ui/skeleton'
import { usePinnedLists } from '@/hooks/use-lists'
import { authClient, useSession } from '@/lib/auth-client'
export const Route = createFileRoute('/_authenticated')({
@@ -36,13 +38,26 @@ function AuthenticatedLayout() {
return <SessionLoading />
}
return <AuthenticatedShell />
}
/** Split from the layout so the lists query only runs once the session is known. */
function AuthenticatedShell() {
// Height of the mobile bottom navigation, which grows by the pinned lists bar.
// Everything placed above it (page padding, install prompt, dictation button)
// reads this variable instead of a fixed offset.
const hasPinnedLists = usePinnedLists().length > 0
const shellStyle = {
'--bottom-nav-height': hasPinnedLists ? '9rem' : '4.5rem',
} as CSSProperties
return (
<SidebarProvider>
<SidebarProvider style={shellStyle}>
<AppBadge />
<AppSidebar />
<SidebarInset>
<AppHeader />
<div className="flex flex-1 flex-col gap-4 p-4 pb-[calc(5rem+env(safe-area-inset-bottom))] md:gap-6 md:p-6 md:pb-6">
<div className="flex flex-1 flex-col gap-4 p-4 pb-[calc(var(--bottom-nav-height)+0.5rem+env(safe-area-inset-bottom))] md:gap-6 md:p-6 md:pb-6">
<Outlet />
</div>
<BottomNav />