MCPcopy Create free account
hub / github.com/arctic-cli/interface / Toasts

Function Toasts

packages/web/components/ui/toast.tsx:52–173  ·  view source on GitHub ↗
({ position = "bottom-right" }: { position: ToastPosition })

Source from the content-addressed store, hash-verified

50}
51
52function Toasts({ position = "bottom-right" }: { position: ToastPosition }) {
53 const { toasts } = Toast.useToastManager();
54 const isTop = position.startsWith("top");
55
56 return (
57 <Toast.Portal data-slot="toast-portal">
58 <Toast.Viewport
59 className={cn(
60 "fixed z-50 mx-auto flex w-[calc(100%-var(--toast-inset)*2)] max-w-90 [--toast-inset:--spacing(4)] sm:[--toast-inset:--spacing(8)]",
61 // Vertical positioning
62 "data-[position*=top]:top-(--toast-inset)",
63 "data-[position*=bottom]:bottom-(--toast-inset)",
64 // Horizontal positioning
65 "data-[position*=left]:left-(--toast-inset)",
66 "data-[position*=right]:right-(--toast-inset)",
67 "data-[position*=center]:-translate-x-1/2 data-[position*=center]:left-1/2",
68 )}
69 data-position={position}
70 data-slot="toast-viewport"
71 >
72 {toasts.map((toast) => {
73 const Icon = toast.type
74 ? TOAST_ICONS[toast.type as keyof typeof TOAST_ICONS]
75 : null;
76
77 return (
78 <Toast.Root
79 className={cn(
80 "absolute z-[calc(9999-var(--toast-index))] h-(--toast-calc-height) w-full select-none rounded-lg border bg-popover bg-clip-padding text-popover-foreground shadow-lg [transition:transform_.5s_cubic-bezier(.22,1,.36,1),opacity_.5s,height_.15s] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]",
81 // Base positioning using data-position
82 "data-[position*=right]:right-0 data-[position*=right]:left-auto",
83 "data-[position*=left]:right-auto data-[position*=left]:left-0",
84 "data-[position*=center]:right-0 data-[position*=center]:left-0",
85 "data-[position*=top]:top-0 data-[position*=top]:bottom-auto data-[position*=top]:origin-top",
86 "data-[position*=bottom]:top-auto data-[position*=bottom]:bottom-0 data-[position*=bottom]:origin-bottom",
87 // Gap fill for hover
88 "after:absolute after:left-0 after:h-[calc(var(--toast-gap)+1px)] after:w-full",
89 "data-[position*=top]:after:top-full",
90 "data-[position*=bottom]:after:bottom-full",
91 // Define some variables
92 "[--toast-calc-height:var(--toast-frontmost-height,var(--toast-height))] [--toast-gap:--spacing(3)] [--toast-peek:--spacing(3)] [--toast-scale:calc(max(0,1-(var(--toast-index)*.1)))] [--toast-shrink:calc(1-var(--toast-scale))]",
93 // Define offset-y variable
94 "data-[position*=top]:[--toast-calc-offset-y:calc(var(--toast-offset-y)+var(--toast-index)*var(--toast-gap)+var(--toast-swipe-movement-y))]",
95 "data-[position*=bottom]:[--toast-calc-offset-y:calc(var(--toast-offset-y)*-1+var(--toast-index)*var(--toast-gap)*-1+var(--toast-swipe-movement-y))]",
96 // Default state transform
97 "data-[position*=top]:transform-[translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+(var(--toast-index)*var(--toast-peek))+(var(--toast-shrink)*var(--toast-calc-height))))_scale(var(--toast-scale))]",
98 "data-[position*=bottom]:transform-[translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--toast-peek))-(var(--toast-shrink)*var(--toast-calc-height))))_scale(var(--toast-scale))]",
99 // Limited state
100 "data-limited:opacity-0",
101 // Expanded state
102 "data-expanded:h-(--toast-height)",
103 "data-position:data-expanded:transform-[translateX(var(--toast-swipe-movement-x))_translateY(var(--toast-calc-offset-y))]",
104 // Starting and ending animations
105 "data-[position*=top]:data-starting-style:transform-[translateY(calc(-100%-var(--toast-inset)))]",
106 "data-[position*=bottom]:data-starting-style:transform-[translateY(calc(100%+var(--toast-inset)))]",
107 "data-ending-style:opacity-0",
108 // Ending animations (direction-aware)
109 "data-ending-style:not-data-limited:not-data-swipe-direction:transform-[translateY(calc(100%+var(--toast-inset)))]",

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected