diff options
| author | Ole Bertram <git@bertr.am> | 2018-06-28 01:08:06 +0200 |
|---|---|---|
| committer | Ole Bertram <git@bertr.am> | 2018-06-28 01:23:19 +0200 |
| commit | 29f69de240530048a31319f8a78274ca7d607853 (patch) | |
| tree | 300a0a9cbc9ef4c3a0d129d3ed9ebe63b837ba96 /src/components/style_switcher/style_switcher.js | |
| parent | c07adb71212e6ffe73deb58f0efade8264e7f7b9 (diff) | |
Add theme export feature
Diffstat (limited to 'src/components/style_switcher/style_switcher.js')
| -rw-r--r-- | src/components/style_switcher/style_switcher.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js index 6f4845c4..041d4b17 100644 --- a/src/components/style_switcher/style_switcher.js +++ b/src/components/style_switcher/style_switcher.js @@ -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 |
