mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 17:23:22 +01:00
better UX for vcard download
This commit is contained in:
parent
e1787e39e6
commit
49178e6834
@ -1,2 +1,3 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.cache/
|
.cache/
|
||||||
|
src/lib/vcf
|
||||||
|
@ -11,10 +11,16 @@ class Footer extends Component {
|
|||||||
this.handleAddressbookClick = this.handleAddressbookClick.bind(this)
|
this.handleAddressbookClick = this.handleAddressbookClick.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateFileName() {
|
||||||
|
// results in 'matthias-kretschmann.vcf'
|
||||||
|
return `${this.props.meta.title.toLowerCase().split(' ').join('-')}.vcf`
|
||||||
|
}
|
||||||
|
|
||||||
constructVcard() {
|
constructVcard() {
|
||||||
const meta = this.props.meta
|
const meta = this.props.meta
|
||||||
const contact = new vCard()
|
const contact = new vCard()
|
||||||
const photo = meta.avatarBase64
|
const photo = meta.avatarBase64
|
||||||
|
|
||||||
contact.set('fn', meta.title)
|
contact.set('fn', meta.title)
|
||||||
contact.set('title', meta.tagline)
|
contact.set('title', meta.tagline)
|
||||||
contact.set('email', meta.email)
|
contact.set('email', meta.email)
|
||||||
@ -24,13 +30,14 @@ class Footer extends Component {
|
|||||||
contact.add('x-socialprofile', meta.social.Twitter, { type: 'twitter' })
|
contact.add('x-socialprofile', meta.social.Twitter, { type: 'twitter' })
|
||||||
contact.add('x-socialprofile', meta.social.GitHub, { type: 'GitHub' })
|
contact.add('x-socialprofile', meta.social.GitHub, { type: 'GitHub' })
|
||||||
contact.set('photo', photo, { encoding: 'b', type: 'JPEG' })
|
contact.set('photo', photo, { encoding: 'b', type: 'JPEG' })
|
||||||
|
|
||||||
const vcard = contact.toString('3.0')
|
const vcard = contact.toString('3.0')
|
||||||
this.downloadVcard(vcard, meta)
|
this.downloadVcard(vcard)
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadVcard(vcard, meta) {
|
downloadVcard(vcard) {
|
||||||
const blob = new Blob([vcard], { type: 'text/x-vcard' })
|
const blob = new Blob([vcard], { type: 'text/x-vcard' })
|
||||||
FileSaver.saveAs(blob, `${meta.title.toLowerCase()}.vcf`)
|
FileSaver.saveAs(blob, this.generateFileName())
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAddressbookClick(e) {
|
handleAddressbookClick(e) {
|
||||||
@ -46,7 +53,7 @@ class Footer extends Component {
|
|||||||
<footer className="footer">
|
<footer className="footer">
|
||||||
<Social meta={meta} minimal />
|
<Social meta={meta} minimal />
|
||||||
<p className="footer__actions">
|
<p className="footer__actions">
|
||||||
<a href="#" onClick={this.handleAddressbookClick}>
|
<a href={`${meta.url}/${this.generateFileName()}`} onClick={this.handleAddressbookClick}>
|
||||||
Add to addressbook
|
Add to addressbook
|
||||||
</a>
|
</a>
|
||||||
<a href={meta.gpg}>PGP/GPG key</a>
|
<a href={meta.gpg}>PGP/GPG key</a>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 4.7 KiB |
Loading…
Reference in New Issue
Block a user