feat: add collaborative shopping lists with items and invitations
Some checks failed
CI / Verify (push) Has been cancelled
Some checks failed
CI / Verify (push) Has been cancelled
API: lists, items and invitations modules (list, create, get, update, set-primary, items create/list, invitation create/accept/list-pending), BetterAuth session helper, list membership, mailer and Prisma schema plus migrations. Web: lists overview, list detail (items) and list management (settings) views, item and invitation forms/hooks, sign-up and invitation accept pages. Shared: shopping list DTOs. Tooling: ignore the generated TanStack Router cache (apps/web/.tanstack).
This commit is contained in:
55
apps/web/src/components/items/create-item-form.tsx
Normal file
55
apps/web/src/components/items/create-item-form.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { PlusIcon } from 'lucide-react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Field, FieldError } from '@/components/ui/field'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { useCreateItem } from '@/hooks/use-items'
|
||||
|
||||
const createItemSchema = z.object({
|
||||
name: z.string().trim().min(1, 'Escribe un artículo').max(120, 'Máximo 120 caracteres'),
|
||||
})
|
||||
|
||||
type CreateItemValues = z.infer<typeof createItemSchema>
|
||||
|
||||
type CreateItemFormProps = {
|
||||
listId: string
|
||||
/** Focus the input when the form mounts, so the user can type right away. */
|
||||
autoFocus?: boolean
|
||||
}
|
||||
|
||||
/** Input to add an item to a list. Submits with Enter or the button. */
|
||||
export function CreateItemForm({ listId, autoFocus = false }: CreateItemFormProps) {
|
||||
const createItem = useCreateItem(listId)
|
||||
|
||||
const form = useForm<CreateItemValues>({
|
||||
resolver: zodResolver(createItemSchema),
|
||||
defaultValues: { name: '' },
|
||||
})
|
||||
|
||||
const onSubmit = form.handleSubmit((values) => {
|
||||
createItem.mutate(values, { onSuccess: () => form.reset() })
|
||||
})
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit} className="flex items-start gap-2">
|
||||
<Field className="flex-1" data-invalid={!!form.formState.errors.name}>
|
||||
<Input
|
||||
aria-label="Nuevo artículo"
|
||||
autoComplete="off"
|
||||
placeholder="Añade un artículo…"
|
||||
autoFocus={autoFocus}
|
||||
{...form.register('name')}
|
||||
/>
|
||||
<FieldError errors={[form.formState.errors.name]} />
|
||||
</Field>
|
||||
|
||||
<Button type="submit" disabled={createItem.isPending}>
|
||||
<PlusIcon />
|
||||
{createItem.isPending ? 'Agregando…' : 'Agregar'}
|
||||
</Button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
93
apps/web/src/components/items/item-list.tsx
Normal file
93
apps/web/src/components/items/item-list.tsx
Normal file
@@ -0,0 +1,93 @@
|
||||
import { CheckIcon, ShoppingBasketIcon } from 'lucide-react'
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { useItems } from '@/hooks/use-items'
|
||||
import { ApiError } from '@/lib/api-client'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
type ItemListProps = {
|
||||
listId: string
|
||||
}
|
||||
|
||||
/** Items loaded from the API, pending ones first. */
|
||||
export function ItemList({ listId }: ItemListProps) {
|
||||
const { data: items, isPending, error } = useItems(listId)
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Alert variant="destructive">
|
||||
<AlertTitle>No pudimos cargar los artículos</AlertTitle>
|
||||
<AlertDescription>
|
||||
{error instanceof ApiError
|
||||
? (error.problem.detail ?? error.problem.title)
|
||||
: 'Inténtalo de nuevo en unos segundos.'}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)
|
||||
}
|
||||
|
||||
if (isPending) {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Skeleton className="h-12 w-full" />
|
||||
<Skeleton className="h-12 w-full" />
|
||||
<Skeleton className="h-12 w-full" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (items.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent className="flex flex-col items-center gap-3 py-10 text-center">
|
||||
<div className="bg-muted text-muted-foreground flex size-12 items-center justify-center rounded-full">
|
||||
<ShoppingBasketIcon className="size-6" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">La lista está vacía</p>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Usa el campo de arriba para añadir tu primer artículo.
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="flex flex-col gap-2">
|
||||
{items.map((item) => (
|
||||
<li key={item.id}>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 p-3">
|
||||
<span
|
||||
className={cn(
|
||||
'flex size-5 shrink-0 items-center justify-center rounded-full border',
|
||||
item.completed
|
||||
? 'bg-primary text-primary-foreground border-primary'
|
||||
: 'border-muted-foreground/40 text-transparent',
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
<CheckIcon className="size-3" />
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
'min-w-0 flex-1 truncate',
|
||||
item.completed && 'text-muted-foreground line-through',
|
||||
)}
|
||||
>
|
||||
{item.name}
|
||||
</span>
|
||||
{item.quantity && (
|
||||
<span className="text-muted-foreground shrink-0 text-sm">{item.quantity}</span>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
@@ -1,34 +1,35 @@
|
||||
import { useRouterState } from '@tanstack/react-router'
|
||||
import { SearchIcon } from 'lucide-react'
|
||||
|
||||
import { ThemeToggle } from '@/components/theme-toggle'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { SidebarTrigger } from '@/components/ui/sidebar'
|
||||
|
||||
function usePageTitle() {
|
||||
const pathname = useRouterState({ select: (state) => state.location.pathname })
|
||||
|
||||
if (pathname === '/') return 'Dashboard'
|
||||
|
||||
const segment = pathname.split('/').filter(Boolean).at(0) ?? ''
|
||||
return segment.charAt(0).toUpperCase() + segment.slice(1)
|
||||
function titleFor(pathname: string) {
|
||||
if (pathname === '/') return 'Panel'
|
||||
if (pathname.startsWith('/lists')) return 'Listas'
|
||||
if (pathname.startsWith('/tasks')) return 'Tareas'
|
||||
if (pathname.startsWith('/settings')) return 'Ajustes'
|
||||
return 'Superlist'
|
||||
}
|
||||
|
||||
export function AppHeader() {
|
||||
const title = usePageTitle()
|
||||
const pathname = useRouterState({ select: (state) => state.location.pathname })
|
||||
const title = titleFor(pathname)
|
||||
|
||||
return (
|
||||
<header className="bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-10 flex h-16 shrink-0 items-center gap-2 border-b backdrop-blur">
|
||||
<div className="flex w-full items-center gap-2 px-4">
|
||||
<SidebarTrigger className="-ml-1" />
|
||||
<Separator orientation="vertical" className="mr-2 h-4" />
|
||||
<h1 className="text-sm font-medium">{title}</h1>
|
||||
<h1 className="truncate text-sm font-medium">{title}</h1>
|
||||
<div className="ml-auto flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
className="text-muted-foreground hover:bg-accent hover:text-accent-foreground mr-1 hidden items-center gap-2 rounded-md border px-3 py-1.5 text-xs md:flex"
|
||||
>
|
||||
<SearchIcon className="size-3.5" />
|
||||
Search
|
||||
Buscar
|
||||
<kbd className="bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-mono text-[10px]">
|
||||
⌘K
|
||||
</kbd>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Link, useRouterState } from '@tanstack/react-router'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
import { LayoutDashboardIcon, ListTodoIcon, SettingsIcon } from 'lucide-react'
|
||||
import { HomeIcon, ListTodoIcon, SettingsIcon, ShoppingCartIcon } from 'lucide-react'
|
||||
|
||||
import { NavUser } from '@/components/layout/nav-user'
|
||||
import {
|
||||
@@ -23,11 +23,17 @@ type NavItem = {
|
||||
}
|
||||
|
||||
const NAV_ITEMS: NavItem[] = [
|
||||
{ title: 'Dashboard', to: '/', icon: LayoutDashboardIcon },
|
||||
{ title: 'Tasks', to: '/tasks', icon: ListTodoIcon },
|
||||
{ title: 'Settings', to: '/settings', icon: SettingsIcon },
|
||||
{ title: 'Principal', to: '/', icon: HomeIcon },
|
||||
{ title: 'Listas', to: '/lists', icon: ShoppingCartIcon },
|
||||
{ title: 'Tareas', to: '/tasks', icon: ListTodoIcon },
|
||||
{ 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 })
|
||||
|
||||
@@ -43,7 +49,7 @@ export function AppSidebar() {
|
||||
</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">Admin</span>
|
||||
<span className="text-muted-foreground truncate text-xs">Listas compartidas</span>
|
||||
</div>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
@@ -53,11 +59,15 @@ export function AppSidebar() {
|
||||
|
||||
<SidebarContent>
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel>Platform</SidebarGroupLabel>
|
||||
<SidebarGroupLabel>Plataforma</SidebarGroupLabel>
|
||||
<SidebarMenu>
|
||||
{NAV_ITEMS.map((item) => (
|
||||
<SidebarMenuItem key={item.to}>
|
||||
<SidebarMenuButton asChild isActive={pathname === item.to} tooltip={item.title}>
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
isActive={isActive(pathname, item.to)}
|
||||
tooltip={item.title}
|
||||
>
|
||||
<Link to={item.to}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
|
||||
@@ -35,7 +35,7 @@ export function NavUser() {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const user = session?.user
|
||||
const name = user?.name ?? 'Signed out'
|
||||
const name = user?.name ?? 'Sin sesión'
|
||||
const email = user?.email ?? ''
|
||||
|
||||
return (
|
||||
@@ -79,7 +79,7 @@ export function NavUser() {
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem onClick={() => void navigate({ to: '/settings' })}>
|
||||
<UserIcon />
|
||||
Account
|
||||
Cuenta
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
@@ -90,7 +90,7 @@ export function NavUser() {
|
||||
}}
|
||||
>
|
||||
<LogOutIcon />
|
||||
Sign out
|
||||
Cerrar sesión
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
81
apps/web/src/components/lists/create-list-form.tsx
Normal file
81
apps/web/src/components/lists/create-list-form.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Field, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { useCreateList } from '@/hooks/use-lists'
|
||||
import { ApiError } from '@/lib/api-client'
|
||||
|
||||
const createListSchema = z.object({
|
||||
name: z.string().trim().min(1, 'El nombre es obligatorio').max(80, 'Máximo 80 caracteres'),
|
||||
})
|
||||
|
||||
type CreateListValues = z.infer<typeof createListSchema>
|
||||
|
||||
type CreateListFormProps = {
|
||||
onCreated?: () => void
|
||||
}
|
||||
|
||||
/** Inline form to create a shopping list. Used by the lists page. */
|
||||
export function CreateListForm({ onCreated }: CreateListFormProps) {
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const createList = useCreateList()
|
||||
|
||||
const form = useForm<CreateListValues>({
|
||||
resolver: zodResolver(createListSchema),
|
||||
defaultValues: { name: '' },
|
||||
})
|
||||
|
||||
const onSubmit = form.handleSubmit((values) => {
|
||||
setError(null)
|
||||
|
||||
createList.mutate(values, {
|
||||
onSuccess: () => {
|
||||
form.reset()
|
||||
onCreated?.()
|
||||
},
|
||||
onError: (mutationError) => {
|
||||
setError(
|
||||
mutationError instanceof ApiError
|
||||
? (mutationError.problem.detail ?? mutationError.problem.title)
|
||||
: 'No pudimos crear la lista.',
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit} className="flex flex-col gap-4">
|
||||
{error && (
|
||||
<Alert variant="destructive">
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<FieldGroup>
|
||||
<Field data-invalid={!!form.formState.errors.name}>
|
||||
<FieldLabel htmlFor="list-name">Nombre de la lista</FieldLabel>
|
||||
<Input
|
||||
id="list-name"
|
||||
placeholder="Compra semanal"
|
||||
autoComplete="off"
|
||||
{...form.register('name')}
|
||||
/>
|
||||
<FieldError errors={[form.formState.errors.name]} />
|
||||
</Field>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full sm:w-auto sm:self-start"
|
||||
disabled={createList.isPending}
|
||||
>
|
||||
{createList.isPending ? 'Creando…' : 'Crear lista'}
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
55
apps/web/src/components/lists/list-card.tsx
Normal file
55
apps/web/src/components/lists/list-card.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { ShoppingListSummary } from '@superlist/shared'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { SettingsIcon, StarIcon, UsersIcon } from 'lucide-react'
|
||||
|
||||
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'
|
||||
|
||||
type ListCardProps = {
|
||||
list: ShoppingListSummary
|
||||
}
|
||||
|
||||
/** A single list in the lists overview. Tapping it opens the list's items. */
|
||||
export function ListCard({ list }: ListCardProps) {
|
||||
const setPrimary = useSetPrimaryList()
|
||||
|
||||
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>
|
||||
|
||||
{!list.isPrimary && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={`Marcar ${list.name} como lista principal`}
|
||||
disabled={setPrimary.isPending}
|
||||
onClick={() => setPrimary.mutate(list.id)}
|
||||
>
|
||||
<StarIcon className="size-4" />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button variant="ghost" size="icon" aria-label={`Editar o configurar ${list.name}`} asChild>
|
||||
<Link to="/lists/$listId/settings" params={{ listId: list.id }}>
|
||||
<SettingsIcon className="size-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
@@ -1,11 +1,84 @@
|
||||
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
||||
import type { ComponentProps } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
|
||||
|
||||
/** Wraps `next-themes` so the theme is toggled by a class on `<html>`. */
|
||||
export function ThemeProvider({ children, ...props }: ComponentProps<typeof NextThemesProvider>) {
|
||||
return (
|
||||
<NextThemesProvider attribute="class" enableSystem disableTransitionOnChange {...props}>
|
||||
{children}
|
||||
</NextThemesProvider>
|
||||
)
|
||||
export type Theme = 'light' | 'dark' | 'system'
|
||||
|
||||
type ResolvedTheme = Exclude<Theme, 'system'>
|
||||
|
||||
type ThemeContextValue = {
|
||||
/** The preference the user picked, `system` included. */
|
||||
theme: Theme
|
||||
/** The preference already resolved against the OS setting. */
|
||||
resolvedTheme: ResolvedTheme
|
||||
setTheme: (theme: Theme) => void
|
||||
}
|
||||
|
||||
const STORAGE_KEY = 'superlist-theme'
|
||||
const DARK_QUERY = '(prefers-color-scheme: dark)'
|
||||
|
||||
/**
|
||||
* This theme handling is hand-rolled on purpose. Libraries such as `next-themes`
|
||||
* avoid the pre-paint flash by rendering a `<script>` from React, but React 19
|
||||
* never executes scripts rendered by components (it even logs a warning). Since
|
||||
* this app is client-rendered, the flash is prevented by the static script in
|
||||
* `index.html`, which runs before React mounts and uses this same storage key
|
||||
* and `.dark` class.
|
||||
*/
|
||||
const ThemeContext = createContext<ThemeContextValue>({
|
||||
theme: 'system',
|
||||
resolvedTheme: 'light',
|
||||
setTheme: () => {},
|
||||
})
|
||||
|
||||
function readStoredTheme(): Theme {
|
||||
try {
|
||||
const stored = window.localStorage.getItem(STORAGE_KEY)
|
||||
if (stored === 'light' || stored === 'dark' || stored === 'system') return stored
|
||||
} catch {
|
||||
// Storage can be unavailable (private mode, blocked cookies); fall back to system.
|
||||
}
|
||||
return 'system'
|
||||
}
|
||||
|
||||
function systemTheme(): ResolvedTheme {
|
||||
return window.matchMedia(DARK_QUERY).matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
export function ThemeProvider({ children }: { children: ReactNode }) {
|
||||
const [theme, setThemeState] = useState<Theme>(readStoredTheme)
|
||||
const [systemDark, setSystemDark] = useState(() => systemTheme() === 'dark')
|
||||
const resolvedTheme: ResolvedTheme = theme === 'system' ? (systemDark ? 'dark' : 'light') : theme
|
||||
|
||||
useEffect(() => {
|
||||
const media = window.matchMedia(DARK_QUERY)
|
||||
const onChange = (event: MediaQueryListEvent) => setSystemDark(event.matches)
|
||||
media.addEventListener('change', onChange)
|
||||
return () => media.removeEventListener('change', onChange)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement
|
||||
root.classList.toggle('dark', resolvedTheme === 'dark')
|
||||
root.style.colorScheme = resolvedTheme
|
||||
}, [resolvedTheme])
|
||||
|
||||
const setTheme = useCallback((next: Theme) => {
|
||||
setThemeState(next)
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, next)
|
||||
} catch {
|
||||
// Ignore storage failures: the theme still applies for this session.
|
||||
}
|
||||
}, [])
|
||||
|
||||
const value = useMemo(
|
||||
() => ({ theme, resolvedTheme, setTheme }),
|
||||
[theme, resolvedTheme, setTheme],
|
||||
)
|
||||
|
||||
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
return useContext(ThemeContext)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MonitorIcon, MoonIcon, SunIcon } from 'lucide-react'
|
||||
import { useTheme } from 'next-themes'
|
||||
|
||||
import { useTheme } from '@/components/theme-provider'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -10,9 +10,9 @@ import {
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
|
||||
const OPTIONS = [
|
||||
{ value: 'light', label: 'Light', icon: SunIcon },
|
||||
{ value: 'dark', label: 'Dark', icon: MoonIcon },
|
||||
{ value: 'system', label: 'System', icon: MonitorIcon },
|
||||
{ value: 'light', label: 'Claro', icon: SunIcon },
|
||||
{ value: 'dark', label: 'Oscuro', icon: MoonIcon },
|
||||
{ value: 'system', label: 'Sistema', icon: MonitorIcon },
|
||||
] as const
|
||||
|
||||
export function ThemeToggle() {
|
||||
@@ -21,7 +21,7 @@ export function ThemeToggle() {
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" aria-label="Toggle theme">
|
||||
<Button variant="ghost" size="icon" aria-label="Cambiar tema">
|
||||
<SunIcon className="size-4 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
|
||||
<MoonIcon className="absolute size-4 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
|
||||
</Button>
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
OctagonXIcon,
|
||||
TriangleAlertIcon,
|
||||
} from 'lucide-react'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { Toaster as Sonner, type ToasterProps } from 'sonner'
|
||||
import { useTheme } from '@/components/theme-provider'
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
const { theme = 'system' } = useTheme()
|
||||
|
||||
Reference in New Issue
Block a user