1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-02-14 21:10:41 +01:00
2021-03-13 01:17:53 +01:00

58 lines
1.3 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import posed from 'react-pose'
import { moveInTop } from '../atoms/Transitions'
import Icon from '../atoms/Icon'
import { useResume } from '../../hooks/use-resume'
import {
link,
title,
small as styleSmall,
networks
} from './Networks.module.css'
const linkClasses = (key) =>
key === 'Mail' ? `u-email ${link}` : `u-url ${link}`
const NetworkLink = ({ name, url }) => (
<a
className={linkClasses(name)}
href={url}
data-testid={`network-${name.toLowerCase()}`}
>
<Icon name={name} />
<span className={title}>{name}</span>
</a>
)
NetworkLink.propTypes = {
name: PropTypes.string.isRequired,
url: PropTypes.string.isRequired
}
export default function Networks({ small, hide }) {
const { basics } = useResume()
if (hide) return null
const Animation = posed.aside(moveInTop)
return (
<Animation className={small ? styleSmall : networks}>
<NetworkLink name="Mail" url={`mailto:${basics.email}`} />
{basics.profiles.map((profile) => (
<NetworkLink
key={profile.network}
name={profile.network}
url={profile.url}
/>
))}
</Animation>
)
}
Networks.propTypes = {
small: PropTypes.bool,
hide: PropTypes.bool
}