perf: reduce the number of icon component instances
This commit is contained in:
9
packages/@core/shared/iconify/src/create-icon.ts
Normal file
9
packages/@core/shared/iconify/src/create-icon.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { h } from 'vue';
|
||||
|
||||
import { Icon } from '@iconify/vue';
|
||||
|
||||
function createIcon(icon: string) {
|
||||
return h(Icon, { icon });
|
||||
}
|
||||
|
||||
export { createIcon };
|
@@ -1,14 +0,0 @@
|
||||
import { defineComponent, h } from 'vue';
|
||||
|
||||
import { Icon } from '@iconify/vue';
|
||||
|
||||
function createIcon(name: string) {
|
||||
return defineComponent({
|
||||
name: `SvgIcon-${name}`,
|
||||
setup(props, { attrs }) {
|
||||
return () => h(Icon, { icon: name, ...props, ...attrs });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export { createIcon };
|
@@ -1,4 +1,4 @@
|
||||
export * from './factory';
|
||||
export * from './create-icon';
|
||||
export * from './material';
|
||||
export * from './mdi';
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { createIcon } from './factory';
|
||||
import { createIcon } from './create-icon';
|
||||
|
||||
export const IconDefault = createIcon('ic:round-auto-awesome');
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { createIcon } from './factory';
|
||||
import { createIcon } from './create-icon';
|
||||
|
||||
export const MdiKeyboardEsc = createIcon('mdi:keyboard-esc');
|
||||
|
||||
|
Reference in New Issue
Block a user