yew_google_material/
lib.rs1use yew::AttrValue;
15
16pub mod icons;
17pub mod input_text;
18pub mod buttons;
19
20#[derive(Default, Debug, PartialEq, Clone)]
21pub enum GIconStyle {
22 #[default]
23 Outlined,
24 Rounded,
25 Sharp,
26}
27
28#[derive(Default, PartialEq)]
29pub enum GInputStyle {
30 #[default]
31 Outlined,
32 Filled,
33}
34
35#[derive(PartialEq, Default, Clone)]
36pub enum GButtonStyle {
37 Elevated,
38 #[default]
39 Filled,
40 Outlined,
41 Text,
42}
43
44pub mod prelude {
45 pub use crate::icons::GIcon;
46 pub use crate::GIconStyle;
47 pub use crate::input_text::{GTextInput, GInputEvent};
48 pub use crate::GInputStyle;
49 pub use crate::buttons::{GButton, DependsOn};
50 pub use crate::GButtonStyle;
51}
52
53fn parse_number_and_unit(input: AttrValue) -> (f64, String) {
54 let input = input.as_str();
55 let pos = input
56 .find(|c: char| !c.is_digit(10) && c != '.' && c != '+' && c != '-');
57
58 match pos {
59 Some(pos) => {
60 let (number_str, unit) = input.split_at(pos);
61 let number = match number_str.parse::<f64>() {
62 Ok(number) => number,
63 Err(_) => {
64 return (3.5, "em".to_string());
65 },
66 };
67 (number, unit.to_string())
68 },
69 None => {
70 let number = match input.parse::<f64>() {
71 Ok(number) => number,
72 Err(_) => {
73 return (3.5, "em".to_string());
74 },
75 };
76 (number, "".to_string())
77 },
78 }
79}