-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67da9a9
commit 38d169a
Showing
9 changed files
with
88 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { FC, useState } from "react"; | ||
|
||
function getEntityLogoURL(entity: string): string { | ||
return `https://wardicons.blob.core.windows.net/icons/${entity}.png`; | ||
} | ||
|
||
interface EntityLogoProps { | ||
entity: string; | ||
className?: string; | ||
} | ||
|
||
const EntityLogo: FC<EntityLogoProps> = ({ entity, className }) => { | ||
const logoURL = getEntityLogoURL(entity); | ||
const [imageError, setImageError] = useState<boolean>(false); | ||
|
||
const handleImageError = () => { | ||
setImageError(true); | ||
}; | ||
|
||
const handleImageLoad = () => { | ||
setImageError(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
{imageError ? null : ( | ||
<img | ||
src={logoURL} | ||
alt={entity} | ||
className={className} | ||
onError={handleImageError} | ||
onLoad={handleImageLoad} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default EntityLogo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters