diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-05-30 23:22:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-30 23:22:02 -0700 |
commit | 5fa6b6cfa6b3010279ead23088add5c5664e8ac0 (patch) | |
tree | 5f3ffa4dc62b4355d38346ef0155878ca6aeedcd /src/components/SettingToggle.vue | |
parent | ab7ac44c191e3b7dea696e76b74097e23f73b18c (diff) | |
parent | 9052ec59b75a37b4518ad39c493ee6c2d4198b98 (diff) | |
download | homer-5fa6b6cfa6b3010279ead23088add5c5664e8ac0.tar.gz homer-5fa6b6cfa6b3010279ead23088add5c5664e8ac0.tar.zst homer-5fa6b6cfa6b3010279ead23088add5c5664e8ac0.zip |
Merge pull request #62 from bastienwirtz/dev/build-system120405250
Build system integration using vue-cli.
Diffstat (limited to 'src/components/SettingToggle.vue')
-rw-r--r-- | src/components/SettingToggle.vue | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/components/SettingToggle.vue b/src/components/SettingToggle.vue new file mode 100644 index 0000000..864a497 --- /dev/null +++ b/src/components/SettingToggle.vue | |||
@@ -0,0 +1,40 @@ | |||
1 | <template> | ||
2 | <a v-on:click="toggleSetting()" class="navbar-item is-inline-block-mobile"> | ||
3 | <span><i :class="['fas', value ? icon : iconAlt]"></i></span> | ||
4 | <slot></slot> | ||
5 | </a> | ||
6 | </template> | ||
7 | |||
8 | <script> | ||
9 | export default { | ||
10 | name: "SettingToggle", | ||
11 | props: { | ||
12 | name: String, | ||
13 | icon: String, | ||
14 | iconAlt: String, | ||
15 | }, | ||
16 | data: function () { | ||
17 | return { | ||
18 | value: true, | ||
19 | }; | ||
20 | }, | ||
21 | created: function () { | ||
22 | if (!this.iconAlt) { | ||
23 | this.iconAlt = this.icon; | ||
24 | } | ||
25 | |||
26 | if (this.name in localStorage) { | ||
27 | this.value = JSON.parse(localStorage[this.name]); | ||
28 | } | ||
29 | |||
30 | this.$emit("updated", this.value); | ||
31 | }, | ||
32 | methods: { | ||
33 | toggleSetting: function () { | ||
34 | this.value = !this.value; | ||
35 | localStorage[this.name] = this.value; | ||
36 | this.$emit("updated", this.value); | ||
37 | }, | ||
38 | }, | ||
39 | }; | ||
40 | </script> | ||