diff --git a/thaw/src/calendar/mod.rs b/thaw/src/calendar/mod.rs index 168d6e7..c5005dc 100644 --- a/thaw/src/calendar/mod.rs +++ b/thaw/src/calendar/mod.rs @@ -136,12 +136,12 @@ fn CalendarItem( ) -> impl IntoView { let is_selected = Memo::new({ let date = date.clone(); - move |_| value.with(|value_date| { - match value_date { - OptionModelWithValue::T(v) => v == date.deref(), - OptionModelWithValue::Option(v) => v.as_ref() == Some(date.deref()), - } - }) + move |_| { + value.with(|value_date| match value_date { + OptionModelWithValue::T(v) => v == date.deref(), + OptionModelWithValue::Option(v) => v.as_ref() == Some(date.deref()), + }) + } }); let weekday_str = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; let on_click = { diff --git a/thaw/src/checkbox/checkbox_group.rs b/thaw/src/checkbox/checkbox_group.rs index 5ea337e..86cfa3b 100644 --- a/thaw/src/checkbox/checkbox_group.rs +++ b/thaw/src/checkbox/checkbox_group.rs @@ -27,12 +27,11 @@ pub fn CheckboxGroup( }); view! { - -
+ +
{children()}
diff --git a/thaw/src/date_picker/mod.rs b/thaw/src/date_picker/mod.rs index b5e7b36..d0b5825 100644 --- a/thaw/src/date_picker/mod.rs +++ b/thaw/src/date_picker/mod.rs @@ -4,7 +4,9 @@ use chrono::NaiveDate; use leptos::{html, prelude::*}; use panel::{Panel, PanelRef}; use thaw_components::{Binder, Follower, FollowerPlacement}; -use thaw_utils::{class_list, mount_style, now_date, ComponentRef, OptionModel, OptionModelWithValue}; +use thaw_utils::{ + class_list, mount_style, now_date, ComponentRef, OptionModel, OptionModelWithValue, +}; #[component] pub fn DatePicker( @@ -21,12 +23,12 @@ pub fn DatePicker( let update_show_date_text = move || { value.with_untracked(move |date| { let text = match date { - OptionModelWithValue::T(v) => v.format(show_date_format).to_string(), + OptionModelWithValue::T(v) => v.format(show_date_format).to_string(), OptionModelWithValue::Option(v) => v.map_or(String::new(), |date| { date.format(show_date_format).to_string() }), }; - + show_date_text.set(text); }); }; diff --git a/thaw/src/field/field.rs b/thaw/src/field/field.rs index 03ab719..a5c81a6 100644 --- a/thaw/src/field/field.rs +++ b/thaw/src/field/field.rs @@ -51,68 +51,86 @@ pub fn Field( } } } - {children()} + {children()} {move || { view! { - { - match validation_state { - FieldValidationState::Error(message) => EitherOf3::A(view! { -
- - - - {message} -
- }), - FieldValidationState::Success(message) => EitherOf3::B(view! { -
- - - - {message} -
- }), - FieldValidationState::Warning(message) => EitherOf3::C(view! { -
- - - - {message} -
- }) + {match validation_state { + FieldValidationState::Error(message) => { + EitherOf3::A( + view! { +
+ + + + {message} +
+ }, + ) } - } + FieldValidationState::Success(message) => { + EitherOf3::B( + view! { +
+ + + + {message} +
+ }, + ) + } + FieldValidationState::Warning(message) => { + EitherOf3::C( + view! { +
+ + + + {message} +
+ }, + ) + } + }}
} diff --git a/thaw/src/field/field_context_provider.rs b/thaw/src/field/field_context_provider.rs index 0748b3a..fef149d 100644 --- a/thaw/src/field/field_context_provider.rs +++ b/thaw/src/field/field_context_provider.rs @@ -3,9 +3,7 @@ use slotmap::{DefaultKey, SlotMap}; #[component] pub fn FieldContextProvider(children: Children) -> impl IntoView { - view! { - {children()} - } + view! { {children()} } } #[derive(Clone)] diff --git a/thaw/src/nav/nav_item.rs b/thaw/src/nav/nav_item.rs index 59ad0fa..73d5985 100644 --- a/thaw/src/nav/nav_item.rs +++ b/thaw/src/nav/nav_item.rs @@ -17,12 +17,10 @@ pub fn NavItem( let value = value.get_untracked(); if nav_drawer .selected_value - .with_untracked(|selected_value| - match selected_value { - OptionModelWithValue::T(v) => v != &value, - OptionModelWithValue::Option(v) => v.as_ref() != Some(&value), - } - ) + .with_untracked(|selected_value| match selected_value { + OptionModelWithValue::T(v) => v != &value, + OptionModelWithValue::Option(v) => v.as_ref() != Some(&value), + }) { nav_drawer.selected_value.set(Some(value)); } @@ -42,12 +40,12 @@ pub fn NavItem( }; let selected = Memo::new(move |_| { - nav_drawer - .selected_value - .with(|selected_value| value.with(|value| match selected_value { - OptionModelWithValue::T(v) => v == value, + nav_drawer.selected_value.with(|selected_value| { + value.with(|value| match selected_value { + OptionModelWithValue::T(v) => v == value, OptionModelWithValue::Option(v) => v.as_ref() == Some(&value), - })) + }) + }) }); if let Some(href) = href { diff --git a/thaw/src/radio/mod.rs b/thaw/src/radio/mod.rs index bb59757..2e58cf0 100644 --- a/thaw/src/radio/mod.rs +++ b/thaw/src/radio/mod.rs @@ -25,11 +25,12 @@ pub fn Radio( let checked = Memo::new({ let group = group.clone(); move |_| { - item_value - .with_value(|value| group.value.with(|group_value| match group_value { - OptionModelWithValue::T(v) => v == value, + item_value.with_value(|value| { + group.value.with(|group_value| match group_value { + OptionModelWithValue::T(v) => v == value, OptionModelWithValue::Option(v) => v.as_ref() == Some(value), - })) + }) + }) } }); diff --git a/thaw/src/radio/radio_group.rs b/thaw/src/radio/radio_group.rs index e87ae22..dd6f566 100644 --- a/thaw/src/radio/radio_group.rs +++ b/thaw/src/radio/radio_group.rs @@ -33,11 +33,7 @@ pub fn RadioGroup( view! { -
+
{children()}
diff --git a/thaw/src/time_picker/mod.rs b/thaw/src/time_picker/mod.rs index f311f00..5222ad2 100644 --- a/thaw/src/time_picker/mod.rs +++ b/thaw/src/time_picker/mod.rs @@ -5,7 +5,9 @@ use crate::{ use chrono::{Local, NaiveTime, Timelike}; use leptos::{html, prelude::*}; use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement}; -use thaw_utils::{class_list, mount_style, ArcOneCallback, ComponentRef, OptionModel, OptionModelWithValue}; +use thaw_utils::{ + class_list, mount_style, ArcOneCallback, ComponentRef, OptionModel, OptionModelWithValue, +}; #[component] pub fn TimePicker( @@ -24,7 +26,7 @@ pub fn TimePicker( let update_show_time_text = move || { value.with_untracked(move |time| { let text = match time { - OptionModelWithValue::T(v) => v.format(show_time_format).to_string(), + OptionModelWithValue::T(v) => v.format(show_time_format).to_string(), OptionModelWithValue::Option(v) => v.map_or(String::new(), |time| { time.format(show_time_format).to_string() }),