diff --git a/src/components/banner.rs b/src/components/banner.rs new file mode 100644 index 0000000..e4f0e2f --- /dev/null +++ b/src/components/banner.rs @@ -0,0 +1,48 @@ +use leptos::prelude::*; +use leptos_router::hooks::use_navigate; + +/// # Banner Component +/// +/// This component displays a red banner at the top of the page with a title and a logo. +/// Clicking the logo will redirect a user to specified page, preferably a home page. +/// +/// Example usage: +/// ``` +/// +/// ``` +#[component] +pub fn Banner( + /// The title of the banner. + #[prop(into)] + title: String, + /// The file path or URL of a logo displayed at the top left of the banner. + #[prop(into)] + logo: String, + /// The route that the navigates user to a page (home page). + #[prop(into)] + path: String, +) -> impl IntoView { + let navigate = use_navigate(); + + let on_click = move |_| navigate(&path, Default::default()); + + view! { +
+
+
+
+ icon +
+
+

{title.clone()}

+
+
+
+
+ + } +} diff --git a/src/components/mod.rs b/src/components/mod.rs index f0297f7..a66f141 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,4 +1,5 @@ mod action_button; +mod banner; mod checkbox; mod chips; mod dashboard_button; @@ -12,6 +13,6 @@ mod text_field; mod utils; pub use self::{ - action_button::*, checkbox::*, chips::*, dashboard_button::*, loading::*, multi_entry::*, - panel::*, radio::*, row::*, select::*, text_field::*, + action_button::*, banner::*, checkbox::*, chips::*, dashboard_button::*, loading::*, + multi_entry::*, panel::*, radio::*, row::*, select::*, text_field::*, };