+
{if let Some(media) = toast_title_media {
Either::Left((media.children)())
} else {
- Either::Right(
- view! {
-
- },
- )
+ aria-hidden="true"
+ width="1em"
+ height="1em"
+ viewBox="0 0 20 20"
+ >
+ {match intent {
+ ToastIntent::Info => {
+ view! {
+
+ }.into_any()
+ },
+ ToastIntent::Success => {
+ view! {
+
+ }.into_any()
+ },
+ ToastIntent::Warning => {
+ view! {
+
+ }.into_any()
+ },
+ ToastIntent::Error => {
+ view! {
+
+ }.into_any()
+ }
+ }}
+
+ },
+ )
+ }
}}
{children()}
diff --git a/thaw/src/toast/toaster.css b/thaw/src/toast/toaster.css
index cf3b453..cf38822 100644
--- a/thaw/src/toast/toaster.css
+++ b/thaw/src/toast/toaster.css
@@ -108,10 +108,25 @@ div.thaw-toaster-wrapper {
grid-column-end: 2;
padding-right: 8px;
font-size: 16px;
- color: var(--colorNeutralForeground1);
color: var(--colorNeutralForeground2);
}
+.thaw-toast-title__info {
+ color: var(--colorNeutralForeground2);
+}
+
+.thaw-toast-title__success {
+ color: var(--colorStatusSuccessForeground1);
+}
+
+.thaw-toast-title__warning {
+ color: var(--colorStatusWarningForeground3);
+}
+
+.thaw-toast-title__error {
+ color: var(--colorStatusDangerForeground1);
+}
+
.thaw-toast-title__media > svg {
display: inline;
line-height: 0;
diff --git a/thaw/src/toast/toaster.rs b/thaw/src/toast/toaster.rs
index 9461254..f6838c7 100644
--- a/thaw/src/toast/toaster.rs
+++ b/thaw/src/toast/toaster.rs
@@ -1,6 +1,6 @@
-use super::{ToastOptions, ToastPosition, ToasterReceiver};
+use super::{ToastIntent, ToastOptions, ToastPosition, ToasterReceiver};
use crate::ConfigInjection;
-use leptos::{either::Either, html, prelude::*};
+use leptos::{context::Provider, either::Either, html, prelude::*};
use send_wrapper::SendWrapper;
use std::{collections::HashMap, time::Duration};
use thaw_components::{CSSTransition, Teleport};
@@ -11,6 +11,7 @@ use wasm_bindgen::UnwrapThrowExt;
pub fn Toaster(
receiver: ToasterReceiver,
#[prop(optional)] position: ToastPosition,
+ #[prop(optional)] intent: ToastIntent,
#[prop(default = Duration::from_secs(3))] timeout: Duration,
) -> impl IntoView {
mount_style("toaster", include_str!("./toaster.css"));
@@ -42,6 +43,9 @@ pub fn Toaster(
if options.timeout.is_none() {
options.timeout = Some(timeout);
}
+ if options.intent.is_none() {
+ options.intent = Some(intent);
+ }
let list = id_list(&options.position.unwrap_throw());
let id = options.id;
@@ -171,10 +175,12 @@ fn ToasterContainer(
id,
timeout,
position,
+ intent,
..
} = options;
let timeout = timeout.unwrap_throw();
let position = position.unwrap_throw();
+ let intent = intent.unwrap_throw();
if !timeout.is_zero() {
set_timeout(
@@ -209,9 +215,11 @@ fn ToasterContainer(
on_after_leave=on_after_leave
let:_
>
-
- {children()}
-
+
+
+ {children()}
+
+
}
}
diff --git a/thaw/src/toast/toaster_provider.rs b/thaw/src/toast/toaster_provider.rs
index 44cc9c8..28a334c 100644
--- a/thaw/src/toast/toaster_provider.rs
+++ b/thaw/src/toast/toaster_provider.rs
@@ -1,4 +1,4 @@
-use super::{toaster::Toaster, ToastPosition, ToasterInjection};
+use super::{toaster::Toaster, ToastIntent, ToastPosition, ToasterInjection};
use leptos::{context::Provider, prelude::*};
#[component]
@@ -6,11 +6,14 @@ pub fn ToasterProvider(
/// The position the toast should render.
#[prop(optional)]
position: ToastPosition,
+ /// The intent of the toasts
+ #[prop(optional)]
+ intent: ToastIntent,
children: Children,
) -> impl IntoView {
let (injection, receiver) = ToasterInjection::channel();
view! {
-
+
{children()}
}
}