perspective_viewer/components/style_controls/number_string_format/
style_section.rs1use yew::html;
14
15use super::CustomNumberFormat;
16use crate::components::form::select_enum_field::SelectEnumField;
17use crate::components::style_controls::{CustomNumberFormatMsg, NumberStyle};
18use crate::config::*;
19
20impl CustomNumberFormat {
21 pub fn style_section(&self, ctx: &yew::prelude::Context<Self>) -> yew::prelude::Html {
22 let section = match &self.config._style {
23 Some(NumberFormatStyle::Currency(style)) => Some(html! {
24 <>
25 <SelectEnumField<CurrencyCode>
26 label="currency"
27 on_change={ctx.link().callback(CustomNumberFormatMsg::CurrencyCode)}
28 current_value={style.currency}
29 />
30 <SelectEnumField<CurrencyDisplay>
31 label="currency-display"
32 on_change={ctx.link().callback(CustomNumberFormatMsg::CurrencyDisplay)}
33 current_value={style.currency_display.unwrap_or_default()}
34 />
35 <SelectEnumField<CurrencySign>
36 label="currency-sign"
37 on_change={ctx.link().callback(CustomNumberFormatMsg::CurrencySign)}
38 current_value={style.currency_sign.unwrap_or_default()}
39 />
40 </>
41 }),
42 Some(NumberFormatStyle::Unit(style)) => Some(html!(
43 <>
44 <SelectEnumField<Unit>
45 label="unit"
46 on_change={ctx.link().callback(CustomNumberFormatMsg::Unit)}
47 current_value={style.unit}
48 />
49 <SelectEnumField<UnitDisplay>
50 label="unit-display"
51 on_change={ctx.link().callback(CustomNumberFormatMsg::UnitDisplay)}
52 current_value={style.unit_display.unwrap_or_default()}
53 />
54 </>
55 )),
56 _ => None,
57 };
58 html! {
59 <>
60 <SelectEnumField<NumberStyle>
61 label="style"
62 current_value={self.style}
63 default_value={NumberStyle::from(&ctx.props().defaults.style)}
64 on_change={ctx.link().callback(CustomNumberFormatMsg::StyleChanged)}
65 />
66 { section }
67 </>
68 }
69 }
70}