1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2025-02-03 23:57:39 +01:00

remove icon duplication

This commit is contained in:
Matthias Kretschmann 2019-04-14 20:14:40 +02:00
parent 4526e29ee7
commit 3e341140e6
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 20 additions and 31 deletions

View File

@ -7,6 +7,9 @@ import { ReactComponent as Info } from '../../images/info.svg'
import { ReactComponent as Styleguide } from '../../images/styleguide.svg'
import { ReactComponent as GitHub } from '../../images/github.svg'
import { ReactComponent as Dribbble } from '../../images/dribbble.svg'
import { ReactComponent as Email } from '../../images/email.svg'
import { ReactComponent as Blog } from '../../images/blog.svg'
import { ReactComponent as Twitter } from '../../images/twitter.svg'
const LinkIcon = ({ title, type, ...props }) => {
let typeOrTitle = type ? type : title
@ -30,6 +33,12 @@ const LinkIcon = ({ title, type, ...props }) => {
case 'styleguide':
case 'Styleguide':
return <Styleguide {...props} />
case 'Email':
return <Email {...props} />
case 'Blog':
return <Blog {...props} />
case 'Twitter':
return <Twitter {...props} />
default:
return null
}

View File

@ -24,6 +24,15 @@ describe('LinkIcon', () => {
rerender(<LinkIcon type={'styleguide'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon title={'Email'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon title={'Blog'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon title={'Twitter'} />)
expect(container.firstChild.nodeName).toBe('svg')
})
it('does not render with unknown type', () => {

View File

@ -4,13 +4,7 @@ import { StaticQuery, graphql } from 'gatsby'
import posed from 'react-pose'
import classNames from 'classnames'
import { moveInTop } from '../atoms/Transitions'
import { ReactComponent as Email } from '../../images/email.svg'
import { ReactComponent as Blog } from '../../images/blog.svg'
import { ReactComponent as Twitter } from '../../images/twitter.svg'
import { ReactComponent as GitHub } from '../../images/github.svg'
import { ReactComponent as Dribbble } from '../../images/dribbble.svg'
import LinkIcon from '../atoms/LinkIcon'
import icons from '../atoms/Icons.module.scss'
import styles from './Networks.module.scss'
@ -28,29 +22,6 @@ const query = graphql`
}
`
class NetworkIcon extends PureComponent {
static propTypes = {
title: PropTypes.string
}
render() {
switch (this.props.title) {
case 'Email':
return <Email {...this.props} />
case 'Blog':
return <Blog {...this.props} />
case 'Twitter':
return <Twitter {...this.props} />
case 'GitHub':
return <GitHub {...this.props} />
case 'Dribbble':
return <Dribbble {...this.props} />
default:
return null
}
}
}
export default class Networks extends PureComponent {
static propTypes = {
minimal: PropTypes.bool,
@ -86,7 +57,7 @@ export default class Networks extends PureComponent {
href={meta.social[key]}
key={i}
>
<NetworkIcon title={key} className={icons.icon} />
<LinkIcon title={key} className={icons.icon} />
<span className={styles.title}>{key}</span>
</a>
))}