Merge branch 'fix-crypto-icons' into 'main'
Fix cryptocurrency icons See merge request soapbox-pub/soapbox!3239
This commit is contained in:
commit
8a4e85010d
|
@ -1,16 +1,11 @@
|
|||
import genericIcon from 'soapbox/assets/cryptocurrency/generic.svg';
|
||||
|
||||
const icons = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true });
|
||||
const icons: Record<string, { default: string }> = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true });
|
||||
|
||||
/** Get crypto icon URL by ticker symbol, or fall back to generic icon */
|
||||
function getIcon(ticker: string): string {
|
||||
const iconPath = `../../../assets/cryptocurrency/${ticker}.svg`;
|
||||
|
||||
if (icons[iconPath]) {
|
||||
return new URL(iconPath, import.meta.url).href;
|
||||
} else {
|
||||
return genericIcon;
|
||||
}
|
||||
return icons[iconPath]?.default || genericIcon;
|
||||
}
|
||||
|
||||
interface ICryptoIcon {
|
||||
|
|
Loading…
Reference in New Issue