freya_elements/attributes/svg_attributes.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
use crate::def_attribute;
def_attribute!(
    /// The `svg_data` attribute lets you provide raw SVG data directly.
    ///
    /// This is similar to the `image_data` attribute but specifically for SVG data.
    ///
    /// ### Example
    ///
    /// ```rust, no_run
    /// static SVG_ICON: &[u8] = include_bytes!("../../../../examples/settings.svg");
    ///
    /// # use freya::prelude::*;
    /// fn app() -> Element {
    ///     rsx!(
    ///         svg {
    ///             width: "100%",
    ///             height: "100%",
    ///             svg_data: static_bytes(SVG_ICON),
    ///         }
    ///     )
    /// }
    /// ```
    svg_data,
    /// The `svg_content` attribute lets you provide SVG content as a string.
    ///
    /// This is useful for including SVG content directly or from external files.
    ///
    /// ### Example
    ///
    /// ```rust, no_run
    /// # use freya::prelude::*;
    /// fn app() -> Element {
    ///     let svg_content = include_str!("../../../../examples/settings.svg");
    ///
    ///     rsx!(
    ///         svg {
    ///             width: "100%",
    ///             height: "100%",
    ///             svg_content,
    ///         }
    ///     )
    /// }
    /// ```
    svg_content,
    /// The `fill` attributes allows you to specify the fill color for the `svg`.
    ///
    /// You can learn about the syntax of this attribute in [`Color Syntax`](crate::_docs::color_syntax).
    ///
    /// ### Example
    ///
    /// ```rust, no_run
    /// # use freya::prelude::*;
    /// fn app() -> Element {
    ///     let svg_content = include_str!("../../../../examples/settings.svg");
    ///
    ///     rsx!(
    ///         svg {
    ///             fill: "red",
    ///             width: "100%",
    ///             height: "100%",
    ///             svg_content,
    ///         }
    ///     )
    /// }
    /// ```
    fill,
    /// The `stroke` attributes allows you to specify stroke color for the `svg`.
    ///
    /// You can learn about the syntax of this attribute in [`Color Syntax`](crate::_docs::color_syntax).
    ///
    /// ### Example
    ///
    /// ```rust, no_run
    /// # use freya::prelude::*;
    /// fn app() -> Element {
    ///     let svg_content = include_str!("../../../../examples/settings.svg");
    ///
    ///     rsx!(
    ///         svg {
    ///             stroke: "red",
    ///             width: "100%",
    ///             height: "100%",
    ///             svg_content,
    ///         }
    ///     )
    /// }
    /// ```
    stroke,
);