mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-14 13:58:21 +00:00
- Icon: build class names, view box and child elements once per icon data instead of on every render, and build the svg props directly - Icon: render nested icon nodes, which were dropped before - createLucideIcon: drop the redundant className destructuring - DynamicIcon: remember loaded icon data so an icon that was loaded before renders right away, without the fallback - shared: cheaper mergeClasses and buildLucideIconNode with identical output - add a render benchmark (pnpm bench) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G9u8Fgx7hqgYx7gfUQgfY6
22 lines
517 B
TypeScript
22 lines
517 B
TypeScript
/**
|
|
* Merges classes into a single string
|
|
*
|
|
* @param {array} classes
|
|
* @returns {string} A string of classes
|
|
*/
|
|
export const mergeClasses = <ClassType = string | undefined | null>(...classes: ClassType[]) => {
|
|
const uniqueClasses: ClassType[] = [];
|
|
|
|
for (const className of classes) {
|
|
if (
|
|
Boolean(className) &&
|
|
(className as string).trim() !== '' &&
|
|
!uniqueClasses.includes(className)
|
|
) {
|
|
uniqueClasses.push(className);
|
|
}
|
|
}
|
|
|
|
return uniqueClasses.join(' ').trim();
|
|
};
|