-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve types export for lucide-react (#1424)
* Add types plugin * Add js doc comment * Only enable dynamic imports for CJS and ESM builds * Add documentation * Adjust docs * Add test for dynamic import * Adjust note * Adjustment in docs
- Loading branch information
1 parent
e9d69c6
commit c97c6ed
Showing
15 changed files
with
271 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
export default ({ componentName, children }) => ` | ||
export default ({ componentName, iconName, children, getSvg }) => { | ||
const svgContents = getSvg(); | ||
|
||
const svgBase64 = Buffer.from( | ||
svgContents | ||
.replace('\n', '') | ||
.replace( | ||
'stroke="currentColor"', | ||
'stroke="#000" style="background-color: #fff; border-radius: 2px"', | ||
), | ||
).toString('base64'); | ||
|
||
// declarationFileContent += `\ | ||
|
||
return ` | ||
import createLucideIcon from '../createLucideIcon'; | ||
/** | ||
* @component @name ${componentName} | ||
* @description Lucide SVG icon component, renders SVG Element with children. | ||
* | ||
* @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName} | ||
* @see https://lucide.dev/guide/packages/lucide-react - Documentation | ||
* | ||
* @param {Object} props - Lucide icons props and any valid SVG attribute | ||
* @returns {JSX.Element} JSX Element | ||
* | ||
*/ | ||
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)}); | ||
export default ${componentName}; | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export * from './icons'; | ||
export * as icons from './icons'; | ||
export * from './aliases'; | ||
export { default as createLucideIcon } from './createLucideIcon'; | ||
export { default as dynamicIconImports } from './dynamicIconImports'; | ||
export { | ||
default as createLucideIcon, | ||
type IconNode, | ||
type LucideProps, | ||
type LucideIcon, | ||
} from './createLucideIcon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.