Commit | Line | Data |
---|---|---|
5b020e73 | 1 | <template lang="pug"> |
7aa548e7 BA |
2 | main |
3 | .row | |
9a3049f3 | 4 | .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 |
910d631b BA |
5 | input#prefixFilter( |
6 | v-model="curPrefix" | |
9e3f662f | 7 | @input="setCurPrefix($event)" |
910d631b BA |
8 | :placeholder="st.tr['Prefix?']" |
9 | ) | |
7aa548e7 BA |
10 | .variant.col-sm-12.col-md-5.col-lg-4( |
11 | v-for="(v,idx) in filteredVariants" | |
09d37571 | 12 | :class="getVclasses(filteredVariants, idx)" |
7aa548e7 BA |
13 | ) |
14 | router-link(:to="getLink(v.name)") | |
15 | h4.boxtitle.text-center {{ v.name }} | |
16 | p.description.text-center {{ st.tr[v.desc] }} | |
5b020e73 BA |
17 | </template> |
18 | ||
19 | <script> | |
20 | import { store } from "@/store"; | |
21 | export default { | |
cf2343ce | 22 | name: "my-variants", |
5b020e73 BA |
23 | data: function() { |
24 | return { | |
85e5b5c1 | 25 | curPrefix: "", |
6808d7a1 | 26 | st: store.state |
5b020e73 | 27 | }; |
85e5b5c1 | 28 | }, |
58bf4670 BA |
29 | mounted: function() { |
30 | document.getElementById("prefixFilter").focus(); | |
31 | }, | |
85e5b5c1 | 32 | computed: { |
6808d7a1 BA |
33 | filteredVariants: function() { |
34 | const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => | |
35 | c.toUpperCase() | |
36 | ); | |
85e5b5c1 | 37 | const variants = this.st.variants |
6808d7a1 BA |
38 | .filter(v => { |
39 | return v.name.startsWith(capitalizedPrefix); | |
40 | }) | |
41 | .map(v => { | |
42 | return { | |
43 | name: v.name, | |
44 | desc: v.description | |
45 | }; | |
46 | }) | |
47 | .sort((a, b) => { | |
48 | return a.name.localeCompare(b.name); | |
49 | }); | |
5b020e73 | 50 | return variants; |
6808d7a1 | 51 | } |
85e5b5c1 | 52 | }, |
5b020e73 | 53 | methods: { |
9e3f662f BA |
54 | // oninput listener, required for smartphones: |
55 | setCurPrefix: function(e) { | |
56 | this.curPrefix = e.target.value; | |
57 | }, | |
5b020e73 BA |
58 | getLink: function(vname) { |
59 | return "/variants/" + vname; | |
09d37571 BA |
60 | }, |
61 | getVclasses: function(varray, idx) { | |
62 | const idxMod2 = idx % 2; | |
63 | return { | |
64 | 'col-md-offset-1': idxMod2 == 0, | |
65 | 'col-lg-offset-2': idxMod2 == 0, | |
66 | 'last-noneighb': idxMod2 == 0 && idx == varray.length - 1 | |
67 | }; | |
68 | }, | |
6808d7a1 | 69 | } |
5b020e73 BA |
70 | }; |
71 | </script> | |
72 | ||
41c80bb6 | 73 | <style lang="sass" scoped> |
bd76b456 BA |
74 | input#prefixFilter |
75 | display: block | |
76 | margin: 0 auto | |
910d631b | 77 | |
fb54f098 BA |
78 | .variant |
79 | box-sizing: border-box | |
80 | border: 1px solid brown | |
81 | background-color: lightyellow | |
82 | &:hover | |
83 | background-color: yellow | |
84 | a | |
85 | color: #663300 | |
86 | text-decoration: none | |
87 | .boxtitle | |
88 | font-weight: bold | |
89 | margin-bottom: 0 | |
90 | .description | |
91 | @media screen and (max-width: 767px) | |
92 | margin-top: 0 | |
09d37571 BA |
93 | |
94 | .last-noneighb | |
95 | margin: 0 auto | |
5b020e73 | 96 | </style> |