zen_rs::layouts::html

Function icon_html

Source
pub fn icon_html(component: &Icon) -> String
Expand description

Renders an Icon component into an SVG string with the specified attributes such as foreground and background colors, width, height, viewBox, and paths.

§Arguments

  • component - A reference to an Icon component containing the properties such as content (paths), size, stroke attributes, and colors.

§Returns

A string representing the SVG element that renders the icon with the specified properties and styles.

§Example

let icon = Icon::new()
    .foreground_color((255, 0, 0))
    .background_color((0, 0, 0))
    .width(24)
    .height(24)
    .content(vec!["M10 10 H 90 V 90 H 10 Z"]);
let svg = icon_html(&icon);
assert_eq!(svg, r#"<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 100 100" fill="rgb(0, 0, 0)" stroke="rgb(255, 0, 0)" stroke-linecap="butt" stroke-linejoin="miter" stroke-width="1"><path d="M10 10 H 90 V 90 H 10 Z" fill="rgb(0, 0, 0)" /></svg>"#);