Skip to content

Commit

Permalink
more polish
Browse files Browse the repository at this point in the history
Co-authored-by: Timothy Bess <timbessmail@gmail.com>
  • Loading branch information
ada-x64 and timbess committed Feb 22, 2024
1 parent c8bd426 commit 990a7f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

use web_sys::Event;
use yew::{classes, function_component, html, Callback, Children, Html, Properties};
use yew::{function_component, html, Callback, Children, Html, Properties};

#[derive(Properties, PartialEq)]
pub struct OptionalFieldProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ pub struct CustomNumberFormat {
style: NumberStyle,
notation: Option<NotationName>,
show_frac: bool,
disable_frac: bool,
show_sig: bool,
disable_rounding_increment: bool,
disable_rounding_priority: bool,
show_sig: bool,
}
impl CustomNumberFormat {
fn initialize(ctx: &yew::prelude::Context<Self>) -> Self {
Expand Down Expand Up @@ -225,10 +224,8 @@ impl Component for CustomNumberFormat {
self.config.rounding_increment = Some(val);
self.config.maximum_fraction_digits = Some(0.);
self.show_frac = false;
self.disable_frac = true;
} else {
self.config.rounding_increment = None;
self.disable_frac = false;
}
},
CustomNumberFormatMsg::TrailingZero(val) => {
Expand All @@ -242,13 +239,8 @@ impl Component for CustomNumberFormat {
},
};

if self.config.rounding_increment.is_some() {
self.show_frac = false;
self.disable_frac = true;
} else {
self.disable_frac = false;
}
self.disable_rounding_increment = self.show_sig
|| self.show_frac
|| !matches!(
self.config.rounding_priority,
Some(RoundingPriority::Auto) | None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ impl CustomNumberFormat {
current_value={self.config.minimum_integer_digits}
on_change={ctx.link().callback(CustomNumberFormatMsg::MinimumIntegerDigits)}
/>
{ self.rounding_increment(ctx) }
if is_float {
{ self.float_section(ctx) }
} else {
{ self.rounding_increment(ctx) }
}
</>
}
Expand Down Expand Up @@ -126,7 +127,6 @@ impl CustomNumberFormat {
</>
};

let disable_frac = self.disable_frac;
let show_frac = self.show_frac;
let show_sig = self.show_sig;
html! {
Expand All @@ -135,7 +135,6 @@ impl CustomNumberFormat {
label="Fractional Digits"
on_check={ctx.link().callback(move |_| CustomNumberFormatMsg::ShowFrac(!show_frac))}
checked={self.show_frac}
disabled={disable_frac}
>
{ fractional_digits }
</CollapsableSection>
Expand All @@ -146,21 +145,22 @@ impl CustomNumberFormat {
>
{ significant_digits }
</CollapsableSection>
<SelectField<TrailingZeroDisplay>
label="Trailing Zero Display"
current_value={self.config.trailing_zero_display}
on_change={ctx.link().callback(CustomNumberFormatMsg::TrailingZero)}
{ self.rounding_increment(ctx) }
<SelectField<RoundingPriority>
label="Rounding Priority"
disabled={!(self.show_frac && self.show_sig)}
current_value={self.config.rounding_priority}
on_change={ctx.link().callback(CustomNumberFormatMsg::RoundingPriority)}
/>
<SelectField<RoundingMode>
label="Rounding Mode"
current_value={self.config.rounding_mode}
on_change={ctx.link().callback(CustomNumberFormatMsg::RoundingMode)}
/>
<SelectField<RoundingPriority>
label="Rounding Priority"
disabled={!(self.show_frac && self.show_sig)}
current_value={self.config.rounding_priority}
on_change={ctx.link().callback(CustomNumberFormatMsg::RoundingPriority)}
<SelectField<TrailingZeroDisplay>
label="Trailing Zero Display"
current_value={self.config.trailing_zero_display}
on_change={ctx.link().callback(CustomNumberFormatMsg::TrailingZero)}
/>
</>
}
Expand Down

0 comments on commit 990a7f1

Please sign in to comment.