🐛 Update to match to the dioxus_free_icons view_box and xmlns definition

This commit is contained in:
2024-04-22 08:58:29 +02:00
parent b3330abecc
commit a3775e35d3
3 changed files with 19 additions and 14 deletions

View File

@@ -18,12 +18,12 @@ macro_rules! svg_text_icon {
#[derive(Copy, Clone, PartialEq)] #[derive(Copy, Clone, PartialEq)]
struct $name; struct $name;
impl IconShape for $name { impl IconShape for $name {
fn view_box(&self) -> String { fn view_box(&self) -> &str {
String::from("0 0 250 50") "0 0 250 50"
} }
fn xmlns(&self) -> String { fn xmlns(&self) -> &str {
String::from("http://www.w3.org/2000/svg") "http://www.w3.org/2000/svg"
} }
fn child_elements(&self) -> Element { fn child_elements(&self) -> Element {

View File

@@ -1,3 +1,4 @@
use const_format::formatcp;
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_free_icons::icons::md_navigation_icons::MdArrowDropDown; use dioxus_free_icons::icons::md_navigation_icons::MdArrowDropDown;
use dioxus_free_icons::{Icon, IconShape}; 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_X: f64 = 130.0 + _PYRAMID_OFFSET_X;
const _PYRAMID_RIGHT_EDGE_E2_Y: f64 = _PYRAMID_LEFT_EDGE_E2_Y; 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)] #[derive(PartialEq, Clone)]
struct PyramidShape { struct PyramidShape {
color: String, color: String,
@@ -47,14 +54,12 @@ struct PyramidShape {
} }
impl IconShape for PyramidShape { impl IconShape for PyramidShape {
fn view_box(&self) -> String { fn view_box(&self) -> &str {
let height = _PYRAMID_CENTRAL_EDGE_E2_Y + _PYRAMID_STROKE_WIDTH; _PYRAMID_VIEWBOX
let width = _PYRAMID_RIGHT_EDGE_E2_X + _PYRAMID_STROKE_WIDTH;
format!("0 0 {width} {height}")
} }
fn xmlns(&self) -> String { fn xmlns(&self) -> &str {
String::from("http://www.w3.org/2000/svg") "http://www.w3.org/2000/svg"
} }
fn child_elements(&self) -> Element { fn child_elements(&self) -> Element {

View File

@@ -6,11 +6,11 @@ turf::style_sheet!("src/ui/components/spinner.scss");
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
struct _Spinner; struct _Spinner;
impl IconShape for _Spinner { impl IconShape for _Spinner {
fn view_box(&self) -> String { fn view_box(&self) -> &str {
String::from("0 0 184 94") "0 0 184 94"
} }
fn xmlns(&self) -> String { fn xmlns(&self) -> &str {
String::from("http://www.w3.org/2000/svg") "http://www.w3.org/2000/svg"
} }
fn child_elements(&self) -> Element { fn child_elements(&self) -> Element {
rsx! { rsx! {