aboutsummaryrefslogtreecommitdiff
path: root/src/components/style_switcher/style_switcher.js
diff options
context:
space:
mode:
authorOle Bertram <git@bertr.am>2018-06-28 02:59:57 +0200
committerOle Bertram <git@bertr.am>2018-06-28 03:28:23 +0200
commitd2b79856c61391e56009cdf313e332ee950b9081 (patch)
tree63b8f6a5be694f670fb6b0a0bcf2d5b4c5d98466 /src/components/style_switcher/style_switcher.js
parentf36984c4a4d1411d4ec4c6aad7f2740fe676a4fa (diff)
Add theme import feature
Diffstat (limited to 'src/components/style_switcher/style_switcher.js')
-rw-r--r--src/components/style_switcher/style_switcher.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js
index d5881a31..7ab56ea2 100644
--- a/src/components/style_switcher/style_switcher.js
+++ b/src/components/style_switcher/style_switcher.js
@@ -52,6 +52,28 @@ export default {
document.body.removeChild(e)
},
+ importTheme () {
+ const filePicker = document.createElement('input')
+ filePicker.setAttribute('type', 'file')
+ filePicker.setAttribute('accept', '.json')
+
+ filePicker.addEventListener('change', event => {
+ if (event.target.files[0]) {
+ // eslint-disable-next-line no-undef
+ const reader = new FileReader()
+ reader.onload = ({target}) => {
+ const parsed = JSON.parse(target.result)
+ this.normalizeLocalState(parsed.colors, parsed.radii)
+ }
+ reader.readAsText(event.target.files[0])
+ }
+ })
+
+ document.body.appendChild(filePicker)
+ filePicker.click()
+ document.body.removeChild(filePicker)
+ },
+
setCustomTheme () {
if (!this.bgColorLocal && !this.btnColorLocal && !this.linkColorLocal) {
// reset to picked themes