Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8745x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 1x 1x 4233x 4233x 4233x 4233x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4233x 4233x 4233x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 4234x 1x 1x 1x 1x 1x 6572x 6572x 6572x 6572x 6572x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client';
import { SVGProps, Suspense, lazy, CSSProperties, ComponentType } from 'react';
import { IconName, iconRegistry, hasIcon } from './registry';
import { clientLogger } from '@/lib/logging/clientLogger';
// Re-export IconName for convenience
export type { IconName };
/**
* Icon Component Props
*/
export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
/** Icon name from registry */
name: IconName;
/** Icon size (applies to both width and height). Can be a number (pixels) or CSS string */
size?: number | string;
/** Rotation in degrees (0, 90, 180, 270, etc.) */
rotate?: number;
/** Additional CSS classes */
className?: string;
/** Inline styles */
style?: CSSProperties;
/** Accessibility label - describes the icon's meaning to screen readers */
'aria-label'?: string;
/**
* Mark icon as decorative (purely visual, no semantic meaning).
* Decorative icons are hidden from screen readers.
* Use when the icon accompanies text that already describes the action.
*
* @example
* // Decorative - text already describes the action:
* <button><Icon name="trash" decorative /> Delete</button>
*
* // Not decorative - icon is the only content:
* <button aria-label="Delete item"><Icon name="trash" /></button>
*/
decorative?: boolean;
}
/**
* Pre-create all lazy-loaded icon components when the module loads
* This prevents creating components during render
*/
const lazyIconComponents: Partial<Record<IconName, ComponentType<SVGProps<SVGSVGElement>>>> = {};
// Initialize all lazy components
Object.entries(iconRegistry).forEach(([name, loader]) => {
lazyIconComponents[name as IconName] = lazy(loader);
});
/**
* Icon - Centralized icon component with lazy loading
*
* Features:
* - TypeScript autocomplete for all icon names
* - Automatic code splitting (only used icons are bundled)
* - Consistent API across all icons
* - Support for sizing, rotation, and styling
*
* @example
* ```tsx
* // Basic usage
* <Icon name="heart" size={24} />
*
* // With styling
* <Icon name="star" className="text-yellow-500" />
*
* // With rotation
* <Icon name="arrow" rotate={180} />
*
* // With custom size
* <Icon name="cart" size="2rem" />
* ```
*/
export function Icon({
name,
size = 24,
rotate,
className = '',
style,
'aria-label': ariaLabel,
decorative = false,
...props
}: IconProps) {
// Validate icon exists
if (process.env.NODE_ENV === 'development' && !hasIcon(name)) {
clientLogger.warn(`Icon "${name}" not found in registry`, {
availableIcons: Object.keys(iconRegistry).join(', ')
});
}
// Get lazy-loaded icon component
const LazyIcon = lazyIconComponents[name];
// If icon not found, render nothing
if (!LazyIcon) {
return null;
}
// Build icon styles
const iconStyle: CSSProperties = {
...style,
width: typeof size === 'number' ? `${size}px` : size,
height: typeof size === 'number' ? `${size}px` : size,
transform: rotate ? `rotate(${rotate}deg)` : style?.transform,
display: 'inline-block'};
// Fallback component shown while icon loads
const fallback = (
<span
style={{
width: iconStyle.width,
height: iconStyle.height,
display: 'inline-block'}}
aria-hidden="true"
/>
);
// Accessibility attributes based on decorative flag
const a11yProps = decorative
? {
'aria-hidden': true as const,
role: undefined,
focusable: 'false' as const,
}
: {
'aria-label': ariaLabel || name,
role: 'img' as const,
};
return (
<Suspense fallback={fallback}>
<LazyIcon
className={className}
style={iconStyle}
{...a11yProps}
{...props}
/>
</Suspense>
);
}
/**
* Helper function to create named icon components
* Reduces code duplication for convenience exports
*/
function createNamedIcon(name: IconName, displayName: string) {
const Comp = (props: Omit<IconProps, 'name'>) => <Icon name={name} {...props} />;
Comp.displayName = displayName;
return Comp;
}
/**
* Convenience exports for commonly used icons
* These provide better autocomplete and are easier to use
*
* @example
* ```tsx
* <Icon.Heart size={24} className="text-red-500" />
* <Icon.Cart size={20} />
* <Icon.Search className="text-gray-600" />
* ```
*/
Icon.Arrow = createNamedIcon('arrow', 'Icon.Arrow');
Icon.Close = createNamedIcon('close', 'Icon.Close');
Icon.UpArrow = createNamedIcon('up-arrow', 'Icon.UpArrow');
Icon.Reload = createNamedIcon('reload', 'Icon.Reload');
Icon.Heart = createNamedIcon('heart', 'Icon.Heart');
Icon.Cart = createNamedIcon('cart', 'Icon.Cart');
Icon.Search = createNamedIcon('search', 'Icon.Search');
Icon.User = createNamedIcon('user', 'Icon.User');
Icon.Trash = createNamedIcon('trash', 'Icon.Trash');
Icon.Star = createNamedIcon('star', 'Icon.Star');
Icon.CheckCircle = createNamedIcon('check-circle', 'Icon.CheckCircle');
Icon.Plus = createNamedIcon('plus', 'Icon.Plus');
Icon.Minus = createNamedIcon('minus', 'Icon.Minus');
Icon.Dashboard = createNamedIcon('dashboard', 'Icon.Dashboard');
Icon.Package = createNamedIcon('package', 'Icon.Package');
Icon.Download = createNamedIcon('download', 'Icon.Download');
Icon.Home = createNamedIcon('home', 'Icon.Home');
Icon.Eye = createNamedIcon('eye', 'Icon.Eye');
Icon.AlertTriangle = createNamedIcon('alert-triangle', 'Icon.AlertTriangle');
Icon.InfoCircle = createNamedIcon('info-circle', 'Icon.InfoCircle');
Icon.Check = createNamedIcon('check', 'Icon.Check');
Icon.ChevronDown = createNamedIcon('chevron-down', 'Icon.ChevronDown');
Icon.XCircle = createNamedIcon('x-circle', 'Icon.XCircle');
Icon.SadFace = createNamedIcon('sad-face', 'Icon.SadFace');
Icon.Expand = createNamedIcon('expand', 'Icon.Expand');
Icon.Tag = createNamedIcon('tag', 'Icon.Tag');
Icon.ChevronLeft = createNamedIcon('chevron-left', 'Icon.ChevronLeft');
Icon.ChevronRight = createNamedIcon('chevron-right', 'Icon.ChevronRight');
Icon.EmptyCart = createNamedIcon('empty-cart', 'Icon.EmptyCart');
Icon.ArrowRight = createNamedIcon('arrow-right', 'Icon.ArrowRight');
Icon.Edit = createNamedIcon('edit', 'Icon.Edit');
Icon.MapPin = createNamedIcon('map-pin', 'Icon.MapPin');
Icon.Phone = createNamedIcon('phone', 'Icon.Phone');
Icon.Email = createNamedIcon('email', 'Icon.Email');
Icon.Facebook = createNamedIcon('facebook', 'Icon.Facebook');
Icon.Instagram = createNamedIcon('instagram', 'Icon.Instagram');
Icon.Twitter = createNamedIcon('twitter', 'Icon.Twitter');
Icon.Linkedin = createNamedIcon('linkedin', 'Icon.Linkedin');
Icon.Github = createNamedIcon('github', 'Icon.Github');
Icon.Google = createNamedIcon('google', 'Icon.Google');
Icon.Pinterest = createNamedIcon('pinterest', 'Icon.Pinterest');
Icon.Visa = createNamedIcon('visa', 'Icon.Visa');
Icon.Mastercard = createNamedIcon('mastercard', 'Icon.Mastercard');
Icon.Paypal = createNamedIcon('paypal', 'Icon.Paypal');
Icon.ApplePay = createNamedIcon('apple-pay', 'Icon.ApplePay');
Icon.GooglePay = createNamedIcon('google-pay', 'Icon.GooglePay');
Icon.BankTransferIcon = createNamedIcon('bank-transfer', 'Icon.BankTransferIcon');
Icon.AppStore = createNamedIcon('app-store', 'Icon.AppStore');
Icon.GooglePlay = createNamedIcon('google-play', 'Icon.GooglePlay');
Icon.DhlIcon = createNamedIcon('dhl-icon', 'Icon.DhlIcon');
Icon.Cube = createNamedIcon('cube', 'Icon.Cube');
Icon.Archive = createNamedIcon('archive', 'Icon.Archive');
Icon.ChatBubble = createNamedIcon('chat-bubble', 'Icon.ChatBubble');
Icon.Support = createNamedIcon('support', 'Icon.Support');
Icon.Code = createNamedIcon('code', 'Icon.Code');
Icon.Document = createNamedIcon('document', 'Icon.Document');
Icon.StarOutline = createNamedIcon('star-outline', 'Icon.StarOutline');
Icon.Sparkles = createNamedIcon('sparkles', 'Icon.Sparkles');
// New icons for SVG migration
Icon.Sun = createNamedIcon('sun', 'Icon.Sun');
Icon.Moon = createNamedIcon('moon', 'Icon.Moon');
Icon.Spinner = createNamedIcon('spinner', 'Icon.Spinner');
Icon.Send = createNamedIcon('send', 'Icon.Send');
Icon.ChevronUp = createNamedIcon('chevron-up', 'Icon.ChevronUp');
Icon.Ticket = createNamedIcon('ticket', 'Icon.Ticket');
Icon.ClockCircle = createNamedIcon('clock-circle', 'Icon.ClockCircle');
Icon.Bolt = createNamedIcon('bolt', 'Icon.Bolt');
Icon.CheckCircleFilled = createNamedIcon('check-circle-filled', 'Icon.CheckCircleFilled');
Icon.Warning = createNamedIcon('warning', 'Icon.Warning');
Icon.ExclamationCircle = createNamedIcon('exclamation-circle', 'Icon.ExclamationCircle');
Icon.Calendar = createNamedIcon('calendar', 'Icon.Calendar');
Icon.Bookmark = createNamedIcon('bookmark', 'Icon.Bookmark');
Icon.FileDownload = createNamedIcon('file-download', 'Icon.FileDownload');
Icon.Terminal = createNamedIcon('terminal', 'Icon.Terminal');
Icon.Sort = createNamedIcon('sort', 'Icon.Sort');
Icon.CodeBrackets = createNamedIcon('code-brackets', 'Icon.CodeBrackets');
Icon.Cpu = createNamedIcon('cpu', 'Icon.Cpu');
Icon.ClipboardCheck = createNamedIcon('clipboard-check', 'Icon.ClipboardCheck');
Icon.BookOpen = createNamedIcon('book-open', 'Icon.BookOpen');
Icon.UserCircle = createNamedIcon('user-circle', 'Icon.UserCircle');
Icon.ChatDots = createNamedIcon('chat-dots', 'Icon.ChatDots');
Icon.PackageBox = createNamedIcon('package-box', 'Icon.PackageBox');
Icon.SupportTicket = createNamedIcon('support-ticket', 'Icon.SupportTicket');
Icon.ThumbUp = createNamedIcon('thumb-up', 'Icon.ThumbUp');
Icon.ThumbDown = createNamedIcon('thumb-down', 'Icon.ThumbDown');
Icon.Paperclip = createNamedIcon('paperclip', 'Icon.Paperclip');
Icon.QuestionCircle = createNamedIcon('question-circle', 'Icon.QuestionCircle');
Icon.Refresh = createNamedIcon('refresh', 'Icon.Refresh');
Icon.CreditCard = createNamedIcon('credit-card', 'Icon.CreditCard');
Icon.SadFaceCircle = createNamedIcon('sad-face-circle', 'Icon.SadFaceCircle');
// Admin & Workflow
Icon.Filter = createNamedIcon('filter', 'Icon.Filter');
Icon.Play = createNamedIcon('play', 'Icon.Play');
Icon.Pause = createNamedIcon('pause', 'Icon.Pause');
Icon.Ban = createNamedIcon('ban', 'Icon.Ban');
Icon.Duplicate = createNamedIcon('duplicate', 'Icon.Duplicate');
Icon.Hourglass = createNamedIcon('hourglass', 'Icon.Hourglass');
// Analytics & Metrics
Icon.TrendingUp = createNamedIcon('trending-up', 'Icon.TrendingUp');
Icon.TrendingDown = createNamedIcon('trending-down', 'Icon.TrendingDown');
Icon.ChartBar = createNamedIcon('chart-bar', 'Icon.ChartBar');
Icon.ChartLine = createNamedIcon('chart-line', 'Icon.ChartLine');
Icon.ChartPie = createNamedIcon('chart-pie', 'Icon.ChartPie');
// Data & Sync
Icon.Sync = createNamedIcon('sync', 'Icon.Sync');
Icon.UploadCloud = createNamedIcon('upload-cloud', 'Icon.UploadCloud');
Icon.DownloadCloud = createNamedIcon('download-cloud', 'Icon.DownloadCloud');
Icon.Database = createNamedIcon('database', 'Icon.Database');
// Commerce
Icon.Percent = createNamedIcon('percent', 'Icon.Percent');
Icon.DollarSign = createNamedIcon('dollar-sign', 'Icon.DollarSign');
Icon.Wallet = createNamedIcon('wallet', 'Icon.Wallet');
Icon.Receipt = createNamedIcon('receipt', 'Icon.Receipt');
Icon.Barcode = createNamedIcon('barcode', 'Icon.Barcode');
// Actions
Icon.Link = createNamedIcon('link', 'Icon.Link');
Icon.Unlink = createNamedIcon('unlink', 'Icon.Unlink');
Icon.Share = createNamedIcon('share', 'Icon.Share');
Icon.Undo = createNamedIcon('undo', 'Icon.Undo');
Icon.Redo = createNamedIcon('redo', 'Icon.Redo');
// UI Enhancement
Icon.Maximize = createNamedIcon('maximize', 'Icon.Maximize');
Icon.Minimize = createNamedIcon('minimize', 'Icon.Minimize');
Icon.Layers = createNamedIcon('layers', 'Icon.Layers');
Icon.Merge = createNamedIcon('merge', 'Icon.Merge');
Icon.Split = createNamedIcon('split', 'Icon.Split');
Icon.Wrench = createNamedIcon('wrench', 'Icon.Wrench');
// Status Variants
Icon.Circle = createNamedIcon('circle', 'Icon.Circle');
Icon.CircleDot = createNamedIcon('circle-dot', 'Icon.CircleDot');
Icon.CheckDouble = createNamedIcon('check-double', 'Icon.CheckDouble');
Icon.ClockFilled = createNamedIcon('clock-filled', 'Icon.ClockFilled');
|