|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Pixelarticons Gallery</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; |
| 10 | + background-color: #f9f9f9; |
| 11 | + padding: 20px; |
| 12 | + color: #333; |
| 13 | + } |
| 14 | + h1 { |
| 15 | + text-align: center; |
| 16 | + font-size: 28px; |
| 17 | + margin-bottom: 5px; |
| 18 | + } |
| 19 | + .gallery { |
| 20 | + display: grid; |
| 21 | + grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); |
| 22 | + gap: 20px; |
| 23 | + max-width: 1200px; |
| 24 | + margin: 0 auto; |
| 25 | + } |
| 26 | + .icon-item { |
| 27 | + display: flex; |
| 28 | + flex-direction: column; |
| 29 | + align-items: center; |
| 30 | + background: white; |
| 31 | + border-radius: 8px; |
| 32 | + padding: 15px 10px; |
| 33 | + box-shadow: 0 2px 4px rgba(0,0,0,0.05); |
| 34 | + transition: transform 0.2s, box-shadow 0.2s; |
| 35 | + } |
| 36 | + .icon-item:hover { |
| 37 | + transform: translateY(-3px); |
| 38 | + box-shadow: 0 4px 8px rgba(0,0,0,0.1); |
| 39 | + } |
| 40 | + .icon-svg { |
| 41 | + width: 32px; |
| 42 | + height: 32px; |
| 43 | + margin-bottom: 8px; |
| 44 | + display: flex; |
| 45 | + align-items: center; |
| 46 | + justify-content: center; |
| 47 | + } |
| 48 | + .icon-svg svg { |
| 49 | + width: 24px; |
| 50 | + height: 24px; |
| 51 | + } |
| 52 | + .icon-name { |
| 53 | + font-size: 12px; |
| 54 | + text-align: center; |
| 55 | + color: #555; |
| 56 | + white-space: nowrap; |
| 57 | + overflow: hidden; |
| 58 | + text-overflow: ellipsis; |
| 59 | + width: 100%; |
| 60 | + } |
| 61 | + .header { |
| 62 | + display: flex; |
| 63 | + flex-direction: column; |
| 64 | + align-items: center; |
| 65 | + margin-bottom: 20px; |
| 66 | + } |
| 67 | + .subtitle { |
| 68 | + margin-top: 5px; |
| 69 | + color: #777; |
| 70 | + font-size: 16px; |
| 71 | + margin-bottom: 20px; |
| 72 | + } |
| 73 | + |
| 74 | + /* Pixel art styling */ |
| 75 | + svg { |
| 76 | + shape-rendering: crispEdges; |
| 77 | + } |
| 78 | + </style> |
| 79 | +</head> |
| 80 | +<body> |
| 81 | + <div class="header"> |
| 82 | + <h1>Pixelarticons React</h1> |
| 83 | + <p class="subtitle">A collection of pixel-perfect icons for React</p> |
| 84 | + </div> |
| 85 | + |
| 86 | + <div class="gallery" id="gallery"> |
| 87 | + <!-- Icons will be inserted here --> |
| 88 | + </div> |
| 89 | + |
| 90 | + <script> |
| 91 | + // List to hold all icon names |
| 92 | + let allIcons = []; |
| 93 | + |
| 94 | + // Fetch all available icons first |
| 95 | + async function fetchAllIcons() { |
| 96 | + try { |
| 97 | + const response = await fetch('../svg/index.json'); |
| 98 | + if (response.ok) { |
| 99 | + // Try to load from index.json if available |
| 100 | + const data = await response.json(); |
| 101 | + allIcons = data.map(icon => { |
| 102 | + // Convert filename to display name (remove .svg extension) |
| 103 | + const name = icon.replace(/\.svg$/, ''); |
| 104 | + return name; |
| 105 | + }); |
| 106 | + } else { |
| 107 | + // Fallback to our predefined list |
| 108 | + console.warn("Could not load icon index file, using predefined list"); |
| 109 | + allIcons = displayIcons; |
| 110 | + } |
| 111 | + } catch (error) { |
| 112 | + console.error("Error loading icons:", error); |
| 113 | + allIcons = displayIcons; |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + // Define mapping for icons with different display name vs filename |
| 118 | + const specialIconMappings = { |
| 119 | + 'settings': 'sliders.svg', |
| 120 | + 'unlock': 'lock-open.svg', |
| 121 | + 'phone': 'device-phone.svg' |
| 122 | + // Add more mappings as needed |
| 123 | + }; |
| 124 | + |
| 125 | + // Predefined list of common icons (for fallback) |
| 126 | + const displayIcons = [ |
| 127 | + 'user', 'heart', 'home', 'settings', 'notification', 'search', |
| 128 | + 'calendar', 'mail', 'camera', 'cart', 'credit-card', 'download', |
| 129 | + 'upload', 'lock', 'unlock', 'file', 'folder', 'trash', |
| 130 | + 'edit', 'plus', 'minus', 'check', 'close', 'alert', |
| 131 | + 'info-box', 'warning-box', 'lightbulb', 'map', 'phone', 'chat', |
| 132 | + 'picture-in-picture', 'image', 'video', 'music', 'coffee', 'gift', |
| 133 | + 'moon', 'sun', 'star', 'bookmark', 'pin', 'link', |
| 134 | + 'github', 'globe', 'battery', 'cloud', 'compass', 'filter', |
| 135 | + 'flag', 'chart', 'eye', 'fire', 'flash', 'key', |
| 136 | + 'layers', 'layout', 'list', 'map-pin', 'menu', 'monitor', |
| 137 | + 'package', 'paperclip', 'save', 'share', 'shield', 'shopping-bag', |
| 138 | + 'tag', 'thumbs-up', 'trending-up', 'wifi', 'zap' |
| 139 | + ]; |
| 140 | + |
| 141 | + // Predefined SVG content for common icons (fallback) |
| 142 | + const fallbackSvgs = { |
| 143 | + 'user': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M12 11C14.2091 11 16 9.20914 16 7C16 4.79086 14.2091 3 12 3C9.79086 3 8 4.79086 8 7C8 9.20914 9.79086 11 12 11Z"/><path d="M12 14C8.13401 14 5 17.134 5 21H19C19 17.134 15.866 14 12 14Z"/></svg>', |
| 144 | + 'heart': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M7 3C4.23858 3 2 5.23858 2 8C2 15 12 21 12 21C12 21 22 15 22 8C22 5.23858 19.7614 3 17 3C15.4459 3 14.0656 3.78074 13.2597 5H10.7403C9.93435 3.78074 8.55414 3 7 3Z"/></svg>', |
| 145 | + 'home': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M5 12.5V20H19V12.5"/><path d="M2 10L12 3L22 10"/></svg>', |
| 146 | + 'check': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M21 6L8.625 18L3 12.5455"/></svg>', |
| 147 | + 'close': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M18 6L6 18"/><path d="M6 6L18 18"/></svg>', |
| 148 | + 'plus': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M5 12H19"/><path d="M12 5V19"/></svg>', |
| 149 | + 'minus': '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"><path d="M5 12H19"/></svg>' |
| 150 | + }; |
| 151 | + |
| 152 | + // Load SVG file content |
| 153 | + async function loadSvg(name) { |
| 154 | + // Check if this icon has a special mapping |
| 155 | + let svgFile = `${name}.svg`; |
| 156 | + if (specialIconMappings[name]) { |
| 157 | + svgFile = specialIconMappings[name]; |
| 158 | + } |
| 159 | + |
| 160 | + try { |
| 161 | + const response = await fetch(`../svg/${svgFile}`); |
| 162 | + |
| 163 | + if (!response.ok) { |
| 164 | + console.warn(`Failed to load SVG for ${name}: ${svgFile}`, response.statusText); |
| 165 | + return fallbackSvgs[name] || null; |
| 166 | + } |
| 167 | + |
| 168 | + return await response.text(); |
| 169 | + } catch (error) { |
| 170 | + console.error(`Error loading SVG for ${name}:`, error); |
| 171 | + return fallbackSvgs[name] || null; |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + // Create icon grid |
| 176 | + async function createIcons() { |
| 177 | + const gallery = document.getElementById('gallery'); |
| 178 | + let loadedCount = 0; |
| 179 | + |
| 180 | + // Use all icons if available, otherwise fall back to display icons |
| 181 | + const iconList = allIcons.length > 0 ? allIcons : displayIcons; |
| 182 | + |
| 183 | + for (const name of iconList) { |
| 184 | + const item = document.createElement('div'); |
| 185 | + item.className = 'icon-item'; |
| 186 | + |
| 187 | + const iconSvg = document.createElement('div'); |
| 188 | + iconSvg.className = 'icon-svg'; |
| 189 | + |
| 190 | + // Load SVG from file |
| 191 | + const svgContent = await loadSvg(name); |
| 192 | + if (svgContent) { |
| 193 | + iconSvg.innerHTML = svgContent; |
| 194 | + loadedCount++; |
| 195 | + } else { |
| 196 | + // Fallback to a simple square for missing icons |
| 197 | + iconSvg.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="arcs"> |
| 198 | + <rect x="4" y="4" width="16" height="16" /> |
| 199 | + </svg>`; |
| 200 | + } |
| 201 | + |
| 202 | + const iconName = document.createElement('div'); |
| 203 | + iconName.className = 'icon-name'; |
| 204 | + iconName.textContent = name; |
| 205 | + |
| 206 | + item.appendChild(iconSvg); |
| 207 | + item.appendChild(iconName); |
| 208 | + gallery.appendChild(item); |
| 209 | + } |
| 210 | + |
| 211 | + // Add icon count to the subtitle |
| 212 | + const subtitle = document.querySelector('.subtitle'); |
| 213 | + subtitle.textContent = `A collection of pixel-perfect icons for React (${loadedCount}/${iconList.length} loaded)`; |
| 214 | + } |
| 215 | + |
| 216 | + // Initialize icon grid |
| 217 | + document.addEventListener('DOMContentLoaded', async () => { |
| 218 | + await fetchAllIcons(); |
| 219 | + createIcons(); |
| 220 | + }); |
| 221 | + </script> |
| 222 | +</body> |
| 223 | +</html> |
0 commit comments