-
Notifications
You must be signed in to change notification settings - Fork 38
fix: stroke omitted for hi_outline_icons.rs #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: stroke omitted for hi_outline_icons.rs #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #62 by omitting the stroke attribute from the generated icon files to allow for parent-based stroke overwriting.
- Excludes the "stroke" attribute in the generated code for SVG child elements.
- Aligns attribute filtering for icon file generation with the desired behavior for Heroicons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed response.
It seems that in Heroicons, not only the stroke attribute, but also stroke-linecap, stroke-linejoin, and stroke-width are included in the returned HTML from child_elements.
dioxus-free-icons/packages/lib/src/icons/hi_outline_icons.rs
Lines 32 to 35 in 5a42938
stroke: "#374151", | |
stroke_linecap: "round", | |
stroke_linejoin: "round", | |
stroke_width: "2", |
In this case, we need to omit those attributes and adjust the settings for extract_svg_colors, extract_stroke_linecap, and extract_stroke_linejoin accordingly.
dioxus-free-icons/packages/codegen/src/create_icon_file.rs
Lines 153 to 176 in 5a42938
fn extract_svg_colors(icon_prefix: &str) -> (&str, &str, &str) { | |
match icon_prefix { | |
"Fi" => ("\"none\"", "user_color", "\"2\""), | |
"Ld" => ("\"none\"", "user_color", "\"2\""), | |
"Io" => ("user_color", "user_color", "\"0\""), | |
_ => ("user_color", "\"none\"", "\"0\""), | |
} | |
} | |
fn extract_stroke_linecap(icon_prefix: &str) -> &str { | |
match icon_prefix { | |
"Ld" => "round", | |
"Fi" => "round", | |
_ => "butt", | |
} | |
} | |
fn extract_stroke_linejoin(icon_prefix: &str) -> &str { | |
match icon_prefix { | |
"Ld" => "round", | |
"Fi" => "round", | |
_ => "miter", | |
} | |
} |
I'll work on this in the upcoming days and check if other icon packs have similar problems. |
@nissy-dev while taking a closer look at this, I noticed some other aspects of the Heroicons:
I was thinking of turning this PR into a draft that solves all of these problems. I would:
Let me know what you think about this :) |
Also, unrelated to this PR, I was considering other modifications as separate PRs:
|
Thank you for doing your work! I think your suggestions look good overall.
If possible, I’d appreciate it if you could split these changes into separate PRs.
This one looks good as well. Again, if it’s a major change, it would be great if you could split it into separate PRs before submitting. |
Solves #62
Omits the
stroke
attribute on codegen. I only tested it for the Heroicons files (the Material repo was too big for me to clone), but I assume it is also beneficial to avoid hardcoding the attribute in other files. Let me know if I should test it for the other files as well.Also, I think it would be better to set
stroke: "currentColor"
to explicitely allow stroke overwriting by the parent, but it seems it isn't totally necessary.