Skip to content

Commit 99d25bd

Browse files
feat(packages): extract icon build logic into @lucide/shared (#4409)
* feat(packages): extract build logic to @lucide/shared, still wip * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * feat(packages): extract build logic to @lucide/shared, still wip * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * feat(): unify icon build logic some more, add nonScalingStroke option, marking absoluteStrokeWidth as deprecated * chore(icons): revert git hook changes made to icons * fix(packages/astro,react-native,vue): fix iconNode type fix(packages/vue): fix hasA11yProp * fix(packages/solid): make component reactive & add unit tests for checking prop changes * test(packages/vue): add reactivity tests to @lucide/vue * fix(packages): replace cpy-cli, accidentally removed during main merge * docs(packages): upgrade react documentation with nonScalingStroke * fix(tests): update snapshots for lucide-react * feat(docs): upgraded package guides with nonScalingStroke, dropping absoluteStrokeWidth * fix(vue,react-native): fix linting issues * fix(icons): add proper fallback for icon width in calculatedStrokeWidth * fix(packages/svelte): add globalProps.class to icons * fix(packages/shared): wrap width, height & size in isDefined * Update types.ts * fix(packages/svelte): do not pass propsClass to mergeClasses --------- Co-authored-by: Eric Fennis <[email protected]>
1 parent 07a2c79 commit 99d25bd

178 files changed

Lines changed: 3152 additions & 3061 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ packages/**/src/aliases.ts
2828
!packages/**/src/aliases/index.ts
2929
packages/**/src/utils/*.ts
3030
!packages/shared/src/utils/*.ts
31+
!packages/shared/src/build/
32+
!packages/shared/src/build/*.ts
33+
packages/shared/src/build/types.d.ts
3134
packages/**/src/dynamicIconImports.ts
3235
packages/**/DynamicIcon.d.ts
3336
packages/**/dynamicIconImports.js

‎docs/guide/angular/advanced/combining-icons.md‎

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Combining icons - Angular
33
description: Learn how to combine multiple icons into a single icon nested SVG elements in your Angular application.
44
---
5+
56
<script setup>
67
import Sandpack from '~/.vitepress/theme/components/editors/SandpackAngular.vue'
78
</script>
@@ -14,28 +15,32 @@ This is useful for if you want to be creative and make your own custom icons by
1415
::: sandpack {template=angular showTabs=false editorHeight=400 editorWidthPercentage=60 dependencies="@lucide/angular"}
1516

1617
```ts /src/app/app.component.ts [active]
17-
import { Component, ViewEncapsulation } from "@angular/core";
18-
import { LucideScan, LucideUser } from "@lucide/angular";
18+
import { Component, ViewEncapsulation } from '@angular/core';
19+
import { LucideScan, LucideUser } from '@lucide/angular';
1920

2021
@Component({
2122
selector: 'app',
2223
imports: [LucideScan, LucideUser],
23-
template: `
24-
<svg lucideScan [size]="48">
25-
<svg lucideUser
26-
[size]="12"
27-
x="6"
28-
y="6"
29-
[strokeWidth]="4"
30-
[absoluteStrokeWidth]="true"
31-
/>
32-
</svg>`,
24+
template: ` <svg
25+
lucideScan
26+
[size]="48"
27+
[nonScalingStroke]="true"
28+
>
29+
<svg
30+
lucideUser
31+
[size]="12"
32+
x="6"
33+
y="6"
34+
[strokeWidth]="4"
35+
[nonScalingStroke]="true"
36+
/>
37+
</svg>`,
3338
styleUrls: ['./app.component.css'],
3439
encapsulation: ViewEncapsulation.None,
3540
})
36-
export class App {
37-
}
41+
export class App {}
3842
```
43+
3944
:::
4045

4146
This is valid SVG and all SVG properties are supported on the icons.
@@ -53,67 +58,70 @@ You can also use SVG elements to create your own icons.
5358

5459
For example, you can add a notification badge to an icon by using the `circle` SVG element.
5560

56-
5761
::: sandpack {template=angular showTabs=false editorHeight=400 editorWidthPercentage=60 dependencies="@lucide/angular"}
5862

5963
```ts /src/app/app.component.ts [active]
60-
import { Component, ViewEncapsulation, signal } from "@angular/core";
61-
import { LucideMail } from "@lucide/angular";
64+
import { Component, ViewEncapsulation, signal } from '@angular/core';
65+
import { LucideMail } from '@lucide/angular';
6266

6367
@Component({
6468
selector: 'app',
6569
imports: [LucideMail],
66-
template: `
67-
<svg lucideMail [size]="48">
68-
@if (hasUnreadMessages()) {
69-
<circle
70-
r="3"
71-
cx="21"
72-
cy="5"
73-
stroke="none"
74-
fill="#F56565"
75-
/>
76-
}
77-
</svg>`,
70+
template: ` <svg
71+
lucideMail
72+
[size]="48"
73+
>
74+
@if (hasUnreadMessages()) {
75+
<circle
76+
r="3"
77+
cx="21"
78+
cy="5"
79+
stroke="none"
80+
fill="#F56565"
81+
/>
82+
}
83+
</svg>`,
7884
styleUrls: ['./app.component.css'],
7985
encapsulation: ViewEncapsulation.None,
8086
})
8187
export class App {
8288
protected readonly hasUnreadMessages = signal<boolean>(true);
8389
}
8490
```
91+
8592
:::
8693

8794
### Example with text element
8895

8996
You can also use the `text` SVG element to add text to your icon.
9097

91-
9298
::: sandpack {template=angular showTabs=false editorHeight=400 editorWidthPercentage=60 dependencies="@lucide/angular"}
9399

94100
```ts /src/app/app.component.ts [active]
95-
import { Component, ViewEncapsulation } from "@angular/core";
96-
import { LucideFile } from "@lucide/angular";
101+
import { Component, ViewEncapsulation } from '@angular/core';
102+
import { LucideFile } from '@lucide/angular';
97103

98104
@Component({
99105
selector: 'app',
100106
imports: [LucideFile],
101-
template: `
102-
<svg lucideFile [size]="48">
103-
<text
104-
x="7.5"
105-
y="19"
106-
font-size="8"
107-
font-family="Verdana,sans-serif"
108-
stroke-width="1"
109-
>
110-
JS
111-
</text>
112-
</svg>`,
107+
template: ` <svg
108+
lucideFile
109+
[size]="48"
110+
>
111+
<text
112+
x="7.5"
113+
y="19"
114+
font-size="8"
115+
font-family="Verdana,sans-serif"
116+
stroke-width="1"
117+
>
118+
JS
119+
</text>
120+
</svg>`,
113121
styleUrls: ['./app.component.css'],
114122
encapsulation: ViewEncapsulation.None,
115123
})
116-
export class App {
117-
}
124+
export class App {}
118125
```
126+
119127
:::

‎docs/guide/angular/advanced/global-styling.md‎

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Global Styling - Angular
33
description: Learn how to style all icons globally in your Angular application using CSS or the provideLucideConfig provider.
44
---
5+
56
<script setup>
67
import Sandpack from '~/.vitepress/theme/components/editors/SandpackAngular.vue'
78
</script>
@@ -29,9 +30,9 @@ import { provideLucideConfig } from '@lucide/angular';
2930
export const appConfig: ApplicationConfig = {
3031
providers: [
3132
provideLucideConfig({
32-
strokeWidth: 1.5
33+
strokeWidth: 1.5,
3334
}),
34-
]
35+
],
3536
};
3637
```
3738

@@ -65,7 +66,7 @@ All Lucide icons include the `lucide` class. You can use this class in your styl
6566
```
6667

6768
```ts /src/app/app.component.ts
68-
import { Component, ViewEncapsulation } from "@angular/core";
69+
import { Component, ViewEncapsulation } from '@angular/core';
6970
import {
7071
LucideCakeSlice,
7172
LucideCandy,
@@ -76,7 +77,7 @@ import {
7677
LucideSandwich,
7778
LucideWine,
7879
LucideDessert,
79-
} from "@lucide/angular";
80+
} from '@lucide/angular';
8081

8182
@Component({
8283
selector: 'app',
@@ -92,28 +93,27 @@ import {
9293
LucideDessert,
9394
],
9495
template: `<div class="grid">
95-
<svg lucideCakeSlice />
96-
<svg lucideCandy />
97-
<svg lucideApple />
98-
<svg lucideCookie />
99-
<svg lucideMartini />
100-
<svg lucideIceCream2 />
101-
<svg lucideSandwich />
102-
<svg lucideWine />
103-
<svg lucideDessert />
104-
</div>`,
96+
<svg lucideCakeSlice />
97+
<svg lucideCandy />
98+
<svg lucideApple />
99+
<svg lucideCookie />
100+
<svg lucideMartini />
101+
<svg lucideIceCream2 />
102+
<svg lucideSandwich />
103+
<svg lucideWine />
104+
<svg lucideDessert />
105+
</div>`,
105106
styleUrls: ['./app.component.css', './icon.css'],
106107
encapsulation: ViewEncapsulation.None,
107108
})
108-
export class App {
109-
}
109+
export class App {}
110110
```
111111

112112
:::
113113

114-
### Absolute stroke width
114+
### Non-scaling strokes
115115

116-
To keep the stroke width constant regardless of icon size, apply `vector-effect: non-scaling-stroke` to the icon's children. See [absolute-stroke-width](../basics/stroke-width.md#absolute-stroke-width) for more details.
116+
To keep the stroke width constant regardless of icon size, apply `vector-effect: non-scaling-stroke` to the icon's children. See [non-scaling strokes](../basics/stroke-width.md#non-scaling-strokes) for more details.
117117

118118
::: sandpack {template=angular editorHeight=300 dependencies="@lucide/angular"}
119119

@@ -137,7 +137,7 @@ To keep the stroke width constant regardless of icon size, apply `vector-effect:
137137
```
138138

139139
```ts /src/app/app.component.ts
140-
import { Component, ViewEncapsulation } from "@angular/core";
140+
import { Component, ViewEncapsulation } from '@angular/core';
141141
import {
142142
LucideTentTree,
143143
LucideCaravan,
@@ -148,7 +148,7 @@ import {
148148
LucideMap,
149149
LucideCloudMoon,
150150
LucideSparkles,
151-
} from "@lucide/angular";
151+
} from '@lucide/angular';
152152

153153
@Component({
154154
selector: 'app',
@@ -164,21 +164,20 @@ import {
164164
LucideSparkles,
165165
],
166166
template: `<div class="grid">
167-
<svg lucideTentTree />
168-
<svg lucideCaravan />
169-
<svg lucideFlameKindling />
170-
<svg lucideMountainSnow />
171-
<svg lucideTrees />
172-
<svg lucideAxe />
173-
<svg lucideMap />
174-
<svg lucideCloudMoon />
175-
<svg lucideSparkles />
176-
</div>`,
167+
<svg lucideTentTree />
168+
<svg lucideCaravan />
169+
<svg lucideFlameKindling />
170+
<svg lucideMountainSnow />
171+
<svg lucideTrees />
172+
<svg lucideAxe />
173+
<svg lucideMap />
174+
<svg lucideCloudMoon />
175+
<svg lucideSparkles />
176+
</div>`,
177177
styleUrls: ['./app.component.css', './icon.css'],
178178
encapsulation: ViewEncapsulation.None,
179179
})
180-
export class App {
181-
}
180+
export class App {}
182181
```
183182

184183
:::
Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
title: Stroke width - Angular
3-
description: Learn how to adjust the stroke width of icons in your Angular application using the `strokeWidth` input or adjust the strokeWidth appearance using the `absoluteStrokeWidth` input.
3+
description: Learn how to adjust the stroke width of icons in your Angular application using the `strokeWidth` input or adjust the strokeWidth appearance using the `nonScalingStroke` input.
44
---
5+
56
<script setup>
67
import Sandpack from '~/.vitepress/theme/components/editors/SandpackAngular.vue'
78
</script>
@@ -18,55 +19,58 @@ The `strokeWidth` can be adjusted to create a different look of the icons.
1819
::: sandpack {template=angular showTabs=false editorHeight=400 editorWidthPercentage=60 dependencies="@lucide/angular"}
1920

2021
```ts /src/app/app.component.ts [active]
21-
import { Component, ViewEncapsulation } from "@angular/core";
22-
import { LucideFolderLock } from "@lucide/angular";
22+
import { Component, ViewEncapsulation } from '@angular/core';
23+
import { LucideFolderLock } from '@lucide/angular';
2324

2425
@Component({
2526
selector: 'app',
2627
imports: [LucideFolderLock],
27-
template: `<svg lucideFolderLock [strokeWidth]="1" />`,
28+
template: `<svg
29+
lucideFolderLock
30+
[strokeWidth]="1"
31+
/>`,
2832
styleUrls: ['./app.component.css'],
2933
encapsulation: ViewEncapsulation.None,
3034
})
31-
export class App {
32-
}
35+
export class App {}
3336
```
37+
3438
:::
3539

36-
## Absolute stroke width
40+
## Non-scaling strokes
3741

38-
When binding the `size` input, the icon's stroke width will be relative to its size, this is the default SVG behavior. The `absoluteStrokeWidth` input is introduced to adjust this behavior to make the stroke width constant no matter the size of the icon.
42+
When binding the `size` input, the icon's stroke width will be relative to its size, this is the default SVG behavior. The `nonScalingStroke` input is introduced to adjust this behavior to make the stroke width constant no matter the size of the icon.
3943

40-
This means that when `absoluteStrokeWidth` is enabled and the `size` of the icons is set to `48px` the `strokeWidth` will still be `2px` on the screen.
44+
This means that when `nonScalingStroke` is enabled and the `size` of the icons is set to `48px` the `strokeWidth` will still be `2px` on the screen.
4145

4246
Note `2px` is the default stroke width for a Lucide icon, this can be adjusted to all sizes.
4347

44-
![Absolute stroke width comparison](../../../images/absolute-stroke-width-compare.png?raw=true "Absolute stroke width comparison")
48+
<!--@include: ../../../images/non-scaling-stroke-compare.svg -->
4549

46-
### Adjusting stroke width with `absoluteStrokeWidth` input
50+
### Adjusting stroke width with `nonScalingStroke` input
4751

48-
Setting `absoluteStrokeWidth` to `true` will make the stroke width absolute.
52+
Setting `nonScalingStroke` to `true` will make the stroke width non-scaling.
4953

5054
::: sandpack {template=angular showTabs=false editorHeight=400 editorWidthPercentage=60 dependencies="@lucide/angular"}
5155

5256
```ts /src/app/app.component.ts [active]
53-
import { Component, ViewEncapsulation } from "@angular/core";
54-
import { LucideRollerCoaster } from "@lucide/angular";
57+
import { Component, ViewEncapsulation } from '@angular/core';
58+
import { LucideRollerCoaster } from '@lucide/angular';
5559

5660
@Component({
5761
selector: 'app',
5862
imports: [LucideRollerCoaster],
5963
template: `
60-
<svg
64+
<svg
6165
lucideRollerCoaster
6266
[size]="96"
63-
[absoluteStrokeWidth]="true"
67+
[nonScalingStroke]="true"
6468
></svg>
65-
`,
69+
`,
6670
styleUrls: ['./app.component.css'],
6771
encapsulation: ViewEncapsulation.None,
6872
})
69-
export class App {
70-
}
73+
export class App {}
7174
```
75+
7276
:::

0 commit comments

Comments
 (0)