2018-05-06 18:38:40 +02:00
|
|
|
import React, { Component } from 'react'
|
2018-04-08 22:49:58 +02:00
|
|
|
import PropTypes from 'prop-types'
|
2018-05-06 18:38:40 +02:00
|
|
|
import vCard from 'vcf'
|
|
|
|
import FileSaver from 'file-saver'
|
2018-04-21 13:39:18 +02:00
|
|
|
import Social from '../molecules/Social'
|
2018-04-06 17:24:35 +02:00
|
|
|
import './Footer.scss'
|
2018-04-02 23:22:48 +02:00
|
|
|
|
2018-05-06 18:38:40 +02:00
|
|
|
class Footer extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.handleAddressbookClick = this.handleAddressbookClick.bind(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
constructVcard() {
|
|
|
|
const meta = this.props.meta
|
|
|
|
const contact = new vCard()
|
|
|
|
const photo = meta.avatarBase64
|
|
|
|
|
|
|
|
contact.set('fn', meta.title)
|
|
|
|
contact.set('title', meta.tagline)
|
|
|
|
contact.set('email', meta.email)
|
|
|
|
contact.set('url', meta.url, { type: 'Portfolio' })
|
|
|
|
contact.add('url', meta.social.Blog, { type: 'Blog' })
|
|
|
|
contact.set('nickname', 'kremalicious')
|
|
|
|
contact.add('x-socialprofile', meta.social.Twitter, { type: 'twitter' })
|
|
|
|
contact.add('x-socialprofile', meta.social.GitHub, { type: 'GitHub' })
|
|
|
|
contact.set('photo', photo, { encoding: 'b', type: 'JPEG' })
|
|
|
|
|
|
|
|
const vcard = contact.toString('3.0')
|
|
|
|
this.downloadVcard(vcard, meta)
|
|
|
|
}
|
|
|
|
|
|
|
|
downloadVcard(vcard, meta) {
|
|
|
|
const blob = new Blob([vcard], { type: 'text/x-vcard' })
|
|
|
|
FileSaver.saveAs(blob, `${meta.title.toLowerCase()}.vcf`)
|
|
|
|
}
|
|
|
|
|
|
|
|
handleAddressbookClick(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
this.constructVcard()
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const year = new Date().getFullYear()
|
|
|
|
const meta = this.props.meta
|
|
|
|
|
|
|
|
return (
|
|
|
|
<footer className="footer">
|
|
|
|
<Social meta={meta} minimal />
|
|
|
|
<p className="footer__actions">
|
|
|
|
<a href="#" onClick={this.handleAddressbookClick}>
|
|
|
|
Add to addressbook
|
|
|
|
</a>
|
|
|
|
<a href={meta.gpg}>PGP/GPG key</a>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<small>
|
|
|
|
© {year} {meta.title} — All Rights Reserved
|
|
|
|
</small>
|
|
|
|
</p>
|
|
|
|
</footer>
|
|
|
|
)
|
|
|
|
}
|
2018-04-02 23:22:48 +02:00
|
|
|
}
|
|
|
|
|
2018-04-08 22:49:58 +02:00
|
|
|
Footer.propTypes = {
|
|
|
|
meta: PropTypes.object,
|
|
|
|
}
|
|
|
|
|
2018-04-02 23:22:48 +02:00
|
|
|
export default Footer
|