Compare commits
3 Commits
eae628bd62
...
843572b487
| Author | SHA1 | Date | |
|---|---|---|---|
|
843572b487
|
|||
|
2cbc6aeaff
|
|||
|
f84e51d13a
|
35
src/components/footer.rs
Normal file
35
src/components/footer.rs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
use crate::app::LOGO_SVG;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn Footer() -> Element {
|
||||||
|
rsx! {
|
||||||
|
footer {
|
||||||
|
class: "footer md:footer-horizontal fixed bottom-0 text-base-content/70 bg-base-300 items-center p-4",
|
||||||
|
|
||||||
|
aside {
|
||||||
|
class: "flex items-center",
|
||||||
|
|
||||||
|
img {
|
||||||
|
class: "w-12 h-12",
|
||||||
|
src: LOGO_SVG,
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
p {
|
||||||
|
class: "text-xl font-bold",
|
||||||
|
"LibreTunes",
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
class: "text-sm",
|
||||||
|
href: env!("CARGO_PKG_REPOSITORY"),
|
||||||
|
"v" {env!("CARGO_PKG_VERSION")},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
|
pub mod footer;
|
||||||
|
|||||||
@@ -45,6 +45,20 @@ impl fmt::Display for ErrorLocation {
|
|||||||
|
|
||||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
|
/// Generate a random string to use as an id for the modal
|
||||||
|
/// This allows multiple toast/modal to be present
|
||||||
|
fn rand_modal_id() -> String {
|
||||||
|
use rand::RngExt;
|
||||||
|
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
|
let random_str = (0..5)
|
||||||
|
.map(|_| rng.sample(rand::distr::Alphanumeric) as char)
|
||||||
|
.collect::<String>();
|
||||||
|
|
||||||
|
format!("err-modal-{random_str}")
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, thiserror::Error)]
|
#[derive(Debug, Clone, Deserialize, Serialize, thiserror::Error)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
#[source]
|
#[source]
|
||||||
@@ -97,6 +111,12 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the original cause of this error
|
||||||
|
/// Like `std::error::Error::source` but doesn't return an `Option`
|
||||||
|
pub fn source(&self) -> &ErrorType {
|
||||||
|
&self.source
|
||||||
|
}
|
||||||
|
|
||||||
/// Display this error as a modal dialog activated by a checkbox with the given id
|
/// Display this error as a modal dialog activated by a checkbox with the given id
|
||||||
pub fn as_modal(&self, id: String) -> Element {
|
pub fn as_modal(&self, id: String) -> Element {
|
||||||
rsx! {
|
rsx! {
|
||||||
@@ -173,28 +193,9 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this error to a toast message, which opens a modal when clicked
|
/// Convert this error into an alert label, tied to the given modal id
|
||||||
pub fn as_toast(&self) -> Element {
|
fn as_alert_for(&self, modal_id: String) -> Element {
|
||||||
// Generate a random string to use as an id for the modal
|
|
||||||
// This allows multiple toast/modal to be present
|
|
||||||
let modal_id = {
|
|
||||||
use rand::RngExt;
|
|
||||||
|
|
||||||
let mut rng = rand::rng();
|
|
||||||
|
|
||||||
let random_str = (0..5)
|
|
||||||
.map(|_| rng.sample(rand::distr::Alphanumeric) as char)
|
|
||||||
.collect::<String>();
|
|
||||||
|
|
||||||
format!("err-modal-{random_str}")
|
|
||||||
};
|
|
||||||
|
|
||||||
rsx! {
|
rsx! {
|
||||||
{self.as_modal(modal_id.clone())}
|
|
||||||
|
|
||||||
div {
|
|
||||||
class: "toast z-99",
|
|
||||||
|
|
||||||
label {
|
label {
|
||||||
class: "alert alert-error alert-soft cursor-pointer",
|
class: "alert alert-error alert-soft cursor-pointer",
|
||||||
role: "alert",
|
role: "alert",
|
||||||
@@ -208,6 +209,29 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert this error to a toast message, which opens a modal when clicked
|
||||||
|
pub fn as_toast(&self) -> Element {
|
||||||
|
let modal_id = rand_modal_id();
|
||||||
|
|
||||||
|
rsx! {
|
||||||
|
{self.as_modal(modal_id.clone())}
|
||||||
|
|
||||||
|
div {
|
||||||
|
class: "toast z-99",
|
||||||
|
{self.as_alert_for(modal_id)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert this error into an alert label, which opens a modal when clicked
|
||||||
|
pub fn as_alert(&self) -> Element {
|
||||||
|
let modal_id = rand_modal_id();
|
||||||
|
|
||||||
|
rsx! {
|
||||||
|
{self.as_modal(modal_id.clone())}
|
||||||
|
{self.as_alert_for(modal_id)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user