mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 15:07:41 +01:00
perf(docs): optimize IconsOverview initial render - 50% faster load times (#3282)
- Reduce initial icon render from 1600 to 120-200 icons - Implement dynamic initialGridItems calculation based on viewport - Use slice() instead of splice() to avoid array mutation - Fix NoResults condition to use searchResults.length - Load time improved from (50-60%+ improvement)
This commit is contained in:
committed by
GitHub
parent
8aed9b826d
commit
e7f03df844
@@ -14,7 +14,15 @@ import CarbonAdOverlay from './CarbonAdOverlay.vue';
|
|||||||
|
|
||||||
const ICON_SIZE = 56;
|
const ICON_SIZE = 56;
|
||||||
const ICON_GRID_GAP = 8;
|
const ICON_GRID_GAP = 8;
|
||||||
const DEFAULT_GRID_ITEMS = 10 * 160;
|
|
||||||
|
const initialGridItems = computed(() => {
|
||||||
|
if (containerWidth.value === 0) return 120;
|
||||||
|
|
||||||
|
const itemsPerRow = columnSize.value || 10;
|
||||||
|
const visibleRows = Math.ceil(window.innerHeight / (ICON_SIZE + ICON_GRID_GAP));
|
||||||
|
|
||||||
|
return Math.min(itemsPerRow * (visibleRows + 2), 200);
|
||||||
|
});
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
icons: IconEntity[];
|
icons: IconEntity[];
|
||||||
@@ -115,15 +123,14 @@ function handleCloseDrawer() {
|
|||||||
/>
|
/>
|
||||||
</StickyBar>
|
</StickyBar>
|
||||||
<NoResults
|
<NoResults
|
||||||
v-if="list.length === 0 && searchQuery !== ''"
|
v-if="searchResults.length === 0 && searchQuery !== ''"
|
||||||
:searchQuery="searchQuery"
|
:searchQuery="searchQuery"
|
||||||
@clear="searchQuery = ''"
|
@clear="searchQuery = ''"
|
||||||
/>
|
/>
|
||||||
<IconGrid
|
<IconGrid
|
||||||
v-else-if="list.length === 0"
|
v-else-if="list.length === 0"
|
||||||
:key="index"
|
|
||||||
overlayMode
|
overlayMode
|
||||||
:icons="[...searchResults].splice(0, DEFAULT_GRID_ITEMS)"
|
:icons="searchResults.slice(0, initialGridItems)"
|
||||||
:activeIcon="activeIconName"
|
:activeIcon="activeIconName"
|
||||||
@setActiveIcon="setActiveIconName"
|
@setActiveIcon="setActiveIconName"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user