The user wants a multi-brand icon loader that handles:
- Sprite splitting - loading icons from sprite sheets efficiently
- Tree-shaking - only loading icons that are actually used
- Accessibility metadata - proper ARIA labels and semantic information
This is a technical/utility request, not a visual animation showcase. I should create a practical, well-designed interface that demonstrates these concepts with good interactivity.
Let me design a sophisticated icon management system with:
- A visual demo showing icons from different "brands"
- Code generation showing tree-shaking in action
- Accessibility panel showing metadata
- Sprite visualization
- Dynamic filtering and search
- Usage statistics
I'll make it visually appealing with a modern dark theme, good typography, and meaningful interactions.
Multi-Brand Icon Loader
This is a comprehensive icon management system that demonstrates sprite splitting, tree-shaking optimization, and accessibility metadata handling. The interface shows real-time usage tracking, code generation, and accessibility compliance.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-Brand Icon Loader</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
display: ['Space Grotesk', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
}
}
}
}
</script>
<style>
:root {
--bg: #0a0a0f;
--bg-elevated: #12121a;
--bg-card: #1a1a24;
--fg: #e8e8ed;
--fg-muted: #6b6b7a;
--accent: #00d4aa;
--accent-dim: rgba(0, 212, 170, 0.15);
--warning: #ffb347;
--error: #ff6b6b;
--border: #2a2a36;
}
* { box-sizing: border-box; }
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.bg-grid {
background-image:
linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
background-size: 32px 32px;
}
.glow-accent {
box-shadow: 0 0 40px rgba(0, 212, 170, 0.2);
}
.icon-card {
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.icon-card:hover {
transform: translateY(-2px);
background: var(--bg-card);
border-color: var(--accent);
}
.icon-card.selected {
background: var(--accent-dim);
border-color: var(--accent);
}
.sprite-preview {
background: repeating-conic-gradient(
var(--bg-card) 0% 25%,
var(--bg-elevated) 0% 50%
) 50% / 16px 16px;
}
.code-block {
background: var(--bg);
border: 1px solid var(--border);
}
.tab-active {
background: var(--accent-dim);
color: var(--accent);
border-color: var(--accent);
}
@keyframes fadeUp {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-in {
animation: fadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
@media (prefers-reduced-motion: reduce) {
.animate-in { animation: none; opacity: 1; }
.icon-card { transition: none; }
}
.scrollbar-thin::-webkit-scrollbar {
width: 6px;
height: 6px;
}
.scrollbar-thin::-webkit-scrollbar-track {
background: var(--bg);
}
.scrollbar-thin::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
.sprite-cell {
transition: all 0.15s ease;
}
.sprite-cell:hover {
background: var(--accent-dim);
outline: 2px solid var(--accent);
}
.sprite-cell.used {
background: rgba(0, 212, 170, 0.1);
}
</style>
</head>
<body class="bg-grid">
<div class="min-h-screen p-4 md:p-8">
<!-- Header -->
<header class="max-w-7xl mx-auto mb-8 animate-in opacity-0">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<h1 class="font-display text-2xl md:text-3xl font-bold tracking-tight">
Icon Loader
</h1>
<p class="text-[var(--fg-muted)] mt-1 font-mono text-sm">
Multi-brand sprite system with tree-shaking & a11y
</p>
</div>
<div class="flex items-center gap-3">
<div class="px-3 py-1.5 rounded-lg text-sm font-mono" style="background: var(--bg-card); border: 1px solid var(--border);">
<span class="text-[var(--fg-muted)]">Bundle:</span>
<span id="bundleSize" class="text-[var(--accent)] ml-1 font-semibold">0 KB</span>
</div>
<div class="px-3 py-1.5 rounded-lg text-sm font-mono" style="background: var(--bg-card); border: 1px solid var(--border);">
<span class="text-[var(--fg-muted)]">Icons:</span>
<span id="iconCount" class="text-[var(--fg)] ml-1 font-semibold">0 / 48</span>
</div>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto grid lg:grid-cols-[1fr_380px] gap-6">
<!-- Left Panel: Icon Browser -->
<div class="space-y-6">
<!-- Brand Filters -->
<div class="animate-in opacity-0 stagger-1 rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<div class="flex flex-wrap items-center gap-3 mb-4">
<span class="text-sm font-medium text-[var(--fg-muted)]">Brands</span>
<div id="brandFilters" class="flex flex-wrap gap-2"></div>
</div>
<div class="flex gap-3">
<div class="relative flex-1">
<input
type="text"
id="searchInput"
placeholder="Search icons..."
class="w-full px-4 py-2.5 pl-10 rounded-lg text-sm font-mono focus:outline-none focus:ring-2 focus:ring-[var(--accent)]"
style="background: var(--bg); border: 1px solid var(--border); color: var(--fg);"
>
<svg class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--fg-muted)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35" stroke-linecap="round"/>
</svg>
</div>
<button
id="clearSelection"
class="px-4 py-2.5 rounded-lg text-sm font-medium transition-colors"
style="background: var(--bg); border: 1px solid var(--border); color: var(--fg-muted);"
>
Clear All
</button>
</div>
</div>
<!-- Icon Grid -->
<div class="animate-in opacity-0 stagger-2 rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<div class="flex items-center justify-between mb-4">
<h2 class="font-display font-semibold">Available Icons</h2>
<span id="filteredCount" class="text-sm text-[var(--fg-muted)] font-mono">48 icons</span>
</div>
<div id="iconGrid" class="grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-2 max-h-[400px] overflow-y-auto scrollbar-thin pr-2">
</div>
</div>
<!-- Sprite Preview -->
<div class="animate-in opacity-0 stagger-3 rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<div class="flex items-center justify-between mb-4">
<h2 class="font-display font-semibold">Sprite Sheet Preview</h2>
<div class="flex gap-2">
<button id="splitToggle" class="px-3 py-1.5 rounded text-xs font-mono transition-colors" style="background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent);">
Split View
</button>
</div>
</div>
<div class="sprite-preview rounded-lg p-4 min-h-[120px]">
<div id="spriteGrid" class="grid grid-cols-12 gap-1">
</div>
</div>
<p class="text-xs text-[var(--fg-muted)] mt-3 font-mono">
Highlighted cells represent icons included in the tree-shaken bundle
</p>
</div>
</div>
<!-- Right Panel: Details & Code -->
<div class="space-y-6">
<!-- Tabs -->
<div class="animate-in opacity-0 stagger-2 flex rounded-lg p-1" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<button data-tab="a11y" class="tab-btn flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors tab-active">
Accessibility
</button>
<button data-tab="code" class="tab-btn flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors" style="color: var(--fg-muted);">
Code Output
</button>
<button data-tab="stats" class="tab-btn flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors" style="color: var(--fg-muted);">
Statistics
</button>
</div>
<!-- Tab Content: Accessibility -->
<div id="tab-a11y" class="tab-content animate-in opacity-0 stagger-3 rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4">Accessibility Metadata</h3>
<div id="a11yPanel" class="space-y-4">
<p class="text-sm text-[var(--fg-muted)]">Select an icon to view its accessibility metadata</p>
</div>
</div>
<!-- Tab Content: Code -->
<div id="tab-code" class="tab-content hidden rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4">Generated Code</h3>
<div class="code-block rounded-lg p-4 overflow-x-auto scrollbar-thin">
<pre id="codeOutput" class="font-mono text-xs leading-relaxed" style="color: var(--fg-muted);">Select icons to generate code</pre>
</div>
<button id="copyCode" class="mt-3 w-full px-4 py-2.5 rounded-lg text-sm font-medium transition-all" style="background: var(--accent); color: var(--bg);">
Copy to Clipboard
</button>
</div>
<!-- Tab Content: Statistics -->
<div id="tab-stats" class="tab-content hidden rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-4">Bundle Statistics</h3>
<div id="statsPanel" class="space-y-4">
</div>
</div>
<!-- Selected Icons -->
<div class="animate-in opacity-0 stagger-4 rounded-xl p-4" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<h3 class="font-display font-semibold mb-3">Selected Icons</h3>
<div id="selectedList" class="flex flex-wrap gap-2 min-h-[48px]">
<span class="text-sm text-[var(--fg-muted)]">No icons selected</span>
</div>
</div>
</div>
</main>
</div>
<script>
// Icon Database with accessibility metadata
const iconDatabase = [
// Core icons
{ id: 'home', name: 'Home', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Home', role: 'img', description: 'Navigate to homepage' }, size: 0.8 },
{ id: 'settings', name: 'Settings', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Settings', role: 'img', description: 'Open application settings' }, size: 0.9 },
{ id: 'user', name: 'User', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'User profile', role: 'img', description: 'View user profile' }, size: 0.7 },
{ id: 'search', name: 'Search', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Search', role: 'img', description: 'Search content' }, size: 0.75 },
{ id: 'menu', name: 'Menu', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Navigation menu', role: 'button', description: 'Toggle navigation menu' }, size: 0.6 },
{ id: 'close', name: 'Close', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Close', role: 'button', description: 'Close dialog or menu' }, size: 0.55 },
{ id: 'check', name: 'Check', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Check mark', role: 'img', description: 'Indicates completion' }, size: 0.5 },
{ id: 'alert', name: 'Alert', brand: 'core', viewBox: '0 0 24 24', a11y: { label: 'Warning', role: 'alert', description: 'Attention required' }, size: 0.85 },
// Brand A - E-commerce
{ id: 'cart', name: 'Cart', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Shopping cart', role: 'img', description: 'View shopping cart' }, size: 0.95 },
{ id: 'heart', name: 'Heart', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Add to favorites', role: 'button', description: 'Save item to wishlist' }, size: 0.8 },
{ id: 'star', name: 'Star', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Rating star', role: 'img', description: 'Product rating indicator' }, size: 0.7 },
{ id: 'tag', name: 'Tag', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Price tag', role: 'img', description: 'Discount or category label' }, size: 0.85 },
{ id: 'truck', name: 'Truck', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Delivery truck', role: 'img', description: 'Shipping information' }, size: 1.1 },
{ id: 'credit-card', name: 'Credit Card', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Payment method', role: 'img', description: 'Credit card payment' }, size: 1.0 },
{ id: 'package', name: 'Package', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Package', role: 'img', description: 'Order package' }, size: 0.9 },
{ id: 'receipt', name: 'Receipt', brand: 'brandA', viewBox: '0 0 24 24', a11y: { label: 'Receipt', role: 'img', description: 'Order receipt' }, size: 0.88 },
// Brand B - Social
{ id: 'message', name: 'Message', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Message', role: 'button', description: 'Open messages' }, size: 0.82 },
{ id: 'notification', name: 'Notification', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Notifications', role: 'button', description: 'View notifications' }, size: 0.78 },
{ id: 'share', name: 'Share', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Share', role: 'button', description: 'Share content' }, size: 0.72 },
{ id: 'bookmark', name: 'Bookmark', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Bookmark', role: 'button', description: 'Save for later' }, size: 0.68 },
{ id: 'comment', name: 'Comment', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Comment', role: 'button', description: 'Add comment' }, size: 0.75 },
{ id: 'like', name: 'Like', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Like', role: 'button', description: 'Express approval' }, size: 0.65 },
{ id: 'follow', name: 'Follow', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Follow', role: 'button', description: 'Follow user' }, size: 0.7 },
{ id: 'block', name: 'Block', brand: 'brandB', viewBox: '0 0 24 24', a11y: { label: 'Block user', role: 'button', description: 'Block this user' }, size: 0.62 },
// Brand C - Media
{ id: 'play', name: 'Play', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Play', role: 'button', description: 'Start playback' }, size: 0.6 },
{ id: 'pause', name: 'Pause', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Pause', role: 'button', description: 'Pause playback' }, size: 0.55 },
{ id: 'volume', name: 'Volume', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Volume control', role: 'slider', description: 'Adjust volume level' }, size: 0.77 },
{ id: 'fullscreen', name: 'Fullscreen', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Fullscreen', role: 'button', description: 'Toggle fullscreen mode' }, size: 0.83 },
{ id: 'skip-next', name: 'Skip Next', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Skip forward', role: 'button', description: 'Skip to next item' }, size: 0.58 },
{ id: 'skip-prev', name: 'Skip Prev', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Skip backward', role: 'button', description: 'Skip to previous item' }, size: 0.58 },
{ id: 'shuffle', name: 'Shuffle', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Shuffle', role: 'button', description: 'Enable shuffle mode' }, size: 0.8 },
{ id: 'repeat', name: 'Repeat', brand: 'brandC', viewBox: '0 0 24 24', a11y: { label: 'Repeat', role: 'button', description: 'Enable repeat mode' }, size: 0.76 },
// Brand D - Finance
{ id: 'wallet', name: 'Wallet', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Wallet', role: 'img', description: 'Digital wallet' }, size: 0.92 },
{ id: 'chart', name: 'Chart', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Chart', role: 'img', description: 'Performance chart' }, size: 1.05 },
{ id: 'transfer', name: 'Transfer', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Transfer funds', role: 'button', description: 'Make a transfer' }, size: 0.88 },
{ id: 'invoice', name: 'Invoice', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Invoice', role: 'img', description: 'View invoice' }, size: 0.86 },
{ id: 'percent', name: 'Percent', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Percentage', role: 'img', description: 'Interest or discount rate' }, size: 0.65 },
{ id: 'bank', name: 'Bank', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Bank account', role: 'img', description: 'Linked bank account' }, size: 1.15 },
{ id: 'shield', name: 'Shield', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Security', role: 'img', description: 'Security and protection' }, size: 0.98 },
{ id: 'lock', name: 'Lock', brand: 'brandD', viewBox: '0 0 24 24', a11y: { label: 'Lock', role: 'img', description: 'Secure and encrypted' }, size: 0.72 },
// Utility icons
{ id: 'download', name: 'Download', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Download', role: 'button', description: 'Download file' }, size: 0.74 },
{ id: 'upload', name: 'Upload', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Upload', role: 'button', description: 'Upload file' }, size: 0.76 },
{ id: 'edit', name: 'Edit', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Edit', role: 'button', description: 'Edit content' }, size: 0.79 },
{ id: 'delete', name: 'Delete', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Delete', role: 'button', description: 'Delete item permanently' }, size: 0.73 },
{ id: 'copy', name: 'Copy', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Copy', role: 'button', description: 'Copy to clipboard' }, size: 0.67 },
{ id: 'refresh', name: 'Refresh', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Refresh', role: 'button', description: 'Reload content' }, size: 0.84 },
{ id: 'filter', name: 'Filter', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Filter', role: 'button', description: 'Filter results' }, size: 0.71 },
{ id: 'sort', name: 'Sort', brand: 'utility', viewBox: '0 0 24 24', a11y: { label: 'Sort', role: 'button', description: 'Change sort order' }, size: 0.69 }
];
const brandConfig = {
core: { name: 'Core', color: '#00d4aa' },
brandA: { name: 'E-commerce', color: '#ff6b9d' },
brandB: { name: 'Social', color: '#6b8aff' },
brandC: { name: 'Media', color: '#ffb347' },
brandD: { name: 'Finance', color: '#a78bfa' },
utility: { name: 'Utility', color: '#6b7280' }
};
// State
let selectedIcons = new Set();
let activeBrand = 'all';
let searchQuery = '';
let activeTab = 'a11y';
// DOM Elements
const iconGrid = document.getElementById('iconGrid');
const brandFilters = document.getElementById('brandFilters');
const searchInput = document.getElementById('searchInput');
const selectedList = document.getElementById('selectedList');
const bundleSizeEl = document.getElementById('bundleSize');
const iconCountEl = document.getElementById('iconCount');
const filteredCountEl = document.getElementById('filteredCount');
const a11yPanel = document.getElementById('a11yPanel');
const codeOutput = document.getElementById('codeOutput');
const statsPanel = document.getElementById('statsPanel');
const spriteGrid = document.getElementById('spriteGrid');
// Initialize
function init() {
renderBrandFilters();
renderIconGrid();
renderSpriteGrid();
updateStats();
setupEventListeners();
}
function renderBrandFilters() {
const allBtn = createFilterButton('all', 'All', '#00d4aa');
brandFilters.appendChild(allBtn);
Object.entries(brandConfig).forEach(([key, config]) => {
const btn = createFilterButton(key, config.name, config.color);
brandFilters.appendChild(btn);
});
}
function createFilterButton(brand, name, color) {
const btn = document.createElement('button');
btn.className = 'brand-filter px-3 py-1.5 rounded-lg text-xs font-medium transition-all';
btn.dataset.brand = brand;
btn.textContent = name;
if (brand === activeBrand) {
btn.style.background = hexToRgba(color, 0.2);
btn.style.color = color;
btn.style.border = `1px solid ${color}`;
} else {
btn.style.background = 'var(--bg)';
btn.style.color = 'var(--fg-muted)';
btn.style.border = '1px solid var(--border)';
}
return btn;
}
function hexToRgba(hex, alpha) {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `rgba(${r},${g},${b},${alpha})`;
}
function getFilteredIcons() {
return iconDatabase.filter(icon => {
const matchesBrand = activeBrand === 'all' || icon.brand === activeBrand;
const matchesSearch = icon.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
icon.id.toLowerCase().includes(searchQuery.toLowerCase());
return matchesBrand && matchesSearch;
});
}
function renderIconGrid() {
const filtered = getFilteredIcons();
iconGrid.innerHTML = '';
filtered.forEach(icon => {
const card = document.createElement('button');
card.className = `icon-card p-3 rounded-lg flex flex-col items-center gap-1.5 ${selectedIcons.has(icon.id) ? 'selected' : ''}`;
card.style.border = '1px solid var(--border)';
card.style.background = 'transparent';
card.dataset.iconId = icon.id;
card.setAttribute('aria-label', `Select ${icon.name} icon`);
card.setAttribute('aria-pressed', selectedIcons.has(icon.id));
const iconSvg = generateIconSvg(icon);
const brandColor = brandConfig[icon.brand].color;
card.innerHTML = `
<div class="w-6 h-6 flex items-center justify-center" style="color: ${brandColor}">
${iconSvg}
</div>
<span class="text-[10px] font-mono text-[var(--fg-muted)] truncate w-full text-center">${icon.name}</span>
`;
iconGrid.appendChild(card);
});
filteredCountEl.textContent = `${filtered.length} icons`;
}
function generateIconSvg(icon) {
// Simplified icon paths based on id
const paths = {
'home': '<path d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/>',
'settings': '<path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/><circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2" fill="none"/>',
'user': '<path d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/>',
'search': '<circle cx="11" cy="11" r="8" stroke="currentColor" stroke-width="2" fill="none"/><path d="M21 21l-4.35-4.35" stroke="currentColor" stroke-linecap="round" stroke-width="2"/>',
'menu': '<path d="M4 6h16M4 12h16M4 18h16" stroke="currentColor" stroke-linecap="round" stroke-width="2"/>',
'close': '<path d="M6 18L18 6M6 6l12 12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/>',
'check': '<path d="M5 13l4 4L19 7" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>',
'alert': '<path d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/>',
'cart': '<circle cx="9" cy="21" r="1" fill="currentColor"/><circle cx="20" cy="21" r="1" fill="currentColor"/><path d="M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/>',
'heart': '<path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/>',
'star': '<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="none"/>',
'play': '<polygon points="5 3 19 12 5 21 5 3" fill="currentColor"/>',
'pause': '<rect x="6" y="4" width="4" height="16" fill="currentColor"/><rect x="14" y="4" width="4" height="16" fill="currentColor"/>',
'wallet': '<rect x="1" y="4" width="22" height="16" rx="2" stroke="currentColor" stroke-width="2" fill="none"/><path d="M1 10h22" stroke="currentColor" stroke-width="2"/>',
'default': '<rect x="3" y="3" width="18" height="18" rx="2" stroke="currentColor" stroke-width="2" fill="none"/>'
};
return `<svg viewBox="${icon.viewBox}" class="w-full h-full" fill="none">${paths[icon.id] || paths['default']}</svg>`;
}
function renderSpriteGrid() {
spriteGrid.innerHTML = '';
iconDatabase.forEach((icon, index) => {
const cell = document.createElement('div');
cell.className = `sprite-cell w-full aspect-square rounded flex items-center justify-center text-[8px] font-mono cursor-pointer ${selectedIcons.has(icon.id) ? 'used' : ''}`;
cell.style.background = 'var(--bg-card)';
cell.style.color = selectedIcons.has(icon.id) ? 'var(--accent)' : 'var(--fg-muted)';
cell.dataset.iconId = icon.id;
cell.textContent = index + 1;
cell.title = `${icon.name} (${icon.brand})`;
spriteGrid.appendChild(cell);
});
}
function updateStats() {
const selectedArray = Array.from(selectedIcons);
const selectedData = selectedArray.map(id => iconDatabase.find(i => i.id === id)).filter(Boolean);
// Bundle size (simulated)
const totalSize = selectedData.reduce((sum, icon) => sum + icon.size, 0);
bundleSizeEl.textContent = `${totalSize.toFixed(1)} KB`;
iconCountEl.textContent = `${selectedIcons.size} / 48`;
// Tree shaking savings
const totalAvailable = iconDatabase.reduce((sum, icon) => sum + icon.size, 0);
const savings = totalAvailable - totalSize;
// Update stats panel
statsPanel.innerHTML = `
<div class="grid grid-cols-2 gap-3">
<div class="p-3 rounded-lg" style="background: var(--bg);">
<div class="text-2xl font-bold text-[var(--accent)]">${selectedIcons.size}</div>
<div class="text-xs text-[var(--fg-muted)]">Selected Icons</div>
</div>
<div class="p-3 rounded-lg" style="background: var(--bg);">
<div class="text-2xl font-bold">${totalSize.toFixed(1)} KB</div>
<div class="text-xs text-[var(--fg-muted)]">Bundle Size</div>
</div>
<div class="p-3 rounded-lg" style="background: var(--bg);">
<div class="text-2xl font-bold text-[var(--warning)]">${savings.toFixed(1)} KB</div>
<div class="text-xs text-[var(--fg-muted)]">Tree-shaken</div>
</div>
<div class="p-3 rounded-lg" style="background: var(--bg);">
<div class="text-2xl font-bold">${Math.round((savings / totalAvailable) * 100) || 0}%</div>
<div class="text-xs text-[var(--fg-muted)]">Reduction</div>
</div>
</div>
<div class="mt-4">
<h4 class="text-sm font-medium mb-2">By Brand</h4>
<div class="space-y-2">
${Object.entries(brandConfig).map(([key, config]) => {
const count = selectedData.filter(i => i.brand === key).length;
const total = iconDatabase.filter(i => i.brand === key).length;
const pct = total > 0 ? Math.round((count / total) * 100) : 0;
return `
<div class="flex items-center gap-2">
<span class="text-xs w-20" style="color: ${config.color}">${config.name}</span>
<div class="flex-1 h-2 rounded-full" style="background: var(--bg);">
<div class="h-full rounded-full transition-all" style="width: ${pct}%; background: ${config.color}"></div>
</div>
<span class="text-xs text-[var(--fg-muted)] w-12 text-right">${count}/${total}</span>
</div>
`;
}).join('')}
</div>
</div>
`;
// Update selected list
if (selectedIcons.size === 0) {
selectedList.innerHTML = '<span class="text-sm text-[var(--fg-muted)]">No icons selected</span>';
} else {
selectedList.innerHTML = selectedData.map(icon => {
const color = brandConfig[icon.brand].color;
return `
<button
class="selected-icon flex items-center gap-1.5 px-2 py-1 rounded text-xs font-mono transition-all hover:opacity-70"
style="background: ${hexToRgba(color, 0.15)}; color: ${color}; border: 1px solid ${hexToRgba(color, 0.3)};"
data-icon-id="${icon.id}"
>
${icon.name}
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path d="M6 18L18 6M6 6l12 12" stroke-linecap="round" stroke-width="2"/>
</svg>
</button>
`;
}).join('');
}
// Update code output
updateCodeOutput(selectedData);
}
function updateCodeOutput(icons) {
if (icons.length === 0) {
codeOutput.textContent = '// Select icons to generate code';
return;
}
const code = `// Tree-shaken icon bundle
// Only includes ${icons.length} selected icons
import { createIconSprite } from '@icons/loader';
const spriteConfig = {
icons: [
${icons.map(i => ` {
id: '${i.id}',
viewBox: '${i.viewBox}',
a11y: {
label: '${i.a11y.label}',
role: '${i.a11y.role}',
description: '${i.a11y.description}'
}
}`).join(',\n')}
]
};
// Generate optimized sprite
export const iconSprite = createIconSprite(spriteConfig);
// Type-safe icon component
export type IconId =
| ${icons.map(i => `'${i.id}'`).join('\n | ')};
// Bundle size: ${(icons.reduce((s, i) => s + i.size, 0)).toFixed(1)}KB
// Tree-shaken: ${(iconDatabase.reduce((s, i) => s + i.size, 0) - icons.reduce((s, i) => s + i.size, 0)).toFixed(1)}KB saved`;
codeOutput.textContent = code;
}
function updateA11yPanel(iconId) {
const icon = iconDatabase.find(i => i.id === iconId);
if (!icon) {
a11yPanel.innerHTML = '<p class="text-sm text-[var(--fg-muted)]">Select an icon to view its accessibility metadata</p>';
return;
}
const color = brandConfig[icon.brand].color;
a11yPanel.innerHTML = `
<div class="flex items-center gap-3 pb-3" style="border-bottom: 1px solid var(--border);">
<div class="w-12 h-12 rounded-lg flex items-center justify-center" style="background: ${hexToRgba(color, 0.15)}; color: ${color}">
${generateIconSvg(icon)}
</div>
<div>
<div class="font-medium">${icon.name}</div>
<div class="text-xs font-mono text-[var(--fg-muted)]">${icon.id}</div>
</div>
</div>
<div class="space-y-3">
<div>
<label class="text-xs font-medium text-[var(--fg-muted)]">ARIA Label</label>
<div class="mt-1 p-2 rounded font-mono text-sm" style="background: var(--bg);">
${icon.a11y.label}
</div>
</div>
<div>
<label class="text-xs font-medium text-[var(--fg-muted)]">Role</label>
<div class="mt-1 p-2 rounded font-mono text-sm inline-block" style="background: ${hexToRgba(color, 0.15)}; color: ${color}">
role="${icon.a11y.role}"
</div>
</div>
<div>
<label class="text-xs font-medium text-[var(--fg-muted)]">Description</label>
<div class="mt-1 p-2 rounded text-sm" style="background: var(--bg);">
${icon.a11y.description}
</div>
</div>
<div>
<label class="text-xs font-medium text-[var(--fg-muted)]">Generated HTML</label>
<div class="mt-1 p-2 rounded font-mono text-xs overflow-x-auto" style="background: var(--bg);">
<svg role="${icon.a11y.role}"<br>
aria-label="${icon.a11y.label}"<br>
aria-describedby="desc-${icon.id}"><br>
<desc id="desc-${icon.id}"><br>
${icon.a11y.description}<br>
</desc><br>
</svg>
</div>
</div>
<div class="flex items-center gap-2 p-2 rounded" style="background: rgba(0, 212, 170, 0.1);">
<svg class="w-4 h-4 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path d="M5 13l4 4L19 7" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
</svg>
<span class="text-xs text-[var(--accent)]">WCAG 2.1 AA Compliant</span>
</div>
</div>
`;
}
function setupEventListeners() {
// Brand filter clicks
brandFilters.addEventListener('click', (e) => {
const btn = e.target.closest('.brand-filter');
if (!btn) return;
activeBrand = btn.dataset.brand;
renderBrandFilters();
renderIconGrid();
});
// Search input
searchInput.addEventListener('input', (e) => {
searchQuery = e.target.value;
renderIconGrid();
});
// Icon selection
iconGrid.addEventListener('click', (e) => {
const card = e.target.closest('.icon-card');
if (!card) return;
const iconId = card.dataset.iconId;
if (selectedIcons.has(iconId)) {
selectedIcons.delete(iconId);
} else {
selectedIcons.add(iconId);
}
renderIconGrid();
renderSpriteGrid();
updateStats();
updateA11yPanel(iconId);
});
// Sprite grid clicks
spriteGrid.addEventListener('click', (e) => {
const cell = e.target.closest('.sprite-cell');
if (!cell) return;
const iconId = cell.dataset.iconId;
if (selectedIcons.has(iconId)) {
selectedIcons.delete(iconId);
} else {
selectedIcons.add(iconId);
}
renderIconGrid();
renderSpriteGrid();
updateStats();
updateA11yPanel(iconId);
});
// Remove selected icon
selectedList.addEventListener('click', (e) => {
const btn = e.target.closest('.selected-icon');
if (!btn) return;
const iconId = btn.dataset.iconId;
selectedIcons.delete(iconId);
renderIconGrid();
renderSpriteGrid();
updateStats();
});
// Clear selection
document.getElementById('clearSelection').addEventListener('click', () => {
selectedIcons.clear();
renderIconGrid();
renderSpriteGrid();
updateStats();
a11yPanel.innerHTML = '<p class="text-sm text-[var(--fg-muted)]">Select an icon to view its accessibility metadata</p>';
});
// Tab switching
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.addEventListener('click', () => {
const tab = btn.dataset.tab;
activeTab = tab;
document.querySelectorAll('.tab-btn').forEach(b => {
b.classList.remove('tab-active');
b.style.color = 'var(--fg-muted)';
});
btn.classList.add('tab-active');
btn.style.color = '';
document.querySelectorAll('.tab-content').forEach(c => c.classList.add('hidden'));
document.getElementById(`tab-${tab}`).classList.remove('hidden');
});
});
// Copy code
document.getElementById('copyCode').addEventListener('click', () => {
navigator.clipboard.writeText(codeOutput.textContent);
const btn = document.getElementById('copyCode');
btn.textContent = 'Copied!';
setTimeout(() => btn.textContent = 'Copy to Clipboard', 2000);
});
}
// Initialize on load
init();
</script>
</body>
</html>
Key Features
1. Sprite Splitting
- Visual sprite grid showing all 48 icons in a grid layout
- Click any cell to toggle selection
- Used icons are highlighted to show which parts of the sprite are included
- Simulates how a real sprite sheet would be split during bundling
2. Tree-Shaking
- Real-time bundle size calculation as you select/deselect icons
- Shows "tree-shaken" savings (KB removed from bundle)
- Percentage reduction display
- Per-brand breakdown of selected vs available icons
3. Accessibility Metadata
- Each icon has:
label, role, description
- Auto-generated accessible HTML output
- WCAG 2.1 AA compliance indicator
- ARIA attributes properly documented
4. Multi-Brand Support
- 6 brand categories: Core, E-commerce, Social, Media, Finance, Utility
- Color-coded by brand
- Filter by brand or search by name
5. Code Generation
- Outputs TypeScript-ready code with proper types
- Includes all accessibility metadata in the config
- Shows tree-shaking statistics in comments
The interface demonstrates how an icon system would work in production, with visual feedback for sprite usage and comprehensive accessibility documentation.