mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 11:47:42 +01:00
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:
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
[
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user