perspective_viewer/components/style_controls/number_string_format/misc_section.rs
1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9// ┃ This file is part of the Perspective library, distributed under the terms ┃
10// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
13use yew::html;
14
15use super::CustomNumberFormat;
16use crate::components::form::select_field::SelectEnumField;
17use crate::components::style_controls::{CustomNumberFormatMsg, NotationName};
18use crate::config::*;
19
20impl CustomNumberFormat {
21 pub fn misc_section(&self, ctx: &yew::prelude::Context<Self>) -> yew::prelude::Html {
22 let compact_display_checkbox = if let Some(Notation::Compact(val)) = self.config._notation {
23 let cb = ctx.link().callback(CustomNumberFormatMsg::CompactDisplay);
24 Some(html! {
25 <SelectEnumField<CompactDisplay>
26 label="compact-display"
27 on_change={cb}
28 current_value={val}
29 />
30 })
31 } else {
32 None
33 };
34
35 html! {
36 <>
37 <SelectEnumField<NotationName>
38 label="notation"
39 on_change={ctx.link().callback(CustomNumberFormatMsg::NotationChanged)}
40 current_value={self.notation.unwrap_or_default()}
41 />
42 { compact_display_checkbox }
43 <SelectEnumField<UseGrouping>
44 label="use-grouping"
45 on_change={ctx.link().callback(CustomNumberFormatMsg::UseGrouping)}
46 current_value={self.config.use_grouping.unwrap_or_default()}
47 />
48 <SelectEnumField<SignDisplay>
49 label="sign-display"
50 on_change={ctx.link().callback(CustomNumberFormatMsg::SignDisplay)}
51 current_value={self.config.sign_display.unwrap_or_default()}
52 />
53 </>
54 }
55 }
56}