Started code review + some fixes (unfinished)
[vchess.git] / client / src / views / Variants.vue
CommitLineData
5b020e73 1<template lang="pug">
7aa548e7
BA
2main
3 .row
9a3049f3 4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
12c5cf05 5 input#prefixFilter(v-model="curPrefix" :placeholder="st.tr['Prefix?']")
7aa548e7
BA
6 .variant.col-sm-12.col-md-5.col-lg-4(
7 v-for="(v,idx) in filteredVariants"
8 :class="{'col-md-offset-1': idx%2==0, 'col-lg-offset-2': idx%2==0}"
9 )
10 router-link(:to="getLink(v.name)")
11 h4.boxtitle.text-center {{ v.name }}
12 p.description.text-center {{ st.tr[v.desc] }}
5b020e73
BA
13</template>
14
15<script>
16import { store } from "@/store";
17export default {
cf2343ce 18 name: "my-variants",
5b020e73
BA
19 data: function() {
20 return {
85e5b5c1 21 curPrefix: "",
6808d7a1 22 st: store.state
5b020e73 23 };
85e5b5c1
BA
24 },
25 computed: {
6808d7a1
BA
26 filteredVariants: function() {
27 const capitalizedPrefix = this.curPrefix.replace(/^\w/, c =>
28 c.toUpperCase()
29 );
85e5b5c1 30 const variants = this.st.variants
6808d7a1
BA
31 .filter(v => {
32 return v.name.startsWith(capitalizedPrefix);
33 })
34 .map(v => {
35 return {
36 name: v.name,
37 desc: v.description
38 };
39 })
40 .sort((a, b) => {
41 return a.name.localeCompare(b.name);
42 });
5b020e73 43 return variants;
6808d7a1 44 }
85e5b5c1 45 },
5b020e73
BA
46 methods: {
47 getLink: function(vname) {
48 return "/variants/" + vname;
6808d7a1
BA
49 }
50 }
5b020e73
BA
51};
52</script>
53
41c80bb6 54<style lang="sass" scoped>
fb54f098 55// TODO: box-shadow or box-sizing ? https://stackoverflow.com/a/13517809
bd76b456
BA
56input#prefixFilter
57 display: block
58 margin: 0 auto
fb54f098
BA
59.variant
60 box-sizing: border-box
61 border: 1px solid brown
62 background-color: lightyellow
63 &:hover
64 background-color: yellow
65 a
66 color: #663300
67 text-decoration: none
68 .boxtitle
69 font-weight: bold
70 margin-bottom: 0
71 .description
72 @media screen and (max-width: 767px)
73 margin-top: 0
5b020e73 74</style>