Add sticky header
This commit is contained in:
21
apps/web/src/components/items/list-composer.tsx
Normal file
21
apps/web/src/components/items/list-composer.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { CreateItemForm } from '@/components/items/create-item-form'
|
||||
import { ListProgress } from '@/components/items/list-progress'
|
||||
|
||||
type ListComposerProps = {
|
||||
listId: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Progress plus the "add an item" input, pinned right below the app header while
|
||||
* the items scroll. `top-16` matches the header's `h-16`, and the negative margins
|
||||
* undo the layout's padding so the solid background also covers the gap above.
|
||||
*/
|
||||
export function ListComposer({ listId }: ListComposerProps) {
|
||||
return (
|
||||
<div className="bg-background sticky top-16 z-[5] -mx-4 -mt-4 flex flex-col gap-4 px-4 pt-4 pb-3 md:-mx-6 md:-mt-6 md:gap-6 md:px-6 md:pt-6">
|
||||
<ListProgress listId={listId} />
|
||||
|
||||
<CreateItemForm listId={listId} autoFocus />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createFileRoute, Link } from '@tanstack/react-router'
|
||||
import { PlusIcon, ShoppingCartIcon } from 'lucide-react'
|
||||
|
||||
import { CreateItemForm } from '@/components/items/create-item-form'
|
||||
import { ItemList } from '@/components/items/item-list'
|
||||
import { ListProgress } from '@/components/items/list-progress'
|
||||
import { ListComposer } from '@/components/items/list-composer'
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
@@ -52,9 +51,7 @@ function HomePage() {
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full max-w-2xl flex-col gap-4 md:gap-6">
|
||||
<ListProgress listId={primaryList.id} />
|
||||
|
||||
<CreateItemForm listId={primaryList.id} autoFocus />
|
||||
<ListComposer listId={primaryList.id} />
|
||||
|
||||
<ItemList listId={primaryList.id} />
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
import { CreateItemForm } from '@/components/items/create-item-form'
|
||||
import { ItemList } from '@/components/items/item-list'
|
||||
import { ListProgress } from '@/components/items/list-progress'
|
||||
import { ListComposer } from '@/components/items/list-composer'
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { itemsQueryOptions } from '@/hooks/use-items'
|
||||
@@ -50,9 +49,7 @@ function ListItemsPage() {
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full max-w-2xl flex-col gap-4 md:gap-6">
|
||||
<ListProgress listId={list.id} />
|
||||
|
||||
<CreateItemForm listId={list.id} autoFocus />
|
||||
<ListComposer listId={list.id} />
|
||||
|
||||
<ItemList listId={list.id} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user