File tree Expand file tree Collapse file tree 2 files changed +73
-111
lines changed Expand file tree Collapse file tree 2 files changed +73
-111
lines changed Original file line number Diff line number Diff line change 1+ // Define Icon type locally since it might not be exported yet
2+ interface Icon {
3+ src : string ;
4+ mimeType ?: string ;
5+ sizes ?: string ;
6+ }
7+
8+ // Helper type for objects that may have icons
9+ export interface WithIcons {
10+ icons ?: Icon [ ] ;
11+ }
12+
13+ interface IconDisplayProps {
14+ icons ?: Icon [ ] ;
15+ className ?: string ;
16+ size ?: "sm" | "md" | "lg" ;
17+ }
18+
19+ const IconDisplay = ( {
20+ icons,
21+ className = "" ,
22+ size = "md" ,
23+ } : IconDisplayProps ) => {
24+ if ( ! icons || icons . length === 0 ) {
25+ return null ;
26+ }
27+
28+ const sizeClasses = {
29+ sm : "w-4 h-4" ,
30+ md : "w-6 h-6" ,
31+ lg : "w-8 h-8" ,
32+ } ;
33+
34+ const sizeClass = sizeClasses [ size ] ;
35+
36+ return (
37+ < div className = { `flex gap-1 ${ className } ` } >
38+ { icons . map ( ( icon , index ) => (
39+ < img
40+ key = { index }
41+ src = { icon . src }
42+ alt = ""
43+ className = { `${ sizeClass } object-contain flex-shrink-0` }
44+ style = { {
45+ imageRendering : "auto" ,
46+ } }
47+ onError = { ( e ) => {
48+ // Hide broken images
49+ e . currentTarget . style . display = "none" ;
50+ } }
51+ />
52+ ) ) }
53+ </ div >
54+ ) ;
55+ } ;
56+
57+ export default IconDisplay ;
You can’t perform that action at this time.
0 commit comments