feat(SocialLink): add fallback to FaExternalLinkAlt
this will be used, when no iconName is provided
This commit is contained in:
committed by
Bastian
parent
5a5dbee6f5
commit
c8a3b528b8
@@ -7,6 +7,7 @@ import {
|
|||||||
FaYoutube,
|
FaYoutube,
|
||||||
FaGithub,
|
FaGithub,
|
||||||
FaInstagram,
|
FaInstagram,
|
||||||
|
FaExternalLinkAlt
|
||||||
} from "react-icons/fa";
|
} from "react-icons/fa";
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
@@ -25,9 +26,7 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SocialLink: React.FC<Props> = ({ href, iconName }) => {
|
const SocialLink: React.FC<Props> = ({ href, iconName }) => {
|
||||||
const Icon = icons[iconName];
|
const Icon = icons[iconName] || FaExternalLinkAlt;
|
||||||
|
|
||||||
if (Icon) {
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={href}
|
href={href}
|
||||||
@@ -39,9 +38,6 @@ const SocialLink: React.FC<Props> = ({ href, iconName }) => {
|
|||||||
<Icon className="social-icon" />
|
<Icon className="social-icon" />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
console.error(`The iconname is unknown: ${iconName}`);
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SocialLink;
|
export default SocialLink;
|
||||||
|
|||||||
Reference in New Issue
Block a user