File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
examples/mapboxgl-v2/docs/modules/icon-card Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,23 @@ const IconCard = (props: IconCardContentProps) => {
13
13
const modal = useRef < any > ( null ) ;
14
14
const title = iconInfo . name ;
15
15
const id = iconInfo . id ;
16
- const isPolygon = type === 'polygon' ;
17
- // eslint-disable-next-line import/no-dynamic-require
18
- const { color, image } = isPolygon && require ( `../../../static/symbols/polygon/polygon-${ id } .json` ) ;
19
- const imgUrl = isPolygon ? image : `../../static/images/${ type } /${ id } .png` ;
16
+
17
+ const getImageUrl = ( id ) => {
18
+ const isPolygon = type === 'polygon' ;
19
+ if ( isPolygon ) {
20
+ const { paint = { } } = isPolygon && require ( `../../../static/symbols/polygon/${ type } -${ id } .json` ) ,
21
+ { 'fill-color' : color , 'fill-pattern' : imgId } = paint ;
22
+ return {
23
+ color,
24
+ imageUrl : imgId ? `../../../static/images/${ type } /${ imgId } .png` : undefined
25
+ }
26
+ }
27
+ return {
28
+ imageUrl : `../../../static/images/${ type } /${ type } -${ id } .png`
29
+ } ;
30
+ }
31
+
32
+ const { imageUrl : imgUrl , color} = getImageUrl ( id ) ;
20
33
return (
21
34
< >
22
35
< div className = "icon-image" onClick = { ( ) => {
You can’t perform that action at this time.
0 commit comments