diff --git a/src/ui/components/button.rs b/src/ui/components/button.rs index f10f73c..1c044de 100644 --- a/src/ui/components/button.rs +++ b/src/ui/components/button.rs @@ -18,12 +18,12 @@ macro_rules! svg_text_icon { #[derive(Copy, Clone, PartialEq)] struct $name; impl IconShape for $name { - fn view_box(&self) -> String { - String::from("0 0 250 50") + fn view_box(&self) -> &str { + "0 0 250 50" } - fn xmlns(&self) -> String { - String::from("http://www.w3.org/2000/svg") + fn xmlns(&self) -> &str { + "http://www.w3.org/2000/svg" } fn child_elements(&self) -> Element { diff --git a/src/ui/components/icons.rs b/src/ui/components/icons.rs index e689af5..d15a782 100644 --- a/src/ui/components/icons.rs +++ b/src/ui/components/icons.rs @@ -1,3 +1,4 @@ +use const_format::formatcp; use dioxus::prelude::*; use dioxus_free_icons::icons::md_navigation_icons::MdArrowDropDown; use dioxus_free_icons::{Icon, IconShape}; @@ -39,6 +40,12 @@ const _PYRAMID_CENTRAL_EDGE_Y_LEN: f64 = _PYRAMID_CENTRAL_EDGE_E2_Y - _PYRAMID_E const _PYRAMID_RIGHT_EDGE_E2_X: f64 = 130.0 + _PYRAMID_OFFSET_X; const _PYRAMID_RIGHT_EDGE_E2_Y: f64 = _PYRAMID_LEFT_EDGE_E2_Y; +// _PYRAMID_VIEWBOX_HEIGHT and _PYRAMID_VIEWBOX_WIDTH are casted as i64 to be able to render +// viwebox string statically (formatcp doesn't support f64 type) +const _PYRAMID_VIEWBOX_HEIGHT: i64 = (_PYRAMID_CENTRAL_EDGE_E2_Y + _PYRAMID_STROKE_WIDTH) as i64; +const _PYRAMID_VIEWBOX_WIDTH: i64 = (_PYRAMID_RIGHT_EDGE_E2_X + _PYRAMID_STROKE_WIDTH) as i64; +const _PYRAMID_VIEWBOX: &str = formatcp!("0 0 {_PYRAMID_VIEWBOX_WIDTH} {_PYRAMID_VIEWBOX_HEIGHT}"); + #[derive(PartialEq, Clone)] struct PyramidShape { color: String, @@ -47,14 +54,12 @@ struct PyramidShape { } impl IconShape for PyramidShape { - fn view_box(&self) -> String { - let height = _PYRAMID_CENTRAL_EDGE_E2_Y + _PYRAMID_STROKE_WIDTH; - let width = _PYRAMID_RIGHT_EDGE_E2_X + _PYRAMID_STROKE_WIDTH; - format!("0 0 {width} {height}") + fn view_box(&self) -> &str { + _PYRAMID_VIEWBOX } - fn xmlns(&self) -> String { - String::from("http://www.w3.org/2000/svg") + fn xmlns(&self) -> &str { + "http://www.w3.org/2000/svg" } fn child_elements(&self) -> Element { diff --git a/src/ui/components/spinner.rs b/src/ui/components/spinner.rs index e1523ac..91ef65c 100644 --- a/src/ui/components/spinner.rs +++ b/src/ui/components/spinner.rs @@ -6,11 +6,11 @@ turf::style_sheet!("src/ui/components/spinner.scss"); #[derive(Clone, PartialEq)] struct _Spinner; impl IconShape for _Spinner { - fn view_box(&self) -> String { - String::from("0 0 184 94") + fn view_box(&self) -> &str { + "0 0 184 94" } - fn xmlns(&self) -> String { - String::from("http://www.w3.org/2000/svg") + fn xmlns(&self) -> &str { + "http://www.w3.org/2000/svg" } fn child_elements(&self) -> Element { rsx! {