Add theme export feature

This commit is contained in:
Ole Bertram 2018-06-28 01:08:06 +02:00
parent c07adb7121
commit 29f69de240
No known key found for this signature in database
GPG key ID: E1B751CB4B7F8D28
3 changed files with 21 additions and 0 deletions

View file

@ -51,6 +51,23 @@ export default {
this.attachmentRadiusLocal = this.$store.state.config.radii.attachmentRadius || 5
},
methods: {
exportCurrentTheme () {
const stringified = JSON.stringify({
colors: this.$store.state.config.colors,
radii: this.$store.state.config.radii
}, null, 2) // Pretty-print and indent with 2 spaces
// Create an invisible link with a data url and simulate a click
const e = document.createElement('a')
e.setAttribute('download', 'pleroma_theme.json')
e.setAttribute('href', 'data:application/json;base64,' + window.btoa(stringified))
e.style.display = 'none'
document.body.appendChild(e)
e.click()
document.body.removeChild(e)
},
setCustomTheme () {
if (!this.bgColorLocal && !this.btnColorLocal && !this.linkColorLocal) {
// reset to picked themes