From 71ff8e6dc9f231390b9343286e4db56385d96e03 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Thu, 28 Aug 2025 11:14:11 -0400 Subject: [PATCH] feat: implement into for all applicable props --- src/common/student_info.rs | 1 + src/components/mod.rs | 13 +++++++- src/components/panel.rs | 37 ++++++++++++++++++++++ src/components/row.rs | 12 ++++++++ src/components/select.rs | 2 +- src/components/text_field.rs | 19 ++++++------ src/pages/home_page.rs | 60 ++++++++++++++++++++++-------------- src/pages/provider_entry.rs | 6 ++-- 8 files changed, 113 insertions(+), 37 deletions(-) create mode 100644 src/components/panel.rs create mode 100644 src/components/row.rs diff --git a/src/common/student_info.rs b/src/common/student_info.rs index eb25697..8f8a983 100644 --- a/src/common/student_info.rs +++ b/src/common/student_info.rs @@ -6,4 +6,5 @@ pub struct StudentInfo { pub first_name: String, pub last_name: String, pub math_sat_score: i32, + pub student_email: String, } diff --git a/src/components/mod.rs b/src/components/mod.rs index f699c48..15ee0ee 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -4,5 +4,16 @@ mod multi_entry; mod text_field; mod select; mod checkboxes; +mod panel; +mod row; -pub use self::{action_button::*, loading::*, multi_entry::*, text_field::*, select::*, checkboxes::*}; +pub use self::{ + action_button::*, + loading::*, + multi_entry::*, + text_field::*, + select::*, + checkboxes::*, + panel::*, + row::* +}; diff --git a/src/components/panel.rs b/src/components/panel.rs new file mode 100644 index 0000000..33e54de --- /dev/null +++ b/src/components/panel.rs @@ -0,0 +1,37 @@ +use leptos::prelude::*; + +/// A panel for use in visual separation of a group of components. A `Panel` arranges +/// a series of elements within a shaded rectangle using the flexbox column layout. +/// +/// It takes a series of children. Usually these would be in the form of a `Row` element, +/// which will arrange its own children in a row within the panel, however it can be any +/// HTML element. +/// +/// Example: +/// ``` +/// view! { +/// +/// +/// +/// +/// +/// +/// } +/// ``` +#[component] +pub fn Panel( + children: Children +) -> impl IntoView { + view! { +
+ {children()} +
+ } +} diff --git a/src/components/row.rs b/src/components/row.rs new file mode 100644 index 0000000..da12adb --- /dev/null +++ b/src/components/row.rs @@ -0,0 +1,12 @@ +use leptos::prelude::*; + +#[component] +pub fn Row( + children: Children +) -> impl IntoView { + view! { +
+ {children()} +
+ } +} diff --git a/src/components/select.rs b/src/components/select.rs index d161304..a5ad616 100644 --- a/src/components/select.rs +++ b/src/components/select.rs @@ -1,4 +1,4 @@ -use leptos::prelude::*; +use leptos::prelude::*; /// A custom-styled select input. /// diff --git a/src/components/text_field.rs b/src/components/text_field.rs index bbe3304..cb7babf 100644 --- a/src/components/text_field.rs +++ b/src/components/text_field.rs @@ -3,12 +3,12 @@ use leptos::prelude::*; #[component] pub fn OutlinedTextField( - #[prop(default = String::from(""))] placeholder: String, + #[prop(default = T::default(), into)] placeholder: T, #[prop(default = RwSignal::new(T::default()))] value: RwSignal, #[prop(default = RwSignal::new(false))] disabled: RwSignal, - #[prop(default = String::from(""))] name: String, - #[prop(default = String::from(""))] label: String, - #[prop(default = String::from(""))] input_type: String, + #[prop(default = String::from(""), into)] name: String, + #[prop(default = String::from(""), into)] label: String, + #[prop(default = String::from(""), into)] input_type: String, ) -> impl IntoView where T: Default + 'static + FromStr + ToString + PartialEq + Send + Sync + Clone @@ -22,16 +22,17 @@ where }; view! ( -
-