fido-node.github.io/components/personal-card/elements/ContactsButtons.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-04-28 22:31:42 +03:00
import * as React from 'react';
import '@fortawesome/fontawesome-svg-core';
import { faEnvelope } from '@fortawesome/free-solid-svg-icons';
import {
faTelegram,
faTwitter,
faGithub,
faLinkedin,
faTwitch,
faTelegramPlane
2021-04-28 22:31:42 +03:00
} from '@fortawesome/free-brands-svg-icons';
import { IconDefinition, IconName, IconPrefix } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Contact, contactToLink, ContactType } from '../../../src/contacts/contacts';
type Props = {
contacts: Contact[];
};
const typeToIcon: { [key in ContactType]: [IconDefinition, string?] } = {
tg: [faTelegramPlane],
2021-04-28 22:31:42 +03:00
mail: [faEnvelope],
twitter: [faTwitter],
github: [faGithub],
linkedin: [faLinkedin],
twitch: [faTwitch]
};
const ContactComp = ({ id, type }: Contact) => {
const iconDescr = typeToIcon[type];
return (
2021-05-06 21:21:20 +03:00
<div className={'p-3'}>
2021-05-06 21:10:55 +03:00
<a
className={'text-5xl text-gray-600' + ' ' + iconDescr[1]}
href={contactToLink({ id, type })}
target="_blank">
<FontAwesomeIcon key={type} icon={iconDescr[0]} />
</a>
</div>
2021-04-28 22:31:42 +03:00
);
};
export default ({ contacts }: Props) => (
2021-05-06 21:10:55 +03:00
<div className={'flex flex-row justify-center'}>{contacts.map((c) => ContactComp(c))}</div>
2021-04-28 22:31:42 +03:00
);