use std::fmt;
use stdweb::{_js_impl, js};
pub struct UIkitService;
pub enum NotificationStatus {
Warning,
Danger,
}
impl fmt::Display for NotificationStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
NotificationStatus::Warning => write!(f, "warning"),
NotificationStatus::Danger => write!(f, "danger"),
}
}
}
impl UIkitService {
pub fn new() -> Self {
Self {}
}
pub fn notify(&self, message: &str, status: &NotificationStatus) {
js! {
UIkit.notification({
message: @{message},
status: @{status.to_string()},
timeout: 3000,
});
};
}
}