Skip to main content

ev_lib_classes/
sonner.rs

1use tailwind_fuse::{AsTailwindClass, TwVariant};
2
3/// Base shared by every toast. The TS mirror appends its swipe-only utilities
4/// (`touch-pan-y select-none`) on top — that styling is behaviour-specific and
5/// stays in the React component (the Rust kit has no swipe-to-dismiss).
6pub const TOAST_BASE: &str = "pointer-events-auto flex w-full items-start gap-3 rounded-md border p-4 text-sm shadow-lg";
7
8pub const TOAST_CLOSE: &str = "text-ink/50 hover:text-ink shrink-0 transition-colors";
9
10pub const TOAST_CONTENT: &str = "flex-1 space-y-1";
11
12pub const TOAST_TITLE: &str = "font-medium";
13
14/// Pinned stack container base; the per-position offsets ride on [`ToastPosition`].
15pub const TOASTER_BASE: &str = "pointer-events-none fixed z-100 w-[calc(100%-2rem)] max-w-sm";
16
17#[derive(PartialEq, TwVariant, strum::AsRefStr, strum::EnumIter)]
18#[strum(serialize_all = "kebab-case")]
19pub enum ToastVariant {
20	#[tw(default, class = "bg-popover text-ink border-border")]
21	Neutral,
22	#[tw(class = "bg-popover text-ink border-positive/40")]
23	Positive,
24	#[tw(class = "bg-popover text-ink border-border")]
25	Info,
26	#[tw(class = "bg-popover text-ink border-border")]
27	Warn,
28	#[tw(class = "bg-popover text-ink border-accent-error/50")]
29	Error,
30}
31
32#[derive(PartialEq, TwVariant, strum::AsRefStr, strum::EnumIter)]
33#[strum(serialize_all = "kebab-case")]
34pub enum ToastPosition {
35	#[tw(class = "top-4 left-4")]
36	TopLeft,
37	#[tw(class = "top-4 left-1/2 -translate-x-1/2")]
38	TopCenter,
39	#[tw(class = "top-4 right-4")]
40	TopRight,
41	#[tw(class = "bottom-4 left-4")]
42	BottomLeft,
43	#[tw(class = "bottom-4 left-1/2 -translate-x-1/2")]
44	BottomCenter,
45	#[tw(default, class = "bottom-4 right-4")]
46	BottomRight,
47}