Started code review + some fixes (unfinished)
[vchess.git] / client / src / views / Variants.vue
index 503be05..3106115 100644 (file)
@@ -1,15 +1,15 @@
 <template lang="pug">
-.row
-  .nopadding.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
-    label(for="prefixFilter") Type first letters...
-    input#prefixFilter(v-model="curPrefix")
-  .variant.col-sm-12.col-md-5.col-lg-4(
-    v-for="(v,idx) in filteredVariants"
-    :class="{'col-md-offset-1': idx%2==0, 'col-lg-offset-2': idx%2==0}"
-  )
-    router-link(:to="getLink(v.name)")
-      h4.boxtitle.text-center {{ v.name }}
-      p.description.text-center {{ st.tr[v.desc] }}
+main
+  .row
+    .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
+      input#prefixFilter(v-model="curPrefix" :placeholder="st.tr['Prefix?']")
+    .variant.col-sm-12.col-md-5.col-lg-4(
+      v-for="(v,idx) in filteredVariants"
+      :class="{'col-md-offset-1': idx%2==0, 'col-lg-offset-2': idx%2==0}"
+    )
+      router-link(:to="getLink(v.name)")
+        h4.boxtitle.text-center {{ v.name }}
+        p.description.text-center {{ st.tr[v.desc] }}
 </template>
 
 <script>
@@ -19,39 +19,43 @@ export default {
   data: function() {
     return {
       curPrefix: "",
-      st: store.state,
+      st: store.state
     };
   },
   computed: {
-    filteredVariants: function () {
-      const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => c.toUpperCase());
+    filteredVariants: function() {
+      const capitalizedPrefix = this.curPrefix.replace(/^\w/, c =>
+        c.toUpperCase()
+      );
       const variants = this.st.variants
-      .filter( v => {
-        return v.name.startsWith(capitalizedPrefix);
-      })
-      .map( v => {
-        return {
-          name: v.name,
-          desc: v.description,
-        };
-      })
-      .sort((a,b) => {
-        return a.name.localeCompare(b.name);
-      });
+        .filter(v => {
+          return v.name.startsWith(capitalizedPrefix);
+        })
+        .map(v => {
+          return {
+            name: v.name,
+            desc: v.description
+          };
+        })
+        .sort((a, b) => {
+          return a.name.localeCompare(b.name);
+        });
       return variants;
-    },
+    }
   },
   methods: {
     getLink: function(vname) {
       return "/variants/" + vname;
-    },
-  },
+    }
+  }
 };
 </script>
 
-<!-- Add "scoped" attribute to limit CSS to this component only -->
-<style scoped lang="sass">
+<style lang="sass" scoped>
 // TODO: box-shadow or box-sizing ? https://stackoverflow.com/a/13517809
+input#prefixFilter
+  display: block
+  margin: 0 auto
 .variant
   box-sizing: border-box
   border: 1px solid brown