Skip to content

Commit 9faa544

Browse files
authored
Merge pull request #45 from MrGVSV/mrgvsv/lucide
Add Lucide support
2 parents 045a3e3 + 79c45ad commit 9faa544

35 files changed

+100440
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
[submodule "icon_resources/feather"]
1717
path = icon_resources/feather
1818
url = https://github.com/feathericons/feather
19+
[submodule "icon_resources/lucide"]
20+
path = icon_resources/lucide
21+
url = https://github.com/lucide-icons/lucide
1922
[submodule "icon_resources/material-design-icons"]
2023
path = icon_resources/material-design-icons
2124
url = https://github.com/google/material-design-icons

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The following features are available. Please see [react-icons site](https://reac
2929
- [hero-icons-outline](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/hi_outline_icons/index.html)
3030
- [hero-icons-solid](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/hi_solid_icons/index.html)
3131
- [ionicons](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/io_icons/index.html)
32+
- [lucide](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/ld_icons/index.html)
3233
- [material-design-icons-action](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/md_action_icons/index.html)
3334
- [material-design-icons-alert](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/md_alert_icons/index.html)
3435
- [material-design-icons-av](https://docs.rs/dioxus-free-icons/latest/dioxus_free_icons/icons/md_av_icons/index.html)
@@ -81,6 +82,7 @@ Icon Library|License|Version
8182
[Font Awesome](https://fontawesome.com/)|[CC BY 4.0 License](https://creativecommons.org/licenses/by/4.0/)| [6.1.1](https://github.com/FortAwesome/Font-Awesome/tree/6.1.1)
8283
[Heroicons](https://heroicons.com/)|[MIT License](https://github.com/tailwindlabs/heroicons/blob/master/LICENSE)| [1.0.6](https://github.com/tailwindlabs/heroicons/tree/v1.0.6)
8384
[Ionicons](https://ionic.io/ionicons)|[MIT License](https://github.com/ionic-team/ionicons/blob/main/LICENSE)| [6.0.2](https://github.com/ionic-team/ionicons/tree/v6.0.2)
85+
[Lucide](https://lucide.dev)|[ISC License](https://github.com/lucide-icons/lucide/blob/main/LICENSE)| [0.265.0](https://github.com/lucide-icons/lucide/tree/v0.265.0)
8486
[Material Design icons](https://developers.google.com/fonts/docs/material_icons)|[Apache License 2.0](https://github.com/google/material-design-icons/blob/master/LICENSE)| [4.0.0](https://github.com/google/material-design-icons/tree/4.0.0)
8587
[Octicons](https://primer.style/octicons/)|[MIT License](https://github.com/primer/octicons/blob/main/LICENSE)| [17.3.0](https://github.com/primer/octicons/tree/v17.3.0)
8688

icon_resources/lucide

Submodule lucide added at 34cf88d

packages/codegen/src/create_icon_file.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ impl IconShape for {ICON_NAME} {
2424
fn fill_and_stroke<'a>(&self, user_color: &'a str) -> (&'a str, &'a str, &'a str) {
2525
({FILL_COLOR}, {STROKE_COLOR}, {STROKE_WIDTH})
2626
}
27+
fn stroke_linecap(&self) -> &str {
28+
"{STROKE_LINECAP}"
29+
}
30+
fn stroke_linejoin(&self) -> &str {
31+
"{STROKE_LINEJOIN}"
32+
}
2733
fn child_elements(&self) -> Element {
2834
rsx! {
2935
{CHILD_ELEMENTS}
@@ -61,6 +67,8 @@ pub fn create_icon_file(svg_path: &str, output_path: &str, icon_prefix: &str) {
6167
let (view_box, xmlns) = extract_svg_attrs(svg_element);
6268
let child_elements = extract_svg_child_elements(svg_child_elements, icon_prefix);
6369
let (fill_color, stroke_color, stroke_width) = extract_svg_colors(icon_prefix);
70+
let stroke_linecap = extract_stroke_linecap(icon_prefix);
71+
let stroke_linejoin = extract_stroke_linejoin(icon_prefix);
6472

6573
ICON_TEMPLATE
6674
.replace("{ICON_NAME}", &format!("{}{}", icon_prefix, &icon_name))
@@ -70,6 +78,8 @@ pub fn create_icon_file(svg_path: &str, output_path: &str, icon_prefix: &str) {
7078
.replace("{FILL_COLOR}", &fill_color)
7179
.replace("{STROKE_COLOR}", &stroke_color)
7280
.replace("{STROKE_WIDTH}", &stroke_width)
81+
.replace("{STROKE_LINECAP}", &stroke_linecap)
82+
.replace("{STROKE_LINEJOIN}", &stroke_linejoin)
7383
})
7484
.collect::<Vec<_>>()
7585
.join("\n");
@@ -143,11 +153,26 @@ fn extract_svg_attrs(element: &Element) -> (String, String) {
143153
fn extract_svg_colors(icon_prefix: &str) -> (&str, &str, &str) {
144154
match icon_prefix {
145155
"Fi" => ("\"none\"", "user_color", "\"2\""),
156+
"Ld" => ("\"none\"", "user_color", "\"2\""),
146157
"Io" => ("user_color", "user_color", "\"0\""),
147158
_ => ("user_color", "\"none\"", "\"0\""),
148159
}
149160
}
150161

162+
fn extract_stroke_linecap(icon_prefix: &str) -> &str {
163+
match icon_prefix {
164+
"Ld" => "round",
165+
_ => "butt",
166+
}
167+
}
168+
169+
fn extract_stroke_linejoin(icon_prefix: &str) -> &str {
170+
match icon_prefix {
171+
"Ld" => "round",
172+
_ => "miter",
173+
}
174+
}
175+
151176
fn extract_svg_child_elements(elements: &[&Element], icon_prefix: &str) -> String {
152177
let elements = match icon_prefix {
153178
"Md" => &elements[1..],

packages/codegen/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ fn main() {
3939
let fi_output_path = format!("{}/fi_icons.rs", OUTPUT_BASE_PATH);
4040
create_icon_file::create_icon_file(FI_SVG_BASE_PATH, &fi_output_path, "Fi");
4141

42+
// create feather icons
43+
const LD_SVG_BASE_PATH: &str = "../../icon_resources/lucide/icons";
44+
let ld_output_path = format!("{}/ld_icons.rs", OUTPUT_BASE_PATH);
45+
create_icon_file::create_icon_file(LD_SVG_BASE_PATH, &ld_output_path, "Ld");
46+
4247
// create material design icons
4348
const MI_SVG_BASE_PATH: &str = "../../icon_resources/material-design-icons/src";
4449
for icon_type in vec![

packages/lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ octicons = []
2121
hero-icons-outline = []
2222
hero-icons-solid = []
2323
ionicons = []
24+
lucide = []
2425
material-design-icons-action = []
2526
material-design-icons-alert = []
2627
material-design-icons-av = []

packages/lib/src/icon_component.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ pub trait IconShape {
88
fn fill_and_stroke<'a>(&self, user_color: &'a str) -> (&'a str, &'a str, &'a str) {
99
("none", user_color, "0")
1010
}
11+
fn stroke_linecap(&self) -> &str {
12+
"butt"
13+
}
14+
fn stroke_linejoin(&self) -> &str {
15+
"miter"
16+
}
1117
}
1218

1319
/// Icon component Props
@@ -45,6 +51,8 @@ pub fn Icon<T: IconShape + Clone + PartialEq + 'static>(props: IconProps<T>) ->
4551
fill,
4652
stroke,
4753
stroke_width,
54+
stroke_linecap: "{props.icon.stroke_linecap()}",
55+
stroke_linejoin: "{props.icon.stroke_linejoin()}",
4856
if let Some(title_text) = props.title {
4957
title {
5058
"{title_text}"

packages/lib/src/icons.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub mod hi_outline_icons;
1616
pub mod hi_solid_icons;
1717
#[cfg(feature = "ionicons")]
1818
pub mod io_icons;
19+
#[cfg(feature = "lucide")]
20+
pub mod ld_icons;
1921
#[cfg(feature = "material-design-icons-action")]
2022
pub mod md_action_icons;
2123
#[cfg(feature = "material-design-icons-alert")]

0 commit comments

Comments
 (0)