mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 09:09:21 -05:00
Feat: Add image
field to UseWebNotificationOptions
and ShowOptions
Added the `image` field to the `UseWebNotificationOptions` and `ShowOptions` structures. This field allows specifying an image URL to be displayed in the notification.
This commit is contained in:
parent
88af0e735d
commit
f37f28cfff
1 changed files with 19 additions and 2 deletions
|
@ -229,7 +229,6 @@ impl From<NotificationDirection> for web_sys::NotificationDirection {
|
||||||
///
|
///
|
||||||
/// The following implementations are missing:
|
/// The following implementations are missing:
|
||||||
/// - `vibrate`
|
/// - `vibrate`
|
||||||
/// - `image`
|
|
||||||
#[derive(DefaultBuilder, Clone)]
|
#[derive(DefaultBuilder, Clone)]
|
||||||
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
||||||
pub struct UseWebNotificationOptions {
|
pub struct UseWebNotificationOptions {
|
||||||
|
@ -263,6 +262,11 @@ pub struct UseWebNotificationOptions {
|
||||||
#[builder(into)]
|
#[builder(into)]
|
||||||
icon: Option<String>,
|
icon: Option<String>,
|
||||||
|
|
||||||
|
/// The URL of the image to be displayed as part of the notification as specified
|
||||||
|
/// in the constructor's options parameter.
|
||||||
|
#[builder(into)]
|
||||||
|
image: Option<String>,
|
||||||
|
|
||||||
/// A boolean value indicating that a notification should remain active until the
|
/// A boolean value indicating that a notification should remain active until the
|
||||||
/// user clicks or dismisses it, rather than closing automatically.
|
/// user clicks or dismisses it, rather than closing automatically.
|
||||||
require_interaction: bool,
|
require_interaction: bool,
|
||||||
|
@ -300,6 +304,7 @@ impl Default for UseWebNotificationOptions {
|
||||||
language: None,
|
language: None,
|
||||||
tag: None,
|
tag: None,
|
||||||
icon: None,
|
icon: None,
|
||||||
|
image: None,
|
||||||
require_interaction: false,
|
require_interaction: false,
|
||||||
renotify: false,
|
renotify: false,
|
||||||
silent: None,
|
silent: None,
|
||||||
|
@ -329,6 +334,10 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
||||||
web_sys_options.icon(icon);
|
web_sys_options.icon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(image) = &options.image {
|
||||||
|
web_sys_options.image(image);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(language) = &options.language {
|
if let Some(language) = &options.language {
|
||||||
web_sys_options.lang(language);
|
web_sys_options.lang(language);
|
||||||
}
|
}
|
||||||
|
@ -347,7 +356,6 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
||||||
///
|
///
|
||||||
/// The following implementations are missing:
|
/// The following implementations are missing:
|
||||||
/// - `vibrate`
|
/// - `vibrate`
|
||||||
/// - `image`
|
|
||||||
#[derive(DefaultBuilder, Default)]
|
#[derive(DefaultBuilder, Default)]
|
||||||
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
||||||
pub struct ShowOptions {
|
pub struct ShowOptions {
|
||||||
|
@ -382,6 +390,11 @@ pub struct ShowOptions {
|
||||||
#[builder(into)]
|
#[builder(into)]
|
||||||
icon: Option<String>,
|
icon: Option<String>,
|
||||||
|
|
||||||
|
/// The URL of the image to be displayed as part of the notification as specified
|
||||||
|
/// in the constructor's options parameter.
|
||||||
|
#[builder(into)]
|
||||||
|
image: Option<String>,
|
||||||
|
|
||||||
/// A boolean value indicating that a notification should remain active until the
|
/// A boolean value indicating that a notification should remain active until the
|
||||||
/// user clicks or dismisses it, rather than closing automatically.
|
/// user clicks or dismisses it, rather than closing automatically.
|
||||||
#[builder(into)]
|
#[builder(into)]
|
||||||
|
@ -417,6 +430,10 @@ impl ShowOptions {
|
||||||
options.icon(icon);
|
options.icon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(image) = &self.image {
|
||||||
|
options.image(image);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(language) = &self.language {
|
if let Some(language) = &self.language {
|
||||||
options.lang(language);
|
options.lang(language);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue