mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
feat(packages): export __iconNode data across framework packages (#4761)
Fixes #4644 Signed-off-by: Liang Xu <lx3133584@users.noreply.github.com> Co-authored-by: Liang Xu <lx3133584@users.noreply.github.com>
This commit is contained in:
@@ -8,9 +8,14 @@ export default defineExportTemplate(
|
||||
|
||||
return `
|
||||
import createLucideIcon from '../createLucideIcon';
|
||||
import type { LucideIconData } from '../types';
|
||||
import type { LucideIconNode, LucideIconData } from '../types';
|
||||
|
||||
const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
export const __iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
|
||||
/**
|
||||
* @deprecated Access \`__iconData\` instead.
|
||||
*/
|
||||
export const __iconNode: LucideIconNode[] = __iconData.node;
|
||||
|
||||
/**
|
||||
* @component @name ${componentName}
|
||||
@@ -23,7 +28,7 @@ const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon(iconData);
|
||||
const ${componentName} = createLucideIcon(__iconData);
|
||||
|
||||
export default ${componentName};
|
||||
`;
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { createLucideIcon } from '../src/lucide-preact';
|
||||
import { __iconData, __iconNode } from '../src/icons/air-vent';
|
||||
import { airVent } from './testIconNodes';
|
||||
import { render } from '@testing-library/preact';
|
||||
|
||||
describe('Using createLucideIcon', () => {
|
||||
it('should export __iconData and __iconNode from icon module', () => {
|
||||
expect(__iconData).toBeDefined();
|
||||
expect(__iconData.node).toBeDefined();
|
||||
expect(__iconNode).toBeDefined();
|
||||
expect(Array.isArray(__iconNode)).toBe(true);
|
||||
expect(__iconNode.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should create a component from icon data', () => {
|
||||
const AirVent = createLucideIcon({
|
||||
name: 'air-vent',
|
||||
|
||||
@@ -8,9 +8,14 @@ export default defineExportTemplate(
|
||||
|
||||
return `
|
||||
import createLucideIcon from '../createLucideIcon';
|
||||
import type { LucideIconData } from '../types';
|
||||
import type { LucideIconNode, LucideIconData } from '../types';
|
||||
|
||||
const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
export const __iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
|
||||
/**
|
||||
* @deprecated Access \`__iconData\` instead.
|
||||
*/
|
||||
export const __iconNode: LucideIconNode[] = __iconData.node;
|
||||
|
||||
/**
|
||||
* @component @name ${componentName}
|
||||
@@ -23,7 +28,7 @@ const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon(iconData);
|
||||
const ${componentName} = createLucideIcon(__iconData);
|
||||
|
||||
export default ${componentName};
|
||||
`;
|
||||
|
||||
@@ -8,9 +8,14 @@ export default defineExportTemplate(
|
||||
|
||||
return `
|
||||
import Icon from '../Icon';
|
||||
import type { LucideIconData, LucideProps } from '../types';
|
||||
import type { LucideIconData, LucideIconNode, LucideProps } from '../types';
|
||||
|
||||
const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
export const __iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
|
||||
/**
|
||||
* @deprecated Access \`__iconData\` instead.
|
||||
*/
|
||||
export const __iconNode: LucideIconNode[] = __iconData.node;
|
||||
|
||||
/**
|
||||
* @component @name ${componentName}
|
||||
@@ -24,7 +29,7 @@ const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = (props: LucideProps) => (
|
||||
<Icon {...props} icon={iconData} />
|
||||
<Icon {...props} icon={__iconData} />
|
||||
)
|
||||
|
||||
export default ${componentName};
|
||||
|
||||
Reference in New Issue
Block a user