Spaces:
Build error
Build error
| import * as React from "react" | |
| import { cva } from "class-variance-authority" | |
| import { cn } from "@/lib/utils" | |
| const ToastProvider = ({ children }) => { | |
| return <div className="fixed top-4 right-4 z-[100] space-y-2">{children}</div> | |
| } | |
| const toastVariants = cva( | |
| "relative w-full rounded-md border p-4 shadow-lg", | |
| { | |
| variants: { | |
| variant: { | |
| default: "bg-background text-foreground", | |
| destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", | |
| }, | |
| }, | |
| defaultVariants: { | |
| variant: "default", | |
| }, | |
| } | |
| ) | |
| const Toast = React.forwardRef(({ className, variant, ...props }, ref) => ( | |
| <div | |
| ref={ref} | |
| className={cn(toastVariants({ variant }), className)} | |
| {...props} | |
| /> | |
| )) | |
| Toast.displayName = "Toast" | |
| const ToastTitle = React.forwardRef(({ className, ...props }, ref) => ( | |
| <div | |
| ref={ref} | |
| className={cn("text-sm font-semibold", className)} | |
| {...props} | |
| /> | |
| )) | |
| ToastTitle.displayName = "ToastTitle" | |
| const ToastDescription = React.forwardRef(({ className, ...props }, ref) => ( | |
| <div | |
| ref={ref} | |
| className={cn("text-sm opacity-90", className)} | |
| {...props} | |
| /> | |
| )) | |
| ToastDescription.displayName = "ToastDescription" | |
| const ToastClose = React.forwardRef(({ className, ...props }, ref) => ( | |
| <button | |
| ref={ref} | |
| className={cn( | |
| "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none group-hover:opacity-100", | |
| className | |
| )} | |
| {...props} | |
| /> | |
| )) | |
| ToastClose.displayName = "ToastClose" | |
| const ToastViewport = React.forwardRef(({ className, ...props }, ref) => ( | |
| <div | |
| ref={ref} | |
| className={cn( | |
| "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]", | |
| className | |
| )} | |
| {...props} | |
| /> | |
| )) | |
| ToastViewport.displayName = "ToastViewport" | |
| export { | |
| ToastProvider, | |
| Toast, | |
| ToastTitle, | |
| ToastDescription, | |
| ToastClose, | |
| ToastViewport, | |
| } |