mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -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:
|
||||
/// - `vibrate`
|
||||
/// - `image`
|
||||
#[derive(DefaultBuilder, Clone)]
|
||||
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
||||
pub struct UseWebNotificationOptions {
|
||||
|
@ -263,6 +262,11 @@ pub struct UseWebNotificationOptions {
|
|||
#[builder(into)]
|
||||
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
|
||||
/// user clicks or dismisses it, rather than closing automatically.
|
||||
require_interaction: bool,
|
||||
|
@ -300,6 +304,7 @@ impl Default for UseWebNotificationOptions {
|
|||
language: None,
|
||||
tag: None,
|
||||
icon: None,
|
||||
image: None,
|
||||
require_interaction: false,
|
||||
renotify: false,
|
||||
silent: None,
|
||||
|
@ -329,6 +334,10 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
|||
web_sys_options.icon(icon);
|
||||
}
|
||||
|
||||
if let Some(image) = &options.image {
|
||||
web_sys_options.image(image);
|
||||
}
|
||||
|
||||
if let Some(language) = &options.language {
|
||||
web_sys_options.lang(language);
|
||||
}
|
||||
|
@ -347,7 +356,6 @@ impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
|||
///
|
||||
/// The following implementations are missing:
|
||||
/// - `vibrate`
|
||||
/// - `image`
|
||||
#[derive(DefaultBuilder, Default)]
|
||||
#[cfg_attr(feature = "ssr", allow(dead_code))]
|
||||
pub struct ShowOptions {
|
||||
|
@ -382,6 +390,11 @@ pub struct ShowOptions {
|
|||
#[builder(into)]
|
||||
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
|
||||
/// user clicks or dismisses it, rather than closing automatically.
|
||||
#[builder(into)]
|
||||
|
@ -417,6 +430,10 @@ impl ShowOptions {
|
|||
options.icon(icon);
|
||||
}
|
||||
|
||||
if let Some(image) = &self.image {
|
||||
options.image(image);
|
||||
}
|
||||
|
||||
if let Some(language) = &self.language {
|
||||
options.lang(language);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue