]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - src/components/SettingToggle.vue
Avoid hidding all info when copy pasting the exemple config
[github/bastienwirtz/homer.git] / src / components / SettingToggle.vue
index 94655bcab19aa06eb33dc54e93b4456e2720b26b..efa7caa89e06142f8ebe8ce13422221fcd48ce54 100644 (file)
@@ -1,7 +1,9 @@
 <template>
-  <a v-on:click="toggleSetting()" class="navbar-item is-inline-block-mobile">
-    <span v-show="value"><i :class="['fas', icon]"></i></span>
-    <span v-show="!value"><i :class="['fas', iconAlt]"></i></span>
+  <a
+    @click.prevent="toggleSetting()"
+    class="navbar-item is-inline-block-mobile"
+  >
+    <span><i :class="['fas', 'fa-fw', value ? icon : secondaryIcon]"></i></span>
     <slot></slot>
   </a>
 </template>
@@ -13,19 +15,21 @@ export default {
     name: String,
     icon: String,
     iconAlt: String,
+    defaultValue: Boolean,
   },
   data: function () {
     return {
+      secondaryIcon: null,
       value: true,
     };
   },
   created: function () {
-    if (!this.iconAlt) {
-      this.iconAlt = this.icon;
-    }
+    this.secondaryIcon = this.iconAlt || this.icon;
 
     if (this.name in localStorage) {
       this.value = JSON.parse(localStorage[this.name]);
+    } else {
+      this.value = this.defaultValue;
     }
 
     this.$emit("updated", this.value);