Fixes, improvements
[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: "",
5b020e73
BA
22 st: store.state,
23 };
85e5b5c1
BA
24 },
25 computed: {
26 filteredVariants: function () {
27 const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => c.toUpperCase());
28 const variants = this.st.variants
29 .filter( v => {
30 return v.name.startsWith(capitalizedPrefix);
31 })
32 .map( v => {
33 return {
34 name: v.name,
35 desc: v.description,
36 };
37 })
5b020e73 38 .sort((a,b) => {
85e5b5c1
BA
39 return a.name.localeCompare(b.name);
40 });
5b020e73 41 return variants;
85e5b5c1
BA
42 },
43 },
5b020e73
BA
44 methods: {
45 getLink: function(vname) {
46 return "/variants/" + vname;
47 },
48 },
49};
50</script>
51
41c80bb6 52<style lang="sass" scoped>
fb54f098 53// TODO: box-shadow or box-sizing ? https://stackoverflow.com/a/13517809
bd76b456
BA
54input#prefixFilter
55 display: block
56 margin: 0 auto
fb54f098
BA
57.variant
58 box-sizing: border-box
59 border: 1px solid brown
60 background-color: lightyellow
61 &:hover
62 background-color: yellow
63 a
64 color: #663300
65 text-decoration: none
66 .boxtitle
67 font-weight: bold
68 margin-bottom: 0
69 .description
70 @media screen and (max-width: 767px)
71 margin-top: 0
5b020e73 72</style>