New booking panel
This commit is contained in:
@@ -1,67 +1,143 @@
|
||||
import { useState } from "react"
|
||||
import { CalendarDays, LogOut, Menu, Settings, User, X } from "lucide-react"
|
||||
import {
|
||||
CalendarDays,
|
||||
Check,
|
||||
Laptop,
|
||||
LogOut,
|
||||
Menu,
|
||||
Moon,
|
||||
Settings,
|
||||
Sun,
|
||||
User,
|
||||
X,
|
||||
} from 'lucide-react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
import PlayzerIcon from "@/assets/playzer-favicon-512-transparent.png"
|
||||
import { Link, useLocation } from "@tanstack/react-router"
|
||||
import PlayzerIcon from '@/assets/playzer-favicon-512-transparent.png';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Link, useLocation, useNavigate } from '@tanstack/react-router';
|
||||
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuRadioGroup,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"
|
||||
import { useAuth } from "@/lib/auth"
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet';
|
||||
import { UserAvatar } from '@/components/user-avatar';
|
||||
import { apiClient } from '@/lib/api-client';
|
||||
import { useAuth } from '@/lib/auth';
|
||||
import { acceptStoredPendingInvite } from '@/lib/invitations';
|
||||
import { useCurrentComplexStore } from '@/lib/stores/current-complex-store';
|
||||
import { useTheme } from '@/lib/theme';
|
||||
|
||||
interface NavItemProps {
|
||||
to: string
|
||||
label: string
|
||||
isMobile?: boolean
|
||||
onClick?: () => void
|
||||
to: '/' | '/about';
|
||||
label: string;
|
||||
isMobile?: boolean;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
function NavItem({ to, label, isMobile, onClick }: NavItemProps) {
|
||||
const location = useLocation()
|
||||
const currentPath = location.pathname
|
||||
const isActive = to === "/" ? currentPath === "/" : currentPath.startsWith(to)
|
||||
const location = useLocation();
|
||||
const currentPath = location.pathname;
|
||||
const isActive = to === '/' ? currentPath === '/' : currentPath.startsWith(to);
|
||||
|
||||
return (
|
||||
<Link to={to} onClick={onClick}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size={isMobile ? "default" : "sm"}
|
||||
size={isMobile ? 'default' : 'sm'}
|
||||
className={[
|
||||
"rounded-none transition-all duration-200 hover:bg-transparent",
|
||||
"focus-visible:ring-2 focus-visible:ring-primary/50",
|
||||
isMobile && "w-full justify-start rounded-2xl",
|
||||
'rounded-none transition-all duration-200 hover:bg-transparent',
|
||||
'focus-visible:ring-2 focus-visible:ring-primary/50',
|
||||
isMobile && 'w-full justify-start rounded-2xl',
|
||||
isActive
|
||||
? "text-primary relative after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-primary"
|
||||
: "text-muted-foreground hover:text-foreground relative hover:after:absolute hover:after:bottom-0 hover:after:left-0 hover:after:right-0 hover:after:h-0.5 hover:after:bg-primary/50",
|
||||
? 'text-primary relative after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-primary'
|
||||
: 'text-muted-foreground hover:text-foreground relative hover:after:absolute hover:after:bottom-0 hover:after:left-0 hover:after:right-0 hover:after:h-0.5 hover:after:bg-primary/50',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ")}
|
||||
.join(' ')}
|
||||
>
|
||||
{label}
|
||||
</Button>
|
||||
</Link>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function Header() {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [open, setOpen] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const { user, isAuthenticated, displayName, avatarUrl, signOut } = useAuth();
|
||||
|
||||
const { theme, setTheme } = useTheme();
|
||||
const { currentComplexSlug, setCurrentComplex } = useCurrentComplexStore();
|
||||
const processedInviteForUser = useRef<string | null>(null);
|
||||
const myComplexesQuery = useQuery({
|
||||
queryKey: ['my-complexes'],
|
||||
enabled: isAuthenticated,
|
||||
queryFn: () => apiClient.complexes.listMine(),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAuthenticated) {
|
||||
processedInviteForUser.current = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const userKey = user?.email ?? displayName ?? 'authenticated-user';
|
||||
|
||||
if (processedInviteForUser.current === userKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
processedInviteForUser.current = userKey;
|
||||
|
||||
void (async () => {
|
||||
await acceptStoredPendingInvite(apiClient.complexes.acceptPendingInvitations);
|
||||
await queryClient.invalidateQueries({ queryKey: ['my-complexes'] });
|
||||
})();
|
||||
}, [displayName, isAuthenticated, queryClient, user?.email]);
|
||||
|
||||
const complexSlug = currentComplexSlug || myComplexesQuery.data?.[0]?.complexSlug;
|
||||
const currentComplexName = useMemo(() => {
|
||||
const complexes = myComplexesQuery.data ?? [];
|
||||
if (complexes.length === 0) return 'Mi complejo';
|
||||
|
||||
const selected = complexes.find((complex) => complex.complexSlug === complexSlug);
|
||||
|
||||
return selected?.complexName ?? complexes[0]?.complexName ?? 'Mi complejo';
|
||||
}, [complexSlug, myComplexesQuery.data]);
|
||||
|
||||
const menuItems = [
|
||||
{ label: "Inicio", to: "/" },
|
||||
{ label: "Reservas", to: "/booking" },
|
||||
{ label: "Canchas", to: "/canchas" },
|
||||
{ label: "Dashboard", to: "/dashboard" },
|
||||
{ label: "Contacto", to: "/contacto" },
|
||||
]
|
||||
{ label: 'Inicio', to: '/' },
|
||||
{ label: 'About', to: '/about' },
|
||||
] as const;
|
||||
|
||||
const handleSelectComplex = async (complexId: string, nextSlug: string) => {
|
||||
await apiClient.complexes.select({ complexId });
|
||||
setCurrentComplex(nextSlug);
|
||||
await queryClient.invalidateQueries({ queryKey: ['current-complex'] });
|
||||
};
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut();
|
||||
await navigate({ to: '/login' });
|
||||
};
|
||||
|
||||
const handleOpenBookingCreate = async () => {
|
||||
if (location.pathname !== '/') {
|
||||
await navigate({ to: '/' });
|
||||
}
|
||||
|
||||
window.setTimeout(() => {
|
||||
window.dispatchEvent(new Event('playzer:open-booking-create'));
|
||||
}, 0);
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-50 w-full border-b border-border/60 bg-background/60 dark:border-primary/20 dark:bg-[#030a10]/90 backdrop-blur-xl">
|
||||
@@ -87,66 +163,147 @@ export function Header() {
|
||||
<div className="flex-1" />
|
||||
|
||||
<div className="hidden items-center gap-2 md:flex">
|
||||
<Button className="rounded-2xl px-5 shadow-lg shadow-primary/20">
|
||||
<Button
|
||||
className="rounded-2xl px-5 shadow-lg shadow-primary/20"
|
||||
onClick={() => {
|
||||
void handleOpenBookingCreate();
|
||||
}}
|
||||
>
|
||||
<CalendarDays className="mr-2 size-4" />
|
||||
Reservar ahora
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="hidden size-10 rounded-full ring-2 ring-transparent transition-all duration-200 hover:ring-primary/30 focus:outline-none md:flex">
|
||||
<Avatar className="size-10 border border-border/60 shadow-lg shadow-black/10">
|
||||
<AvatarImage src={avatarUrl!} alt="Usuario" />
|
||||
<AvatarFallback className="bg-primary/15 text-primary">
|
||||
JD
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
{isAuthenticated ? (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="hidden size-10 rounded-full ring-2 ring-transparent transition-all duration-200 hover:ring-primary/30 focus:outline-none md:flex"
|
||||
>
|
||||
<UserAvatar
|
||||
src={avatarUrl}
|
||||
alt={displayName}
|
||||
fallbackText={displayName}
|
||||
className="size-10 border border-border/60 shadow-lg shadow-black/10"
|
||||
/>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className="w-64 rounded-2xl border-border/60 bg-popover/95 p-2 shadow-xl shadow-black/20 backdrop-blur-xl"
|
||||
>
|
||||
<DropdownMenuLabel className="px-2 py-2">
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar className="size-9">
|
||||
<AvatarImage src={ avatarUrl ?? "https://github.com/shadcn.png"} alt="Usuario" />
|
||||
<AvatarFallback className="bg-primary/15 text-primary">
|
||||
JD
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className="w-64 rounded-2xl border-border/60 bg-popover/95 p-2 shadow-xl shadow-black/20 backdrop-blur-xl"
|
||||
>
|
||||
<DropdownMenuLabel className="px-2 py-2">
|
||||
<div className="flex items-center gap-3">
|
||||
<UserAvatar
|
||||
src={avatarUrl}
|
||||
alt={displayName}
|
||||
fallbackText={displayName}
|
||||
className="size-9"
|
||||
/>
|
||||
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="truncate text-sm font-medium">{displayName}</span>
|
||||
<span className="truncate text-xs text-muted-foreground">
|
||||
{user?.email}
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="truncate text-sm font-medium">{displayName}</span>
|
||||
<span className="truncate text-xs text-muted-foreground">{user?.email}</span>
|
||||
<span className="truncate text-xs text-muted-foreground">
|
||||
{currentComplexName}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
</DropdownMenuLabel>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem className="cursor-pointer rounded-xl">
|
||||
<User className="mr-2 size-4" />
|
||||
Mi Perfil
|
||||
</DropdownMenuItem>
|
||||
{myComplexesQuery.data && myComplexesQuery.data.length > 1 && (
|
||||
<>
|
||||
<DropdownMenuLabel className="px-2 text-xs font-normal text-muted-foreground">
|
||||
Cambiar complejo
|
||||
</DropdownMenuLabel>
|
||||
{myComplexesQuery.data.map((complex) => (
|
||||
<DropdownMenuItem
|
||||
key={complex.id}
|
||||
className="cursor-pointer rounded-xl"
|
||||
onSelect={() => {
|
||||
void handleSelectComplex(complex.id, complex.complexSlug);
|
||||
}}
|
||||
>
|
||||
<span className="mr-2 flex size-4 items-center justify-center">
|
||||
{complex.complexSlug === complexSlug && <Check className="size-4" />}
|
||||
</span>
|
||||
{complex.complexName}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
</>
|
||||
)}
|
||||
|
||||
<DropdownMenuItem className="cursor-pointer rounded-xl">
|
||||
<Settings className="mr-2 size-4" />
|
||||
Configuración
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuLabel className="px-2 text-xs font-normal text-muted-foreground">
|
||||
Apariencia
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuRadioGroup
|
||||
value={theme}
|
||||
onValueChange={(value) => setTheme(value as 'light' | 'dark' | 'system')}
|
||||
>
|
||||
<DropdownMenuRadioItem value="light" className="cursor-pointer rounded-xl">
|
||||
<Sun className="mr-2 size-4" />
|
||||
Light
|
||||
</DropdownMenuRadioItem>
|
||||
<DropdownMenuRadioItem value="dark" className="cursor-pointer rounded-xl">
|
||||
<Moon className="mr-2 size-4" />
|
||||
Dark
|
||||
</DropdownMenuRadioItem>
|
||||
<DropdownMenuRadioItem value="system" className="cursor-pointer rounded-xl">
|
||||
<Laptop className="mr-2 size-4" />
|
||||
System
|
||||
</DropdownMenuRadioItem>
|
||||
</DropdownMenuRadioGroup>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem className="cursor-pointer rounded-xl text-destructive focus:bg-destructive/10 focus:text-destructive">
|
||||
<LogOut className="mr-2 size-4" />
|
||||
Cerrar sesión
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer rounded-xl"
|
||||
onSelect={() => {
|
||||
void navigate({ to: '/profile' });
|
||||
}}
|
||||
>
|
||||
<User className="mr-2 size-4" />
|
||||
Mi Perfil
|
||||
</DropdownMenuItem>
|
||||
|
||||
{currentComplexSlug && (
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer rounded-xl"
|
||||
onSelect={() => {
|
||||
void navigate({
|
||||
to: '/complex/$slug/edit',
|
||||
params: { slug: currentComplexSlug },
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Settings className="mr-2 size-4" />
|
||||
Configuración
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer rounded-xl text-destructive focus:bg-destructive/10 focus:text-destructive"
|
||||
onSelect={() => {
|
||||
void handleSignOut();
|
||||
}}
|
||||
>
|
||||
<LogOut className="mr-2 size-4" />
|
||||
Cerrar sesión
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
<Button asChild size="sm" variant="outline" className="hidden rounded-2xl md:inline-flex">
|
||||
<Link to="/login">Login</Link>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Sheet open={open} onOpenChange={setOpen}>
|
||||
<SheetTrigger asChild>
|
||||
@@ -162,18 +319,19 @@ export function Header() {
|
||||
<div className="mt-6 flex flex-col gap-6">
|
||||
<div className="rounded-3xl border border-border/60 bg-card/70 p-4 shadow-xl shadow-black/10">
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar className="size-11">
|
||||
<AvatarImage src="https://github.com/shadcn.png" alt="Usuario" />
|
||||
<AvatarFallback className="bg-primary/15 text-primary">
|
||||
JD
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<UserAvatar
|
||||
src={avatarUrl}
|
||||
alt={displayName}
|
||||
fallbackText={displayName}
|
||||
className="size-11"
|
||||
/>
|
||||
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium">John Doe</p>
|
||||
<p className="truncate text-xs text-muted-foreground">
|
||||
john@example.com
|
||||
</p>
|
||||
<p className="truncate text-sm font-medium">{displayName}</p>
|
||||
<p className="truncate text-xs text-muted-foreground">{user?.email}</p>
|
||||
{isAuthenticated && (
|
||||
<p className="truncate text-xs text-muted-foreground">{currentComplexName}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -192,44 +350,131 @@ export function Header() {
|
||||
|
||||
<Button
|
||||
className="rounded-2xl shadow-lg shadow-primary/20"
|
||||
onClick={() => setOpen(false)}
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void handleOpenBookingCreate();
|
||||
}}
|
||||
>
|
||||
<CalendarDays className="mr-2 size-4" />
|
||||
Reservar ahora
|
||||
</Button>
|
||||
|
||||
<div className="border-t border-border/60 pt-4">
|
||||
<p className="mb-2 px-2 text-xs font-medium uppercase tracking-wider text-muted-foreground">
|
||||
Cuenta
|
||||
</p>
|
||||
<div className="mb-2 flex items-center justify-between px-2">
|
||||
<p className="text-xs font-medium uppercase tracking-wider text-muted-foreground">
|
||||
Cuenta
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<nav className="flex flex-col gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<User className="mr-2 size-4" />
|
||||
Mi Perfil
|
||||
</Button>
|
||||
{!isAuthenticated && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void navigate({ to: '/login' });
|
||||
}}
|
||||
>
|
||||
Login
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<Settings className="mr-2 size-4" />
|
||||
Configuración
|
||||
</Button>
|
||||
<div className="py-1">
|
||||
<p className="px-3 py-1 text-xs text-muted-foreground">Apariencia</p>
|
||||
{[
|
||||
{ value: 'light', label: 'Light', icon: Sun },
|
||||
{ value: 'dark', label: 'Dark', icon: Moon },
|
||||
{ value: 'system', label: 'System', icon: Laptop },
|
||||
].map((item) => {
|
||||
const Icon = item.icon;
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl text-destructive hover:bg-destructive/10 hover:text-destructive"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<LogOut className="mr-2 size-4" />
|
||||
Cerrar sesión
|
||||
</Button>
|
||||
return (
|
||||
<Button
|
||||
key={item.value}
|
||||
variant="ghost"
|
||||
className="w-full justify-start rounded-2xl"
|
||||
onClick={() => setTheme(item.value as 'light' | 'dark' | 'system')}
|
||||
>
|
||||
<span className="mr-2 flex size-4 items-center justify-center">
|
||||
{theme === item.value ? (
|
||||
<Check className="size-4" />
|
||||
) : (
|
||||
<Icon className="size-4" />
|
||||
)}
|
||||
</span>
|
||||
{item.label}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{myComplexesQuery.data && myComplexesQuery.data.length > 1 && (
|
||||
<div className="py-1">
|
||||
<p className="px-3 py-1 text-xs text-muted-foreground">Cambiar complejo</p>
|
||||
{myComplexesQuery.data.map((complex) => (
|
||||
<Button
|
||||
key={complex.id}
|
||||
variant="ghost"
|
||||
className="w-full justify-start rounded-2xl"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void handleSelectComplex(complex.id, complex.complexSlug);
|
||||
}}
|
||||
>
|
||||
<span className="mr-2 flex size-4 items-center justify-center">
|
||||
{complex.complexSlug === complexSlug && <Check className="size-4" />}
|
||||
</span>
|
||||
{complex.complexName}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isAuthenticated && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void navigate({ to: '/profile' });
|
||||
}}
|
||||
>
|
||||
<User className="mr-2 size-4" />
|
||||
Mi Perfil
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{currentComplexSlug && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void navigate({
|
||||
to: '/complex/$slug/edit',
|
||||
params: { slug: currentComplexSlug },
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Settings className="mr-2 size-4" />
|
||||
Configuración
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{isAuthenticated && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="justify-start rounded-2xl text-destructive hover:bg-destructive/10 hover:text-destructive"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void handleSignOut();
|
||||
}}
|
||||
>
|
||||
<LogOut className="mr-2 size-4" />
|
||||
Cerrar sesión
|
||||
</Button>
|
||||
)}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
@@ -239,5 +484,5 @@ export function Header() {
|
||||
|
||||
<div className="h-px bg-gradient-to-r from-transparent via-primary/40 to-transparent" />
|
||||
</header>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { ReactNode } from "react"
|
||||
import { Header } from "./header"
|
||||
import type { ReactNode } from 'react';
|
||||
import { Header } from './header';
|
||||
|
||||
interface LayoutProps {
|
||||
children: ReactNode
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function Layout({ children }: LayoutProps) {
|
||||
@@ -14,7 +14,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function Background() {
|
||||
@@ -30,5 +30,5 @@ function Background() {
|
||||
|
||||
<div className="absolute inset-0 bg-[radial-gradient(circle_at_center,transparent_0%,#09131c_78%)]" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
import * as React from "react"
|
||||
import { Dialog as SheetPrimitive } from "radix-ui"
|
||||
import { Dialog as SheetPrimitive } from 'radix-ui';
|
||||
import * as React from 'react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { XIcon } from "lucide-react"
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { XIcon } from 'lucide-react';
|
||||
|
||||
function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
||||
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
||||
return <SheetPrimitive.Root data-slot="sheet" {...props} />;
|
||||
}
|
||||
|
||||
function SheetTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
|
||||
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
||||
function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
|
||||
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
|
||||
}
|
||||
|
||||
function SheetClose({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Close>) {
|
||||
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
|
||||
function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
|
||||
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
|
||||
}
|
||||
|
||||
function SheetPortal({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Portal>) {
|
||||
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
|
||||
function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
|
||||
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
|
||||
}
|
||||
|
||||
function SheetOverlay({
|
||||
@@ -35,23 +29,23 @@ function SheetOverlay({
|
||||
<SheetPrimitive.Overlay
|
||||
data-slot="sheet-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
||||
'fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function SheetContent({
|
||||
className,
|
||||
children,
|
||||
side = "right",
|
||||
side = 'right',
|
||||
showCloseButton = true,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
||||
side?: "top" | "right" | "bottom" | "left"
|
||||
showCloseButton?: boolean
|
||||
side?: 'top' | 'right' | 'bottom' | 'left';
|
||||
showCloseButton?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<SheetPortal>
|
||||
@@ -60,7 +54,7 @@ function SheetContent({
|
||||
data-slot="sheet-content"
|
||||
data-side={side}
|
||||
className={cn(
|
||||
"fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",
|
||||
'fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -68,56 +62,45 @@ function SheetContent({
|
||||
{children}
|
||||
{showCloseButton && (
|
||||
<SheetPrimitive.Close data-slot="sheet-close" asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="absolute top-3 right-3"
|
||||
size="icon-sm"
|
||||
>
|
||||
<XIcon
|
||||
/>
|
||||
<Button variant="ghost" className="absolute top-3 right-3" size="icon-sm">
|
||||
<XIcon />
|
||||
<span className="sr-only">Close</span>
|
||||
</Button>
|
||||
</SheetPrimitive.Close>
|
||||
)}
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPortal>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
function SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-header"
|
||||
className={cn("flex flex-col gap-0.5 p-4", className)}
|
||||
className={cn('flex flex-col gap-0.5 p-4', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
function SheetFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-footer"
|
||||
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
||||
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function SheetTitle({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Title>) {
|
||||
function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>) {
|
||||
return (
|
||||
<SheetPrimitive.Title
|
||||
data-slot="sheet-title"
|
||||
className={cn(
|
||||
"font-heading text-base font-medium text-foreground",
|
||||
className
|
||||
)}
|
||||
className={cn('font-heading text-base font-medium text-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function SheetDescription({
|
||||
@@ -127,10 +110,10 @@ function SheetDescription({
|
||||
return (
|
||||
<SheetPrimitive.Description
|
||||
data-slot="sheet-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
className={cn('text-sm text-muted-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -142,4 +125,4 @@ export {
|
||||
SheetFooter,
|
||||
SheetTitle,
|
||||
SheetDescription,
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user