Skip to content

Commit c009fc1

Browse files
committed
Experiment with raw HTML string.
1 parent 6033777 commit c009fc1

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "yew_icons"
33
authors = ["Finn Bear"]
44
license = "MIT"
5-
version = "0.8.0"
5+
version = "0.9.0"
66
edition = "2021"
77
repository = "https://github.com/finnbear/yew_icons/"
88
description = "Easily include a variety of SVG icons into your Yew app"

src/generator.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ fn main() {
8585

8686
let (first_tag, remainder) = svg.split_once('>').unwrap();
8787
let mut first_tag = first_tag.to_owned() + ">";
88+
let (remainder, _last_tag) = remainder.rsplit_once('<').unwrap();
8889
let remainder = remainder.to_owned();
8990

9091
assert!(first_tag.len() > 5, "{}", first_tag);
@@ -131,7 +132,10 @@ fn main() {
131132

132133
let svg = first_tag
133134
+ "if let Some(title) = title.clone() { <title>{title}</title> }"
134-
+ &remainder;
135+
+ &remainder
136+
// Would work if it weren't for XMLNS
137+
// + &format!("{{yew::Html::from_html_unchecked(yew::virtual_dom::AttrValue::from(r##\"{remainder}\"##))}}")
138+
+ "</svg>";
135139
let svg_tokens = TokenStream::from_str(&svg).expect(&path);
136140

137141
let constant_name = name.to_case(Case::UpperSnake);

src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use yew::prelude::*;
99
#[cfg(not(feature = "generator"))]
1010
use yew::virtual_dom::AttrValue;
1111

12+
/// SVG icon design. Enable icon collections, consisting of
13+
/// associated constants, with feature flags.
1214
#[derive(Copy, Clone)]
1315
#[cfg(not(feature = "generator"))]
1416
pub struct IconData {
@@ -43,7 +45,7 @@ impl std::fmt::Debug for IconData {
4345
}
4446
}
4547

46-
/// For customizing icon rendering. Only `icon_id` is required.
48+
/// For customizing icon rendering. Only `data` is required.
4749
#[cfg(not(feature = "generator"))]
4850
#[derive(Properties, PartialEq)]
4951
pub struct IconProps {

test-app/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ yew_icons = { path = "..", features = [
4242
"heroicons_mini_solid",
4343
"lucide",
4444
"octicons",
45+
#"lipis_flag_icons_1_x_1",
46+
#"lipis_flag_icons_4_x_3"
47+
#"simple_icons",
4548
] }
4649
wasm-bindgen = "0.2.84"

0 commit comments

Comments
 (0)