import { html } from '@design.estate/dees-element'; import { icons, type IconWithPrefix } from './dees-icon.js'; import * as lucideIcons from 'lucide'; export const demoFunc = () => { // Group FontAwesome icons by type const faIcons = Object.keys(icons.fa); // Extract Lucide icons from the lucideIcons object directly // Log the first few keys to understand the structure console.log('First few Lucide keys:', Object.keys(lucideIcons).slice(0, 5)); // Get all icon functions from lucideIcons (they have PascalCase names) const lucideIconsList = Object.keys(lucideIcons) .filter(key => { // Skip utility functions and focus on icon components (first letter is uppercase) const isUppercaseFirst = key[0] === key[0].toUpperCase() && key[0] !== key[0].toLowerCase(); const isFunction = typeof lucideIcons[key] === 'function'; const notUtility = !['createElement', 'createIcons', 'default'].includes(key); return isFunction && isUppercaseFirst && notUtility; }) .map(pascalName => { // Convert PascalCase to camelCase return pascalName.charAt(0).toLowerCase() + pascalName.slice(1); }); // Log how many icons we found console.log(`Found ${lucideIconsList.length} Lucide icons`); // If we didn't find any, try an alternative approach if (lucideIconsList.length === 0) { console.log('Trying alternative approach to find Lucide icons'); // Try to get icon names from a known property if available if (lucideIcons.icons) { const iconSource = lucideIcons.icons || {}; lucideIconsList.push(...Object.keys(iconSource)); console.log(`Found ${lucideIconsList.length} icons via alternative method`); } } // Define the functions in TS scope instead of script tags const searchIcons = (event: InputEvent) => { const searchTerm = (event.target as HTMLInputElement).value.toLowerCase().trim(); // Get the demo container first, then search within it const demoContainer = (event.target as HTMLElement).closest('.demoContainer'); const containers = demoContainer.querySelectorAll('.iconContainer'); containers.forEach(container => { const iconName = container.getAttribute('data-name'); if (searchTerm === '') { container.classList.remove('hidden'); } else if (iconName && iconName.includes(searchTerm)) { container.classList.remove('hidden'); } else { container.classList.add('hidden'); } }); // Update counts - search within demoContainer demoContainer.querySelectorAll('.section-container').forEach(section => { const visibleIcons = section.querySelectorAll('.iconContainer:not(.hidden)').length; const countElement = section.querySelector('.icon-count'); if (countElement) { const totalIconsCount = section.classList.contains('fa-section') ? faIcons.length : lucideIconsList.length; countElement.textContent = visibleIcons === totalIconsCount ? `${totalIconsCount} icons` : `${visibleIcons} of ${totalIconsCount} icons`; } }); }; const copyIconName = (iconNameToCopy: string, type: 'fa' | 'lucide') => { // Use the new prefix format const textToCopy = `${type}:${iconNameToCopy}`; navigator.clipboard.writeText(textToCopy).then(() => { // Find the event target const currentEvent = window.event as MouseEvent; const currentTarget = currentEvent.currentTarget as HTMLElement; // Show feedback const tooltip = currentTarget.querySelector('.copy-tooltip'); if (tooltip) { tooltip.textContent = 'Copied!'; setTimeout(() => { tooltip.textContent = 'Click to copy'; }, 2000); } }); }; return html`
icon="fa:iconName"
or icon="lucide:iconName"
instead of iconFA
.
Click any icon to copy its new format to clipboard.