Make sure we apply all classes to the lucide icons (#1691)

* Make sure all classes are applied for all packages

* Add class test to angular component

* Adjust lucide-static tests

* update snapshot

* Fix types
This commit is contained in:
Eric Fennis
2023-11-24 13:59:12 +01:00
committed by GitHub
parent fbaccc7d9f
commit 75e9724072
26 changed files with 2159 additions and 558 deletions

View File

@@ -47,7 +47,7 @@
"devDependencies": {
"@lucide/rollup-plugins": "workspace:*",
"@lucide/build-icons": "workspace:*",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/vue": "^6.6.1",
"@vue/compiler-sfc": "3.2.45",
"@vue/test-utils": "2.2.4",

View File

@@ -23,7 +23,7 @@ type IconNode = [elementName: string, attrs: Record<string, string>][]
export const toKebabCase = (string: string) => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
const createLucideIcon = (iconName: string, iconNode: IconNode): FunctionalComponent<SVGProps> => (
{ size, strokeWidth = 2, absoluteStrokeWidth, color, ...props }, // props
{ size, strokeWidth = 2, absoluteStrokeWidth, color, class: classes, ...props }, // props
{ attrs, slots } // context
) => {
return h(
@@ -35,7 +35,7 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): FunctionalCompo
stroke: color || defaultAttributes.stroke,
'stroke-width': absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
...attrs,
class: ['lucide', `lucide-${toKebabCase(iconName)}`, attrs?.class || ''],
class: ['lucide', `lucide-${toKebabCase(iconName)}`],
...props,
},
[

View File

@@ -3,7 +3,7 @@
exports[`Using lucide icon components > should add a class to the element 1`] = `
<div>
<svg
class="my-icon"
class="lucide lucide-smile-icon my-icon"
fill="none"
height="24"
stroke="currentColor"

View File

@@ -41,6 +41,8 @@ describe('Using lucide icon components', () => {
const [icon] = document.getElementsByClassName('my-icon');
expect(icon).toHaveClass('my-icon')
expect(icon).toHaveClass('lucide')
expect(icon).toHaveClass('lucide-smile-icon')
});
it('should add a style attribute to the element', () => {