Add theme export feature
This commit is contained in:
parent
c07adb7121
commit
29f69de240
3 changed files with 21 additions and 0 deletions
|
@ -51,6 +51,23 @@ export default {
|
||||||
this.attachmentRadiusLocal = this.$store.state.config.radii.attachmentRadius || 5
|
this.attachmentRadiusLocal = this.$store.state.config.radii.attachmentRadius || 5
|
||||||
},
|
},
|
||||||
methods: {
|
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 () {
|
setCustomTheme () {
|
||||||
if (!this.bgColorLocal && !this.btnColorLocal && !this.linkColorLocal) {
|
if (!this.bgColorLocal && !this.btnColorLocal && !this.linkColorLocal) {
|
||||||
// reset to picked themes
|
// reset to picked themes
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
<i class="icon-down-open"/>
|
<i class="icon-down-open"/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<button class="btn" @click="exportCurrentTheme">{{ $t('settings.export_theme') }}</button>
|
||||||
|
</div>
|
||||||
<div class="color-container">
|
<div class="color-container">
|
||||||
<p>{{$t('settings.theme_help')}}</p>
|
<p>{{$t('settings.theme_help')}}</p>
|
||||||
<div class="color-item">
|
<div class="color-item">
|
||||||
|
|
|
@ -288,6 +288,7 @@ const en = {
|
||||||
settings: 'Settings',
|
settings: 'Settings',
|
||||||
theme: 'Theme',
|
theme: 'Theme',
|
||||||
presets: 'Presets',
|
presets: 'Presets',
|
||||||
|
export_theme: 'Export current theme',
|
||||||
theme_help: 'Use hex color codes (#rrggbb) to customize your color theme.',
|
theme_help: 'Use hex color codes (#rrggbb) to customize your color theme.',
|
||||||
radii_help: 'Set up interface edge rounding (in pixels)',
|
radii_help: 'Set up interface edge rounding (in pixels)',
|
||||||
background: 'Background',
|
background: 'Background',
|
||||||
|
|
Loading…
Reference in a new issue