From 754d71ec1933d897f9206ddca080bb258256edbb Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 23 Nov 2018 08:24:55 +0300 Subject: [PATCH] added checkboxes to keep current roundness and shadows, also cleaned up how shadows/roundness are reset when switching themes --- .../style_switcher/style_switcher.js | 52 +++++++++++++---- .../style_switcher/style_switcher.scss | 18 ++++-- .../style_switcher/style_switcher.vue | 57 ++++++++++++------- src/i18n/en.json | 5 ++ 4 files changed, 99 insertions(+), 33 deletions(-) diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js index edc614c3..0c302e93 100644 --- a/src/components/style_switcher/style_switcher.js +++ b/src/components/style_switcher/style_switcher.js @@ -27,6 +27,9 @@ export default { selected: this.$store.state.config.theme, invalidThemeImported: false, + keepShadows: false, + keepRoundness: false, + textColorLocal: '', linkColorLocal: '', @@ -375,6 +378,19 @@ export default { }) }, + clearRoundness () { + Object.keys(this.$data) + .filter(_ => _.endsWith('RadiusLocal')) + .forEach(key => { + set(this.$data, key, undefined) + }) + }, + + clearShadows () { + this.shadowsLocal = {} + console.log(this.shadowsLocal) + }, + /** * This applies stored theme data onto form. * @param {Object} input - input data @@ -420,17 +436,24 @@ export default { this[key + 'ColorLocal'] = rgb2hex(colors[key]) }) - // TODO optimize this - this.btnRadiusLocal = radii.btn - this.inputRadiusLocal = radii.input - this.checkboxRadiusLocal = radii.checkbox - this.panelRadiusLocal = radii.panel - this.avatarRadiusLocal = radii.avatar - this.avatarAltRadiusLocal = radii.avatarAlt - this.tooltipRadiusLocal = radii.tooltip - this.attachmentRadiusLocal = radii.attachment + if (!this.keepRoundness) { + this.clearRoundness() + // TODO optimize this + this.btnRadiusLocal = radii.btn + this.inputRadiusLocal = radii.input + this.checkboxRadiusLocal = radii.checkbox + this.panelRadiusLocal = radii.panel + this.avatarRadiusLocal = radii.avatar + this.avatarAltRadiusLocal = radii.avatarAlt + this.tooltipRadiusLocal = radii.tooltip + this.attachmentRadiusLocal = radii.attachment + } - this.shadowsLocal = shadows + if (!this.keepShadows) { + this.clearShadows() + this.shadowsLocal = shadows + this.shadowSelected = this.shadowsAvailable[0] + } Object.entries(opacity).forEach(([k, v]) => { if (typeof v === 'undefined' || v === null || Number.isNaN(v)) return @@ -441,7 +464,16 @@ export default { watch: { selected () { if (this.selectedVersion === 1) { + if (!this.keepRoundness) { + this.clearRoundness() + } + + if (!this.keepShadows) { + this.clearShadows() + } + this.clearV1() + this.bgColorLocal = this.selected[1] this.fgColorLocal = this.selected[2] this.textColorLocal = this.selected[3] diff --git a/src/components/style_switcher/style_switcher.scss b/src/components/style_switcher/style_switcher.scss index f8529b4f..9cdc9f33 100644 --- a/src/components/style_switcher/style_switcher.scss +++ b/src/components/style_switcher/style_switcher.scss @@ -66,7 +66,7 @@ .apply-container, .radius-container, .color-container, - .presets-container { + { display: flex; p { @@ -88,12 +88,14 @@ .color-container, .shadow-container, - .radius-container { + .radius-container, + .presets-container { margin: 1em 1em 0; } - .presets-container, - .shadow-selector { + .shadow-selector, + .save-load, + .save-load-options { display: flex; justify-content: center; align-items: baseline; @@ -110,6 +112,14 @@ } } + .save-load-options { + flex-wrap: wrap; + margin-top: .5em; + span { + margin: 0 .5em; + } + } + .preview-container { border-top: 1px dashed; border-bottom: 1px dashed; diff --git a/src/components/style_switcher/style_switcher.vue b/src/components/style_switcher/style_switcher.vue index 6463a4ca..0c6b811d 100644 --- a/src/components/style_switcher/style_switcher.vue +++ b/src/components/style_switcher/style_switcher.vue @@ -1,26 +1,45 @@