use crate::IconKind;
use dioxus::prelude::*;
#[component]
pub fn IconFont(cx: Scope) -> Element {
render!(
link {
href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200",
rel: "stylesheet"
}
)
}
#[component]
pub fn Icon(
cx: Scope,
kind: IconKind,
is_filled: Option<bool>,
weight: Option<u32>,
size: Option<f32>,
) -> Element {
let font_variation_settings = use_memo(cx, (is_filled, weight, size), move |_| {
let mut s = String::new();
let mut is_first = true;
if *is_filled == Some(true) {
if !is_first {
s.push_str(", ");
}
s.push_str("'FILL' 1");
is_first = false;
}
if let Some(weight) = weight {
if !is_first {
s.push_str(", ");
}
s.push_str(&format!("'wght' {}", weight));
is_first = false;
}
if let Some(size) = size {
if !is_first {
s.push_str(", ");
}
s.push_str(&format!("'opsz' {}", size));
}
s
});
render!(
span {
class: "material-symbols-rounded",
style: "font-variation-settings: {font_variation_settings};",
kind.name()
}
)
}